@lobehub/ui 5.32.5 → 5.32.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/Markdown/SyntaxMarkdown/StreamdownRender.mjs +15 -294
- package/es/Markdown/SyntaxMarkdown/StreamdownRender.mjs.map +1 -1
- package/es/Markdown/type.d.mts +2 -3
- package/es/base-ui/ContextMenu/renderItems.mjs +24 -1
- package/es/base-ui/ContextMenu/renderItems.mjs.map +1 -1
- package/es/base-ui/Input/style.d.mts +1 -1
- package/es/base-ui/Segmented/Segmented.mjs +4 -0
- package/es/base-ui/Segmented/Segmented.mjs.map +1 -1
- package/es/base-ui/Segmented/style.mjs +4 -0
- package/es/base-ui/Segmented/style.mjs.map +1 -1
- package/es/base-ui/Tabs/style.mjs +12 -0
- package/es/base-ui/Tabs/style.mjs.map +1 -1
- package/es/hooks/useMarkdown/useMarkdownContent.mjs +4 -16
- package/es/hooks/useMarkdown/useMarkdownContent.mjs.map +1 -1
- package/es/hooks/useMarkdown/utils.mjs +1 -1
- package/es/hooks/useMarkdown/utils.mjs.map +1 -1
- package/es/index.d.mts +1 -1
- package/es/index.mjs +1 -1
- package/package.json +2 -88
- package/es/Markdown/SyntaxMarkdown/CachedMarkdown.mjs +0 -83
- package/es/Markdown/SyntaxMarkdown/CachedMarkdown.mjs.map +0 -1
- package/es/Markdown/SyntaxMarkdown/fenceState.mjs +0 -42
- package/es/Markdown/SyntaxMarkdown/fenceState.mjs.map +0 -1
- package/es/Markdown/SyntaxMarkdown/streamAnimationMeta.mjs +0 -14
- package/es/Markdown/SyntaxMarkdown/streamAnimationMeta.mjs.map +0 -1
- package/es/Markdown/SyntaxMarkdown/style.mjs +0 -28
- package/es/Markdown/SyntaxMarkdown/style.mjs.map +0 -1
- package/es/Markdown/SyntaxMarkdown/useSmoothStreamContent.mjs +0 -314
- package/es/Markdown/SyntaxMarkdown/useSmoothStreamContent.mjs.map +0 -1
- package/es/Markdown/SyntaxMarkdown/useStreamQueue.mjs +0 -88
- package/es/Markdown/SyntaxMarkdown/useStreamQueue.mjs.map +0 -1
- package/es/Markdown/plugins/rehypeStreamAnimated.d.mts +0 -33
- package/es/Markdown/plugins/rehypeStreamAnimated.mjs +0 -115
- package/es/Markdown/plugins/rehypeStreamAnimated.mjs.map +0 -1
- package/es/Markdown/streamProfiler/StreamdownProfilerProvider.mjs +0 -19
- package/es/Markdown/streamProfiler/StreamdownProfilerProvider.mjs.map +0 -1
- package/es/hooks/useMarkdown/latex.mjs +0 -294
- package/es/hooks/useMarkdown/latex.mjs.map +0 -1
- package/es/node_modules/.pnpm/@types_hast@3.0.5/node_modules/@types/hast/index.d.mts +0 -869
- package/es/utils/getNow.mjs +0 -8
- package/es/utils/getNow.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style.mjs","names":["lobeStaticStylish"],"sources":["../../../src/base-ui/Segmented/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, cssVar }) => ({\n indicator: css`\n pointer-events: none;\n\n position: absolute;\n z-index: 0;\n inset-block-start: var(--active-item-top);\n inset-inline-start: var(--active-item-left);\n\n width: var(--active-item-width);\n height: var(--active-item-height);\n border-radius: ${cssVar.borderRadius};\n\n background: ${cssVar.colorBgElevated};\n box-shadow: ${cssVar.boxShadowTertiary};\n\n transition-timing-function: ${cssVar.motionEaseOut};\n transition-duration: 240ms;\n transition-property: inset-inline-start, inset-block-start, width, height;\n\n @media (prefers-reduced-motion: reduce) {\n transition-duration: 0s;\n }\n `,\n item: css`\n cursor: pointer;\n user-select: none;\n\n position: relative;\n z-index: 1;\n\n display: inline-flex;\n flex-shrink: 0;\n gap: 6px;\n align-items: center;\n justify-content: center;\n\n box-sizing: border-box;\n border: 0;\n\n font-weight: 500;\n color: ${cssVar.colorTextSecondary};\n white-space: nowrap;\n\n background: transparent;\n outline: none;\n\n transition:\n color 120ms ${cssVar.motionEaseOut},\n transform 120ms ${cssVar.motionEaseOut};\n\n &:hover:not([data-disabled], [data-pressed]) {\n color: ${cssVar.colorText};\n }\n\n &:active:not([data-disabled]) {\n transform: scale(0.98);\n }\n\n &:focus-visible {\n border-radius: ${cssVar.borderRadius};\n outline: 2px solid ${cssVar.colorPrimaryBorder};\n outline-offset: -2px;\n }\n\n &[data-pressed] {\n color: ${cssVar.colorText};\n }\n\n &[data-disabled] {\n cursor: not-allowed;\n color: ${cssVar.colorTextDisabled};\n }\n\n @media (prefers-reduced-motion: reduce) {\n transition-duration: 0s;\n }\n `,\n itemBlock: css`\n flex: 1 1 0;\n `,\n itemIcon: css`\n display: inline-flex;\n align-items: center;\n justify-content: center;\n `,\n itemLabel: css`\n display: inline-flex;\n align-items: center;\n `,\n itemLarge: css`\n height: 36px;\n padding-inline: 16px;\n border-radius: ${cssVar.borderRadius};\n font-size: 14px;\n `,\n itemMiddle: css`\n height: 32px;\n padding-inline: 12px;\n border-radius: ${cssVar.borderRadius};\n font-size: 13px;\n `,\n itemSmall: css`\n height: 26px;\n padding-inline: 10px;\n border-radius: ${cssVar.borderRadius};\n font-size: 12px;\n `,\n list: css`\n position: relative;\n\n display: inline-flex;\n flex-wrap: nowrap;\n gap: 4px;\n align-items: center;\n align-self: flex-start;\n\n box-sizing: border-box;\n padding: 3px;\n border-radius: ${cssVar.borderRadiusLG};\n\n &[data-orientation='vertical'] {\n flex-direction: column;\n align-items: stretch;\n align-self: stretch;\n }\n `,\n listBlock: css`\n display: flex;\n align-self: stretch;\n width: 100%;\n `,\n listFilled: css`\n border: 1px solid ${cssVar.colorFillQuaternary};\n background: ${cssVar.colorBgLayout};\n `,\n listGlass: lobeStaticStylish.blur,\n listOutlined: css`\n border: 1px solid ${cssVar.colorBorderSecondary};\n background: transparent;\n `,\n listShadow: lobeStaticStylish.shadow,\n root: css`\n display: inline-flex;\n\n &[data-block='true'] {\n display: flex;\n width: 100%;\n }\n `,\n}));\n\nexport const listVariants = cva(styles.list, {\n defaultVariants: {\n block: false,\n glass: false,\n shadow: false,\n variant: 'filled',\n },\n variants: {\n block: {\n false: null,\n true: styles.listBlock,\n },\n glass: {\n false: null,\n true: styles.listGlass,\n },\n shadow: {\n false: null,\n true: styles.listShadow,\n },\n variant: {\n filled: styles.listFilled,\n outlined: styles.listOutlined,\n },\n },\n});\n\nexport const itemVariants = cva(styles.item, {\n defaultVariants: {\n block: false,\n size: 'middle',\n },\n variants: {\n block: {\n false: null,\n true: styles.itemBlock,\n },\n size: {\n large: styles.itemLarge,\n middle: styles.itemMiddle,\n small: styles.itemSmall,\n },\n },\n});\n"],"mappings":";;;;AAKA,MAAa,SAAS,oBAAoB,EAAE,KAAK,cAAc;CAC7D,WAAW,GAAG;;;;;;;;;;qBAUK,OAAO,aAAa;;kBAEvB,OAAO,gBAAgB;kBACvB,OAAO,kBAAkB;;kCAET,OAAO,cAAc
|
|
1
|
+
{"version":3,"file":"style.mjs","names":["lobeStaticStylish"],"sources":["../../../src/base-ui/Segmented/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, cssVar }) => ({\n indicator: css`\n pointer-events: none;\n\n position: absolute;\n z-index: 0;\n inset-block-start: var(--active-item-top);\n inset-inline-start: var(--active-item-left);\n\n width: var(--active-item-width);\n height: var(--active-item-height);\n border-radius: ${cssVar.borderRadius};\n\n background: ${cssVar.colorBgElevated};\n box-shadow: ${cssVar.boxShadowTertiary};\n\n transition-timing-function: ${cssVar.motionEaseOut};\n transition-duration: 240ms;\n transition-property: inset-inline-start, inset-block-start, width, height;\n\n [data-orientation='horizontal'] &:dir(rtl) {\n inset-inline-start: var(--active-item-right);\n }\n\n @media (prefers-reduced-motion: reduce) {\n transition-duration: 0s;\n }\n `,\n item: css`\n cursor: pointer;\n user-select: none;\n\n position: relative;\n z-index: 1;\n\n display: inline-flex;\n flex-shrink: 0;\n gap: 6px;\n align-items: center;\n justify-content: center;\n\n box-sizing: border-box;\n border: 0;\n\n font-weight: 500;\n color: ${cssVar.colorTextSecondary};\n white-space: nowrap;\n\n background: transparent;\n outline: none;\n\n transition:\n color 120ms ${cssVar.motionEaseOut},\n transform 120ms ${cssVar.motionEaseOut};\n\n &:hover:not([data-disabled], [data-pressed]) {\n color: ${cssVar.colorText};\n }\n\n &:active:not([data-disabled]) {\n transform: scale(0.98);\n }\n\n &:focus-visible {\n border-radius: ${cssVar.borderRadius};\n outline: 2px solid ${cssVar.colorPrimaryBorder};\n outline-offset: -2px;\n }\n\n &[data-pressed] {\n color: ${cssVar.colorText};\n }\n\n &[data-disabled] {\n cursor: not-allowed;\n color: ${cssVar.colorTextDisabled};\n }\n\n @media (prefers-reduced-motion: reduce) {\n transition-duration: 0s;\n }\n `,\n itemBlock: css`\n flex: 1 1 0;\n `,\n itemIcon: css`\n display: inline-flex;\n align-items: center;\n justify-content: center;\n `,\n itemLabel: css`\n display: inline-flex;\n align-items: center;\n `,\n itemLarge: css`\n height: 36px;\n padding-inline: 16px;\n border-radius: ${cssVar.borderRadius};\n font-size: 14px;\n `,\n itemMiddle: css`\n height: 32px;\n padding-inline: 12px;\n border-radius: ${cssVar.borderRadius};\n font-size: 13px;\n `,\n itemSmall: css`\n height: 26px;\n padding-inline: 10px;\n border-radius: ${cssVar.borderRadius};\n font-size: 12px;\n `,\n list: css`\n position: relative;\n\n display: inline-flex;\n flex-wrap: nowrap;\n gap: 4px;\n align-items: center;\n align-self: flex-start;\n\n box-sizing: border-box;\n padding: 3px;\n border-radius: ${cssVar.borderRadiusLG};\n\n &[data-orientation='vertical'] {\n flex-direction: column;\n align-items: stretch;\n align-self: stretch;\n }\n `,\n listBlock: css`\n display: flex;\n align-self: stretch;\n width: 100%;\n `,\n listFilled: css`\n border: 1px solid ${cssVar.colorFillQuaternary};\n background: ${cssVar.colorBgLayout};\n `,\n listGlass: lobeStaticStylish.blur,\n listOutlined: css`\n border: 1px solid ${cssVar.colorBorderSecondary};\n background: transparent;\n `,\n listShadow: lobeStaticStylish.shadow,\n root: css`\n display: inline-flex;\n\n &[data-block='true'] {\n display: flex;\n width: 100%;\n }\n `,\n}));\n\nexport const listVariants = cva(styles.list, {\n defaultVariants: {\n block: false,\n glass: false,\n shadow: false,\n variant: 'filled',\n },\n variants: {\n block: {\n false: null,\n true: styles.listBlock,\n },\n glass: {\n false: null,\n true: styles.listGlass,\n },\n shadow: {\n false: null,\n true: styles.listShadow,\n },\n variant: {\n filled: styles.listFilled,\n outlined: styles.listOutlined,\n },\n },\n});\n\nexport const itemVariants = cva(styles.item, {\n defaultVariants: {\n block: false,\n size: 'middle',\n },\n variants: {\n block: {\n false: null,\n true: styles.itemBlock,\n },\n size: {\n large: styles.itemLarge,\n middle: styles.itemMiddle,\n small: styles.itemSmall,\n },\n },\n});\n"],"mappings":";;;;AAKA,MAAa,SAAS,oBAAoB,EAAE,KAAK,cAAc;CAC7D,WAAW,GAAG;;;;;;;;;;qBAUK,OAAO,aAAa;;kBAEvB,OAAO,gBAAgB;kBACvB,OAAO,kBAAkB;;kCAET,OAAO,cAAc;;;;;;;;;;;;CAYrD,MAAM,GAAG;;;;;;;;;;;;;;;;;aAiBE,OAAO,mBAAmB;;;;;;;oBAOnB,OAAO,cAAc;wBACjB,OAAO,cAAc;;;eAG9B,OAAO,UAAU;;;;;;;;uBAQT,OAAO,aAAa;2BAChB,OAAO,mBAAmB;;;;;eAKtC,OAAO,UAAU;;;;;eAKjB,OAAO,kBAAkB;;;;;;;CAOtC,WAAW,GAAG;;;CAGd,UAAU,GAAG;;;;;CAKb,WAAW,GAAG;;;;CAId,WAAW,GAAG;;;qBAGK,OAAO,aAAa;;;CAGvC,YAAY,GAAG;;;qBAGI,OAAO,aAAa;;;CAGvC,WAAW,GAAG;;;qBAGK,OAAO,aAAa;;;CAGvC,MAAM,GAAG;;;;;;;;;;;qBAWU,OAAO,eAAe;;;;;;;;CAQzC,WAAW,GAAG;;;;;CAKd,YAAY,GAAG;wBACO,OAAO,oBAAoB;kBACjC,OAAO,cAAc;;CAErC,WAAWA,cAAkB;CAC7B,cAAc,GAAG;wBACK,OAAO,qBAAqB;;;CAGlD,YAAYA,cAAkB;CAC9B,MAAM,GAAG;;;;;;;;AAQX,EAAE;AAEF,MAAa,eAAe,IAAI,OAAO,MAAM;CAC3C,iBAAiB;EACf,OAAO;EACP,OAAO;EACP,QAAQ;EACR,SAAS;CACX;CACA,UAAU;EACR,OAAO;GACL,OAAO;GACP,MAAM,OAAO;EACf;EACA,OAAO;GACL,OAAO;GACP,MAAM,OAAO;EACf;EACA,QAAQ;GACN,OAAO;GACP,MAAM,OAAO;EACf;EACA,SAAS;GACP,QAAQ,OAAO;GACf,UAAU,OAAO;EACnB;CACF;AACF,CAAC;AAED,MAAa,eAAe,IAAI,OAAO,MAAM;CAC3C,iBAAiB;EACf,OAAO;EACP,MAAM;CACR;CACA,UAAU;EACR,OAAO;GACL,OAAO;GACP,MAAM,OAAO;EACf;EACA,MAAM;GACJ,OAAO,OAAO;GACd,QAAQ,OAAO;GACf,OAAO,OAAO;EAChB;CACF;AACF,CAAC"}
|
|
@@ -25,6 +25,10 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
|
|
|
25
25
|
border-radius: 50%;
|
|
26
26
|
|
|
27
27
|
background: ${cssVar.colorPrimary};
|
|
28
|
+
|
|
29
|
+
[data-orientation='horizontal'] &:dir(rtl) {
|
|
30
|
+
inset-inline-start: calc(var(--active-tab-right) + var(--active-tab-width) / 2 - 2.5px);
|
|
31
|
+
}
|
|
28
32
|
`,
|
|
29
33
|
indicatorRounded: css`
|
|
30
34
|
inset-block-start: var(--active-tab-top);
|
|
@@ -36,6 +40,10 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
|
|
|
36
40
|
|
|
37
41
|
background: ${cssVar.colorBgElevated};
|
|
38
42
|
box-shadow: ${cssVar.boxShadowTertiary};
|
|
43
|
+
|
|
44
|
+
[data-orientation='horizontal'] &:dir(rtl) {
|
|
45
|
+
inset-inline-start: var(--active-tab-right);
|
|
46
|
+
}
|
|
39
47
|
`,
|
|
40
48
|
indicatorSquare: css`
|
|
41
49
|
inset-block-end: 0;
|
|
@@ -45,6 +53,10 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
|
|
|
45
53
|
height: 2px;
|
|
46
54
|
|
|
47
55
|
background: ${cssVar.colorPrimary};
|
|
56
|
+
|
|
57
|
+
[data-orientation='horizontal'] &:dir(rtl) {
|
|
58
|
+
inset-inline-start: var(--active-tab-right);
|
|
59
|
+
}
|
|
48
60
|
`,
|
|
49
61
|
list: css`
|
|
50
62
|
position: relative;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style.mjs","names":[],"sources":["../../../src/base-ui/Tabs/style.ts"],"sourcesContent":["import { createStaticStyles } from 'antd-style';\nimport { cva } from 'class-variance-authority';\n\nexport const styles = createStaticStyles(({ css, cssVar }) => ({\n indicator: css`\n pointer-events: none;\n\n position: absolute;\n z-index: 0;\n\n transition-timing-function: ${cssVar.motionEaseOut};\n transition-duration: 240ms;\n transition-property: inset-inline-start, inset-block-start, width, height, transform;\n\n @media (prefers-reduced-motion: reduce) {\n transition-duration: 0s;\n }\n `,\n indicatorPoint: css`\n inset-block-end: 6px;\n inset-inline-start: calc(var(--active-tab-left) + var(--active-tab-width) / 2 - 2.5px);\n\n width: 5px;\n height: 5px;\n border-radius: 50%;\n\n background: ${cssVar.colorPrimary};\n `,\n indicatorRounded: css`\n inset-block-start: var(--active-tab-top);\n inset-inline-start: var(--active-tab-left);\n\n width: var(--active-tab-width);\n height: var(--active-tab-height);\n border-radius: ${cssVar.borderRadius};\n\n background: ${cssVar.colorBgElevated};\n box-shadow: ${cssVar.boxShadowTertiary};\n `,\n indicatorSquare: css`\n inset-block-end: 0;\n inset-inline-start: var(--active-tab-left);\n\n width: var(--active-tab-width);\n height: 2px;\n\n background: ${cssVar.colorPrimary};\n `,\n list: css`\n position: relative;\n\n display: inline-flex;\n flex-wrap: nowrap;\n gap: 2px;\n align-items: center;\n\n &[data-orientation='vertical'] {\n flex-direction: column;\n align-items: stretch;\n }\n `,\n listRounded: css`\n gap: 4px;\n align-self: flex-start;\n\n padding: 3px;\n border-radius: ${cssVar.borderRadiusLG};\n\n background: ${cssVar.colorBgLayout};\n\n &[data-orientation='vertical'] {\n align-self: stretch;\n }\n `,\n listSquare: css`\n gap: 16px;\n box-shadow: inset 0 -1px 0 ${cssVar.colorBorderSecondary};\n\n &[data-orientation='vertical'] {\n box-shadow: inset -1px 0 0 ${cssVar.colorBorderSecondary};\n }\n `,\n panel: css`\n padding-block-start: 12px;\n outline: none;\n\n &:focus-visible {\n border-radius: ${cssVar.borderRadius};\n outline: 2px solid ${cssVar.colorPrimaryBorder};\n outline-offset: 2px;\n }\n `,\n root: css`\n display: flex;\n flex-direction: column;\n width: 100%;\n\n &[data-orientation='vertical'] {\n flex-direction: row;\n }\n `,\n tab: css`\n cursor: pointer;\n user-select: none;\n\n position: relative;\n z-index: 1;\n\n display: inline-flex;\n flex-shrink: 0;\n gap: 6px;\n align-items: center;\n justify-content: center;\n\n box-sizing: border-box;\n border: 0;\n\n font-weight: 500;\n color: ${cssVar.colorTextSecondary};\n white-space: nowrap;\n\n background: transparent;\n outline: none;\n\n transition:\n color 120ms ${cssVar.motionEaseOut},\n transform 120ms ${cssVar.motionEaseOut};\n\n &:hover:not([data-disabled]) {\n color: ${cssVar.colorText};\n }\n\n &:active:not([data-disabled]) {\n transform: scale(0.98);\n }\n\n &:focus-visible {\n outline: 2px solid ${cssVar.colorPrimaryBorder};\n outline-offset: -2px;\n }\n\n &[data-active] {\n color: ${cssVar.colorPrimary};\n }\n\n &[data-disabled] {\n cursor: not-allowed;\n color: ${cssVar.colorTextDisabled};\n }\n\n @media (prefers-reduced-motion: reduce) {\n transition-duration: 0s;\n }\n `,\n tabLarge: css`\n height: 36px;\n padding-inline: 16px;\n border-radius: ${cssVar.borderRadius};\n font-size: 14px;\n `,\n tabMiddle: css`\n height: 32px;\n padding-inline: 12px;\n border-radius: ${cssVar.borderRadius};\n font-size: 13px;\n `,\n tabPoint: css`\n height: auto;\n padding-block: 8px 14px;\n `,\n tabSmall: css`\n height: 26px;\n padding-inline: 10px;\n border-radius: ${cssVar.borderRadius};\n font-size: 12px;\n `,\n tabSquare: css`\n height: auto;\n padding-block: 8px;\n border-radius: 0;\n `,\n}));\n\nexport const tabVariants = cva(styles.tab, {\n defaultVariants: {\n size: 'middle',\n variant: 'rounded',\n },\n variants: {\n size: {\n large: styles.tabLarge,\n middle: styles.tabMiddle,\n small: styles.tabSmall,\n },\n variant: {\n point: styles.tabPoint,\n rounded: null,\n square: styles.tabSquare,\n },\n },\n});\n\nexport const indicatorVariants = cva(styles.indicator, {\n defaultVariants: {\n variant: 'rounded',\n },\n variants: {\n variant: {\n point: styles.indicatorPoint,\n rounded: styles.indicatorRounded,\n square: styles.indicatorSquare,\n },\n },\n});\n\nexport const listVariants = cva(styles.list, {\n defaultVariants: {\n variant: 'rounded',\n },\n variants: {\n variant: {\n point: null,\n rounded: styles.listRounded,\n square: styles.listSquare,\n },\n },\n});\n"],"mappings":";;;AAGA,MAAa,SAAS,oBAAoB,EAAE,KAAK,cAAc;CAC7D,WAAW,GAAG;;;;;;kCAMkB,OAAO,cAAc;;;;;;;;CAQrD,gBAAgB,GAAG;;;;;;;;kBAQH,OAAO,aAAa
|
|
1
|
+
{"version":3,"file":"style.mjs","names":[],"sources":["../../../src/base-ui/Tabs/style.ts"],"sourcesContent":["import { createStaticStyles } from 'antd-style';\nimport { cva } from 'class-variance-authority';\n\nexport const styles = createStaticStyles(({ css, cssVar }) => ({\n indicator: css`\n pointer-events: none;\n\n position: absolute;\n z-index: 0;\n\n transition-timing-function: ${cssVar.motionEaseOut};\n transition-duration: 240ms;\n transition-property: inset-inline-start, inset-block-start, width, height, transform;\n\n @media (prefers-reduced-motion: reduce) {\n transition-duration: 0s;\n }\n `,\n indicatorPoint: css`\n inset-block-end: 6px;\n inset-inline-start: calc(var(--active-tab-left) + var(--active-tab-width) / 2 - 2.5px);\n\n width: 5px;\n height: 5px;\n border-radius: 50%;\n\n background: ${cssVar.colorPrimary};\n\n [data-orientation='horizontal'] &:dir(rtl) {\n inset-inline-start: calc(var(--active-tab-right) + var(--active-tab-width) / 2 - 2.5px);\n }\n `,\n indicatorRounded: css`\n inset-block-start: var(--active-tab-top);\n inset-inline-start: var(--active-tab-left);\n\n width: var(--active-tab-width);\n height: var(--active-tab-height);\n border-radius: ${cssVar.borderRadius};\n\n background: ${cssVar.colorBgElevated};\n box-shadow: ${cssVar.boxShadowTertiary};\n\n [data-orientation='horizontal'] &:dir(rtl) {\n inset-inline-start: var(--active-tab-right);\n }\n `,\n indicatorSquare: css`\n inset-block-end: 0;\n inset-inline-start: var(--active-tab-left);\n\n width: var(--active-tab-width);\n height: 2px;\n\n background: ${cssVar.colorPrimary};\n\n [data-orientation='horizontal'] &:dir(rtl) {\n inset-inline-start: var(--active-tab-right);\n }\n `,\n list: css`\n position: relative;\n\n display: inline-flex;\n flex-wrap: nowrap;\n gap: 2px;\n align-items: center;\n\n &[data-orientation='vertical'] {\n flex-direction: column;\n align-items: stretch;\n }\n `,\n listRounded: css`\n gap: 4px;\n align-self: flex-start;\n\n padding: 3px;\n border-radius: ${cssVar.borderRadiusLG};\n\n background: ${cssVar.colorBgLayout};\n\n &[data-orientation='vertical'] {\n align-self: stretch;\n }\n `,\n listSquare: css`\n gap: 16px;\n box-shadow: inset 0 -1px 0 ${cssVar.colorBorderSecondary};\n\n &[data-orientation='vertical'] {\n box-shadow: inset -1px 0 0 ${cssVar.colorBorderSecondary};\n }\n `,\n panel: css`\n padding-block-start: 12px;\n outline: none;\n\n &:focus-visible {\n border-radius: ${cssVar.borderRadius};\n outline: 2px solid ${cssVar.colorPrimaryBorder};\n outline-offset: 2px;\n }\n `,\n root: css`\n display: flex;\n flex-direction: column;\n width: 100%;\n\n &[data-orientation='vertical'] {\n flex-direction: row;\n }\n `,\n tab: css`\n cursor: pointer;\n user-select: none;\n\n position: relative;\n z-index: 1;\n\n display: inline-flex;\n flex-shrink: 0;\n gap: 6px;\n align-items: center;\n justify-content: center;\n\n box-sizing: border-box;\n border: 0;\n\n font-weight: 500;\n color: ${cssVar.colorTextSecondary};\n white-space: nowrap;\n\n background: transparent;\n outline: none;\n\n transition:\n color 120ms ${cssVar.motionEaseOut},\n transform 120ms ${cssVar.motionEaseOut};\n\n &:hover:not([data-disabled]) {\n color: ${cssVar.colorText};\n }\n\n &:active:not([data-disabled]) {\n transform: scale(0.98);\n }\n\n &:focus-visible {\n outline: 2px solid ${cssVar.colorPrimaryBorder};\n outline-offset: -2px;\n }\n\n &[data-active] {\n color: ${cssVar.colorPrimary};\n }\n\n &[data-disabled] {\n cursor: not-allowed;\n color: ${cssVar.colorTextDisabled};\n }\n\n @media (prefers-reduced-motion: reduce) {\n transition-duration: 0s;\n }\n `,\n tabLarge: css`\n height: 36px;\n padding-inline: 16px;\n border-radius: ${cssVar.borderRadius};\n font-size: 14px;\n `,\n tabMiddle: css`\n height: 32px;\n padding-inline: 12px;\n border-radius: ${cssVar.borderRadius};\n font-size: 13px;\n `,\n tabPoint: css`\n height: auto;\n padding-block: 8px 14px;\n `,\n tabSmall: css`\n height: 26px;\n padding-inline: 10px;\n border-radius: ${cssVar.borderRadius};\n font-size: 12px;\n `,\n tabSquare: css`\n height: auto;\n padding-block: 8px;\n border-radius: 0;\n `,\n}));\n\nexport const tabVariants = cva(styles.tab, {\n defaultVariants: {\n size: 'middle',\n variant: 'rounded',\n },\n variants: {\n size: {\n large: styles.tabLarge,\n middle: styles.tabMiddle,\n small: styles.tabSmall,\n },\n variant: {\n point: styles.tabPoint,\n rounded: null,\n square: styles.tabSquare,\n },\n },\n});\n\nexport const indicatorVariants = cva(styles.indicator, {\n defaultVariants: {\n variant: 'rounded',\n },\n variants: {\n variant: {\n point: styles.indicatorPoint,\n rounded: styles.indicatorRounded,\n square: styles.indicatorSquare,\n },\n },\n});\n\nexport const listVariants = cva(styles.list, {\n defaultVariants: {\n variant: 'rounded',\n },\n variants: {\n variant: {\n point: null,\n rounded: styles.listRounded,\n square: styles.listSquare,\n },\n },\n});\n"],"mappings":";;;AAGA,MAAa,SAAS,oBAAoB,EAAE,KAAK,cAAc;CAC7D,WAAW,GAAG;;;;;;kCAMkB,OAAO,cAAc;;;;;;;;CAQrD,gBAAgB,GAAG;;;;;;;;kBAQH,OAAO,aAAa;;;;;;CAMpC,kBAAkB,GAAG;;;;;;qBAMF,OAAO,aAAa;;kBAEvB,OAAO,gBAAgB;kBACvB,OAAO,kBAAkB;;;;;;CAMzC,iBAAiB,GAAG;;;;;;;kBAOJ,OAAO,aAAa;;;;;;CAMpC,MAAM,GAAG;;;;;;;;;;;;;CAaT,aAAa,GAAG;;;;;qBAKG,OAAO,eAAe;;kBAEzB,OAAO,cAAc;;;;;;CAMrC,YAAY,GAAG;;iCAEgB,OAAO,qBAAqB;;;mCAG1B,OAAO,qBAAqB;;;CAG7D,OAAO,GAAG;;;;;uBAKW,OAAO,aAAa;2BAChB,OAAO,mBAAmB;;;;CAInD,MAAM,GAAG;;;;;;;;;CAST,KAAK,GAAG;;;;;;;;;;;;;;;;;aAiBG,OAAO,mBAAmB;;;;;;;oBAOnB,OAAO,cAAc;wBACjB,OAAO,cAAc;;;eAG9B,OAAO,UAAU;;;;;;;;2BAQL,OAAO,mBAAmB;;;;;eAKtC,OAAO,aAAa;;;;;eAKpB,OAAO,kBAAkB;;;;;;;CAOtC,UAAU,GAAG;;;qBAGM,OAAO,aAAa;;;CAGvC,WAAW,GAAG;;;qBAGK,OAAO,aAAa;;;CAGvC,UAAU,GAAG;;;;CAIb,UAAU,GAAG;;;qBAGM,OAAO,aAAa;;;CAGvC,WAAW,GAAG;;;;;AAKhB,EAAE;AAEF,MAAa,cAAc,IAAI,OAAO,KAAK;CACzC,iBAAiB;EACf,MAAM;EACN,SAAS;CACX;CACA,UAAU;EACR,MAAM;GACJ,OAAO,OAAO;GACd,QAAQ,OAAO;GACf,OAAO,OAAO;EAChB;EACA,SAAS;GACP,OAAO,OAAO;GACd,SAAS;GACT,QAAQ,OAAO;EACjB;CACF;AACF,CAAC;AAED,MAAa,oBAAoB,IAAI,OAAO,WAAW;CACrD,iBAAiB,EACf,SAAS,UACX;CACA,UAAU,EACR,SAAS;EACP,OAAO,OAAO;EACd,SAAS,OAAO;EAChB,QAAQ,OAAO;CACjB,EACF;AACF,CAAC;AAED,MAAa,eAAe,IAAI,OAAO,MAAM;CAC3C,iBAAiB,EACf,SAAS,UACX;CACA,UAAU,EACR,SAAS;EACP,OAAO;EACP,SAAS,OAAO;EAChB,QAAQ,OAAO;CACjB,EACF;AACF,CAAC"}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { isLastFormulaRenderable } from "./latex.mjs";
|
|
3
2
|
import { addToCache, contentCache, preprocessMarkdownContent } from "./utils.mjs";
|
|
4
3
|
import { useMarkdownContext } from "../../Markdown/components/MarkdownProvider.mjs";
|
|
5
|
-
import { useMemo
|
|
4
|
+
import { useMemo } from "react";
|
|
6
5
|
//#region src/hooks/useMarkdown/useMarkdownContent.ts
|
|
7
6
|
const useMarkdownContent = (children) => {
|
|
8
|
-
const {
|
|
9
|
-
const [validContent, setValidContent] = useState("");
|
|
10
|
-
const prevProcessedContent = useRef("");
|
|
7
|
+
const { enableLatex = true, enableCustomFootnotes, citations } = useMarkdownContext();
|
|
11
8
|
const citationsLength = citations?.length || 0;
|
|
12
9
|
const cacheKey = useMemo(() => `${children}|${enableLatex ? 1 : 0}|${enableCustomFootnotes ? 1 : 0}|${citationsLength}`, [
|
|
13
10
|
children,
|
|
@@ -17,18 +14,11 @@ const useMarkdownContent = (children) => {
|
|
|
17
14
|
]);
|
|
18
15
|
return useMemo(() => {
|
|
19
16
|
if (contentCache.has(cacheKey)) return contentCache.get(cacheKey);
|
|
20
|
-
|
|
17
|
+
const processedContent = preprocessMarkdownContent(children, {
|
|
21
18
|
citationsLength,
|
|
22
19
|
enableCustomFootnotes,
|
|
23
20
|
enableLatex
|
|
24
21
|
});
|
|
25
|
-
if (animated && enableLatex) {
|
|
26
|
-
if (!isLastFormulaRenderable(processedContent) && validContent) processedContent = validContent;
|
|
27
|
-
}
|
|
28
|
-
if (processedContent !== prevProcessedContent.current) {
|
|
29
|
-
setValidContent(processedContent);
|
|
30
|
-
prevProcessedContent.current = processedContent;
|
|
31
|
-
}
|
|
32
22
|
addToCache(cacheKey, processedContent);
|
|
33
23
|
return processedContent;
|
|
34
24
|
}, [
|
|
@@ -36,9 +26,7 @@ const useMarkdownContent = (children) => {
|
|
|
36
26
|
children,
|
|
37
27
|
enableLatex,
|
|
38
28
|
enableCustomFootnotes,
|
|
39
|
-
citationsLength
|
|
40
|
-
animated,
|
|
41
|
-
validContent
|
|
29
|
+
citationsLength
|
|
42
30
|
]);
|
|
43
31
|
};
|
|
44
32
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMarkdownContent.mjs","names":[],"sources":["../../../src/hooks/useMarkdown/useMarkdownContent.ts"],"sourcesContent":["'use client';\n\nimport { useMemo
|
|
1
|
+
{"version":3,"file":"useMarkdownContent.mjs","names":[],"sources":["../../../src/hooks/useMarkdown/useMarkdownContent.ts"],"sourcesContent":["'use client';\n\nimport { useMemo } from 'react';\n\nimport { useMarkdownContext } from '@/Markdown/components/MarkdownProvider';\n\nimport { addToCache, contentCache, preprocessMarkdownContent } from './utils';\n\nexport const useMarkdownContent = (children: string): string | undefined => {\n const { enableLatex = true, enableCustomFootnotes, citations } = useMarkdownContext();\n\n const citationsLength = citations?.length || 0;\n\n const cacheKey = useMemo(\n () => `${children}|${enableLatex ? 1 : 0}|${enableCustomFootnotes ? 1 : 0}|${citationsLength}`,\n [children, enableLatex, enableCustomFootnotes, citationsLength],\n );\n\n return useMemo(() => {\n if (contentCache.has(cacheKey)) {\n return contentCache.get(cacheKey);\n }\n\n const processedContent = preprocessMarkdownContent(children, {\n citationsLength,\n enableCustomFootnotes,\n enableLatex,\n });\n\n addToCache(cacheKey, processedContent);\n return processedContent;\n }, [cacheKey, children, enableLatex, enableCustomFootnotes, citationsLength]);\n};\n"],"mappings":";;;;;AAQA,MAAa,sBAAsB,aAAyC;CAC1E,MAAM,EAAE,cAAc,MAAM,uBAAuB,cAAc,mBAAmB;CAEpF,MAAM,kBAAkB,WAAW,UAAU;CAE7C,MAAM,WAAW,cACT,GAAG,SAAS,GAAG,cAAc,IAAI,EAAE,GAAG,wBAAwB,IAAI,EAAE,GAAG,mBAC7E;EAAC;EAAU;EAAa;EAAuB;CAAe,CAChE;CAEA,OAAO,cAAc;EACnB,IAAI,aAAa,IAAI,QAAQ,GAC3B,OAAO,aAAa,IAAI,QAAQ;EAGlC,MAAM,mBAAmB,0BAA0B,UAAU;GAC3D;GACA;GACA;EACF,CAAC;EAED,WAAW,UAAU,gBAAgB;EACrC,OAAO;CACT,GAAG;EAAC;EAAU;EAAU;EAAa;EAAuB;CAAe,CAAC;AAC9E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","names":[],"sources":["../../../src/hooks/useMarkdown/utils.ts"],"sourcesContent":["import { preprocessLaTeX } from '
|
|
1
|
+
{"version":3,"file":"utils.mjs","names":[],"sources":["../../../src/hooks/useMarkdown/utils.ts"],"sourcesContent":["import { preprocessLaTeX } from '@lobehub/streamdown';\n\n// Cache configuration\nconst CACHE_SIZE = 50;\n\n/**\n * Cache for storing processed content to avoid redundant processing\n */\nexport const contentCache = new Map<string, string>();\n\n/**\n * Adds content to the cache with size limitation\n * Removes oldest entry if cache size limit is reached\n *\n * @param key The cache key\n * @param value The processed content to store\n */\nexport const addToCache = (key: string, value: string) => {\n if (contentCache.size >= CACHE_SIZE) {\n // Remove the oldest cache entry\n const firstKey = contentCache.keys().next().value;\n if (firstKey) contentCache.delete(firstKey);\n }\n contentCache.set(key, value);\n};\n\n/**\n * Transforms citation references in the format [n] to markdown links\n *\n * @param rawContent The markdown content with citation references\n * @param length The number of citations\n * @returns The content with citations transformed to markdown links\n */\nexport const transformCitations = (rawContent: string, length: number = 0) => {\n if (length === 0) return rawContent;\n\n // 生成引用索引\n const citationIndices = Array.from({ length })\n .fill('')\n .map((_, index) => index + 1);\n\n // 匹配所有潜在的引用\n const pattern = new RegExp(`\\\\[(${citationIndices.join('|')})\\\\]`, 'g');\n const matches: { id: string; index: number; length: number }[] = [];\n\n let match;\n while ((match = pattern.exec(rawContent)) !== null) {\n matches.push({\n id: match[1],\n index: match.index,\n length: match[0].length,\n });\n }\n\n // 识别所有需要排除的区域\n const excludedRanges: { end: number; start: number }[] = [];\n\n // 查找LaTeX块 $$...$$\n const latexBlockRegex = /\\$\\$([\\s\\S]*?)\\$\\$/g;\n while ((match = latexBlockRegex.exec(rawContent)) !== null) {\n excludedRanges.push({\n end: match.index + match[0].length - 1,\n start: match.index,\n });\n }\n\n // 查找行内LaTeX $...$\n const inlineLatexRegex = /\\$([^$]*)\\$/g;\n while ((match = inlineLatexRegex.exec(rawContent)) !== null) {\n excludedRanges.push({\n end: match.index + match[0].length - 1,\n start: match.index,\n });\n }\n\n // 查找代码块 ```...```\n const codeBlockRegex = /```([\\s\\S]*?)```/g;\n while ((match = codeBlockRegex.exec(rawContent)) !== null) {\n excludedRanges.push({\n end: match.index + match[0].length - 1,\n start: match.index,\n });\n }\n\n // 查找行内代码 `...`\n const inlineCodeRegex = /`([^`]*)`/g;\n while ((match = inlineCodeRegex.exec(rawContent)) !== null) {\n excludedRanges.push({\n end: match.index + match[0].length - 1,\n start: match.index,\n });\n }\n\n // 过滤掉在排除区域内的引用\n const validMatches = matches.filter((citation) => {\n return !excludedRanges.some(\n (range) => citation.index >= range.start && citation.index <= range.end,\n );\n });\n\n // 从后向前替换,避免索引变化问题\n let result = rawContent;\n for (let i = validMatches.length - 1; i >= 0; i--) {\n const citation = validMatches[i];\n const before = result.slice(0, Math.max(0, citation.index));\n const after = result.slice(Math.max(0, citation.index + citation.length));\n result = before + `[#citation-${citation.id}](citation-${citation.id})` + after;\n }\n\n // 处理连续引用\n return result.replaceAll('][', '] [');\n};\n\n/**\n * Preprocessing options for markdown content\n */\ninterface PreprocessOptions {\n citationsLength?: number;\n enableCustomFootnotes?: boolean;\n enableLatex?: boolean;\n}\n\nexport const preprocessMarkdownContent = (\n str: string,\n { enableCustomFootnotes, enableLatex, citationsLength }: PreprocessOptions = {},\n) => {\n let content = str;\n\n // Process LaTeX expressions\n if (enableLatex) {\n content = preprocessLaTeX(content);\n }\n\n // Process custom footnotes/citations\n if (enableCustomFootnotes) {\n content = transformCitations(content, citationsLength);\n }\n\n return content;\n};\n"],"mappings":";;AAGA,MAAM,aAAa;;;;AAKnB,MAAa,+BAAe,IAAI,IAAoB;;;;;;;;AASpD,MAAa,cAAc,KAAa,UAAkB;CACxD,IAAI,aAAa,QAAQ,YAAY;EAEnC,MAAM,WAAW,aAAa,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC;EAC5C,IAAI,UAAU,aAAa,OAAO,QAAQ;CAC5C;CACA,aAAa,IAAI,KAAK,KAAK;AAC7B;;;;;;;;AASA,MAAa,sBAAsB,YAAoB,SAAiB,MAAM;CAC5E,IAAI,WAAW,GAAG,OAAO;CAGzB,MAAM,kBAAkB,MAAM,KAAK,EAAE,OAAO,CAAC,CAAC,CAC3C,KAAK,EAAE,CAAC,CACR,KAAK,GAAG,UAAU,QAAQ,CAAC;CAG9B,MAAM,UAAU,IAAI,OAAO,OAAO,gBAAgB,KAAK,GAAG,EAAE,OAAO,GAAG;CACtE,MAAM,UAA2D,CAAC;CAElE,IAAI;CACJ,QAAQ,QAAQ,QAAQ,KAAK,UAAU,OAAO,MAC5C,QAAQ,KAAK;EACX,IAAI,MAAM;EACV,OAAO,MAAM;EACb,QAAQ,MAAM,EAAE,CAAC;CACnB,CAAC;CAIH,MAAM,iBAAmD,CAAC;CAG1D,MAAM,kBAAkB;CACxB,QAAQ,QAAQ,gBAAgB,KAAK,UAAU,OAAO,MACpD,eAAe,KAAK;EAClB,KAAK,MAAM,QAAQ,MAAM,EAAE,CAAC,SAAS;EACrC,OAAO,MAAM;CACf,CAAC;CAIH,MAAM,mBAAmB;CACzB,QAAQ,QAAQ,iBAAiB,KAAK,UAAU,OAAO,MACrD,eAAe,KAAK;EAClB,KAAK,MAAM,QAAQ,MAAM,EAAE,CAAC,SAAS;EACrC,OAAO,MAAM;CACf,CAAC;CAIH,MAAM,iBAAiB;CACvB,QAAQ,QAAQ,eAAe,KAAK,UAAU,OAAO,MACnD,eAAe,KAAK;EAClB,KAAK,MAAM,QAAQ,MAAM,EAAE,CAAC,SAAS;EACrC,OAAO,MAAM;CACf,CAAC;CAIH,MAAM,kBAAkB;CACxB,QAAQ,QAAQ,gBAAgB,KAAK,UAAU,OAAO,MACpD,eAAe,KAAK;EAClB,KAAK,MAAM,QAAQ,MAAM,EAAE,CAAC,SAAS;EACrC,OAAO,MAAM;CACf,CAAC;CAIH,MAAM,eAAe,QAAQ,QAAQ,aAAa;EAChD,OAAO,CAAC,eAAe,MACpB,UAAU,SAAS,SAAS,MAAM,SAAS,SAAS,SAAS,MAAM,GACtE;CACF,CAAC;CAGD,IAAI,SAAS;CACb,KAAK,IAAI,IAAI,aAAa,SAAS,GAAG,KAAK,GAAG,KAAK;EACjD,MAAM,WAAW,aAAa;EAC9B,MAAM,SAAS,OAAO,MAAM,GAAG,KAAK,IAAI,GAAG,SAAS,KAAK,CAAC;EAC1D,MAAM,QAAQ,OAAO,MAAM,KAAK,IAAI,GAAG,SAAS,QAAQ,SAAS,MAAM,CAAC;EACxE,SAAS,SAAS,cAAc,SAAS,GAAG,aAAa,SAAS,GAAG,KAAK;CAC5E;CAGA,OAAO,OAAO,WAAW,MAAM,KAAK;AACtC;AAWA,MAAa,6BACX,KACA,EAAE,uBAAuB,aAAa,oBAAuC,CAAC,MAC3E;CACH,IAAI,UAAU;CAGd,IAAI,aACF,UAAU,gBAAgB,OAAO;CAInC,IAAI,uBACF,UAAU,mBAAmB,SAAS,eAAe;CAGvD,OAAO;AACT"}
|
package/es/index.d.mts
CHANGED
|
@@ -225,7 +225,6 @@ import "./Markdown/index.mjs";
|
|
|
225
225
|
import SearchResultCards, { SearchResultCardsProps } from "./Markdown/components/SearchResultCards/index.mjs";
|
|
226
226
|
import { rehypeCustomFootnotes } from "./Markdown/plugins/rehypeCustomFootnotes.mjs";
|
|
227
227
|
import { rehypeKatexDir } from "./Markdown/plugins/rehypeKatexDir.mjs";
|
|
228
|
-
import { rehypeStreamAnimated } from "./Markdown/plugins/rehypeStreamAnimated.mjs";
|
|
229
228
|
import { remarkBr } from "./Markdown/plugins/remarkBr.mjs";
|
|
230
229
|
import { remarkColor } from "./Markdown/plugins/remarkColor.mjs";
|
|
231
230
|
import { remarkCustomFootnotes } from "./Markdown/plugins/remarkCustomFootnotes.mjs";
|
|
@@ -309,5 +308,6 @@ import { LayoutSidebar } from "./Layout/components/LayoutSidebar.mjs";
|
|
|
309
308
|
import { LayoutSidebarInner } from "./Layout/components/LayoutSidebarInner.mjs";
|
|
310
309
|
import { LayoutToc } from "./Layout/components/LayoutToc.mjs";
|
|
311
310
|
import Layout from "./Layout/index.mjs";
|
|
311
|
+
import { rehypeStreamAnimated } from "@lobehub/streamdown";
|
|
312
312
|
import { ErrorBoundary, ErrorBoundaryProps } from "react-error-boundary";
|
|
313
313
|
export { A, type AProps, Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, ActionIcon, ActionIconGroup, type ActionIconGroupEvent, type MenuItemType as ActionIconGroupItemType, type ActionIconGroupProps, type ActionIconProps, type ActionIconSize, Alert, type AlertProps, AutoComplete, type AutoCompleteProps, Avatar, AvatarGroup, type AvatarGroupProps, type AvatarProps, type BaseMenuItemType, Block, type BlockProps, Burger, type BurgerProps, Button, type ButtonProps, type CDN, CLASSNAMES, Center, type CenterProps, Checkbox, CheckboxGroup, type CheckboxGroupOption, type CheckboxGroupProps, type CheckboxProps, CodeDiff, type CodeDiffProps, CodeEditor, type CodeEditorProps, Collapse, type CollapseItemType, type CollapseProps, type ColorPalettes, type ColorPalettesAlpha, ColorSwatches, type ColorSwatchesProps, type ColorToken, type Config, ConfigProvider, type ContextMenuCheckboxItem, ContextMenuHost, type ContextMenuInterceptor, type ContextMenuItem, ContextMenuTrigger, CopyButton, type CopyButtonProps, DatePicker, type DatePickerProps, type DiffViewMode, type DivProps, DownloadButton, type DownloadButtonProps, DraggablePanel, DraggablePanelBody, type DraggablePanelBodyProps, DraggablePanelContainer, type DraggablePanelContainerProps, DraggablePanelFooter, type DraggablePanelFooterProps, DraggablePanelHeader, type DraggablePanelHeaderProps, type DraggablePanelProps, DraggableSideNav, type DraggableSideNavProps, Drawer, type DrawerProps, Dropdown, type DropdownItem, DropdownMenu, type DropdownMenuCheckboxItem, DropdownMenuCheckboxItemIndicator, DropdownMenuCheckboxItemPrimitive, DropdownMenuFooter, type DropdownMenuFooterProps, DropdownMenuGroup, DropdownMenuGroupLabel, type DropdownMenuGroupLabelProps, DropdownMenuHeader, type DropdownMenuHeaderProps, DropdownMenuItem, DropdownMenuItemContent, type DropdownMenuItemContentProps, DropdownMenuItemExtra, type DropdownMenuItemExtraProps, DropdownMenuItemIcon, type DropdownMenuItemIconProps, DropdownMenuItemLabel, type DropdownMenuItemLabelProps, type DropdownMenuItemProps, type MenuItemType as DropdownMenuItemType, type DropdownMenuPlacement, DropdownMenuPopup, type DropdownMenuPopupProps, DropdownMenuPortal, type DropdownMenuPortalProps, DropdownMenuPositioner, type DropdownMenuPositionerProps, type DropdownMenuProps, DropdownMenuRoot, DropdownMenuScrollViewport, type DropdownMenuScrollViewportProps, DropdownMenuSeparator, type DropdownMenuSeparatorProps, DropdownMenuSubmenuArrow, type DropdownMenuSubmenuArrowProps, DropdownMenuSubmenuRoot, DropdownMenuSubmenuTrigger, type DropdownMenuSubmenuTriggerProps, DropdownMenuTrigger, type DropdownMenuTriggerProps, type DropdownProps, EditableText, type EditableTextProps, EditorSlashMenu, type EditorSlashMenuGroup, type EditorSlashMenuItems, type EditorSlashMenuOption, EmojiPicker, type EmojiPickerProps, Empty, type EmptyProps, ErrorBoundary, type ErrorBoundaryProps, FileTypeIcon, type FileTypeIconProps, _default as FlexBasic, type FlexBasicProps, _default as Flexbox, type FlexboxProps, FluentEmoji, type FluentEmojiProps, FontLoader, type FontLoaderProps, Footer, type FooterProps, Form, FormGroup, type FormGroupItemType, type FormGroupProps, type FormInstance, FormItem, type FormItemProps, FormModal, type FormModalProps, type FormProps, FormSubmitFooter, type FormSubmitFooterProps, FormTitle, type FormTitleProps, Freeze, type FreezeProps, type GenericItemType, Grid, type GridProps, GroupAvatar, type GroupAvatarProps, GuideCard, type GuideCardProps, DEFAULT_HEIGHT as HTML_PREVIEW_DEFAULT_HEIGHT, DEFAULT_SANDBOX as HTML_PREVIEW_DEFAULT_SANDBOX, AUTO_HEIGHT_MESSAGE_TYPE as HTML_PREVIEW_RESIZE_MESSAGE, Header, type HeaderProps, Highlighter, type HighlighterProps, Hotkey, HotkeyInput, type HotkeyInputProps, type HotkeyProps, HtmlPreview, HtmlPreviewIframe, type HtmlPreviewIframeProps, type HtmlPreviewMode, type HtmlPreviewProps, type HtmlPreviewStreamingMode, I18nProvider, type I18nProviderProps, Icon, type IconProps, IconProvider, type IconSize, Image, type ImagePreviewOptions, type ImageProps, ImageSelect, type ImageSelectItem, type ImageSelectProps, type ImgProps, type ImperativeModalProps, Input, InputNumber, type InputNumberProps, InputOPT, type InputOPTProps, InputPassword, type InputPasswordProps, type InputProps, type ItemType, KeyMapEnum, LOBE_THEME_APP_ID, Layout, LayoutFooter, type LayoutFooterProps, LayoutHeader, type LayoutHeaderProps, LayoutMain, type LayoutMainProps, type LayoutProps, LayoutSidebar, LayoutSidebarInner, type LayoutSidebarInnerProps, type LayoutSidebarProps, LayoutToc, type LayoutTocProps, List, ListItem, type ListItemProps, type ListProps, type LobeCustomStylish, type LobeCustomToken, I18nProvider as LobeUIProvider, Markdown, type MarkdownProps, MaskShadow, type MaskShadowProps, MaterialFileTypeIcon, type MaterialFileTypeIconProps, Menu, type MenuCheckboxItemType, type MenuInfo, type MenuItemType, type MenuProps, Mermaid, type MermaidProps, Meta, type MetaProps, Modal, ModalHost, type ModalHostProps, type ModalInstance, type ModalProps, ModalProvider, MotionComponent, type MotionComponentType, MotionProvider, NeuralNetworkLoading, type NeuralNetworkLoadingProps, NeutralColors, NeutralColorsObj, PatchDiff, type PatchDiffProps, type Placement, type PlacementConfig, Popover, PopoverArrow, type PopoverArrowAtomProps, PopoverArrowIcon, PopoverBackdrop, type PopoverContextValue, PopoverGroup, type PopoverGroupHandle, type PopoverGroupItem, type PopoverPlacement, PopoverPopup, type PopoverPopupAtomProps, PopoverPortal, type PopoverPortalAtomProps, PopoverPositioner, type PopoverPositionerAtomProps, type PopoverProps, PopoverProvider, PopoverRoot, type PopoverTrigger, PopoverTriggerElement, type PopoverTriggerElementProps, PopoverViewport, type PopoverViewportAtomProps, type PresetColorKey, type PresetColorType, type PresetSystemColorKey, type PresetSystemColorType, PreviewGroup, type PreviewGroupProps, PrimaryColors, PrimaryColorsObj, type RawModalComponent, type RawModalComponentProps, type RawModalInstance, type RawModalKeyOptions, type RawModalOptions, ScrollArea, ScrollAreaContent, type ScrollAreaContentProps, ScrollAreaCorner, type ScrollAreaCornerProps, type ScrollAreaProps, ScrollAreaRoot, type ScrollAreaRootProps, ScrollAreaScrollbar, type ScrollAreaScrollbarProps, ScrollAreaThumb, type ScrollAreaThumbProps, ScrollAreaViewport, type ScrollAreaViewportProps, ScrollShadow, type ScrollShadowProps, SearchBar, type SearchBarProps, SearchResultCards, type SearchResultCardsProps, Segmented, type SegmentedProps, Select, type SelectProps, _default$1 as ShikiLobeTheme, SideNav, type SideNavProps, Skeleton, SkeletonAvatar, type SkeletonAvatarProps, SkeletonBlock, type SkeletonBlockProps, SkeletonButton, type SkeletonButtonProps, SkeletonParagraph, type SkeletonParagraphProps, type SkeletonProps, SkeletonTags, type SkeletonTagsProps, SkeletonTitle, type SkeletonTitleProps, SliderWithInput, type SliderWithInputProps, Snippet, type SnippetProps, SortableList, type SortableListProps, type SpanProps, type SvgProps, SyntaxHighlighter, type SyntaxHighlighterProps, SyntaxMermaid, type SyntaxMermaidProps, type SystemColorToken, Tabs, type TabsProps, Tag, type TagProps, Text, TextArea, type TextAreaProps, type TextProps, ThemeProvider, type ThemeProviderProps, ThemeSwitch, type ThemeSwitchProps, type ToastAPI, ToastHost, type ToastHostProps, type ToastInstance, type ToastOptions, type ToastPosition, type ToastPromiseOptions, type ToastProps, type ToastType, Toc, type TocProps, Tooltip, TooltipGroup, type TooltipProps, type Trigger, Typography, type TypographyProps, Video, type VideoProps, closeContextMenu, combineKeys, copyToClipboard, createModal, createRawModal, findCustomThemeName, genCdnUrl, generateColorNeutralPalette, generateColorPalette, highlighterThemes, containsScript as htmlPreviewContainsScript, isFullHtmlDocument, isHtmlContentClosed, generateCustomStylish as lobeCustomStylish, generateCustomToken as lobeCustomToken, staticStylish as lobeStaticStylish, styles as menuSharedStyles, mermaidThemes, neutralColors, neutralColorsSwatches, placementMap, preprocessMarkdownContent, preventDefault, preventDefaultAndStopPropagation, primaryColors, primaryColorsSwatches, rehypeCustomFootnotes, rehypeKatexDir, rehypeStreamAnimated, remarkBr, remarkColor, remarkCustomFootnotes, remarkGfmPlus, remarkVideo, renderDropdownMenuItems, setContextMenuInterceptor, showContextMenu, stopPropagation, toFloatingUIPlacement, toast, updateContextMenuItems, useAppElement, useCdnFn, useModalContext, useMotionComponent, usePopoverContext, usePopoverGroupHandle, usePopoverPortalContainer, useToast, useTranslation };
|
package/es/index.mjs
CHANGED
|
@@ -146,7 +146,6 @@ import { remarkBr } from "./Markdown/plugins/remarkBr.mjs";
|
|
|
146
146
|
import { remarkCustomFootnotes } from "./Markdown/plugins/remarkCustomFootnotes.mjs";
|
|
147
147
|
import { remarkGfmPlus } from "./Markdown/plugins/remarkGfmPlus.mjs";
|
|
148
148
|
import { remarkVideo } from "./Markdown/plugins/remarkVideo.mjs";
|
|
149
|
-
import { rehypeStreamAnimated } from "./Markdown/plugins/rehypeStreamAnimated.mjs";
|
|
150
149
|
import Typography from "./Markdown/Typography.mjs";
|
|
151
150
|
import Markdown from "./Markdown/Markdown.mjs";
|
|
152
151
|
import { remarkColor } from "./Markdown/plugins/remarkColor.mjs";
|
|
@@ -160,5 +159,6 @@ import SliderWithInput from "./SliderWithInput/SliderWithInput.mjs";
|
|
|
160
159
|
import SortableList from "./SortableList/SortableList.mjs";
|
|
161
160
|
import ThemeSwitch from "./ThemeSwitch/ThemeSwitch.mjs";
|
|
162
161
|
import Toc from "./Toc/Toc.mjs";
|
|
162
|
+
import { rehypeStreamAnimated } from "@lobehub/streamdown";
|
|
163
163
|
import { ErrorBoundary } from "react-error-boundary";
|
|
164
164
|
export { A, Accordion, AccordionItem, ActionIcon, ActionIconGroup, Alert, AutoComplete, Avatar, AvatarGroup, Block, Burger, Button, CLASSNAMES, Center, Checkbox, CheckboxGroup, CodeDiff, CodeEditor, Collapse, ColorSwatches, ConfigProvider, ContextMenuHost, ContextMenuTrigger, CopyButton, DatePicker, DownloadButton, DraggablePanel, DraggablePanelBody, DraggablePanelContainer, DraggablePanelFooter, DraggablePanelHeader, DraggableSideNav, Drawer, Dropdown, DropdownMenu, DropdownMenuCheckboxItemIndicator, DropdownMenuCheckboxItemPrimitive, DropdownMenuFooter, DropdownMenuGroup, DropdownMenuGroupLabel, DropdownMenuHeader, DropdownMenuItem, DropdownMenuItemContent, DropdownMenuItemExtra, DropdownMenuItemIcon, DropdownMenuItemLabel, DropdownMenuPopup, DropdownMenuPortal, DropdownMenuPositioner, DropdownMenuRoot, DropdownMenuScrollViewport, DropdownMenuSeparator, DropdownMenuSubmenuArrow, DropdownMenuSubmenuRoot, DropdownMenuSubmenuTrigger, DropdownMenuTrigger, EditableText, EditorSlashMenu, EmojiPicker, Empty, ErrorBoundary, FileTypeIcon, FlexBasic_default as FlexBasic, FlexBasic_default as Flexbox, FluentEmoji, FontLoader, Footer, Form, FormGroup, FormItem, FormModal, FormSubmitFooter, FormTitle, Freeze, Grid, GroupAvatar, GuideCard, DEFAULT_HEIGHT as HTML_PREVIEW_DEFAULT_HEIGHT, DEFAULT_SANDBOX as HTML_PREVIEW_DEFAULT_SANDBOX, AUTO_HEIGHT_MESSAGE_TYPE as HTML_PREVIEW_RESIZE_MESSAGE, Header, Highlighter, Hotkey, HotkeyInput, HtmlPreview, HtmlPreviewIframe, I18nProvider, Icon, IconProvider, Image, ImageSelect, Input, InputNumber, InputOPT, InputPassword, KeyMapEnum, LOBE_THEME_APP_ID, Layout, LayoutFooter, LayoutHeader, LayoutMain, LayoutSidebar, LayoutSidebarInner, LayoutToc, List, ListItem, I18nProvider as LobeUIProvider, Markdown, MaskShadow, MaterialFileTypeIcon, Menu, Mermaid, Meta, Modal, ModalHost, ModalProvider, MotionComponent, MotionProvider, NeuralNetworkLoading, PatchDiff, Popover, PopoverArrow, PopoverArrowIcon, PopoverBackdrop, PopoverGroup, PopoverPopup, PopoverPortal, PopoverPositioner, PopoverProvider, PopoverRoot, PopoverTriggerElement, PopoverViewport, PreviewGroup, ScrollArea, ScrollAreaContent, ScrollAreaCorner, ScrollAreaRoot, ScrollAreaScrollbar, ScrollAreaThumb, ScrollAreaViewport, ScrollShadow, SearchBar, SearchResultCards, Segmented, Select, lobe_theme_default as ShikiLobeTheme, SideNav, Skeleton, SkeletonAvatar, SkeletonBlock, SkeletonButton, SkeletonParagraph, SkeletonTags, SkeletonTitle, SliderWithInput, Snippet, SortableList, SyntaxHighlighter, SyntaxMermaid, Tabs, Tag, Text, TextArea, ThemeProvider, ThemeSwitch, ToastHost, Toc, Tooltip, TooltipGroup, Typography, Video, closeContextMenu, combineKeys, copyToClipboard, createModal, createRawModal, findCustomThemeName, genCdnUrl, generateColorNeutralPalette, generateColorPalette, highlighterThemes, containsScript as htmlPreviewContainsScript, isFullHtmlDocument, isHtmlContentClosed, generateCustomStylish as lobeCustomStylish, generateCustomToken as lobeCustomToken, staticStylish as lobeStaticStylish, styles as menuSharedStyles, mermaidThemes, neutralColors, neutralColorsSwatches, placementMap, preprocessMarkdownContent, preventDefault, preventDefaultAndStopPropagation, primaryColors, primaryColorsSwatches, rehypeCustomFootnotes, rehypeKatexDir, rehypeStreamAnimated, remarkBr, remarkColor, remarkCustomFootnotes, remarkGfmPlus, remarkVideo, renderDropdownMenuItems, setContextMenuInterceptor, showContextMenu, stopPropagation, toFloatingUIPlacement, toast, updateContextMenuItems, useAppElement, useCdnFn, useModalContext, useMotionComponent, usePopoverContext, usePopoverGroupHandle, usePopoverPortalContainer, useToast, useTranslation };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/ui",
|
|
3
|
-
"version": "5.32.
|
|
3
|
+
"version": "5.32.7",
|
|
4
4
|
"description": "Lobe UI is an open-source UI component library for building AIGC web apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lobehub",
|
|
@@ -136,24 +136,6 @@
|
|
|
136
136
|
"test:update": "vitest -u",
|
|
137
137
|
"type-check": "lobedocs typegen && tsc --noEmit && tsc --noEmit -p tsconfig.site.json"
|
|
138
138
|
},
|
|
139
|
-
"lint-staged": {
|
|
140
|
-
"*.{md,mdx}": [
|
|
141
|
-
"prettier --write --no-error-on-unmatched-pattern"
|
|
142
|
-
],
|
|
143
|
-
"*.json": [
|
|
144
|
-
"prettier --write --no-error-on-unmatched-pattern"
|
|
145
|
-
],
|
|
146
|
-
"*.{js,jsx}": [
|
|
147
|
-
"prettier --write",
|
|
148
|
-
"stylelint --fix",
|
|
149
|
-
"eslint --fix"
|
|
150
|
-
],
|
|
151
|
-
"*.{ts,tsx}": [
|
|
152
|
-
"prettier --parser=typescript --write",
|
|
153
|
-
"stylelint --fix",
|
|
154
|
-
"eslint --fix"
|
|
155
|
-
]
|
|
156
|
-
},
|
|
157
139
|
"dependencies": {
|
|
158
140
|
"@ant-design/cssinjs": "^2.1.2",
|
|
159
141
|
"@base-ui/react": "1.6.0",
|
|
@@ -166,6 +148,7 @@
|
|
|
166
148
|
"@emotion/is-prop-valid": "^1.4.0",
|
|
167
149
|
"@floating-ui/react": "^0.27.19",
|
|
168
150
|
"@giscus/react": "^3.1.0",
|
|
151
|
+
"@lobehub/streamdown": "^1.0.0",
|
|
169
152
|
"@mdx-js/mdx": "^3.1.1",
|
|
170
153
|
"@mdx-js/react": "^3.1.1",
|
|
171
154
|
"@pierre/diffs": "1.2.12",
|
|
@@ -229,75 +212,6 @@
|
|
|
229
212
|
"vfile": "^6.0.3",
|
|
230
213
|
"virtua": "^0.49.3"
|
|
231
214
|
},
|
|
232
|
-
"devDependencies": {
|
|
233
|
-
"@ant-design/icons": "^6.3.2",
|
|
234
|
-
"@commitlint/cli": "^21.2.1",
|
|
235
|
-
"@lobehub/docs-kit": "workspace:*",
|
|
236
|
-
"@lobehub/eslint-config": "2.1.5",
|
|
237
|
-
"@lobehub/fluent-emoji": "^4.1.0",
|
|
238
|
-
"@lobehub/icons": "^5.10.1",
|
|
239
|
-
"@lobehub/lint": "^2.1.5",
|
|
240
|
-
"@mdx-js/rollup": "3.1.1",
|
|
241
|
-
"@playwright/test": "1.61.1",
|
|
242
|
-
"@react-router/dev": "8.2.0",
|
|
243
|
-
"@testing-library/react": "^16.3.2",
|
|
244
|
-
"@types/chroma-js": "^3.1.2",
|
|
245
|
-
"@types/hast": "^3.0.5",
|
|
246
|
-
"@types/mdx": "^2.0.14",
|
|
247
|
-
"@types/node": "26.1.1",
|
|
248
|
-
"@types/numeral": "^2.0.5",
|
|
249
|
-
"@types/pangu": "^4.0.2",
|
|
250
|
-
"@types/react": "^19.2.17",
|
|
251
|
-
"@types/react-dom": "^19.2.3",
|
|
252
|
-
"@types/unist": "^3.0.3",
|
|
253
|
-
"@typescript-eslint/eslint-plugin": "^8.63.0",
|
|
254
|
-
"@typescript-eslint/parser": "^8.63.0",
|
|
255
|
-
"@vitest/coverage-v8": "^4.1.10",
|
|
256
|
-
"antd": "^6.5.0",
|
|
257
|
-
"cheerio": "^1.2.0",
|
|
258
|
-
"clean-package": "^2.2.0",
|
|
259
|
-
"code-inspector-plugin": "^1.6.6",
|
|
260
|
-
"commitlint": "^21.2.1",
|
|
261
|
-
"concurrently": "^10.0.3",
|
|
262
|
-
"conventional-changelog-gitmoji-config": "1.5.2",
|
|
263
|
-
"cross-env": "^10.1.0",
|
|
264
|
-
"dotenv": "^17.4.2",
|
|
265
|
-
"dpdm": "^4.2.0",
|
|
266
|
-
"eslint": "^9.39.5",
|
|
267
|
-
"eslint-plugin-sort-keys-fix": "^1.1.2",
|
|
268
|
-
"figma-js": "1.16.1-0",
|
|
269
|
-
"husky": "^9.1.7",
|
|
270
|
-
"jsdom": "^29.1.1",
|
|
271
|
-
"lint-staged": "^17.0.8",
|
|
272
|
-
"mdast-util-to-markdown": "^2.1.2",
|
|
273
|
-
"next-themes": "^0.4.6",
|
|
274
|
-
"pagefind": "1.5.2",
|
|
275
|
-
"prettier": "^3.9.5",
|
|
276
|
-
"prettier-plugin-packagejson": "^3.0.2",
|
|
277
|
-
"prettier-plugin-sh": "^0.19.0",
|
|
278
|
-
"prettier-plugin-sort-json": "^4.2.0",
|
|
279
|
-
"react": "^19.2.7",
|
|
280
|
-
"react-dom": "^19.2.7",
|
|
281
|
-
"react-live": "4.1.8",
|
|
282
|
-
"react-router": "8.2.0",
|
|
283
|
-
"remark": "^15.0.1",
|
|
284
|
-
"remark-cli": "^12.0.1",
|
|
285
|
-
"remark-frontmatter": "^5.0.0",
|
|
286
|
-
"remark-mdx-frontmatter": "^5.2.0",
|
|
287
|
-
"rollup-plugin-visualizer": "7.0.1",
|
|
288
|
-
"semantic-release": "^25.0.6",
|
|
289
|
-
"stylelint": "^16.26.1",
|
|
290
|
-
"svgo": "^4.0.1",
|
|
291
|
-
"tsdown": "^0.22.4",
|
|
292
|
-
"tsx": "^4.23.0",
|
|
293
|
-
"typescript": "^6.0.3",
|
|
294
|
-
"unist-util-is": "^6.0.1",
|
|
295
|
-
"unist-util-visit": "^5.1.0",
|
|
296
|
-
"vite": "8.1.4",
|
|
297
|
-
"vitest": "^4.1.10",
|
|
298
|
-
"yaml": "^2.9.0",
|
|
299
|
-
"zod": "^4.4.3"
|
|
300
|
-
},
|
|
301
215
|
"peerDependencies": {
|
|
302
216
|
"@lobehub/fluent-emoji": "^4.0.0",
|
|
303
217
|
"@lobehub/icons": "^5.0.0",
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { visit } from "../../node_modules/.pnpm/unist-util-visit@5.1.0/node_modules/unist-util-visit/lib/index.mjs";
|
|
3
|
-
import { useMemo } from "react";
|
|
4
|
-
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
-
import { defaultUrlTransform } from "react-markdown";
|
|
6
|
-
import { toJsxRuntime } from "hast-util-to-jsx-runtime";
|
|
7
|
-
import { urlAttributes } from "html-url-attributes";
|
|
8
|
-
import remarkParse from "remark-parse";
|
|
9
|
-
import remarkRehype from "remark-rehype";
|
|
10
|
-
import { unified } from "unified";
|
|
11
|
-
import { VFile } from "vfile";
|
|
12
|
-
//#region src/Markdown/SyntaxMarkdown/CachedMarkdown.tsx
|
|
13
|
-
const EMPTY_PLUGINS = [];
|
|
14
|
-
const DEFAULT_REMARK_REHYPE_OPTIONS = { allowDangerousHtml: true };
|
|
15
|
-
/**
|
|
16
|
-
* Render-equivalent of react-markdown's synchronous `<Markdown>` that keeps
|
|
17
|
-
* the unified processor across renders. react-markdown rebuilds the whole
|
|
18
|
-
* plugin chain on every render; the streaming tail block re-renders on every
|
|
19
|
-
* reveal commit (~20/s) with identical plugin identities, so caching the
|
|
20
|
-
* processor removes the per-commit chain construction. `post`/`transform`
|
|
21
|
-
* mirror react-markdown@10 — keep them in sync when upgrading it.
|
|
22
|
-
*/
|
|
23
|
-
const CachedMarkdown = (options) => {
|
|
24
|
-
const { children, rehypePlugins, remarkPlugins, remarkRehypeOptions } = options;
|
|
25
|
-
const processor = useMemo(() => {
|
|
26
|
-
return unified().use(remarkParse).use(remarkPlugins || EMPTY_PLUGINS).use(remarkRehype, remarkRehypeOptions ? {
|
|
27
|
-
...remarkRehypeOptions,
|
|
28
|
-
...DEFAULT_REMARK_REHYPE_OPTIONS
|
|
29
|
-
} : DEFAULT_REMARK_REHYPE_OPTIONS).use(rehypePlugins || EMPTY_PLUGINS);
|
|
30
|
-
}, [
|
|
31
|
-
rehypePlugins,
|
|
32
|
-
remarkPlugins,
|
|
33
|
-
remarkRehypeOptions
|
|
34
|
-
]);
|
|
35
|
-
const file = new VFile();
|
|
36
|
-
file.value = typeof children === "string" ? children : "";
|
|
37
|
-
return post(processor.runSync(processor.parse(file), file), options);
|
|
38
|
-
};
|
|
39
|
-
function post(tree, options) {
|
|
40
|
-
const { allowedElements, allowElement, components, disallowedElements, skipHtml, unwrapDisallowed } = options;
|
|
41
|
-
const urlTransform = options.urlTransform || defaultUrlTransform;
|
|
42
|
-
if (allowedElements && disallowedElements) throw new Error("Unexpected combined `allowedElements` and `disallowedElements`, expected one or the other");
|
|
43
|
-
const transform = (node, index, parent) => {
|
|
44
|
-
const rawNode = node;
|
|
45
|
-
if (rawNode.type === "raw" && typeof rawNode.value === "string" && parent && typeof index === "number") {
|
|
46
|
-
if (skipHtml) parent.children.splice(index, 1);
|
|
47
|
-
else parent.children[index] = {
|
|
48
|
-
type: "text",
|
|
49
|
-
value: rawNode.value
|
|
50
|
-
};
|
|
51
|
-
return index;
|
|
52
|
-
}
|
|
53
|
-
if (node.type === "element") {
|
|
54
|
-
let key;
|
|
55
|
-
for (key in urlAttributes) if (Object.hasOwn(urlAttributes, key) && Object.hasOwn(node.properties, key)) {
|
|
56
|
-
const value = node.properties[key];
|
|
57
|
-
const test = urlAttributes[key];
|
|
58
|
-
if (test === null || test.includes(node.tagName)) node.properties[key] = urlTransform(String(value || ""), key, node);
|
|
59
|
-
}
|
|
60
|
-
let remove = allowedElements ? !allowedElements.includes(node.tagName) : disallowedElements ? disallowedElements.includes(node.tagName) : false;
|
|
61
|
-
if (!remove && allowElement && typeof index === "number") remove = !allowElement(node, index, parent);
|
|
62
|
-
if (remove && parent && typeof index === "number") {
|
|
63
|
-
if (unwrapDisallowed && node.children) parent.children.splice(index, 1, ...node.children);
|
|
64
|
-
else parent.children.splice(index, 1);
|
|
65
|
-
return index;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
visit(tree, transform);
|
|
70
|
-
return toJsxRuntime(tree, {
|
|
71
|
-
Fragment: Fragment$1,
|
|
72
|
-
components,
|
|
73
|
-
ignoreInvalidStyle: true,
|
|
74
|
-
jsx,
|
|
75
|
-
jsxs,
|
|
76
|
-
passKeys: true,
|
|
77
|
-
passNode: true
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
//#endregion
|
|
81
|
-
export { CachedMarkdown };
|
|
82
|
-
|
|
83
|
-
//# sourceMappingURL=CachedMarkdown.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CachedMarkdown.mjs","names":[],"sources":["../../../src/Markdown/SyntaxMarkdown/CachedMarkdown.tsx"],"sourcesContent":["'use client';\n\nimport { type Nodes, type Root } from 'hast';\nimport { toJsxRuntime } from 'hast-util-to-jsx-runtime';\nimport { urlAttributes } from 'html-url-attributes';\nimport { useMemo } from 'react';\nimport { Fragment, jsx, jsxs } from 'react/jsx-runtime';\nimport { defaultUrlTransform, type Options } from 'react-markdown';\nimport remarkParse from 'remark-parse';\nimport remarkRehype from 'remark-rehype';\nimport { type PluggableList, unified } from 'unified';\nimport { type BuildVisitor, visit } from 'unist-util-visit';\nimport { VFile } from 'vfile';\n\nconst EMPTY_PLUGINS: PluggableList = [];\nconst DEFAULT_REMARK_REHYPE_OPTIONS = { allowDangerousHtml: true };\n\n/**\n * Render-equivalent of react-markdown's synchronous `<Markdown>` that keeps\n * the unified processor across renders. react-markdown rebuilds the whole\n * plugin chain on every render; the streaming tail block re-renders on every\n * reveal commit (~20/s) with identical plugin identities, so caching the\n * processor removes the per-commit chain construction. `post`/`transform`\n * mirror react-markdown@10 — keep them in sync when upgrading it.\n */\nexport const CachedMarkdown = (options: Options) => {\n const { children, rehypePlugins, remarkPlugins, remarkRehypeOptions } = options;\n\n const processor = useMemo(() => {\n return unified()\n .use(remarkParse)\n .use(remarkPlugins || EMPTY_PLUGINS)\n .use(\n remarkRehype,\n remarkRehypeOptions\n ? { ...remarkRehypeOptions, ...DEFAULT_REMARK_REHYPE_OPTIONS }\n : DEFAULT_REMARK_REHYPE_OPTIONS,\n )\n .use(rehypePlugins || EMPTY_PLUGINS);\n }, [rehypePlugins, remarkPlugins, remarkRehypeOptions]);\n\n const file = new VFile();\n file.value = typeof children === 'string' ? children : '';\n\n return post(processor.runSync(processor.parse(file), file) as Nodes, options);\n};\n\nfunction post(tree: Nodes, options: Options) {\n const {\n allowedElements,\n allowElement,\n components,\n disallowedElements,\n skipHtml,\n unwrapDisallowed,\n } = options;\n const urlTransform = options.urlTransform || defaultUrlTransform;\n\n if (allowedElements && disallowedElements) {\n throw new Error(\n 'Unexpected combined `allowedElements` and `disallowedElements`, expected one or the other',\n );\n }\n\n const transform: BuildVisitor<Root> = (node, index, parent) => {\n const rawNode = node as unknown as { type?: string; value?: unknown };\n if (\n rawNode.type === 'raw' &&\n typeof rawNode.value === 'string' &&\n parent &&\n typeof index === 'number'\n ) {\n if (skipHtml) {\n parent.children.splice(index, 1);\n } else {\n parent.children[index] = { type: 'text', value: rawNode.value };\n }\n\n return index;\n }\n\n if (node.type === 'element') {\n let key: string;\n\n for (key in urlAttributes) {\n if (Object.hasOwn(urlAttributes, key) && Object.hasOwn(node.properties, key)) {\n const value = node.properties[key];\n const test = urlAttributes[key];\n if (test === null || test.includes(node.tagName)) {\n node.properties[key] = urlTransform(String(value || ''), key, node);\n }\n }\n }\n\n let remove = allowedElements\n ? !allowedElements.includes(node.tagName)\n : disallowedElements\n ? disallowedElements.includes(node.tagName)\n : false;\n\n if (!remove && allowElement && typeof index === 'number') {\n remove = !allowElement(node, index, parent);\n }\n\n if (remove && parent && typeof index === 'number') {\n if (unwrapDisallowed && node.children) {\n parent.children.splice(index, 1, ...node.children);\n } else {\n parent.children.splice(index, 1);\n }\n\n return index;\n }\n }\n };\n\n visit(tree as Root, transform);\n\n return toJsxRuntime(tree, {\n Fragment,\n components,\n ignoreInvalidStyle: true,\n jsx,\n jsxs,\n passKeys: true,\n passNode: true,\n });\n}\n"],"mappings":";;;;;;;;;;;;AAcA,MAAM,gBAA+B,CAAC;AACtC,MAAM,gCAAgC,EAAE,oBAAoB,KAAK;;;;;;;;;AAUjE,MAAa,kBAAkB,YAAqB;CAClD,MAAM,EAAE,UAAU,eAAe,eAAe,wBAAwB;CAExE,MAAM,YAAY,cAAc;EAC9B,OAAO,QAAQ,CAAC,CACb,IAAI,WAAW,CAAC,CAChB,IAAI,iBAAiB,aAAa,CAAC,CACnC,IACC,cACA,sBACI;GAAE,GAAG;GAAqB,GAAG;EAA8B,IAC3D,6BACN,CAAC,CACA,IAAI,iBAAiB,aAAa;CACvC,GAAG;EAAC;EAAe;EAAe;CAAmB,CAAC;CAEtD,MAAM,OAAO,IAAI,MAAM;CACvB,KAAK,QAAQ,OAAO,aAAa,WAAW,WAAW;CAEvD,OAAO,KAAK,UAAU,QAAQ,UAAU,MAAM,IAAI,GAAG,IAAI,GAAY,OAAO;AAC9E;AAEA,SAAS,KAAK,MAAa,SAAkB;CAC3C,MAAM,EACJ,iBACA,cACA,YACA,oBACA,UACA,qBACE;CACJ,MAAM,eAAe,QAAQ,gBAAgB;CAE7C,IAAI,mBAAmB,oBACrB,MAAM,IAAI,MACR,2FACF;CAGF,MAAM,aAAiC,MAAM,OAAO,WAAW;EAC7D,MAAM,UAAU;EAChB,IACE,QAAQ,SAAS,SACjB,OAAO,QAAQ,UAAU,YACzB,UACA,OAAO,UAAU,UACjB;GACA,IAAI,UACF,OAAO,SAAS,OAAO,OAAO,CAAC;QAE/B,OAAO,SAAS,SAAS;IAAE,MAAM;IAAQ,OAAO,QAAQ;GAAM;GAGhE,OAAO;EACT;EAEA,IAAI,KAAK,SAAS,WAAW;GAC3B,IAAI;GAEJ,KAAK,OAAO,eACV,IAAI,OAAO,OAAO,eAAe,GAAG,KAAK,OAAO,OAAO,KAAK,YAAY,GAAG,GAAG;IAC5E,MAAM,QAAQ,KAAK,WAAW;IAC9B,MAAM,OAAO,cAAc;IAC3B,IAAI,SAAS,QAAQ,KAAK,SAAS,KAAK,OAAO,GAC7C,KAAK,WAAW,OAAO,aAAa,OAAO,SAAS,EAAE,GAAG,KAAK,IAAI;GAEtE;GAGF,IAAI,SAAS,kBACT,CAAC,gBAAgB,SAAS,KAAK,OAAO,IACtC,qBACE,mBAAmB,SAAS,KAAK,OAAO,IACxC;GAEN,IAAI,CAAC,UAAU,gBAAgB,OAAO,UAAU,UAC9C,SAAS,CAAC,aAAa,MAAM,OAAO,MAAM;GAG5C,IAAI,UAAU,UAAU,OAAO,UAAU,UAAU;IACjD,IAAI,oBAAoB,KAAK,UAC3B,OAAO,SAAS,OAAO,OAAO,GAAG,GAAG,KAAK,QAAQ;SAEjD,OAAO,SAAS,OAAO,OAAO,CAAC;IAGjC,OAAO;GACT;EACF;CACF;CAEA,MAAM,MAAc,SAAS;CAE7B,OAAO,aAAa,MAAM;EACxB,UAAA;EACA;EACA,oBAAoB;EACpB;EACA;EACA,UAAU;EACV,UAAU;CACZ,CAAC;AACH"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
//#region src/Markdown/SyntaxMarkdown/fenceState.ts
|
|
2
|
-
/**
|
|
3
|
-
* Walk `content` and return the language of the last *unclosed* fenced
|
|
4
|
-
* code block, or `null` if every fence is closed (or there are none).
|
|
5
|
-
*
|
|
6
|
-
* Used by the smoother to decide whether to bypass its buffer for the
|
|
7
|
-
* current input. CommonMark recognises an opening fence as a line whose
|
|
8
|
-
* first non-space chars are 3+ backticks; we deliberately stay simple:
|
|
9
|
-
* 3 literal backticks at line start, language word after. That covers
|
|
10
|
-
* the markdown LLMs actually emit; tildes and indented fences fall back
|
|
11
|
-
* to normal smoothing rather than getting clever.
|
|
12
|
-
*
|
|
13
|
-
* Linear scan over the input, ~10ns per char on V8. Called on every
|
|
14
|
-
* smoothing tick during streaming so the simplicity matters.
|
|
15
|
-
*/
|
|
16
|
-
const findOpenFenceLanguage = (content) => {
|
|
17
|
-
let inFence = false;
|
|
18
|
-
let lang = "";
|
|
19
|
-
let i = 0;
|
|
20
|
-
const len = content.length;
|
|
21
|
-
while (i < len) {
|
|
22
|
-
const nl = content.indexOf("\n", i);
|
|
23
|
-
const lineEnd = nl === -1 ? len : nl;
|
|
24
|
-
const line = content.slice(i, lineEnd);
|
|
25
|
-
if (line.startsWith("```")) {
|
|
26
|
-
if (inFence) {
|
|
27
|
-
inFence = false;
|
|
28
|
-
lang = "";
|
|
29
|
-
} else {
|
|
30
|
-
inFence = true;
|
|
31
|
-
lang = line.slice(3).trim().toLowerCase();
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
if (nl === -1) break;
|
|
35
|
-
i = nl + 1;
|
|
36
|
-
}
|
|
37
|
-
return inFence ? lang : null;
|
|
38
|
-
};
|
|
39
|
-
//#endregion
|
|
40
|
-
export { findOpenFenceLanguage };
|
|
41
|
-
|
|
42
|
-
//# sourceMappingURL=fenceState.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fenceState.mjs","names":[],"sources":["../../../src/Markdown/SyntaxMarkdown/fenceState.ts"],"sourcesContent":["/**\n * Walk `content` and return the language of the last *unclosed* fenced\n * code block, or `null` if every fence is closed (or there are none).\n *\n * Used by the smoother to decide whether to bypass its buffer for the\n * current input. CommonMark recognises an opening fence as a line whose\n * first non-space chars are 3+ backticks; we deliberately stay simple:\n * 3 literal backticks at line start, language word after. That covers\n * the markdown LLMs actually emit; tildes and indented fences fall back\n * to normal smoothing rather than getting clever.\n *\n * Linear scan over the input, ~10ns per char on V8. Called on every\n * smoothing tick during streaming so the simplicity matters.\n */\nexport const findOpenFenceLanguage = (content: string): string | null => {\n let inFence = false;\n let lang = '';\n let i = 0;\n const len = content.length;\n while (i < len) {\n const nl = content.indexOf('\\n', i);\n const lineEnd = nl === -1 ? len : nl;\n const line = content.slice(i, lineEnd);\n if (line.startsWith('```')) {\n if (inFence) {\n inFence = false;\n lang = '';\n } else {\n inFence = true;\n lang = line.slice(3).trim().toLowerCase();\n }\n }\n if (nl === -1) break;\n i = nl + 1;\n }\n return inFence ? lang : null;\n};\n"],"mappings":";;;;;;;;;;;;;;;AAcA,MAAa,yBAAyB,YAAmC;CACvE,IAAI,UAAU;CACd,IAAI,OAAO;CACX,IAAI,IAAI;CACR,MAAM,MAAM,QAAQ;CACpB,OAAO,IAAI,KAAK;EACd,MAAM,KAAK,QAAQ,QAAQ,MAAM,CAAC;EAClC,MAAM,UAAU,OAAO,KAAK,MAAM;EAClC,MAAM,OAAO,QAAQ,MAAM,GAAG,OAAO;EACrC,IAAI,KAAK,WAAW,KAAK,GAAG;GAC1B,IAAI,SAAS;IACX,UAAU;IACV,OAAO;GACT,OAAO;IACL,UAAU;IACV,OAAO,KAAK,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,YAAY;GAC1C;EACF;EACA,IAAI,OAAO,IAAI;EACf,IAAI,KAAK;CACX;CACA,OAAO,UAAU,OAAO;AAC1B"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
//#region src/Markdown/SyntaxMarkdown/streamAnimationMeta.ts
|
|
2
|
-
const isActiveBlock = (state) => {
|
|
3
|
-
return state === "animating" || state === "streaming";
|
|
4
|
-
};
|
|
5
|
-
const resolveBlockAnimationMeta = ({ currentCharDelay, fadeDuration, lastElapsedMs, previousCharDelay, state }) => {
|
|
6
|
-
return {
|
|
7
|
-
charDelay: isActiveBlock(state) ? currentCharDelay : previousCharDelay ?? currentCharDelay,
|
|
8
|
-
settled: state === "revealed" && lastElapsedMs >= fadeDuration
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
//#endregion
|
|
12
|
-
export { resolveBlockAnimationMeta };
|
|
13
|
-
|
|
14
|
-
//# sourceMappingURL=streamAnimationMeta.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"streamAnimationMeta.mjs","names":[],"sources":["../../../src/Markdown/SyntaxMarkdown/streamAnimationMeta.ts"],"sourcesContent":["import { type BlockState } from './useStreamQueue';\n\nexport interface ResolveBlockAnimationMetaOptions {\n currentCharDelay: number;\n fadeDuration: number;\n lastElapsedMs: number;\n previousCharDelay?: number;\n state: BlockState;\n}\n\nexport interface BlockAnimationMeta {\n charDelay: number;\n settled: boolean;\n}\n\nconst isActiveBlock = (state: BlockState) => {\n return state === 'animating' || state === 'streaming';\n};\n\nexport const resolveBlockAnimationMeta = ({\n currentCharDelay,\n fadeDuration,\n lastElapsedMs,\n previousCharDelay,\n state,\n}: ResolveBlockAnimationMetaOptions): BlockAnimationMeta => {\n const charDelay = isActiveBlock(state)\n ? currentCharDelay\n : (previousCharDelay ?? currentCharDelay);\n const settled = state === 'revealed' && lastElapsedMs >= fadeDuration;\n\n return {\n charDelay,\n settled,\n };\n};\n"],"mappings":";AAeA,MAAM,iBAAiB,UAAsB;CAC3C,OAAO,UAAU,eAAe,UAAU;AAC5C;AAEA,MAAa,6BAA6B,EACxC,kBACA,cACA,eACA,mBACA,YAC0D;CAM1D,OAAO;EACL,WANgB,cAAc,KAAK,IACjC,mBACC,qBAAqB;EAKxB,SAJc,UAAU,cAAc,iBAAiB;CAKzD;AACF"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { fadeIn } from "../../styles/animations.mjs";
|
|
2
|
-
import { createStaticStyles } from "antd-style";
|
|
3
|
-
const styles = createStaticStyles(({ css }) => {
|
|
4
|
-
return { animated: css`
|
|
5
|
-
.stream-char {
|
|
6
|
-
opacity: 0;
|
|
7
|
-
|
|
8
|
-
animation-name: ${fadeIn};
|
|
9
|
-
animation-duration: ${180}ms;
|
|
10
|
-
animation-timing-function: cubic-bezier(0.33, 0, 0.67, 1);
|
|
11
|
-
animation-fill-mode: forwards;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.stream-char-revealed {
|
|
15
|
-
opacity: 1;
|
|
16
|
-
animation: none;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.katex-display .katex-html span {
|
|
20
|
-
mask: none !important;
|
|
21
|
-
animation: none !important;
|
|
22
|
-
}
|
|
23
|
-
` };
|
|
24
|
-
});
|
|
25
|
-
//#endregion
|
|
26
|
-
export { styles };
|
|
27
|
-
|
|
28
|
-
//# sourceMappingURL=style.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"style.mjs","names":[],"sources":["../../../src/Markdown/SyntaxMarkdown/style.ts"],"sourcesContent":["import { createStaticStyles } from 'antd-style';\n\nimport { fadeIn } from '@/styles/animations';\n\nexport const STREAM_FADE_DURATION = 180;\n\nexport const styles = createStaticStyles(({ css }) => {\n return {\n animated: css`\n .stream-char {\n opacity: 0;\n\n animation-name: ${fadeIn};\n animation-duration: ${STREAM_FADE_DURATION}ms;\n animation-timing-function: cubic-bezier(0.33, 0, 0.67, 1);\n animation-fill-mode: forwards;\n }\n\n .stream-char-revealed {\n opacity: 1;\n animation: none;\n }\n\n .katex-display .katex-html span {\n mask: none !important;\n animation: none !important;\n }\n `,\n };\n});\n"],"mappings":";;AAMA,MAAa,SAAS,oBAAoB,EAAE,UAAU;CACpD,OAAO,EACL,UAAU,GAAG;;;;0BAIS,OAAO;8BACkB,IAAA;;;;;;;;;;;;;;MAejD;AACF,CAAC"}
|