@lobehub/ui 5.34.1 → 5.34.3

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,73 @@
1
+ import { SKIP, visitParents } from "unist-util-visit-parents";
2
+ import { fromHtmlIsomorphic } from "hast-util-from-html-isomorphic";
3
+ import { toText } from "hast-util-to-text";
4
+ import katex from "katex";
5
+ //#region src/Markdown/plugins/rehypeKatex.ts
6
+ const emptyClasses = [];
7
+ const rehypeKatex = (options) => (tree, file) => {
8
+ const settings = options || {};
9
+ visitParents(tree, "element", (element, parents) => {
10
+ const classes = Array.isArray(element.properties.className) ? element.properties.className : emptyClasses;
11
+ const languageMath = classes.includes("language-math");
12
+ const mathDisplay = classes.includes("math-display");
13
+ const mathInline = classes.includes("math-inline");
14
+ let displayMode = mathDisplay;
15
+ if (!languageMath && !mathDisplay && !mathInline) return;
16
+ let parent = parents.at(-1);
17
+ let scope = element;
18
+ if (element.tagName === "code" && languageMath && parent && parent.type === "element" && parent.tagName === "pre") {
19
+ scope = parent;
20
+ parent = parents.at(-2);
21
+ displayMode = true;
22
+ }
23
+ if (!parent) return;
24
+ const value = toText(scope, { whitespace: "pre" });
25
+ let result;
26
+ try {
27
+ result = katex.renderToString(value, {
28
+ ...settings,
29
+ displayMode,
30
+ throwOnError: true
31
+ });
32
+ } catch (error) {
33
+ const cause = error;
34
+ file.message("Could not render math with KaTeX", {
35
+ ancestors: [...parents, element],
36
+ cause,
37
+ place: element.position,
38
+ ruleId: cause.name.toLowerCase(),
39
+ source: "rehype-katex"
40
+ });
41
+ try {
42
+ result = katex.renderToString(value, {
43
+ ...settings,
44
+ displayMode,
45
+ strict: "ignore",
46
+ throwOnError: false
47
+ });
48
+ } catch {
49
+ result = [{
50
+ children: [{
51
+ type: "text",
52
+ value
53
+ }],
54
+ properties: {
55
+ className: ["katex-error"],
56
+ style: "color:" + (settings.errorColor || "#cc0000"),
57
+ title: String(error)
58
+ },
59
+ tagName: "span",
60
+ type: "element"
61
+ }];
62
+ }
63
+ }
64
+ if (typeof result === "string") result = fromHtmlIsomorphic(result, { fragment: true }).children;
65
+ const index = parent.children.indexOf(scope);
66
+ parent.children.splice(index, 1, ...result);
67
+ return SKIP;
68
+ });
69
+ };
70
+ //#endregion
71
+ export { rehypeKatex };
72
+
73
+ //# sourceMappingURL=rehypeKatex.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rehypeKatex.mjs","names":[],"sources":["../../../src/Markdown/plugins/rehypeKatex.ts"],"sourcesContent":["import type { ElementContent, Root } from 'hast';\nimport { fromHtmlIsomorphic } from 'hast-util-from-html-isomorphic';\nimport { toText } from 'hast-util-to-text';\nimport katex, { type KatexOptions } from 'katex';\nimport { SKIP, visitParents } from 'unist-util-visit-parents';\nimport type { VFile } from 'vfile';\n\n// 内联自 rehype-katex@7,因为它硬依赖 katex ^0.16,下游安装时会得到一份嵌套的\n// 0.16 渲染出 v0.18 之前的 class 名,与我们注入的 v0.18 样式表对不上。\n// 升级 rehype-katex 到支持 katex ^0.18 的版本后可以删掉本文件。\n\nexport type RehypeKatexOptions = Omit<KatexOptions, 'displayMode' | 'throwOnError'>;\n\nconst emptyClasses: unknown[] = [];\n\nexport const rehypeKatex =\n (options?: RehypeKatexOptions) =>\n (tree: Root, file: VFile): undefined => {\n const settings = options || {};\n\n visitParents(tree, 'element', (element, parents) => {\n const classes = Array.isArray(element.properties.className)\n ? element.properties.className\n : emptyClasses;\n const languageMath = classes.includes('language-math');\n const mathDisplay = classes.includes('math-display');\n const mathInline = classes.includes('math-inline');\n let displayMode = mathDisplay;\n\n if (!languageMath && !mathDisplay && !mathInline) return;\n\n let parent: any = parents.at(-1);\n let scope: any = element;\n\n if (\n element.tagName === 'code' &&\n languageMath &&\n parent &&\n parent.type === 'element' &&\n parent.tagName === 'pre'\n ) {\n scope = parent;\n parent = parents.at(-2);\n displayMode = true;\n }\n\n if (!parent) return;\n\n const value = toText(scope, { whitespace: 'pre' });\n\n let result: ElementContent[] | string | undefined;\n\n try {\n result = katex.renderToString(value, { ...settings, displayMode, throwOnError: true });\n } catch (error) {\n const cause = error as Error;\n\n file.message('Could not render math with KaTeX', {\n ancestors: [...parents, element],\n cause,\n place: element.position,\n ruleId: cause.name.toLowerCase(),\n source: 'rehype-katex',\n });\n\n try {\n result = katex.renderToString(value, {\n ...settings,\n displayMode,\n strict: 'ignore',\n throwOnError: false,\n });\n } catch {\n result = [\n {\n children: [{ type: 'text', value }],\n properties: {\n className: ['katex-error'],\n style: 'color:' + (settings.errorColor || '#cc0000'),\n title: String(error),\n },\n tagName: 'span',\n type: 'element',\n },\n ];\n }\n }\n\n if (typeof result === 'string') {\n result = fromHtmlIsomorphic(result, { fragment: true }).children as ElementContent[];\n }\n\n const index = parent.children.indexOf(scope);\n parent.children.splice(index, 1, ...result);\n return SKIP;\n });\n };\n"],"mappings":";;;;;AAaA,MAAM,eAA0B,CAAC;AAEjC,MAAa,eACV,aACA,MAAY,SAA2B;CACtC,MAAM,WAAW,WAAW,CAAC;CAE7B,aAAa,MAAM,YAAY,SAAS,YAAY;EAClD,MAAM,UAAU,MAAM,QAAQ,QAAQ,WAAW,SAAS,IACtD,QAAQ,WAAW,YACnB;EACJ,MAAM,eAAe,QAAQ,SAAS,eAAe;EACrD,MAAM,cAAc,QAAQ,SAAS,cAAc;EACnD,MAAM,aAAa,QAAQ,SAAS,aAAa;EACjD,IAAI,cAAc;EAElB,IAAI,CAAC,gBAAgB,CAAC,eAAe,CAAC,YAAY;EAElD,IAAI,SAAc,QAAQ,GAAG,EAAE;EAC/B,IAAI,QAAa;EAEjB,IACE,QAAQ,YAAY,UACpB,gBACA,UACA,OAAO,SAAS,aAChB,OAAO,YAAY,OACnB;GACA,QAAQ;GACR,SAAS,QAAQ,GAAG,EAAE;GACtB,cAAc;EAChB;EAEA,IAAI,CAAC,QAAQ;EAEb,MAAM,QAAQ,OAAO,OAAO,EAAE,YAAY,MAAM,CAAC;EAEjD,IAAI;EAEJ,IAAI;GACF,SAAS,MAAM,eAAe,OAAO;IAAE,GAAG;IAAU;IAAa,cAAc;GAAK,CAAC;EACvF,SAAS,OAAO;GACd,MAAM,QAAQ;GAEd,KAAK,QAAQ,oCAAoC;IAC/C,WAAW,CAAC,GAAG,SAAS,OAAO;IAC/B;IACA,OAAO,QAAQ;IACf,QAAQ,MAAM,KAAK,YAAY;IAC/B,QAAQ;GACV,CAAC;GAED,IAAI;IACF,SAAS,MAAM,eAAe,OAAO;KACnC,GAAG;KACH;KACA,QAAQ;KACR,cAAc;IAChB,CAAC;GACH,QAAQ;IACN,SAAS,CACP;KACE,UAAU,CAAC;MAAE,MAAM;MAAQ;KAAM,CAAC;KAClC,YAAY;MACV,WAAW,CAAC,aAAa;MACzB,OAAO,YAAY,SAAS,cAAc;MAC1C,OAAO,OAAO,KAAK;KACrB;KACA,SAAS;KACT,MAAM;IACR,CACF;GACF;EACF;EAEA,IAAI,OAAO,WAAW,UACpB,SAAS,mBAAmB,QAAQ,EAAE,UAAU,KAAK,CAAC,CAAC,CAAC;EAG1D,MAAM,QAAQ,OAAO,SAAS,QAAQ,KAAK;EAC3C,OAAO,SAAS,OAAO,OAAO,GAAG,GAAG,MAAM;EAC1C,OAAO;CACT,CAAC;AACH"}
@@ -1,5 +1,4 @@
1
- import { SKIP } from "../../node_modules/.pnpm/unist-util-visit-parents@6.0.2/node_modules/unist-util-visit-parents/lib/index.mjs";
2
- import { visit } from "../../node_modules/.pnpm/unist-util-visit@5.1.0/node_modules/unist-util-visit/lib/index.mjs";
1
+ import { SKIP, visit } from "../../node_modules/.pnpm/unist-util-visit@5.1.0/node_modules/unist-util-visit/lib/index.mjs";
3
2
  //#region src/Markdown/plugins/remarkCustomFootnotes.ts
4
3
  const remarkCustomFootnotes = () => (tree, file) => {
5
4
  const footnoteLinks = /* @__PURE__ */ new Map();
@@ -1 +1 @@
1
- {"version":3,"file":"remarkCustomFootnotes.mjs","names":[],"sources":["../../../src/Markdown/plugins/remarkCustomFootnotes.ts"],"sourcesContent":["import type { Node } from 'unist';\nimport { SKIP, visit } from 'unist-util-visit';\n\nexport interface FootnoteLink {\n alt?: string;\n title?: string;\n url: string;\n}\n\nexport const remarkCustomFootnotes = () => (tree: any, file: any) => {\n const footnoteLinks = new Map();\n\n visit(tree, 'footnoteDefinition', (node) => {\n let linkData: FootnoteLink | null = null;\n\n // 查找第一个link类型的子节点\n visit(node, 'link', (linkNode) => {\n if (linkData) return SKIP; // 只取第一个链接\n\n // 提取链接文本\n const textNode = linkNode.children.find((n: Node) => n.type === 'text');\n\n linkData = {\n alt: textNode?.value || '',\n title: textNode?.value || '',\n url: linkNode.url, // 或者根据需求处理\n };\n\n return SKIP; // 找到后停止遍历\n });\n\n if (linkData) {\n footnoteLinks.set(node.identifier, linkData);\n }\n });\n\n // 将数据存入文件上下文\n file.data.footnoteLinks = Object.fromEntries(footnoteLinks);\n};\n"],"mappings":";;;AASA,MAAa,+BAA+B,MAAW,SAAc;CACnE,MAAM,gCAAgB,IAAI,IAAI;CAE9B,MAAM,MAAM,uBAAuB,SAAS;EAC1C,IAAI,WAAgC;EAGpC,MAAM,MAAM,SAAS,aAAa;GAChC,IAAI,UAAU,OAAO;GAGrB,MAAM,WAAW,SAAS,SAAS,MAAM,MAAY,EAAE,SAAS,MAAM;GAEtE,WAAW;IACT,KAAK,UAAU,SAAS;IACxB,OAAO,UAAU,SAAS;IAC1B,KAAK,SAAS;GAChB;GAEA,OAAO;EACT,CAAC;EAED,IAAI,UACF,cAAc,IAAI,KAAK,YAAY,QAAQ;CAE/C,CAAC;CAGD,KAAK,KAAK,gBAAgB,OAAO,YAAY,aAAa;AAC5D"}
1
+ {"version":3,"file":"remarkCustomFootnotes.mjs","names":[],"sources":["../../../src/Markdown/plugins/remarkCustomFootnotes.ts"],"sourcesContent":["import type { Node } from 'unist';\nimport { SKIP, visit } from 'unist-util-visit';\n\nexport interface FootnoteLink {\n alt?: string;\n title?: string;\n url: string;\n}\n\nexport const remarkCustomFootnotes = () => (tree: any, file: any) => {\n const footnoteLinks = new Map();\n\n visit(tree, 'footnoteDefinition', (node) => {\n let linkData: FootnoteLink | null = null;\n\n // 查找第一个link类型的子节点\n visit(node, 'link', (linkNode) => {\n if (linkData) return SKIP; // 只取第一个链接\n\n // 提取链接文本\n const textNode = linkNode.children.find((n: Node) => n.type === 'text');\n\n linkData = {\n alt: textNode?.value || '',\n title: textNode?.value || '',\n url: linkNode.url, // 或者根据需求处理\n };\n\n return SKIP; // 找到后停止遍历\n });\n\n if (linkData) {\n footnoteLinks.set(node.identifier, linkData);\n }\n });\n\n // 将数据存入文件上下文\n file.data.footnoteLinks = Object.fromEntries(footnoteLinks);\n};\n"],"mappings":";;AASA,MAAa,+BAA+B,MAAW,SAAc;CACnE,MAAM,gCAAgB,IAAI,IAAI;CAE9B,MAAM,MAAM,uBAAuB,SAAS;EAC1C,IAAI,WAAgC;EAGpC,MAAM,MAAM,SAAS,aAAa;GAChC,IAAI,UAAU,OAAO;GAGrB,MAAM,WAAW,SAAS,SAAS,MAAM,MAAY,EAAE,SAAS,MAAM;GAEtE,WAAW;IACT,KAAK,UAAU,SAAS;IACxB,OAAO,UAAU,SAAS;IAC1B,KAAK,SAAS;GAChB;GAEA,OAAO;EACT,CAAC;EAED,IAAI,UACF,cAAc,IAAI,KAAK,YAAY,QAAQ;CAE/C,CAAC;CAGD,KAAK,KAAK,gBAAgB,OAAO,YAAY,aAAa;AAC5D"}
@@ -23,8 +23,8 @@ declare const styles: {
23
23
  };
24
24
  declare const rootVariants: (props?: ({
25
25
  shadow?: boolean | null | undefined;
26
- size?: "large" | "middle" | "small" | null | undefined;
27
- variant?: "filled" | "borderless" | "outlined" | null | undefined;
26
+ size?: "small" | "middle" | "large" | null | undefined;
27
+ variant?: "filled" | "outlined" | "borderless" | null | undefined;
28
28
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
29
29
  //#endregion
30
30
  export { rootVariants, styles };
@@ -25,10 +25,17 @@ const styles = createStaticStyles(({ css }) => ({
25
25
  height: 28px;
26
26
  padding-inline: 12px;
27
27
  border-radius: 6px;
28
+ `,
29
+ middle: css`
30
+ height: 22px;
31
+ padding-inline: 8px;
32
+ border-radius: 3px;
28
33
  `,
29
34
  outlined: staticStylish.variantOutlinedWithoutHover,
30
35
  round: css`
31
- border-radius: 999px;
36
+ && {
37
+ border-radius: 999px;
38
+ }
32
39
  `,
33
40
  roundLarge: css`
34
41
  padding-inline: 14px;
@@ -48,7 +55,6 @@ const styles = createStaticStyles(({ css }) => ({
48
55
  justify-content: center;
49
56
 
50
57
  width: fit-content;
51
- height: 22px;
52
58
  margin: 0;
53
59
 
54
60
  font-size: inherit;
@@ -95,7 +101,7 @@ const variants = cva(styles.root, {
95
101
  },
96
102
  size: {
97
103
  large: styles.large,
98
- middle: null,
104
+ middle: styles.middle,
99
105
  small: styles.small
100
106
  },
101
107
  variant: {
@@ -1 +1 @@
1
- {"version":3,"file":"style.mjs","names":["lobeStaticStylish"],"sources":["../../../src/base-ui/Tag/style.ts"],"sourcesContent":["import { createStaticStyles } from 'antd-style';\nimport { cva } from 'class-variance-authority';\n\nimport { lobeStaticStylish } from '@/styles';\n\nexport const styles = createStaticStyles(({ css }) => ({\n borderless: lobeStaticStylish.variantBorderlessWithoutHover,\n close: css`\n cursor: pointer;\n\n display: inline-flex;\n gap: 0;\n align-items: center;\n justify-content: center;\n\n margin: 0;\n padding: 0;\n border: none;\n\n color: inherit;\n\n background: none;\n `,\n filled: lobeStaticStylish.variantFilledWithoutHover,\n large: css`\n height: 28px;\n padding-inline: 12px;\n border-radius: 6px;\n `,\n outlined: lobeStaticStylish.variantOutlinedWithoutHover,\n round: css`\n border-radius: 999px;\n `,\n roundLarge: css`\n padding-inline: 14px;\n `,\n roundMiddle: css`\n padding-inline: 10px;\n `,\n roundSmall: css`\n padding-inline: 8px;\n `,\n root: css`\n user-select: none;\n\n display: inline-flex;\n gap: 0.4em;\n align-items: center;\n justify-content: center;\n\n width: fit-content;\n height: 22px;\n margin: 0;\n\n font-size: inherit;\n line-height: 1.2;\n\n span {\n margin: 0;\n line-height: inherit;\n }\n `,\n small: css`\n height: 20px;\n padding-inline: 4px;\n border-radius: 3px;\n `,\n}));\n\nexport const variants = cva(styles.root, {\n compoundVariants: [\n {\n className: styles.roundSmall,\n shape: 'round',\n size: 'small',\n },\n {\n className: styles.roundMiddle,\n shape: 'round',\n size: 'middle',\n },\n {\n className: styles.roundLarge,\n shape: 'round',\n size: 'large',\n },\n ],\n defaultVariants: {\n shape: 'normal',\n size: 'middle',\n variant: 'filled',\n },\n variants: {\n shape: {\n normal: null,\n round: styles.round,\n },\n size: {\n large: styles.large,\n middle: null,\n small: styles.small,\n },\n variant: {\n borderless: styles.borderless,\n filled: styles.filled,\n outlined: styles.outlined,\n solid: styles.filled,\n },\n },\n});\n"],"mappings":";;;;AAKA,MAAa,SAAS,oBAAoB,EAAE,WAAW;CACrD,YAAYA,cAAkB;CAC9B,OAAO,GAAG;;;;;;;;;;;;;;;;CAgBV,QAAQA,cAAkB;CAC1B,OAAO,GAAG;;;;;CAKV,UAAUA,cAAkB;CAC5B,OAAO,GAAG;;;CAGV,YAAY,GAAG;;;CAGf,aAAa,GAAG;;;CAGhB,YAAY,GAAG;;;CAGf,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;CAoBT,OAAO,GAAG;;;;;AAKZ,EAAE;AAEF,MAAa,WAAW,IAAI,OAAO,MAAM;CACvC,kBAAkB;EAChB;GACE,WAAW,OAAO;GAClB,OAAO;GACP,MAAM;EACR;EACA;GACE,WAAW,OAAO;GAClB,OAAO;GACP,MAAM;EACR;EACA;GACE,WAAW,OAAO;GAClB,OAAO;GACP,MAAM;EACR;CACF;CACA,iBAAiB;EACf,OAAO;EACP,MAAM;EACN,SAAS;CACX;CACA,UAAU;EACR,OAAO;GACL,QAAQ;GACR,OAAO,OAAO;EAChB;EACA,MAAM;GACJ,OAAO,OAAO;GACd,QAAQ;GACR,OAAO,OAAO;EAChB;EACA,SAAS;GACP,YAAY,OAAO;GACnB,QAAQ,OAAO;GACf,UAAU,OAAO;GACjB,OAAO,OAAO;EAChB;CACF;AACF,CAAC"}
1
+ {"version":3,"file":"style.mjs","names":["lobeStaticStylish"],"sources":["../../../src/base-ui/Tag/style.ts"],"sourcesContent":["import { createStaticStyles } from 'antd-style';\nimport { cva } from 'class-variance-authority';\n\nimport { lobeStaticStylish } from '@/styles';\n\nexport const styles = createStaticStyles(({ css }) => ({\n borderless: lobeStaticStylish.variantBorderlessWithoutHover,\n close: css`\n cursor: pointer;\n\n display: inline-flex;\n gap: 0;\n align-items: center;\n justify-content: center;\n\n margin: 0;\n padding: 0;\n border: none;\n\n color: inherit;\n\n background: none;\n `,\n filled: lobeStaticStylish.variantFilledWithoutHover,\n large: css`\n height: 28px;\n padding-inline: 12px;\n border-radius: 6px;\n `,\n middle: css`\n height: 22px;\n padding-inline: 8px;\n border-radius: 3px;\n `,\n outlined: lobeStaticStylish.variantOutlinedWithoutHover,\n round: css`\n && {\n border-radius: 999px;\n }\n `,\n roundLarge: css`\n padding-inline: 14px;\n `,\n roundMiddle: css`\n padding-inline: 10px;\n `,\n roundSmall: css`\n padding-inline: 8px;\n `,\n root: css`\n user-select: none;\n\n display: inline-flex;\n gap: 0.4em;\n align-items: center;\n justify-content: center;\n\n width: fit-content;\n margin: 0;\n\n font-size: inherit;\n line-height: 1.2;\n\n span {\n margin: 0;\n line-height: inherit;\n }\n `,\n small: css`\n height: 20px;\n padding-inline: 4px;\n border-radius: 3px;\n `,\n}));\n\nexport const variants = cva(styles.root, {\n compoundVariants: [\n {\n className: styles.roundSmall,\n shape: 'round',\n size: 'small',\n },\n {\n className: styles.roundMiddle,\n shape: 'round',\n size: 'middle',\n },\n {\n className: styles.roundLarge,\n shape: 'round',\n size: 'large',\n },\n ],\n defaultVariants: {\n shape: 'normal',\n size: 'middle',\n variant: 'filled',\n },\n variants: {\n shape: {\n normal: null,\n round: styles.round,\n },\n size: {\n large: styles.large,\n middle: styles.middle,\n small: styles.small,\n },\n variant: {\n borderless: styles.borderless,\n filled: styles.filled,\n outlined: styles.outlined,\n solid: styles.filled,\n },\n },\n});\n"],"mappings":";;;;AAKA,MAAa,SAAS,oBAAoB,EAAE,WAAW;CACrD,YAAYA,cAAkB;CAC9B,OAAO,GAAG;;;;;;;;;;;;;;;;CAgBV,QAAQA,cAAkB;CAC1B,OAAO,GAAG;;;;;CAKV,QAAQ,GAAG;;;;;CAKX,UAAUA,cAAkB;CAC5B,OAAO,GAAG;;;;;CAKV,YAAY,GAAG;;;CAGf,aAAa,GAAG;;;CAGhB,YAAY,GAAG;;;CAGf,MAAM,GAAG;;;;;;;;;;;;;;;;;;;CAmBT,OAAO,GAAG;;;;;AAKZ,EAAE;AAEF,MAAa,WAAW,IAAI,OAAO,MAAM;CACvC,kBAAkB;EAChB;GACE,WAAW,OAAO;GAClB,OAAO;GACP,MAAM;EACR;EACA;GACE,WAAW,OAAO;GAClB,OAAO;GACP,MAAM;EACR;EACA;GACE,WAAW,OAAO;GAClB,OAAO;GACP,MAAM;EACR;CACF;CACA,iBAAiB;EACf,OAAO;EACP,MAAM;EACN,SAAS;CACX;CACA,UAAU;EACR,OAAO;GACL,QAAQ;GACR,OAAO,OAAO;EAChB;EACA,MAAM;GACJ,OAAO,OAAO;GACd,QAAQ,OAAO;GACf,OAAO,OAAO;EAChB;EACA,SAAS;GACP,YAAY,OAAO;GACnB,QAAQ,OAAO;GACf,UAAU,OAAO;GACjB,OAAO,OAAO;EAChB;CACF;AACF,CAAC"}
@@ -1,10 +1,10 @@
1
1
  "use client";
2
2
  import { useMarkdownContext } from "../../Markdown/components/MarkdownProvider.mjs";
3
3
  import { rehypeCustomFootnotes } from "../../Markdown/plugins/rehypeCustomFootnotes.mjs";
4
+ import { rehypeKatex } from "../../Markdown/plugins/rehypeKatex.mjs";
4
5
  import { rehypeKatexDir } from "../../Markdown/plugins/rehypeKatexDir.mjs";
5
6
  import { useMemo } from "react";
6
7
  import { rehypeGithubAlerts } from "rehype-github-alerts";
7
- import rehypeKatex from "rehype-katex";
8
8
  import rehypeRaw from "rehype-raw";
9
9
  //#region src/hooks/useMarkdown/useMarkdownRehypePlugins.ts
10
10
  const useMarkdownRehypePlugins = () => {
@@ -1 +1 @@
1
- {"version":3,"file":"useMarkdownRehypePlugins.mjs","names":[],"sources":["../../../src/hooks/useMarkdown/useMarkdownRehypePlugins.ts"],"sourcesContent":["'use client';\n\nimport { useMemo } from 'react';\nimport { rehypeGithubAlerts } from 'rehype-github-alerts';\nimport rehypeKatex from 'rehype-katex';\nimport rehypeRaw from 'rehype-raw';\nimport type { Pluggable } from 'unified';\n\nimport { useMarkdownContext } from '@/Markdown/components/MarkdownProvider';\nimport { rehypeCustomFootnotes } from '@/Markdown/plugins/rehypeCustomFootnotes';\nimport { rehypeKatexDir } from '@/Markdown/plugins/rehypeKatexDir';\n\nexport const useMarkdownRehypePlugins = (): Pluggable[] => {\n const {\n enableLatex,\n enableCustomFootnotes,\n enableGithubAlert,\n allowHtml,\n rehypePlugins = [],\n rehypePluginsAhead = [],\n } = useMarkdownContext();\n\n const memoPlugins = useMemo(\n () =>\n [\n allowHtml && rehypeRaw,\n enableGithubAlert && rehypeGithubAlerts,\n enableLatex && rehypeKatex,\n enableLatex && rehypeKatexDir,\n enableCustomFootnotes && rehypeCustomFootnotes,\n ].filter(Boolean) as Pluggable[],\n [enableLatex, enableGithubAlert, enableCustomFootnotes, allowHtml],\n );\n\n return useMemo(\n () => [...rehypePluginsAhead, ...memoPlugins, ...rehypePlugins],\n [rehypePlugins, memoPlugins, rehypePluginsAhead],\n );\n};\n"],"mappings":";;;;;;;;;AAYA,MAAa,iCAA8C;CACzD,MAAM,EACJ,aACA,uBACA,mBACA,WACA,gBAAgB,CAAC,GACjB,qBAAqB,CAAC,MACpB,mBAAmB;CAEvB,MAAM,cAAc,cAEhB;EACE,aAAa;EACb,qBAAqB;EACrB,eAAe;EACf,eAAe;EACf,yBAAyB;CAC3B,CAAC,CAAC,OAAO,OAAO,GAClB;EAAC;EAAa;EAAmB;EAAuB;CAAS,CACnE;CAEA,OAAO,cACC;EAAC,GAAG;EAAoB,GAAG;EAAa,GAAG;CAAa,GAC9D;EAAC;EAAe;EAAa;CAAkB,CACjD;AACF"}
1
+ {"version":3,"file":"useMarkdownRehypePlugins.mjs","names":[],"sources":["../../../src/hooks/useMarkdown/useMarkdownRehypePlugins.ts"],"sourcesContent":["'use client';\n\nimport { useMemo } from 'react';\nimport { rehypeGithubAlerts } from 'rehype-github-alerts';\nimport rehypeRaw from 'rehype-raw';\nimport type { Pluggable } from 'unified';\n\nimport { useMarkdownContext } from '@/Markdown/components/MarkdownProvider';\nimport { rehypeCustomFootnotes } from '@/Markdown/plugins/rehypeCustomFootnotes';\nimport { rehypeKatex } from '@/Markdown/plugins/rehypeKatex';\nimport { rehypeKatexDir } from '@/Markdown/plugins/rehypeKatexDir';\n\nexport const useMarkdownRehypePlugins = (): Pluggable[] => {\n const {\n enableLatex,\n enableCustomFootnotes,\n enableGithubAlert,\n allowHtml,\n rehypePlugins = [],\n rehypePluginsAhead = [],\n } = useMarkdownContext();\n\n const memoPlugins = useMemo(\n () =>\n [\n allowHtml && rehypeRaw,\n enableGithubAlert && rehypeGithubAlerts,\n enableLatex && rehypeKatex,\n enableLatex && rehypeKatexDir,\n enableCustomFootnotes && rehypeCustomFootnotes,\n ].filter(Boolean) as Pluggable[],\n [enableLatex, enableGithubAlert, enableCustomFootnotes, allowHtml],\n );\n\n return useMemo(\n () => [...rehypePluginsAhead, ...memoPlugins, ...rehypePlugins],\n [rehypePlugins, memoPlugins, rehypePluginsAhead],\n );\n};\n"],"mappings":";;;;;;;;;AAYA,MAAa,iCAA8C;CACzD,MAAM,EACJ,aACA,uBACA,mBACA,WACA,gBAAgB,CAAC,GACjB,qBAAqB,CAAC,MACpB,mBAAmB;CAEvB,MAAM,cAAc,cAEhB;EACE,aAAa;EACb,qBAAqB;EACrB,eAAe;EACf,eAAe;EACf,yBAAyB;CAC3B,CAAC,CAAC,OAAO,OAAO,GAClB;EAAC;EAAa;EAAmB;EAAuB;CAAS,CACnE;CAEA,OAAO,cACC;EAAC,GAAG;EAAoB,GAAG;EAAa,GAAG;CAAa,GAC9D;EAAC;EAAe;EAAa;CAAkB,CACjD;AACF"}
@@ -5,6 +5,7 @@ import { styles } from "../../Markdown/style.mjs";
5
5
  import Image from "../mdxComponents/Image.mjs";
6
6
  import Video from "../mdxComponents/Video.mjs";
7
7
  import { useMarkdownContent } from "../../hooks/useMarkdown/useMarkdownContent.mjs";
8
+ import { rehypeKatex } from "../../Markdown/plugins/rehypeKatex.mjs";
8
9
  import Typography from "../../Markdown/Typography.mjs";
9
10
  import mdxComponents from "../mdxComponents/index.mjs";
10
11
  import CodeBlock from "../mdxComponents/CodeBlock.mjs";
@@ -12,7 +13,6 @@ import { memo, useEffect, useMemo, useState } from "react";
12
13
  import jsxRuntime, { jsx } from "react/jsx-runtime";
13
14
  import { cx } from "antd-style";
14
15
  import { rehypeGithubAlerts } from "rehype-github-alerts";
15
- import rehypeKatex from "rehype-katex";
16
16
  import remarkGfm from "remark-gfm";
17
17
  import remarkMath from "remark-math";
18
18
  import { evaluate } from "@mdx-js/mdx";
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/mdx/Mdx/index.tsx"],"sourcesContent":["'use client';\n\nimport { evaluate } from '@mdx-js/mdx';\nimport { cx } from 'antd-style';\nimport { memo, type ReactNode, useEffect, useMemo, useState } from 'react';\nimport jsxDevRuntime from 'react/jsx-dev-runtime';\nimport jsxRuntime from 'react/jsx-runtime';\nimport { rehypeGithubAlerts } from 'rehype-github-alerts';\nimport rehypeKatex from 'rehype-katex';\nimport remarkGfm from 'remark-gfm';\nimport remarkMath from 'remark-math';\nimport { type Pluggable } from 'unified';\n\nimport Alert from '@/Alert';\nimport { useMarkdownContent } from '@/hooks/useMarkdown';\nimport { PreviewGroup } from '@/Image';\nimport { Typography, type TypographyProps } from '@/Markdown';\nimport { styles } from '@/Markdown/style';\n\nimport mdxComponents from '../mdxComponents';\nimport CodeBlock from '../mdxComponents/CodeBlock';\nimport Image from '../mdxComponents/Image';\nimport Video from '../mdxComponents/Video';\n\nconst runtime = process.env.NODE_ENV === 'production' ? jsxRuntime : jsxDevRuntime;\n\nexport interface MdxProps extends Omit<TypographyProps, 'children'> {\n children: string;\n components?: any[];\n enableImageGallery?: boolean;\n enableLatex?: boolean;\n enableMermaid?: boolean;\n fallback?: ReactNode;\n fullFeaturedCodeBlock?: boolean;\n onDoubleClick?: () => void;\n rehypePlugins?: Pluggable[];\n remarkPlugins?: Pluggable[];\n variant?: 'normal' | 'chat';\n}\n\nconst Mdx = memo<MdxProps>(\n ({\n children,\n className,\n style,\n fullFeaturedCodeBlock = true,\n enableImageGallery,\n enableLatex = true,\n enableMermaid = true,\n rehypePlugins,\n remarkPlugins,\n components = {},\n fallback = null,\n fontSize,\n headerMultiple,\n lineHeight,\n marginMultiple,\n variant,\n ...rest\n }) => {\n const escapedContent = useMarkdownContent(children);\n\n const isChatMode = variant === 'chat';\n\n const [MDXContent, setMDXContent] = useState<any>(() => () => null);\n\n const innerRehypePlugins = Array.isArray(rehypePlugins) ? rehypePlugins : [rehypePlugins];\n const memoRehypePlugins = useMemo(\n () =>\n [rehypeGithubAlerts, enableLatex && rehypeKatex, ...innerRehypePlugins].filter(\n Boolean,\n ) as any,\n [enableLatex, ...innerRehypePlugins],\n );\n\n const innerRemarkPlugins = Array.isArray(remarkPlugins) ? remarkPlugins : [remarkPlugins];\n const memoRemarkPlugins = useMemo(\n () => [remarkGfm, enableLatex && remarkMath, ...innerRemarkPlugins].filter(Boolean) as any,\n [enableLatex, ...innerRemarkPlugins],\n );\n\n const memoComponents = useMemo(() => {\n const list: any = {};\n Object.entries({\n ...mdxComponents,\n img: Image,\n pre: (props: any) => (\n <CodeBlock\n {...props}\n enableMermaid={enableMermaid}\n fullFeatured={fullFeaturedCodeBlock}\n />\n ),\n video: Video,\n ...components,\n }).forEach(([key, Render]: any) => {\n list[key] = (props: any) => <Render {...props} />;\n });\n return list;\n }, [components, enableMermaid, fullFeaturedCodeBlock]);\n\n useEffect(() => {\n if (!escapedContent) return;\n (async () => {\n try {\n const { default: Content } = await evaluate(escapedContent, {\n ...runtime,\n development: process.env.NODE_ENV !== 'production',\n rehypePlugins: memoRehypePlugins,\n remarkPlugins: memoRemarkPlugins,\n });\n setMDXContent(() => Content);\n } catch (error: any) {\n // @ts-ignore\n setMDXContent(() => () => (\n <Alert\n description={String(error?.message as string)}\n title={'Error compiling MDX'}\n type=\"error\"\n style={{\n width: '100%',\n }}\n />\n ));\n console.error('Error compiling MDX:', error);\n }\n })();\n }, [escapedContent, memoRehypePlugins, memoRemarkPlugins]);\n\n if (!escapedContent || !MDXContent) return fallback;\n\n return (\n <Typography\n className={cx(enableLatex && styles.latex, isChatMode && styles.chat, className)}\n data-code-type=\"mdx\"\n fontSize={fontSize}\n headerMultiple={headerMultiple}\n lineHeight={lineHeight}\n marginMultiple={marginMultiple}\n style={style}\n {...rest}\n >\n <PreviewGroup enable={enableImageGallery}>\n <MDXContent components={memoComponents} />\n </PreviewGroup>\n </Typography>\n );\n },\n);\n\nMdx.displayName = 'Mdx';\n\nexport default Mdx;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAwBA,MAAM,UAAU,QAAQ,IAAI,aAAa,eAAe,aAAa;AAgBrE,MAAM,MAAM,MACT,EACC,UACA,WACA,OACA,wBAAwB,MACxB,oBACA,cAAc,MACd,gBAAgB,MAChB,eACA,eACA,aAAa,CAAC,GACd,WAAW,MACX,UACA,gBACA,YACA,gBACA,SACA,GAAG,WACC;CACJ,MAAM,iBAAiB,mBAAmB,QAAQ;CAElD,MAAM,aAAa,YAAY;CAE/B,MAAM,CAAC,YAAY,iBAAiB,qBAA0B,IAAI;CAElE,MAAM,qBAAqB,MAAM,QAAQ,aAAa,IAAI,gBAAgB,CAAC,aAAa;CACxF,MAAM,oBAAoB,cAEtB;EAAC;EAAoB,eAAe;EAAa,GAAG;CAAkB,CAAC,CAAC,OACtE,OACF,GACF,CAAC,aAAa,GAAG,kBAAkB,CACrC;CAEA,MAAM,qBAAqB,MAAM,QAAQ,aAAa,IAAI,gBAAgB,CAAC,aAAa;CACxF,MAAM,oBAAoB,cAClB;EAAC;EAAW,eAAe;EAAY,GAAG;CAAkB,CAAC,CAAC,OAAO,OAAO,GAClF,CAAC,aAAa,GAAG,kBAAkB,CACrC;CAEA,MAAM,iBAAiB,cAAc;EACnC,MAAM,OAAY,CAAC;EACnB,OAAO,QAAQ;GACb,GAAG;GACH,KAAK;GACL,MAAM,UACJ,oBAAC,WAAD;IACE,GAAI;IACW;IACf,cAAc;GACf,CAAA;GAEH,OAAO;GACP,GAAG;EACL,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,YAAiB;GACjC,KAAK,QAAQ,UAAe,oBAAC,QAAD,EAAQ,GAAI,MAAQ,CAAA;EAClD,CAAC;EACD,OAAO;CACT,GAAG;EAAC;EAAY;EAAe;CAAqB,CAAC;CAErD,gBAAgB;EACd,IAAI,CAAC,gBAAgB;EACrB,CAAC,YAAY;GACX,IAAI;IACF,MAAM,EAAE,SAAS,YAAY,MAAM,SAAS,gBAAgB;KAC1D,GAAG;KACH,aAAa,QAAQ,IAAI,aAAa;KACtC,eAAe;KACf,eAAe;IACjB,CAAC;IACD,oBAAoB,OAAO;GAC7B,SAAS,OAAY;IAEnB,0BACE,oBAAC,OAAD;KACE,aAAa,OAAO,OAAO,OAAiB;KAC5C,OAAO;KACP,MAAK;KACL,OAAO,EACL,OAAO,OACT;IACD,CAAA,CACF;IACD,QAAQ,MAAM,wBAAwB,KAAK;GAC7C;EACF,EAAA,CAAG;CACL,GAAG;EAAC;EAAgB;EAAmB;CAAiB,CAAC;CAEzD,IAAI,CAAC,kBAAkB,CAAC,YAAY,OAAO;CAE3C,OACE,oBAAC,YAAD;EACE,WAAW,GAAG,eAAe,OAAO,OAAO,cAAc,OAAO,MAAM,SAAS;EAC/E,kBAAe;EACL;EACM;EACJ;EACI;EACT;EACP,GAAI;EAEJ,UAAA,oBAAC,cAAD;GAAc,QAAQ;GACpB,UAAA,oBAAC,YAAD,EAAY,YAAY,eAAiB,CAAA;EAC7B,CAAA;CACJ,CAAA;AAEhB,CACF;AAEA,IAAI,cAAc"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/mdx/Mdx/index.tsx"],"sourcesContent":["'use client';\n\nimport { evaluate } from '@mdx-js/mdx';\nimport { cx } from 'antd-style';\nimport { memo, type ReactNode, useEffect, useMemo, useState } from 'react';\nimport jsxDevRuntime from 'react/jsx-dev-runtime';\nimport jsxRuntime from 'react/jsx-runtime';\nimport { rehypeGithubAlerts } from 'rehype-github-alerts';\nimport remarkGfm from 'remark-gfm';\nimport remarkMath from 'remark-math';\nimport { type Pluggable } from 'unified';\n\nimport Alert from '@/Alert';\nimport { useMarkdownContent } from '@/hooks/useMarkdown';\nimport { PreviewGroup } from '@/Image';\nimport { Typography, type TypographyProps } from '@/Markdown';\nimport { rehypeKatex } from '@/Markdown/plugins/rehypeKatex';\nimport { styles } from '@/Markdown/style';\n\nimport mdxComponents from '../mdxComponents';\nimport CodeBlock from '../mdxComponents/CodeBlock';\nimport Image from '../mdxComponents/Image';\nimport Video from '../mdxComponents/Video';\n\nconst runtime = process.env.NODE_ENV === 'production' ? jsxRuntime : jsxDevRuntime;\n\nexport interface MdxProps extends Omit<TypographyProps, 'children'> {\n children: string;\n components?: any[];\n enableImageGallery?: boolean;\n enableLatex?: boolean;\n enableMermaid?: boolean;\n fallback?: ReactNode;\n fullFeaturedCodeBlock?: boolean;\n onDoubleClick?: () => void;\n rehypePlugins?: Pluggable[];\n remarkPlugins?: Pluggable[];\n variant?: 'normal' | 'chat';\n}\n\nconst Mdx = memo<MdxProps>(\n ({\n children,\n className,\n style,\n fullFeaturedCodeBlock = true,\n enableImageGallery,\n enableLatex = true,\n enableMermaid = true,\n rehypePlugins,\n remarkPlugins,\n components = {},\n fallback = null,\n fontSize,\n headerMultiple,\n lineHeight,\n marginMultiple,\n variant,\n ...rest\n }) => {\n const escapedContent = useMarkdownContent(children);\n\n const isChatMode = variant === 'chat';\n\n const [MDXContent, setMDXContent] = useState<any>(() => () => null);\n\n const innerRehypePlugins = Array.isArray(rehypePlugins) ? rehypePlugins : [rehypePlugins];\n const memoRehypePlugins = useMemo(\n () =>\n [rehypeGithubAlerts, enableLatex && rehypeKatex, ...innerRehypePlugins].filter(\n Boolean,\n ) as any,\n [enableLatex, ...innerRehypePlugins],\n );\n\n const innerRemarkPlugins = Array.isArray(remarkPlugins) ? remarkPlugins : [remarkPlugins];\n const memoRemarkPlugins = useMemo(\n () => [remarkGfm, enableLatex && remarkMath, ...innerRemarkPlugins].filter(Boolean) as any,\n [enableLatex, ...innerRemarkPlugins],\n );\n\n const memoComponents = useMemo(() => {\n const list: any = {};\n Object.entries({\n ...mdxComponents,\n img: Image,\n pre: (props: any) => (\n <CodeBlock\n {...props}\n enableMermaid={enableMermaid}\n fullFeatured={fullFeaturedCodeBlock}\n />\n ),\n video: Video,\n ...components,\n }).forEach(([key, Render]: any) => {\n list[key] = (props: any) => <Render {...props} />;\n });\n return list;\n }, [components, enableMermaid, fullFeaturedCodeBlock]);\n\n useEffect(() => {\n if (!escapedContent) return;\n (async () => {\n try {\n const { default: Content } = await evaluate(escapedContent, {\n ...runtime,\n development: process.env.NODE_ENV !== 'production',\n rehypePlugins: memoRehypePlugins,\n remarkPlugins: memoRemarkPlugins,\n });\n setMDXContent(() => Content);\n } catch (error: any) {\n // @ts-ignore\n setMDXContent(() => () => (\n <Alert\n description={String(error?.message as string)}\n title={'Error compiling MDX'}\n type=\"error\"\n style={{\n width: '100%',\n }}\n />\n ));\n console.error('Error compiling MDX:', error);\n }\n })();\n }, [escapedContent, memoRehypePlugins, memoRemarkPlugins]);\n\n if (!escapedContent || !MDXContent) return fallback;\n\n return (\n <Typography\n className={cx(enableLatex && styles.latex, isChatMode && styles.chat, className)}\n data-code-type=\"mdx\"\n fontSize={fontSize}\n headerMultiple={headerMultiple}\n lineHeight={lineHeight}\n marginMultiple={marginMultiple}\n style={style}\n {...rest}\n >\n <PreviewGroup enable={enableImageGallery}>\n <MDXContent components={memoComponents} />\n </PreviewGroup>\n </Typography>\n );\n },\n);\n\nMdx.displayName = 'Mdx';\n\nexport default Mdx;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAwBA,MAAM,UAAU,QAAQ,IAAI,aAAa,eAAe,aAAa;AAgBrE,MAAM,MAAM,MACT,EACC,UACA,WACA,OACA,wBAAwB,MACxB,oBACA,cAAc,MACd,gBAAgB,MAChB,eACA,eACA,aAAa,CAAC,GACd,WAAW,MACX,UACA,gBACA,YACA,gBACA,SACA,GAAG,WACC;CACJ,MAAM,iBAAiB,mBAAmB,QAAQ;CAElD,MAAM,aAAa,YAAY;CAE/B,MAAM,CAAC,YAAY,iBAAiB,qBAA0B,IAAI;CAElE,MAAM,qBAAqB,MAAM,QAAQ,aAAa,IAAI,gBAAgB,CAAC,aAAa;CACxF,MAAM,oBAAoB,cAEtB;EAAC;EAAoB,eAAe;EAAa,GAAG;CAAkB,CAAC,CAAC,OACtE,OACF,GACF,CAAC,aAAa,GAAG,kBAAkB,CACrC;CAEA,MAAM,qBAAqB,MAAM,QAAQ,aAAa,IAAI,gBAAgB,CAAC,aAAa;CACxF,MAAM,oBAAoB,cAClB;EAAC;EAAW,eAAe;EAAY,GAAG;CAAkB,CAAC,CAAC,OAAO,OAAO,GAClF,CAAC,aAAa,GAAG,kBAAkB,CACrC;CAEA,MAAM,iBAAiB,cAAc;EACnC,MAAM,OAAY,CAAC;EACnB,OAAO,QAAQ;GACb,GAAG;GACH,KAAK;GACL,MAAM,UACJ,oBAAC,WAAD;IACE,GAAI;IACW;IACf,cAAc;GACf,CAAA;GAEH,OAAO;GACP,GAAG;EACL,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,YAAiB;GACjC,KAAK,QAAQ,UAAe,oBAAC,QAAD,EAAQ,GAAI,MAAQ,CAAA;EAClD,CAAC;EACD,OAAO;CACT,GAAG;EAAC;EAAY;EAAe;CAAqB,CAAC;CAErD,gBAAgB;EACd,IAAI,CAAC,gBAAgB;EACrB,CAAC,YAAY;GACX,IAAI;IACF,MAAM,EAAE,SAAS,YAAY,MAAM,SAAS,gBAAgB;KAC1D,GAAG;KACH,aAAa,QAAQ,IAAI,aAAa;KACtC,eAAe;KACf,eAAe;IACjB,CAAC;IACD,oBAAoB,OAAO;GAC7B,SAAS,OAAY;IAEnB,0BACE,oBAAC,OAAD;KACE,aAAa,OAAO,OAAO,OAAiB;KAC5C,OAAO;KACP,MAAK;KACL,OAAO,EACL,OAAO,OACT;IACD,CAAA,CACF;IACD,QAAQ,MAAM,wBAAwB,KAAK;GAC7C;EACF,EAAA,CAAG;CACL,GAAG;EAAC;EAAgB;EAAmB;CAAiB,CAAC;CAEzD,IAAI,CAAC,kBAAkB,CAAC,YAAY,OAAO;CAE3C,OACE,oBAAC,YAAD;EACE,WAAW,GAAG,eAAe,OAAO,OAAO,cAAc,OAAO,MAAM,SAAS;EAC/E,kBAAe;EACL;EACM;EACJ;EACI;EACT;EACP,GAAI;EAEJ,UAAA,oBAAC,cAAD;GAAc,QAAQ;GACpB,UAAA,oBAAC,YAAD,EAAY,YAAY,eAAiB,CAAA;EAC7B,CAAA;CACJ,CAAA;AAEhB,CACF;AAEA,IAAI,cAAc"}
@@ -1,4 +1,4 @@
1
- import { SKIP, visitParents } from "../../../../unist-util-visit-parents@6.0.2/node_modules/unist-util-visit-parents/lib/index.mjs";
1
+ import { SKIP as SKIP$1, visitParents } from "unist-util-visit-parents";
2
2
  //#region node_modules/.pnpm/unist-util-visit@5.1.0/node_modules/unist-util-visit/lib/index.js
3
3
  /**
4
4
  * @import {Node as UnistNode, Parent as UnistParent} from 'unist'
@@ -284,6 +284,6 @@ function visit(tree, testOrVisitor, visitorOrReverse, maybeReverse) {
284
284
  }
285
285
  }
286
286
  //#endregion
287
- export { SKIP, visit };
287
+ export { SKIP$1 as SKIP, visit };
288
288
 
289
289
  //# sourceMappingURL=index.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "5.34.1",
3
+ "version": "5.34.3",
4
4
  "description": "Lobe UI is an open-source UI component library for building AIGC web apps",
5
5
  "keywords": [
6
6
  "lobehub",
@@ -167,7 +167,9 @@
167
167
  "emoji-mart": "^5.6.0",
168
168
  "es-toolkit": "^1.49.0",
169
169
  "fast-deep-equal": "^3.1.3",
170
+ "hast-util-from-html-isomorphic": "^2.0.0",
170
171
  "hast-util-to-jsx-runtime": "^2.3.6",
172
+ "hast-util-to-text": "^4.0.2",
171
173
  "html-url-attributes": "^3.0.1",
172
174
  "immer": "^11.1.11",
173
175
  "katex": "^0.18.1",
@@ -192,7 +194,6 @@
192
194
  "react-rnd": "^10.5.3",
193
195
  "react-zoom-pan-pinch": "^4.0.3",
194
196
  "rehype-github-alerts": "^4.2.0",
195
- "rehype-katex": "^7.0.1",
196
197
  "rehype-raw": "^7.0.0",
197
198
  "remark-breaks": "^4.0.0",
198
199
  "remark-cjk-friendly": "^2.3.1",
@@ -206,6 +207,7 @@
206
207
  "swr": "^2.4.2",
207
208
  "ts-md5": "^2.0.1",
208
209
  "unified": "^11.0.5",
210
+ "unist-util-visit-parents": "^6.0.2",
209
211
  "url-join": "^5.0.0",
210
212
  "use-merge-value": "^1.2.0",
211
213
  "uuid": "^14.0.1",
@@ -1,117 +0,0 @@
1
- //#region node_modules/.pnpm/unist-util-is@6.0.1/node_modules/unist-util-is/lib/index.js
2
- /**
3
- * Generate an assertion from a test.
4
- *
5
- * Useful if you’re going to test many nodes, for example when creating a
6
- * utility where something else passes a compatible test.
7
- *
8
- * The created function is a bit faster because it expects valid input only:
9
- * a `node`, `index`, and `parent`.
10
- *
11
- * @param {Test} test
12
- * * when nullish, checks if `node` is a `Node`.
13
- * * when `string`, works like passing `(node) => node.type === test`.
14
- * * when `function` checks if function passed the node is true.
15
- * * when `object`, checks that all keys in test are in node, and that they have (strictly) equal values.
16
- * * when `array`, checks if any one of the subtests pass.
17
- * @returns {Check}
18
- * An assertion.
19
- */
20
- const convert = (
21
- /**
22
- * @param {Test} [test]
23
- * @returns {Check}
24
- */
25
- function(test) {
26
- if (test === null || test === void 0) return ok;
27
- if (typeof test === "function") return castFactory(test);
28
- if (typeof test === "object") return Array.isArray(test) ? anyFactory(test) : propertiesFactory(test);
29
- if (typeof test === "string") return typeFactory(test);
30
- throw new Error("Expected function, string, or object as test");
31
- });
32
- /**
33
- * @param {Array<Props | TestFunction | string>} tests
34
- * @returns {Check}
35
- */
36
- function anyFactory(tests) {
37
- /** @type {Array<Check>} */
38
- const checks = [];
39
- let index = -1;
40
- while (++index < tests.length) checks[index] = convert(tests[index]);
41
- return castFactory(any);
42
- /**
43
- * @this {unknown}
44
- * @type {TestFunction}
45
- */
46
- function any(...parameters) {
47
- let index = -1;
48
- while (++index < checks.length) if (checks[index].apply(this, parameters)) return true;
49
- return false;
50
- }
51
- }
52
- /**
53
- * Turn an object into a test for a node with a certain fields.
54
- *
55
- * @param {Props} check
56
- * @returns {Check}
57
- */
58
- function propertiesFactory(check) {
59
- const checkAsRecord = check;
60
- return castFactory(all);
61
- /**
62
- * @param {Node} node
63
- * @returns {boolean}
64
- */
65
- function all(node) {
66
- const nodeAsRecord = node;
67
- /** @type {string} */
68
- let key;
69
- for (key in check) if (nodeAsRecord[key] !== checkAsRecord[key]) return false;
70
- return true;
71
- }
72
- }
73
- /**
74
- * Turn a string into a test for a node with a certain type.
75
- *
76
- * @param {string} check
77
- * @returns {Check}
78
- */
79
- function typeFactory(check) {
80
- return castFactory(type);
81
- /**
82
- * @param {Node} node
83
- */
84
- function type(node) {
85
- return node && node.type === check;
86
- }
87
- }
88
- /**
89
- * Turn a custom test into a test for a node that passes that test.
90
- *
91
- * @param {TestFunction} testFunction
92
- * @returns {Check}
93
- */
94
- function castFactory(testFunction) {
95
- return check;
96
- /**
97
- * @this {unknown}
98
- * @type {Check}
99
- */
100
- function check(value, index, parent) {
101
- return Boolean(looksLikeANode(value) && testFunction.call(this, value, typeof index === "number" ? index : void 0, parent || void 0));
102
- }
103
- }
104
- function ok() {
105
- return true;
106
- }
107
- /**
108
- * @param {unknown} value
109
- * @returns {value is Node}
110
- */
111
- function looksLikeANode(value) {
112
- return value !== null && typeof value === "object" && "type" in value;
113
- }
114
- //#endregion
115
- export { convert };
116
-
117
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../../../../../node_modules/.pnpm/unist-util-is@6.0.1/node_modules/unist-util-is/lib/index.js"],"sourcesContent":["/**\n * @import {Node, Parent} from 'unist'\n */\n\n/**\n * @template Fn\n * @template Fallback\n * @typedef {Fn extends (value: any) => value is infer Thing ? Thing : Fallback} Predicate\n */\n\n/**\n * @callback Check\n * Check that an arbitrary value is a node.\n * @param {unknown} this\n * The given context.\n * @param {unknown} [node]\n * Anything (typically a node).\n * @param {number | null | undefined} [index]\n * The node’s position in its parent.\n * @param {Parent | null | undefined} [parent]\n * The node’s parent.\n * @returns {boolean}\n * Whether this is a node and passes a test.\n *\n * @typedef {Record<string, unknown> | Node} Props\n * Object to check for equivalence.\n *\n * Note: `Node` is included as it is common but is not indexable.\n *\n * @typedef {Array<Props | TestFunction | string> | ReadonlyArray<Props | TestFunction | string> | Props | TestFunction | string | null | undefined} Test\n * Check for an arbitrary node.\n *\n * @callback TestFunction\n * Check if a node passes a test.\n * @param {unknown} this\n * The given context.\n * @param {Node} node\n * A node.\n * @param {number | undefined} [index]\n * The node’s position in its parent.\n * @param {Parent | undefined} [parent]\n * The node’s parent.\n * @returns {boolean | undefined | void}\n * Whether this node passes the test.\n *\n * Note: `void` is included until TS sees no return as `undefined`.\n */\n\n/**\n * Check if `node` is a `Node` and whether it passes the given test.\n *\n * @param {unknown} node\n * Thing to check, typically `Node`.\n * @param {Test} test\n * A check for a specific node.\n * @param {number | null | undefined} index\n * The node’s position in its parent.\n * @param {Parent | null | undefined} parent\n * The node’s parent.\n * @param {unknown} context\n * Context object (`this`) to pass to `test` functions.\n * @returns {boolean}\n * Whether `node` is a node and passes a test.\n */\nexport const is =\n // Note: overloads in JSDoc can’t yet use different `@template`s.\n /**\n * @type {(\n * (<Condition extends ReadonlyArray<string>>(node: unknown, test: Condition, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & {type: Condition[number]}) &\n * (<Condition extends Array<string>>(node: unknown, test: Condition, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & {type: Condition[number]}) &\n * (<Condition extends string>(node: unknown, test: Condition, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & {type: Condition}) &\n * (<Condition extends Props>(node: unknown, test: Condition, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Condition) &\n * (<Condition extends TestFunction>(node: unknown, test: Condition, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Predicate<Condition, Node>) &\n * ((node?: null | undefined) => false) &\n * ((node: unknown, test?: null | undefined, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node) &\n * ((node: unknown, test?: Test, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => boolean)\n * )}\n */\n (\n /**\n * @param {unknown} [node]\n * @param {Test} [test]\n * @param {number | null | undefined} [index]\n * @param {Parent | null | undefined} [parent]\n * @param {unknown} [context]\n * @returns {boolean}\n */\n // eslint-disable-next-line max-params\n function (node, test, index, parent, context) {\n const check = convert(test)\n\n if (\n index !== undefined &&\n index !== null &&\n (typeof index !== 'number' ||\n index < 0 ||\n index === Number.POSITIVE_INFINITY)\n ) {\n throw new Error('Expected positive finite index')\n }\n\n if (\n parent !== undefined &&\n parent !== null &&\n (!is(parent) || !parent.children)\n ) {\n throw new Error('Expected parent node')\n }\n\n if (\n (parent === undefined || parent === null) !==\n (index === undefined || index === null)\n ) {\n throw new Error('Expected both parent and index')\n }\n\n return looksLikeANode(node)\n ? check.call(context, node, index, parent)\n : false\n }\n )\n\n/**\n * Generate an assertion from a test.\n *\n * Useful if you’re going to test many nodes, for example when creating a\n * utility where something else passes a compatible test.\n *\n * The created function is a bit faster because it expects valid input only:\n * a `node`, `index`, and `parent`.\n *\n * @param {Test} test\n * * when nullish, checks if `node` is a `Node`.\n * * when `string`, works like passing `(node) => node.type === test`.\n * * when `function` checks if function passed the node is true.\n * * when `object`, checks that all keys in test are in node, and that they have (strictly) equal values.\n * * when `array`, checks if any one of the subtests pass.\n * @returns {Check}\n * An assertion.\n */\nexport const convert =\n // Note: overloads in JSDoc can’t yet use different `@template`s.\n /**\n * @type {(\n * (<Condition extends string>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & {type: Condition}) &\n * (<Condition extends Props>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Condition) &\n * (<Condition extends TestFunction>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Predicate<Condition, Node>) &\n * ((test?: null | undefined) => (node?: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node) &\n * ((test?: Test) => Check)\n * )}\n */\n (\n /**\n * @param {Test} [test]\n * @returns {Check}\n */\n function (test) {\n if (test === null || test === undefined) {\n return ok\n }\n\n if (typeof test === 'function') {\n return castFactory(test)\n }\n\n if (typeof test === 'object') {\n return Array.isArray(test)\n ? anyFactory(test)\n : // Cast because `ReadonlyArray` goes into the above but `isArray`\n // narrows to `Array`.\n propertiesFactory(/** @type {Props} */ (test))\n }\n\n if (typeof test === 'string') {\n return typeFactory(test)\n }\n\n throw new Error('Expected function, string, or object as test')\n }\n )\n\n/**\n * @param {Array<Props | TestFunction | string>} tests\n * @returns {Check}\n */\nfunction anyFactory(tests) {\n /** @type {Array<Check>} */\n const checks = []\n let index = -1\n\n while (++index < tests.length) {\n checks[index] = convert(tests[index])\n }\n\n return castFactory(any)\n\n /**\n * @this {unknown}\n * @type {TestFunction}\n */\n function any(...parameters) {\n let index = -1\n\n while (++index < checks.length) {\n if (checks[index].apply(this, parameters)) return true\n }\n\n return false\n }\n}\n\n/**\n * Turn an object into a test for a node with a certain fields.\n *\n * @param {Props} check\n * @returns {Check}\n */\nfunction propertiesFactory(check) {\n const checkAsRecord = /** @type {Record<string, unknown>} */ (check)\n\n return castFactory(all)\n\n /**\n * @param {Node} node\n * @returns {boolean}\n */\n function all(node) {\n const nodeAsRecord = /** @type {Record<string, unknown>} */ (\n /** @type {unknown} */ (node)\n )\n\n /** @type {string} */\n let key\n\n for (key in check) {\n if (nodeAsRecord[key] !== checkAsRecord[key]) return false\n }\n\n return true\n }\n}\n\n/**\n * Turn a string into a test for a node with a certain type.\n *\n * @param {string} check\n * @returns {Check}\n */\nfunction typeFactory(check) {\n return castFactory(type)\n\n /**\n * @param {Node} node\n */\n function type(node) {\n return node && node.type === check\n }\n}\n\n/**\n * Turn a custom test into a test for a node that passes that test.\n *\n * @param {TestFunction} testFunction\n * @returns {Check}\n */\nfunction castFactory(testFunction) {\n return check\n\n /**\n * @this {unknown}\n * @type {Check}\n */\n function check(value, index, parent) {\n return Boolean(\n looksLikeANode(value) &&\n testFunction.call(\n this,\n value,\n typeof index === 'number' ? index : undefined,\n parent || undefined\n )\n )\n }\n}\n\nfunction ok() {\n return true\n}\n\n/**\n * @param {unknown} value\n * @returns {value is Node}\n */\nfunction looksLikeANode(value) {\n return value !== null && typeof value === 'object' && 'type' in value\n}\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;;;;;;;;AA4IA,MAAa;;;;;AAgBT,SAAU,MAAM;CACd,IAAI,SAAS,QAAQ,SAAS,KAAA,GAC5B,OAAO;CAGT,IAAI,OAAO,SAAS,YAClB,OAAO,YAAY,IAAI;CAGzB,IAAI,OAAO,SAAS,UAClB,OAAO,MAAM,QAAQ,IAAI,IACrB,WAAW,IAAI,IAGf,kBAAwC,IAAK;CAGnD,IAAI,OAAO,SAAS,UAClB,OAAO,YAAY,IAAI;CAGzB,MAAM,IAAI,MAAM,8CAA8C;AAChE;;;;;AAOJ,SAAS,WAAW,OAAO;;CAEzB,MAAM,SAAS,CAAC;CAChB,IAAI,QAAQ;CAEZ,OAAO,EAAE,QAAQ,MAAM,QACrB,OAAO,SAAS,QAAQ,MAAM,MAAM;CAGtC,OAAO,YAAY,GAAG;;;;;CAMtB,SAAS,IAAI,GAAG,YAAY;EAC1B,IAAI,QAAQ;EAEZ,OAAO,EAAE,QAAQ,OAAO,QACtB,IAAI,OAAO,MAAM,CAAC,MAAM,MAAM,UAAU,GAAG,OAAO;EAGpD,OAAO;CACT;AACF;;;;;;;AAQA,SAAS,kBAAkB,OAAO;CAChC,MAAM,gBAAwD;CAE9D,OAAO,YAAY,GAAG;;;;;CAMtB,SAAS,IAAI,MAAM;EACjB,MAAM,eACoB;;EAI1B,IAAI;EAEJ,KAAK,OAAO,OACV,IAAI,aAAa,SAAS,cAAc,MAAM,OAAO;EAGvD,OAAO;CACT;AACF;;;;;;;AAQA,SAAS,YAAY,OAAO;CAC1B,OAAO,YAAY,IAAI;;;;CAKvB,SAAS,KAAK,MAAM;EAClB,OAAO,QAAQ,KAAK,SAAS;CAC/B;AACF;;;;;;;AAQA,SAAS,YAAY,cAAc;CACjC,OAAO;;;;;CAMP,SAAS,MAAM,OAAO,OAAO,QAAQ;EACnC,OAAO,QACL,eAAe,KAAK,KAClB,aAAa,KACX,MACA,OACA,OAAO,UAAU,WAAW,QAAQ,KAAA,GACpC,UAAU,KAAA,CACZ,CACJ;CACF;AACF;AAEA,SAAS,KAAK;CACZ,OAAO;AACT;;;;;AAMA,SAAS,eAAe,OAAO;CAC7B,OAAO,UAAU,QAAQ,OAAO,UAAU,YAAY,UAAU;AAClE"}
@@ -1,12 +0,0 @@
1
- //#region node_modules/.pnpm/unist-util-visit-parents@6.0.2/node_modules/unist-util-visit-parents/lib/color.node.js
2
- /**
3
- * @param {string} d
4
- * @returns {string}
5
- */
6
- function color(d) {
7
- return "\x1B[33m" + d + "\x1B[39m";
8
- }
9
- //#endregion
10
- export { color };
11
-
12
- //# sourceMappingURL=color.node.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"color.node.mjs","names":[],"sources":["../../../../../../../node_modules/.pnpm/unist-util-visit-parents@6.0.2/node_modules/unist-util-visit-parents/lib/color.node.js"],"sourcesContent":["/**\n * @param {string} d\n * @returns {string}\n */\nexport function color(d) {\n return '\\u001B[33m' + d + '\\u001B[39m'\n}\n"],"x_google_ignoreList":[0],"mappings":";;;;;AAIA,SAAgB,MAAM,GAAG;CACvB,OAAO,aAAe,IAAI;AAC5B"}
@@ -1,330 +0,0 @@
1
- import { convert } from "../../../../unist-util-is@6.0.1/node_modules/unist-util-is/lib/index.mjs";
2
- import { color } from "./color.node.mjs";
3
- //#region node_modules/.pnpm/unist-util-visit-parents@6.0.2/node_modules/unist-util-visit-parents/lib/index.js
4
- /**
5
- * @import {Node as UnistNode, Parent as UnistParent} from 'unist'
6
- */
7
- /**
8
- * @typedef {Exclude<import('unist-util-is').Test, undefined> | undefined} Test
9
- * Test from `unist-util-is`.
10
- *
11
- * Note: we have remove and add `undefined`, because otherwise when generating
12
- * automatic `.d.ts` files, TS tries to flatten paths from a local perspective,
13
- * which doesn’t work when publishing on npm.
14
- */
15
- /**
16
- * @typedef {(
17
- * Fn extends (value: any) => value is infer Thing
18
- * ? Thing
19
- * : Fallback
20
- * )} Predicate
21
- * Get the value of a type guard `Fn`.
22
- * @template Fn
23
- * Value; typically function that is a type guard (such as `(x): x is Y`).
24
- * @template Fallback
25
- * Value to yield if `Fn` is not a type guard.
26
- */
27
- /**
28
- * @typedef {(
29
- * Check extends null | undefined // No test.
30
- * ? Value
31
- * : Value extends {type: Check} // String (type) test.
32
- * ? Value
33
- * : Value extends Check // Partial test.
34
- * ? Value
35
- * : Check extends Function // Function test.
36
- * ? Predicate<Check, Value> extends Value
37
- * ? Predicate<Check, Value>
38
- * : never
39
- * : never // Some other test?
40
- * )} MatchesOne
41
- * Check whether a node matches a primitive check in the type system.
42
- * @template Value
43
- * Value; typically unist `Node`.
44
- * @template Check
45
- * Value; typically `unist-util-is`-compatible test, but not arrays.
46
- */
47
- /**
48
- * @typedef {(
49
- * Check extends ReadonlyArray<infer T>
50
- * ? MatchesOne<Value, T>
51
- * : Check extends Array<infer T>
52
- * ? MatchesOne<Value, T>
53
- * : MatchesOne<Value, Check>
54
- * )} Matches
55
- * Check whether a node matches a check in the type system.
56
- * @template Value
57
- * Value; typically unist `Node`.
58
- * @template Check
59
- * Value; typically `unist-util-is`-compatible test.
60
- */
61
- /**
62
- * @typedef {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10} Uint
63
- * Number; capped reasonably.
64
- */
65
- /**
66
- * @typedef {I extends 0 ? 1 : I extends 1 ? 2 : I extends 2 ? 3 : I extends 3 ? 4 : I extends 4 ? 5 : I extends 5 ? 6 : I extends 6 ? 7 : I extends 7 ? 8 : I extends 8 ? 9 : 10} Increment
67
- * Increment a number in the type system.
68
- * @template {Uint} [I=0]
69
- * Index.
70
- */
71
- /**
72
- * @typedef {(
73
- * Node extends UnistParent
74
- * ? Node extends {children: Array<infer Children>}
75
- * ? Child extends Children ? Node : never
76
- * : never
77
- * : never
78
- * )} InternalParent
79
- * Collect nodes that can be parents of `Child`.
80
- * @template {UnistNode} Node
81
- * All node types in a tree.
82
- * @template {UnistNode} Child
83
- * Node to search for.
84
- */
85
- /**
86
- * @typedef {InternalParent<InclusiveDescendant<Tree>, Child>} Parent
87
- * Collect nodes in `Tree` that can be parents of `Child`.
88
- * @template {UnistNode} Tree
89
- * All node types in a tree.
90
- * @template {UnistNode} Child
91
- * Node to search for.
92
- */
93
- /**
94
- * @typedef {(
95
- * Depth extends Max
96
- * ? never
97
- * :
98
- * | InternalParent<Node, Child>
99
- * | InternalAncestor<Node, InternalParent<Node, Child>, Max, Increment<Depth>>
100
- * )} InternalAncestor
101
- * Collect nodes in `Tree` that can be ancestors of `Child`.
102
- * @template {UnistNode} Node
103
- * All node types in a tree.
104
- * @template {UnistNode} Child
105
- * Node to search for.
106
- * @template {Uint} [Max=10]
107
- * Max; searches up to this depth.
108
- * @template {Uint} [Depth=0]
109
- * Current depth.
110
- */
111
- /**
112
- * @typedef {InternalAncestor<InclusiveDescendant<Tree>, Child>} Ancestor
113
- * Collect nodes in `Tree` that can be ancestors of `Child`.
114
- * @template {UnistNode} Tree
115
- * All node types in a tree.
116
- * @template {UnistNode} Child
117
- * Node to search for.
118
- */
119
- /**
120
- * @typedef {(
121
- * Tree extends UnistParent
122
- * ? Depth extends Max
123
- * ? Tree
124
- * : Tree | InclusiveDescendant<Tree['children'][number], Max, Increment<Depth>>
125
- * : Tree
126
- * )} InclusiveDescendant
127
- * Collect all (inclusive) descendants of `Tree`.
128
- *
129
- * > 👉 **Note**: for performance reasons, this seems to be the fastest way to
130
- * > recurse without actually running into an infinite loop, which the
131
- * > previous version did.
132
- * >
133
- * > Practically, a max of `2` is typically enough assuming a `Root` is
134
- * > passed, but it doesn’t improve performance.
135
- * > It gets higher with `List > ListItem > Table > TableRow > TableCell`.
136
- * > Using up to `10` doesn’t hurt or help either.
137
- * @template {UnistNode} Tree
138
- * Tree type.
139
- * @template {Uint} [Max=10]
140
- * Max; searches up to this depth.
141
- * @template {Uint} [Depth=0]
142
- * Current depth.
143
- */
144
- /**
145
- * @typedef {'skip' | boolean} Action
146
- * Union of the action types.
147
- *
148
- * @typedef {number} Index
149
- * Move to the sibling at `index` next (after node itself is completely
150
- * traversed).
151
- *
152
- * Useful if mutating the tree, such as removing the node the visitor is
153
- * currently on, or any of its previous siblings.
154
- * Results less than 0 or greater than or equal to `children.length` stop
155
- * traversing the parent.
156
- *
157
- * @typedef {[(Action | null | undefined | void)?, (Index | null | undefined)?]} ActionTuple
158
- * List with one or two values, the first an action, the second an index.
159
- *
160
- * @typedef {Action | ActionTuple | Index | null | undefined | void} VisitorResult
161
- * Any value that can be returned from a visitor.
162
- */
163
- /**
164
- * @callback Visitor
165
- * Handle a node (matching `test`, if given).
166
- *
167
- * Visitors are free to transform `node`.
168
- * They can also transform the parent of node (the last of `ancestors`).
169
- *
170
- * Replacing `node` itself, if `SKIP` is not returned, still causes its
171
- * descendants to be walked (which is a bug).
172
- *
173
- * When adding or removing previous siblings of `node` (or next siblings, in
174
- * case of reverse), the `Visitor` should return a new `Index` to specify the
175
- * sibling to traverse after `node` is traversed.
176
- * Adding or removing next siblings of `node` (or previous siblings, in case
177
- * of reverse) is handled as expected without needing to return a new `Index`.
178
- *
179
- * Removing the children property of an ancestor still results in them being
180
- * traversed.
181
- * @param {Visited} node
182
- * Found node.
183
- * @param {Array<VisitedParents>} ancestors
184
- * Ancestors of `node`.
185
- * @returns {VisitorResult}
186
- * What to do next.
187
- *
188
- * An `Index` is treated as a tuple of `[CONTINUE, Index]`.
189
- * An `Action` is treated as a tuple of `[Action]`.
190
- *
191
- * Passing a tuple back only makes sense if the `Action` is `SKIP`.
192
- * When the `Action` is `EXIT`, that action can be returned.
193
- * When the `Action` is `CONTINUE`, `Index` can be returned.
194
- * @template {UnistNode} [Visited=UnistNode]
195
- * Visited node type.
196
- * @template {UnistParent} [VisitedParents=UnistParent]
197
- * Ancestor type.
198
- */
199
- /**
200
- * @typedef {Visitor<Matches<InclusiveDescendant<Tree>, Check>, Ancestor<Tree, Matches<InclusiveDescendant<Tree>, Check>>>} BuildVisitor
201
- * Build a typed `Visitor` function from a tree and a test.
202
- *
203
- * It will infer which values are passed as `node` and which as `parents`.
204
- * @template {UnistNode} [Tree=UnistNode]
205
- * Tree type.
206
- * @template {Test} [Check=Test]
207
- * Test type.
208
- */
209
- /** @type {Readonly<ActionTuple>} */
210
- const empty = [];
211
- /**
212
- * Do not traverse this node’s children.
213
- */
214
- const SKIP = "skip";
215
- /**
216
- * Visit nodes, with ancestral information.
217
- *
218
- * This algorithm performs *depth-first* *tree traversal* in *preorder*
219
- * (**NLR**) or if `reverse` is given, in *reverse preorder* (**NRL**).
220
- *
221
- * You can choose for which nodes `visitor` is called by passing a `test`.
222
- * For complex tests, you should test yourself in `visitor`, as it will be
223
- * faster and will have improved type information.
224
- *
225
- * Walking the tree is an intensive task.
226
- * Make use of the return values of the visitor when possible.
227
- * Instead of walking a tree multiple times, walk it once, use `unist-util-is`
228
- * to check if a node matches, and then perform different operations.
229
- *
230
- * You can change the tree.
231
- * See `Visitor` for more info.
232
- *
233
- * @overload
234
- * @param {Tree} tree
235
- * @param {Check} check
236
- * @param {BuildVisitor<Tree, Check>} visitor
237
- * @param {boolean | null | undefined} [reverse]
238
- * @returns {undefined}
239
- *
240
- * @overload
241
- * @param {Tree} tree
242
- * @param {BuildVisitor<Tree>} visitor
243
- * @param {boolean | null | undefined} [reverse]
244
- * @returns {undefined}
245
- *
246
- * @param {UnistNode} tree
247
- * Tree to traverse.
248
- * @param {Visitor | Test} test
249
- * `unist-util-is`-compatible test
250
- * @param {Visitor | boolean | null | undefined} [visitor]
251
- * Handle each node.
252
- * @param {boolean | null | undefined} [reverse]
253
- * Traverse in reverse preorder (NRL) instead of the default preorder (NLR).
254
- * @returns {undefined}
255
- * Nothing.
256
- *
257
- * @template {UnistNode} Tree
258
- * Node type.
259
- * @template {Test} Check
260
- * `unist-util-is`-compatible test.
261
- */
262
- function visitParents(tree, test, visitor, reverse) {
263
- /** @type {Test} */
264
- let check;
265
- if (typeof test === "function" && typeof visitor !== "function") {
266
- reverse = visitor;
267
- visitor = test;
268
- } else check = test;
269
- const is = convert(check);
270
- const step = reverse ? -1 : 1;
271
- factory(tree, void 0, [])();
272
- /**
273
- * @param {UnistNode} node
274
- * @param {number | undefined} index
275
- * @param {Array<UnistParent>} parents
276
- */
277
- function factory(node, index, parents) {
278
- const value = node && typeof node === "object" ? node : {};
279
- if (typeof value.type === "string") {
280
- const name = typeof value.tagName === "string" ? value.tagName : typeof value.name === "string" ? value.name : void 0;
281
- Object.defineProperty(visit, "name", { value: "node (" + color(node.type + (name ? "<" + name + ">" : "")) + ")" });
282
- }
283
- return visit;
284
- function visit() {
285
- /** @type {Readonly<ActionTuple>} */
286
- let result = empty;
287
- /** @type {Readonly<ActionTuple>} */
288
- let subresult;
289
- /** @type {number} */
290
- let offset;
291
- /** @type {Array<UnistParent>} */
292
- let grandparents;
293
- if (!test || is(node, index, parents[parents.length - 1] || void 0)) {
294
- result = toResult(visitor(node, parents));
295
- if (result[0] === false) return result;
296
- }
297
- if ("children" in node && node.children) {
298
- const nodeAsParent = node;
299
- if (nodeAsParent.children && result[0] !== "skip") {
300
- offset = (reverse ? nodeAsParent.children.length : -1) + step;
301
- grandparents = parents.concat(nodeAsParent);
302
- while (offset > -1 && offset < nodeAsParent.children.length) {
303
- const child = nodeAsParent.children[offset];
304
- subresult = factory(child, offset, grandparents)();
305
- if (subresult[0] === false) return subresult;
306
- offset = typeof subresult[1] === "number" ? subresult[1] : offset + step;
307
- }
308
- }
309
- }
310
- return result;
311
- }
312
- }
313
- }
314
- /**
315
- * Turn a return value into a clean result.
316
- *
317
- * @param {VisitorResult} value
318
- * Valid return values from visitors.
319
- * @returns {Readonly<ActionTuple>}
320
- * Clean result.
321
- */
322
- function toResult(value) {
323
- if (Array.isArray(value)) return value;
324
- if (typeof value === "number") return [true, value];
325
- return value === null || value === void 0 ? empty : [value];
326
- }
327
- //#endregion
328
- export { SKIP, visitParents };
329
-
330
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../../../../../node_modules/.pnpm/unist-util-visit-parents@6.0.2/node_modules/unist-util-visit-parents/lib/index.js"],"sourcesContent":["/**\n * @import {Node as UnistNode, Parent as UnistParent} from 'unist'\n */\n\n/**\n * @typedef {Exclude<import('unist-util-is').Test, undefined> | undefined} Test\n * Test from `unist-util-is`.\n *\n * Note: we have remove and add `undefined`, because otherwise when generating\n * automatic `.d.ts` files, TS tries to flatten paths from a local perspective,\n * which doesn’t work when publishing on npm.\n */\n\n/**\n * @typedef {(\n * Fn extends (value: any) => value is infer Thing\n * ? Thing\n * : Fallback\n * )} Predicate\n * Get the value of a type guard `Fn`.\n * @template Fn\n * Value; typically function that is a type guard (such as `(x): x is Y`).\n * @template Fallback\n * Value to yield if `Fn` is not a type guard.\n */\n\n/**\n * @typedef {(\n * Check extends null | undefined // No test.\n * ? Value\n * : Value extends {type: Check} // String (type) test.\n * ? Value\n * : Value extends Check // Partial test.\n * ? Value\n * : Check extends Function // Function test.\n * ? Predicate<Check, Value> extends Value\n * ? Predicate<Check, Value>\n * : never\n * : never // Some other test?\n * )} MatchesOne\n * Check whether a node matches a primitive check in the type system.\n * @template Value\n * Value; typically unist `Node`.\n * @template Check\n * Value; typically `unist-util-is`-compatible test, but not arrays.\n */\n\n/**\n * @typedef {(\n * Check extends ReadonlyArray<infer T>\n * ? MatchesOne<Value, T>\n * : Check extends Array<infer T>\n * ? MatchesOne<Value, T>\n * : MatchesOne<Value, Check>\n * )} Matches\n * Check whether a node matches a check in the type system.\n * @template Value\n * Value; typically unist `Node`.\n * @template Check\n * Value; typically `unist-util-is`-compatible test.\n */\n\n/**\n * @typedef {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10} Uint\n * Number; capped reasonably.\n */\n\n/**\n * @typedef {I extends 0 ? 1 : I extends 1 ? 2 : I extends 2 ? 3 : I extends 3 ? 4 : I extends 4 ? 5 : I extends 5 ? 6 : I extends 6 ? 7 : I extends 7 ? 8 : I extends 8 ? 9 : 10} Increment\n * Increment a number in the type system.\n * @template {Uint} [I=0]\n * Index.\n */\n\n/**\n * @typedef {(\n * Node extends UnistParent\n * ? Node extends {children: Array<infer Children>}\n * ? Child extends Children ? Node : never\n * : never\n * : never\n * )} InternalParent\n * Collect nodes that can be parents of `Child`.\n * @template {UnistNode} Node\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n */\n\n/**\n * @typedef {InternalParent<InclusiveDescendant<Tree>, Child>} Parent\n * Collect nodes in `Tree` that can be parents of `Child`.\n * @template {UnistNode} Tree\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n */\n\n/**\n * @typedef {(\n * Depth extends Max\n * ? never\n * :\n * | InternalParent<Node, Child>\n * | InternalAncestor<Node, InternalParent<Node, Child>, Max, Increment<Depth>>\n * )} InternalAncestor\n * Collect nodes in `Tree` that can be ancestors of `Child`.\n * @template {UnistNode} Node\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n * @template {Uint} [Max=10]\n * Max; searches up to this depth.\n * @template {Uint} [Depth=0]\n * Current depth.\n */\n\n/**\n * @typedef {InternalAncestor<InclusiveDescendant<Tree>, Child>} Ancestor\n * Collect nodes in `Tree` that can be ancestors of `Child`.\n * @template {UnistNode} Tree\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n */\n\n/**\n * @typedef {(\n * Tree extends UnistParent\n * ? Depth extends Max\n * ? Tree\n * : Tree | InclusiveDescendant<Tree['children'][number], Max, Increment<Depth>>\n * : Tree\n * )} InclusiveDescendant\n * Collect all (inclusive) descendants of `Tree`.\n *\n * > 👉 **Note**: for performance reasons, this seems to be the fastest way to\n * > recurse without actually running into an infinite loop, which the\n * > previous version did.\n * >\n * > Practically, a max of `2` is typically enough assuming a `Root` is\n * > passed, but it doesn’t improve performance.\n * > It gets higher with `List > ListItem > Table > TableRow > TableCell`.\n * > Using up to `10` doesn’t hurt or help either.\n * @template {UnistNode} Tree\n * Tree type.\n * @template {Uint} [Max=10]\n * Max; searches up to this depth.\n * @template {Uint} [Depth=0]\n * Current depth.\n */\n\n/**\n * @typedef {'skip' | boolean} Action\n * Union of the action types.\n *\n * @typedef {number} Index\n * Move to the sibling at `index` next (after node itself is completely\n * traversed).\n *\n * Useful if mutating the tree, such as removing the node the visitor is\n * currently on, or any of its previous siblings.\n * Results less than 0 or greater than or equal to `children.length` stop\n * traversing the parent.\n *\n * @typedef {[(Action | null | undefined | void)?, (Index | null | undefined)?]} ActionTuple\n * List with one or two values, the first an action, the second an index.\n *\n * @typedef {Action | ActionTuple | Index | null | undefined | void} VisitorResult\n * Any value that can be returned from a visitor.\n */\n\n/**\n * @callback Visitor\n * Handle a node (matching `test`, if given).\n *\n * Visitors are free to transform `node`.\n * They can also transform the parent of node (the last of `ancestors`).\n *\n * Replacing `node` itself, if `SKIP` is not returned, still causes its\n * descendants to be walked (which is a bug).\n *\n * When adding or removing previous siblings of `node` (or next siblings, in\n * case of reverse), the `Visitor` should return a new `Index` to specify the\n * sibling to traverse after `node` is traversed.\n * Adding or removing next siblings of `node` (or previous siblings, in case\n * of reverse) is handled as expected without needing to return a new `Index`.\n *\n * Removing the children property of an ancestor still results in them being\n * traversed.\n * @param {Visited} node\n * Found node.\n * @param {Array<VisitedParents>} ancestors\n * Ancestors of `node`.\n * @returns {VisitorResult}\n * What to do next.\n *\n * An `Index` is treated as a tuple of `[CONTINUE, Index]`.\n * An `Action` is treated as a tuple of `[Action]`.\n *\n * Passing a tuple back only makes sense if the `Action` is `SKIP`.\n * When the `Action` is `EXIT`, that action can be returned.\n * When the `Action` is `CONTINUE`, `Index` can be returned.\n * @template {UnistNode} [Visited=UnistNode]\n * Visited node type.\n * @template {UnistParent} [VisitedParents=UnistParent]\n * Ancestor type.\n */\n\n/**\n * @typedef {Visitor<Matches<InclusiveDescendant<Tree>, Check>, Ancestor<Tree, Matches<InclusiveDescendant<Tree>, Check>>>} BuildVisitor\n * Build a typed `Visitor` function from a tree and a test.\n *\n * It will infer which values are passed as `node` and which as `parents`.\n * @template {UnistNode} [Tree=UnistNode]\n * Tree type.\n * @template {Test} [Check=Test]\n * Test type.\n */\n\nimport {convert} from 'unist-util-is'\nimport {color} from 'unist-util-visit-parents/do-not-use-color'\n\n/** @type {Readonly<ActionTuple>} */\nconst empty = []\n\n/**\n * Continue traversing as normal.\n */\nexport const CONTINUE = true\n\n/**\n * Stop traversing immediately.\n */\nexport const EXIT = false\n\n/**\n * Do not traverse this node’s children.\n */\nexport const SKIP = 'skip'\n\n/**\n * Visit nodes, with ancestral information.\n *\n * This algorithm performs *depth-first* *tree traversal* in *preorder*\n * (**NLR**) or if `reverse` is given, in *reverse preorder* (**NRL**).\n *\n * You can choose for which nodes `visitor` is called by passing a `test`.\n * For complex tests, you should test yourself in `visitor`, as it will be\n * faster and will have improved type information.\n *\n * Walking the tree is an intensive task.\n * Make use of the return values of the visitor when possible.\n * Instead of walking a tree multiple times, walk it once, use `unist-util-is`\n * to check if a node matches, and then perform different operations.\n *\n * You can change the tree.\n * See `Visitor` for more info.\n *\n * @overload\n * @param {Tree} tree\n * @param {Check} check\n * @param {BuildVisitor<Tree, Check>} visitor\n * @param {boolean | null | undefined} [reverse]\n * @returns {undefined}\n *\n * @overload\n * @param {Tree} tree\n * @param {BuildVisitor<Tree>} visitor\n * @param {boolean | null | undefined} [reverse]\n * @returns {undefined}\n *\n * @param {UnistNode} tree\n * Tree to traverse.\n * @param {Visitor | Test} test\n * `unist-util-is`-compatible test\n * @param {Visitor | boolean | null | undefined} [visitor]\n * Handle each node.\n * @param {boolean | null | undefined} [reverse]\n * Traverse in reverse preorder (NRL) instead of the default preorder (NLR).\n * @returns {undefined}\n * Nothing.\n *\n * @template {UnistNode} Tree\n * Node type.\n * @template {Test} Check\n * `unist-util-is`-compatible test.\n */\nexport function visitParents(tree, test, visitor, reverse) {\n /** @type {Test} */\n let check\n\n if (typeof test === 'function' && typeof visitor !== 'function') {\n reverse = visitor\n // @ts-expect-error no visitor given, so `visitor` is test.\n visitor = test\n } else {\n // @ts-expect-error visitor given, so `test` isn’t a visitor.\n check = test\n }\n\n const is = convert(check)\n const step = reverse ? -1 : 1\n\n factory(tree, undefined, [])()\n\n /**\n * @param {UnistNode} node\n * @param {number | undefined} index\n * @param {Array<UnistParent>} parents\n */\n function factory(node, index, parents) {\n const value = /** @type {Record<string, unknown>} */ (\n node && typeof node === 'object' ? node : {}\n )\n\n if (typeof value.type === 'string') {\n const name =\n // `hast`\n typeof value.tagName === 'string'\n ? value.tagName\n : // `xast`\n typeof value.name === 'string'\n ? value.name\n : undefined\n\n Object.defineProperty(visit, 'name', {\n value:\n 'node (' + color(node.type + (name ? '<' + name + '>' : '')) + ')'\n })\n }\n\n return visit\n\n function visit() {\n /** @type {Readonly<ActionTuple>} */\n let result = empty\n /** @type {Readonly<ActionTuple>} */\n let subresult\n /** @type {number} */\n let offset\n /** @type {Array<UnistParent>} */\n let grandparents\n\n if (!test || is(node, index, parents[parents.length - 1] || undefined)) {\n // @ts-expect-error: `visitor` is now a visitor.\n result = toResult(visitor(node, parents))\n\n if (result[0] === EXIT) {\n return result\n }\n }\n\n if ('children' in node && node.children) {\n const nodeAsParent = /** @type {UnistParent} */ (node)\n\n if (nodeAsParent.children && result[0] !== SKIP) {\n offset = (reverse ? nodeAsParent.children.length : -1) + step\n grandparents = parents.concat(nodeAsParent)\n\n while (offset > -1 && offset < nodeAsParent.children.length) {\n const child = nodeAsParent.children[offset]\n\n subresult = factory(child, offset, grandparents)()\n\n if (subresult[0] === EXIT) {\n return subresult\n }\n\n offset =\n typeof subresult[1] === 'number' ? subresult[1] : offset + step\n }\n }\n }\n\n return result\n }\n }\n}\n\n/**\n * Turn a return value into a clean result.\n *\n * @param {VisitorResult} value\n * Valid return values from visitors.\n * @returns {Readonly<ActionTuple>}\n * Clean result.\n */\nfunction toResult(value) {\n if (Array.isArray(value)) {\n return value\n }\n\n if (typeof value === 'number') {\n return [CONTINUE, value]\n }\n\n return value === null || value === undefined ? empty : [value]\n}\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgOA,MAAM,QAAQ,CAAC;;;;AAef,MAAa,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDpB,SAAgB,aAAa,MAAM,MAAM,SAAS,SAAS;;CAEzD,IAAI;CAEJ,IAAI,OAAO,SAAS,cAAc,OAAO,YAAY,YAAY;EAC/D,UAAU;EAEV,UAAU;CACZ,OAEE,QAAQ;CAGV,MAAM,KAAK,QAAQ,KAAK;CACxB,MAAM,OAAO,UAAU,KAAK;CAE5B,QAAQ,MAAM,KAAA,GAAW,CAAC,CAAC,CAAC,CAAC;;;;;;CAO7B,SAAS,QAAQ,MAAM,OAAO,SAAS;EACrC,MAAM,QACJ,QAAQ,OAAO,SAAS,WAAW,OAAO,CAAC;EAG7C,IAAI,OAAO,MAAM,SAAS,UAAU;GAClC,MAAM,OAEJ,OAAO,MAAM,YAAY,WACrB,MAAM,UAEN,OAAO,MAAM,SAAS,WACpB,MAAM,OACN,KAAA;GAER,OAAO,eAAe,OAAO,QAAQ,EACnC,OACE,WAAW,MAAM,KAAK,QAAQ,OAAO,MAAM,OAAO,MAAM,GAAG,IAAI,IACnE,CAAC;EACH;EAEA,OAAO;EAEP,SAAS,QAAQ;;GAEf,IAAI,SAAS;;GAEb,IAAI;;GAEJ,IAAI;;GAEJ,IAAI;GAEJ,IAAI,CAAC,QAAQ,GAAG,MAAM,OAAO,QAAQ,QAAQ,SAAS,MAAM,KAAA,CAAS,GAAG;IAEtE,SAAS,SAAS,QAAQ,MAAM,OAAO,CAAC;IAExC,IAAI,OAAO,OAAA,OACT,OAAO;GAEX;GAEA,IAAI,cAAc,QAAQ,KAAK,UAAU;IACvC,MAAM,eAA2C;IAEjD,IAAI,aAAa,YAAY,OAAO,OAAA,QAAa;KAC/C,UAAU,UAAU,aAAa,SAAS,SAAS,MAAM;KACzD,eAAe,QAAQ,OAAO,YAAY;KAE1C,OAAO,SAAS,MAAM,SAAS,aAAa,SAAS,QAAQ;MAC3D,MAAM,QAAQ,aAAa,SAAS;MAEpC,YAAY,QAAQ,OAAO,QAAQ,YAAY,CAAC,CAAC;MAEjD,IAAI,UAAU,OAAA,OACZ,OAAO;MAGT,SACE,OAAO,UAAU,OAAO,WAAW,UAAU,KAAK,SAAS;KAC/D;IACF;GACF;GAEA,OAAO;EACT;CACF;AACF;;;;;;;;;AAUA,SAAS,SAAS,OAAO;CACvB,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO;CAGT,IAAI,OAAO,UAAU,UACnB,OAAO,CAAA,MAAW,KAAK;CAGzB,OAAO,UAAU,QAAQ,UAAU,KAAA,IAAY,QAAQ,CAAC,KAAK;AAC/D"}