@lobehub/ui 6.16.0 → 6.16.2

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.
@@ -41,7 +41,7 @@ declare const styleArrays: {
41
41
  }> | Readonly<{
42
42
  readonly backgroundColor: stylex.StyleXClassNameFor<"backgroundColor", "transparent">;
43
43
  readonly cursor: stylex.StyleXClassNameFor<"cursor", "default">;
44
- readonly display: stylex.StyleXClassNameFor<"display", "flex" | "none">;
44
+ readonly display: stylex.StyleXClassNameFor<"display", "none" | "flex">;
45
45
  }>)[];
46
46
  item: Readonly<{
47
47
  readonly borderRadius: stylex.StyleXClassNameFor<"borderRadius", string>;
@@ -1,6 +1,5 @@
1
1
  "use client";
2
2
  import { useAppElement } from "../ConfigProvider/AppElementContext.mjs";
3
- import "../ConfigProvider/index.mjs";
4
3
  import { menuClassNames, menuStyles } from "../DropdownMenu/style.mjs";
5
4
  import { editorSlashMenuClasses } from "./stable.mjs";
6
5
  import { styles } from "./style.mjs";
@@ -1 +1 @@
1
- {"version":3,"file":"atoms.mjs","names":["clsx"],"sources":["../../src/EditorSlashMenu/atoms.tsx"],"sourcesContent":["'use client';\n\nimport { Autocomplete } from '@base-ui/react/autocomplete';\nimport * as stylex from '@stylexjs/stylex';\nimport clsx from 'clsx';\nimport type React from 'react';\n\nimport { useAppElement } from '@/ConfigProvider';\nimport { menuClassNames, menuStyles } from '@/DropdownMenu/sharedStyle';\nimport { type styleProps } from '@/styles/stylex/props';\n\nimport { editorSlashMenuClasses } from './stable';\nimport { styles } from './style';\n\nconst mergeStateClassName = <TState,>(\n base: string,\n className: string | ((state: TState) => string | undefined) | undefined,\n) => {\n if (typeof className === 'function') return (state: TState) => clsx(base, className(state));\n return clsx(base, className);\n};\n\nconst sx = (styles: Parameters<typeof styleProps>[0]) => stylex.props(styles).className ?? '';\n\nexport const EditorSlashMenuRoot = Autocomplete.Root;\nexport const EditorSlashMenuList = ({\n ref,\n className,\n ...rest\n}: React.ComponentProps<typeof Autocomplete.List> & {\n ref?: React.RefObject<HTMLDivElement | null>;\n}) => {\n return (\n <Autocomplete.List\n {...rest}\n ref={ref}\n className={\n mergeStateClassName(\n clsx(sx(styles.list), editorSlashMenuClasses('list')),\n className as any,\n ) as any\n }\n />\n );\n};\nEditorSlashMenuList.displayName = 'EditorSlashMenuList';\n\nexport type EditorSlashMenuPortalProps = React.ComponentProps<typeof Autocomplete.Portal> & {\n /**\n * When `container` is not provided, it uses a shared container created by `usePortalContainer`.\n */\n container?: HTMLElement | null;\n};\n\nexport const EditorSlashMenuPortal = ({ container, ...rest }: EditorSlashMenuPortalProps) => {\n const appElement = useAppElement();\n return <Autocomplete.Portal container={container ?? appElement ?? undefined} {...rest} />;\n};\nEditorSlashMenuPortal.displayName = 'EditorSlashMenuPortal';\n\nexport type EditorSlashMenuPositionerProps = React.ComponentProps<typeof Autocomplete.Positioner>;\n\nexport const EditorSlashMenuPositioner = ({\n className,\n align,\n positionMethod,\n side,\n sideOffset,\n ...rest\n}: EditorSlashMenuPositionerProps) => {\n return (\n <Autocomplete.Positioner\n {...rest}\n align={align ?? 'start'}\n positionMethod={positionMethod ?? 'fixed'}\n side={side ?? 'bottom'}\n sideOffset={sideOffset ?? 6}\n className={\n mergeStateClassName(\n clsx(\n sx(menuStyles.positioner),\n menuClassNames.positioner,\n editorSlashMenuClasses('positioner'),\n ),\n className as any,\n ) as any\n }\n />\n );\n};\nEditorSlashMenuPositioner.displayName = 'EditorSlashMenuPositioner';\n\nexport type EditorSlashMenuPopupProps = React.ComponentProps<typeof Autocomplete.Popup>;\n\nexport const EditorSlashMenuPopup = ({\n className,\n initialFocus = false,\n ...rest\n}: EditorSlashMenuPopupProps) => {\n return (\n <Autocomplete.Popup\n {...rest}\n initialFocus={initialFocus}\n className={\n mergeStateClassName(\n clsx(sx(menuStyles.popup), menuClassNames.popup, editorSlashMenuClasses()),\n className as any,\n ) as any\n }\n />\n );\n};\nEditorSlashMenuPopup.displayName = 'EditorSlashMenuPopup';\n\nexport type EditorSlashMenuItemProps = React.ComponentProps<typeof Autocomplete.Item> & {\n danger?: boolean;\n};\n\nexport const EditorSlashMenuItem = ({ className, danger, ...rest }: EditorSlashMenuItemProps) => {\n return (\n <Autocomplete.Item\n {...rest}\n className={(state) =>\n clsx(\n sx([menuStyles.item, danger && menuStyles.danger]),\n editorSlashMenuClasses('item'),\n typeof className === 'function' ? className(state) : className,\n )\n }\n />\n );\n};\nEditorSlashMenuItem.displayName = 'EditorSlashMenuItem';\n\nexport type EditorSlashMenuGroupProps = React.ComponentProps<typeof Autocomplete.Group>;\nexport const EditorSlashMenuGroup = ({ className, ...rest }: EditorSlashMenuGroupProps) => (\n <Autocomplete.Group\n {...rest}\n className={mergeStateClassName(editorSlashMenuClasses('group'), className as any) as any}\n />\n);\nEditorSlashMenuGroup.displayName = 'EditorSlashMenuGroup';\n\nexport type EditorSlashMenuGroupLabelProps = React.ComponentProps<typeof Autocomplete.GroupLabel>;\n\nexport const EditorSlashMenuGroupLabel = ({\n className,\n ...rest\n}: EditorSlashMenuGroupLabelProps) => {\n return (\n <Autocomplete.GroupLabel\n {...rest}\n className={(state) =>\n clsx(\n sx(menuStyles.groupLabel),\n editorSlashMenuClasses('group-label'),\n typeof className === 'function' ? className(state) : className,\n )\n }\n />\n );\n};\nEditorSlashMenuGroupLabel.displayName = 'EditorSlashMenuGroupLabel';\n\nexport type EditorSlashMenuEmptyProps = React.ComponentProps<typeof Autocomplete.Empty>;\n\nexport const EditorSlashMenuEmpty = ({ className, ...rest }: EditorSlashMenuEmptyProps) => {\n return (\n <Autocomplete.Empty\n {...rest}\n className={(state) =>\n clsx(\n sx([menuStyles.item, menuStyles.empty]),\n editorSlashMenuClasses('empty'),\n typeof className === 'function' ? className(state) : className,\n )\n }\n />\n );\n};\nEditorSlashMenuEmpty.displayName = 'EditorSlashMenuEmpty';\n\nexport type EditorSlashMenuItemContentProps = React.HTMLAttributes<HTMLDivElement>;\nexport const EditorSlashMenuItemContent = ({\n className,\n ...rest\n}: EditorSlashMenuItemContentProps) => {\n return (\n <div\n {...rest}\n className={clsx(\n sx(menuStyles.itemContent),\n editorSlashMenuClasses('item-content'),\n className,\n )}\n />\n );\n};\nEditorSlashMenuItemContent.displayName = 'EditorSlashMenuItemContent';\n\nexport type EditorSlashMenuItemIconProps = React.HTMLAttributes<HTMLSpanElement>;\nexport const EditorSlashMenuItemIcon = ({ className, ...rest }: EditorSlashMenuItemIconProps) => {\n return (\n <span\n {...rest}\n className={clsx(\n sx(menuStyles.icon),\n menuClassNames.icon,\n editorSlashMenuClasses('icon'),\n className,\n )}\n />\n );\n};\nEditorSlashMenuItemIcon.displayName = 'EditorSlashMenuItemIcon';\n\nexport type EditorSlashMenuItemLabelProps = React.HTMLAttributes<HTMLSpanElement>;\nexport const EditorSlashMenuItemLabel = ({ className, ...rest }: EditorSlashMenuItemLabelProps) => {\n return (\n <span\n {...rest}\n className={clsx(\n sx(menuStyles.label),\n menuClassNames.label,\n editorSlashMenuClasses('label'),\n className,\n )}\n />\n );\n};\nEditorSlashMenuItemLabel.displayName = 'EditorSlashMenuItemLabel';\n\nexport type EditorSlashMenuItemExtraProps = React.HTMLAttributes<HTMLSpanElement>;\nexport const EditorSlashMenuItemExtra = ({ className, ...rest }: EditorSlashMenuItemExtraProps) => {\n return (\n <span\n {...rest}\n className={clsx(sx(menuStyles.extra), editorSlashMenuClasses('extra'), className)}\n />\n );\n};\nEditorSlashMenuItemExtra.displayName = 'EditorSlashMenuItemExtra';\n\nexport type EditorSlashMenuHiddenInputProps = React.ComponentProps<typeof Autocomplete.Input>;\nexport const EditorSlashMenuHiddenInput = ({\n className,\n ...rest\n}: EditorSlashMenuHiddenInputProps) => {\n return (\n <Autocomplete.Input\n {...rest}\n className={\n mergeStateClassName(\n clsx(sx(styles.hiddenInput), editorSlashMenuClasses('input')),\n className as any,\n ) as any\n }\n />\n );\n};\nEditorSlashMenuHiddenInput.displayName = 'EditorSlashMenuHiddenInput';\n"],"mappings":";;;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,MAAM,uBAAuB,MAAM,GAAG,SAAS;CAAI,CAAA;AAChI;AACA,wBAAwB,cAAc;AAEtC,MAAa,4BAA4B,EACvC,WACA,GAAG,WACgC;CACnC,OAAO,oBAAC,QAAD;EAAM,GAAI;EAAM,WAAWA,OAAK,GAAG,WAAW,KAAK,GAAG,eAAe,OAAO,uBAAuB,OAAO,GAAG,SAAS;CAAI,CAAA;AACnI;AACA,yBAAyB,cAAc;AAEvC,MAAa,4BAA4B,EACvC,WACA,GAAG,WACgC;CACnC,OAAO,oBAAC,QAAD;EAAM,GAAI;EAAM,WAAWA,OAAK,GAAG,WAAW,KAAK,GAAG,uBAAuB,OAAO,GAAG,SAAS;CAAI,CAAA;AAC7G;AACA,yBAAyB,cAAc;AAEvC,MAAa,8BAA8B,EACzC,WACA,GAAG,WACkC;CACrC,OAAO,oBAAC,aAAa,OAAd;EAAoB,GAAI;EAAM,WAAW,oBAAoBA,OAAK,GAAG,OAAO,WAAW,GAAG,uBAAuB,OAAO,CAAC,GAAG,SAAgB;CAAW,CAAA;AAChK;AACA,2BAA2B,cAAc"}
1
+ {"version":3,"file":"atoms.mjs","names":["clsx"],"sources":["../../src/EditorSlashMenu/atoms.tsx"],"sourcesContent":["'use client';\n\nimport { Autocomplete } from '@base-ui/react/autocomplete';\nimport * as stylex from '@stylexjs/stylex';\nimport clsx from 'clsx';\nimport type React from 'react';\n\nimport { useAppElement } from '@/ConfigProvider';\nimport { menuClassNames, menuStyles } from '@/DropdownMenu/sharedStyle';\nimport { type styleProps } from '@/styles/stylex/props';\n\nimport { editorSlashMenuClasses } from './stable';\nimport { styles } from './style';\n\nconst mergeStateClassName = <TState,>(\n base: string,\n className: string | ((state: TState) => string | undefined) | undefined,\n) => {\n if (typeof className === 'function') return (state: TState) => clsx(base, className(state));\n return clsx(base, className);\n};\n\nconst sx = (styles: Parameters<typeof styleProps>[0]) => stylex.props(styles).className ?? '';\n\nexport const EditorSlashMenuRoot = Autocomplete.Root;\nexport const EditorSlashMenuList = ({\n ref,\n className,\n ...rest\n}: React.ComponentProps<typeof Autocomplete.List> & {\n ref?: React.RefObject<HTMLDivElement | null>;\n}) => {\n return (\n <Autocomplete.List\n {...rest}\n ref={ref}\n className={\n mergeStateClassName(\n clsx(sx(styles.list), editorSlashMenuClasses('list')),\n className as any,\n ) as any\n }\n />\n );\n};\nEditorSlashMenuList.displayName = 'EditorSlashMenuList';\n\nexport type EditorSlashMenuPortalProps = React.ComponentProps<typeof Autocomplete.Portal> & {\n /**\n * When `container` is not provided, it uses a shared container created by `usePortalContainer`.\n */\n container?: HTMLElement | null;\n};\n\nexport const EditorSlashMenuPortal = ({ container, ...rest }: EditorSlashMenuPortalProps) => {\n const appElement = useAppElement();\n return <Autocomplete.Portal container={container ?? appElement ?? undefined} {...rest} />;\n};\nEditorSlashMenuPortal.displayName = 'EditorSlashMenuPortal';\n\nexport type EditorSlashMenuPositionerProps = React.ComponentProps<typeof Autocomplete.Positioner>;\n\nexport const EditorSlashMenuPositioner = ({\n className,\n align,\n positionMethod,\n side,\n sideOffset,\n ...rest\n}: EditorSlashMenuPositionerProps) => {\n return (\n <Autocomplete.Positioner\n {...rest}\n align={align ?? 'start'}\n positionMethod={positionMethod ?? 'fixed'}\n side={side ?? 'bottom'}\n sideOffset={sideOffset ?? 6}\n className={\n mergeStateClassName(\n clsx(\n sx(menuStyles.positioner),\n menuClassNames.positioner,\n editorSlashMenuClasses('positioner'),\n ),\n className as any,\n ) as any\n }\n />\n );\n};\nEditorSlashMenuPositioner.displayName = 'EditorSlashMenuPositioner';\n\nexport type EditorSlashMenuPopupProps = React.ComponentProps<typeof Autocomplete.Popup>;\n\nexport const EditorSlashMenuPopup = ({\n className,\n initialFocus = false,\n ...rest\n}: EditorSlashMenuPopupProps) => {\n return (\n <Autocomplete.Popup\n {...rest}\n initialFocus={initialFocus}\n className={\n mergeStateClassName(\n clsx(sx(menuStyles.popup), menuClassNames.popup, editorSlashMenuClasses()),\n className as any,\n ) as any\n }\n />\n );\n};\nEditorSlashMenuPopup.displayName = 'EditorSlashMenuPopup';\n\nexport type EditorSlashMenuItemProps = React.ComponentProps<typeof Autocomplete.Item> & {\n danger?: boolean;\n};\n\nexport const EditorSlashMenuItem = ({ className, danger, ...rest }: EditorSlashMenuItemProps) => {\n return (\n <Autocomplete.Item\n {...rest}\n className={(state) =>\n clsx(\n sx([menuStyles.item, danger && menuStyles.danger]),\n editorSlashMenuClasses('item'),\n typeof className === 'function' ? className(state) : className,\n )\n }\n />\n );\n};\nEditorSlashMenuItem.displayName = 'EditorSlashMenuItem';\n\nexport type EditorSlashMenuGroupProps = React.ComponentProps<typeof Autocomplete.Group>;\nexport const EditorSlashMenuGroup = ({ className, ...rest }: EditorSlashMenuGroupProps) => (\n <Autocomplete.Group\n {...rest}\n className={mergeStateClassName(editorSlashMenuClasses('group'), className as any) as any}\n />\n);\nEditorSlashMenuGroup.displayName = 'EditorSlashMenuGroup';\n\nexport type EditorSlashMenuGroupLabelProps = React.ComponentProps<typeof Autocomplete.GroupLabel>;\n\nexport const EditorSlashMenuGroupLabel = ({\n className,\n ...rest\n}: EditorSlashMenuGroupLabelProps) => {\n return (\n <Autocomplete.GroupLabel\n {...rest}\n className={(state) =>\n clsx(\n sx(menuStyles.groupLabel),\n editorSlashMenuClasses('group-label'),\n typeof className === 'function' ? className(state) : className,\n )\n }\n />\n );\n};\nEditorSlashMenuGroupLabel.displayName = 'EditorSlashMenuGroupLabel';\n\nexport type EditorSlashMenuEmptyProps = React.ComponentProps<typeof Autocomplete.Empty>;\n\nexport const EditorSlashMenuEmpty = ({ className, ...rest }: EditorSlashMenuEmptyProps) => {\n return (\n <Autocomplete.Empty\n {...rest}\n className={(state) =>\n clsx(\n sx([menuStyles.item, menuStyles.empty]),\n editorSlashMenuClasses('empty'),\n typeof className === 'function' ? className(state) : className,\n )\n }\n />\n );\n};\nEditorSlashMenuEmpty.displayName = 'EditorSlashMenuEmpty';\n\nexport type EditorSlashMenuItemContentProps = React.HTMLAttributes<HTMLDivElement>;\nexport const EditorSlashMenuItemContent = ({\n className,\n ...rest\n}: EditorSlashMenuItemContentProps) => {\n return (\n <div\n {...rest}\n className={clsx(\n sx(menuStyles.itemContent),\n editorSlashMenuClasses('item-content'),\n className,\n )}\n />\n );\n};\nEditorSlashMenuItemContent.displayName = 'EditorSlashMenuItemContent';\n\nexport type EditorSlashMenuItemIconProps = React.HTMLAttributes<HTMLSpanElement>;\nexport const EditorSlashMenuItemIcon = ({ className, ...rest }: EditorSlashMenuItemIconProps) => {\n return (\n <span\n {...rest}\n className={clsx(\n sx(menuStyles.icon),\n menuClassNames.icon,\n editorSlashMenuClasses('icon'),\n className,\n )}\n />\n );\n};\nEditorSlashMenuItemIcon.displayName = 'EditorSlashMenuItemIcon';\n\nexport type EditorSlashMenuItemLabelProps = React.HTMLAttributes<HTMLSpanElement>;\nexport const EditorSlashMenuItemLabel = ({ className, ...rest }: EditorSlashMenuItemLabelProps) => {\n return (\n <span\n {...rest}\n className={clsx(\n sx(menuStyles.label),\n menuClassNames.label,\n editorSlashMenuClasses('label'),\n className,\n )}\n />\n );\n};\nEditorSlashMenuItemLabel.displayName = 'EditorSlashMenuItemLabel';\n\nexport type EditorSlashMenuItemExtraProps = React.HTMLAttributes<HTMLSpanElement>;\nexport const EditorSlashMenuItemExtra = ({ className, ...rest }: EditorSlashMenuItemExtraProps) => {\n return (\n <span\n {...rest}\n className={clsx(sx(menuStyles.extra), editorSlashMenuClasses('extra'), className)}\n />\n );\n};\nEditorSlashMenuItemExtra.displayName = 'EditorSlashMenuItemExtra';\n\nexport type EditorSlashMenuHiddenInputProps = React.ComponentProps<typeof Autocomplete.Input>;\nexport const EditorSlashMenuHiddenInput = ({\n className,\n ...rest\n}: EditorSlashMenuHiddenInputProps) => {\n return (\n <Autocomplete.Input\n {...rest}\n className={\n mergeStateClassName(\n clsx(sx(styles.hiddenInput), editorSlashMenuClasses('input')),\n className as any,\n ) as any\n }\n />\n );\n};\nEditorSlashMenuHiddenInput.displayName = 'Edit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,GAAG,WAAW,IAAI,GAAG,eAAe,MAAM,uBAAuB,MAAM,GAAG,SAAS;CAAI,CAAA;AAChI;AACA,wBAAwB,cAAc;AAEtC,MAAa,4BAA4B,EACvC,WACA,GAAG,WACgC;CACnC,OAAO,oBAAC,QAAD;EAAM,GAAI;EAAM,WAAWA,OAAK,GAAG,WAAW,KAAK,GAAG,eAAe,OAAO,uBAAuB,OAAO,GAAG,SAAS;CAAI,CAAA;AACnI;AACA,yBAAyB,cAAc;AAEvC,MAAa,4BAA4B,EACvC,WACA,GAAG,WACgC;CACnC,OAAO,oBAAC,QAAD;EAAM,GAAI;EAAM,WAAWA,OAAK,GAAG,WAAW,KAAK,GAAG,uBAAuB,OAAO,GAAG,SAAS;CAAI,CAAA;AAC7G;AACA,yBAAyB,cAAc;AAEvC,MAAa,8BAA8B,EACzC,WACA,GAAG,WACkC;CACrC,OAAO,oBAAC,aAAa,OAAd;EAAoB,GAAI;EAAM,WAAW,oBAAoBA,OAAK,GAAG,OAAO,WAAW,GAAG,uBAAuB,OAAO,CAAC,GAAG,SAAgB;CAAW,CAAA;AAChK;AACA,2BAA2B,cAAc"}
@@ -14,7 +14,7 @@ import { memo, useCallback } from "react";
14
14
  import { jsx } from "react/jsx-runtime";
15
15
  // src/Markdown/Markdown.tsx
16
16
  const Markdown = memo((props) => {
17
- const { ref, children = "", className, style, fullFeaturedCodeBlock, onDoubleClick, animated, enableHtmlPreview = false, enableLatex = true, enableMermaid = true, enableImageGallery, enableCustomFootnotes, enableGithubAlert, enableStream = true, componentProps, rehypePluginsAhead, allowHtml, borderRadius, fontSize, headerMultiple, marginMultiple, variant = "default", reactMarkdownProps, lineHeight, rehypePlugins, remarkPlugins, remarkPluginsAhead, components = {}, customRender, showFootnotes = true, streamAnimationGranularity, streamSmoothingPreset, citations, ...rest } = props;
17
+ const { ref, children = "", className, style, fullFeaturedCodeBlock, onDoubleClick, animated, enableHtmlPreview = false, enableLatex = true, enableMermaid = true, enableImageGallery, enableCustomFootnotes, enableGithubAlert, enableParseCache = false, enableStream = true, componentProps, rehypePluginsAhead, allowHtml, borderRadius, fontSize, headerMultiple, marginMultiple, variant = "default", reactMarkdownProps, lineHeight, rehypePlugins, remarkPlugins, remarkPluginsAhead, components = {}, customRender, showFootnotes = true, streamAnimationGranularity, streamSmoothingPreset, citations, ...rest } = props;
18
18
  const delayedAnimated = useDelayedAnimated(animated);
19
19
  const stableComponentProps = useStableValue(componentProps);
20
20
  const stableComponents = useStableValue(components);
@@ -52,6 +52,7 @@ const Markdown = memo((props) => {
52
52
  enableHtmlPreview,
53
53
  enableLatex,
54
54
  enableMermaid,
55
+ enableParseCache,
55
56
  fullFeaturedCodeBlock,
56
57
  rehypePlugins,
57
58
  rehypePluginsAhead,
@@ -1 +1 @@
1
- {"version":3,"file":"Markdown.mjs","names":["MarkdownRender","clsx"],"sources":["../../src/Markdown/Markdown.tsx"],"sourcesContent":["'use client';\n\nimport clsx from 'clsx';\nimport { memo, useCallback } from 'react';\n\nimport { useStableValue } from '@/hooks/useStableValue';\nimport { PreviewGroup } from '@/Image';\nimport { toDataAttributes } from '@/utils/bem';\n\nimport { MarkdownProvider } from './components/MarkdownProvider';\nimport { useDelayedAnimated } from './components/useDelayedAnimated';\nimport { markdownClasses } from './stable';\nimport { rootStyles, styles } from './style';\nimport { MarkdownRender, StreamdownRender } from './SyntaxMarkdown';\nimport { type MarkdownProps } from './type';\nimport { TypographyImpl } from './Typography';\n\nconst Markdown = memo<MarkdownProps>((props) => {\n const {\n ref,\n children = '',\n className,\n style,\n fullFeaturedCodeBlock,\n onDoubleClick,\n animated,\n enableHtmlPreview = false,\n enableLatex = true,\n enableMermaid = true,\n enableImageGallery,\n enableCustomFootnotes,\n enableGithubAlert,\n enableStream = true,\n componentProps,\n rehypePluginsAhead,\n allowHtml,\n borderRadius,\n fontSize,\n headerMultiple,\n marginMultiple,\n variant = 'default',\n reactMarkdownProps,\n lineHeight,\n rehypePlugins,\n remarkPlugins,\n remarkPluginsAhead,\n components = {},\n customRender,\n showFootnotes = true,\n streamAnimationGranularity,\n streamSmoothingPreset,\n citations,\n ...rest\n } = props;\n\n const delayedAnimated = useDelayedAnimated(animated);\n\n // Stabilise structural props so an inline `componentProps={{ html:\n // {...} }}` from the caller doesn't cascade through MarkdownProvider →\n // useMarkdownComponents → react-markdown's `components` and remount the\n // entire code-block subtree (including the HtmlPreview iframe) on\n // every parent render. The deep-equal compare treats inline literals\n // as the same object as long as their structure matches. Inline\n // callbacks (`actionsRender`, custom `components`) still need\n // `useCallback` at the call site — function bodies aren't compared.\n const stableComponentProps = useStableValue(componentProps);\n const stableComponents = useStableValue(components);\n\n const Render = useCallback(\n ({\n enableStream,\n children,\n reactMarkdownProps,\n }: Pick<MarkdownProps, 'children' | 'enableStream' | 'reactMarkdownProps'>) => {\n const DefaultRender = enableStream ? StreamdownRender : MarkdownRender;\n const defaultDOM = <DefaultRender {...reactMarkdownProps}>{children}</DefaultRender>;\n return customRender ? customRender(defaultDOM, { text: children }) : defaultDOM;\n },\n [customRender],\n );\n\n return (\n <PreviewGroup enable={enableImageGallery}>\n <TypographyImpl\n borderRadius={borderRadius}\n data-code-type=\"markdown\"\n fontSize={fontSize}\n headerMultiple={headerMultiple}\n lineHeight={lineHeight}\n marginMultiple={marginMultiple}\n ref={ref}\n style={style}\n xstyle={rootStyles.root}\n className={clsx(\n variant === 'chat' && styles.chat,\n enableLatex && styles.latex,\n styles.gfm,\n markdownClasses(),\n className,\n )}\n onDoubleClick={onDoubleClick}\n {...toDataAttributes({ variant })}\n {...rest}\n >\n <MarkdownProvider\n allowHtml={allowHtml}\n animated={delayedAnimated}\n citations={citations}\n componentProps={stableComponentProps}\n components={stableComponents}\n enableCustomFootnotes={enableCustomFootnotes}\n enableGithubAlert={enableGithubAlert}\n enableHtmlPreview={enableHtmlPreview}\n enableLatex={enableLatex}\n enableMermaid={enableMermaid}\n fullFeaturedCodeBlock={fullFeaturedCodeBlock}\n rehypePlugins={rehypePlugins}\n rehypePluginsAhead={rehypePluginsAhead}\n remarkPlugins={remarkPlugins}\n remarkPluginsAhead={remarkPluginsAhead}\n showFootnotes={showFootnotes}\n streamAnimationGranularity={streamAnimationGranularity}\n streamSmoothingPreset={streamSmoothingPreset}\n variant={variant}\n >\n <Render\n enableStream={enableStream && delayedAnimated}\n reactMarkdownProps={reactMarkdownProps}\n >\n {children}\n </Render>\n </MarkdownProvider>\n </TypographyImpl>\n </PreviewGroup>\n );\n});\n\nMarkdown.displayName = 'Markdown';\n\nexport default Markdown;\n"],"mappings":";;;;;;;;;;;;;;;AAiBA,MAAM,WAAW,MAAqB,UAAU;CAC9C,MAAM,EACJ,KACA,WAAW,IACX,WACA,OACA,uBACA,eACA,UACA,oBAAoB,OACpB,cAAc,MACd,gBAAgB,MAChB,oBACA,uBACA,mBACA,eAAe,MACf,gBACA,oBACA,WACA,cACA,UACA,gBACA,gBACA,UAAU,WACV,oBACA,YACA,eACA,eACA,oBACA,aAAa,CAAC,GACd,cACA,gBAAgB,MAChB,4BACA,uBACA,WACA,GAAG,SACD;CAEJ,MAAM,kBAAkB,mBAAmB,QAAQ;CAUnD,MAAM,uBAAuB,eAAe,cAAc;CAC1D,MAAM,mBAAmB,eAAe,UAAU;CAElD,MAAM,SAAS,aACZ,EACC,cACA,UACA,yBAC6E;EAE7E,MAAM,aAAa,oBADG,eAAe,mBAAmBA,kBACrC;GAAe,GAAI;GAAqB;EAAwB,CAAA;EACnF,OAAO,eAAe,aAAa,YAAY,EAAE,MAAM,SAAS,CAAC,IAAI;CACvE,GACA,CAAC,YAAY,CACf;CAEA,OACE,oBAAC,cAAD;EAAc,QAAQ;EACpB,UAAA,oBAAC,gBAAD;GACgB;GACd,kBAAe;GACL;GACM;GACJ;GACI;GACX;GACE;GACP,QAAQ,WAAW;GACnB,WAAWC,OACT,YAAY,UAAU,OAAO,MAC7B,eAAe,OAAO,OACtB,OAAO,KACP,gBAAgB,GAChB,SACF;GACe;GACf,GAAI,iBAAiB,EAAE,QAAQ,CAAC;GAChC,GAAI;GAEJ,UAAA,oBAAC,kBAAD;IACa;IACX,UAAU;IACC;IACX,gBAAgB;IAChB,YAAY;IACW;IACJ;IACA;IACN;IACE;IACQ;IACR;IACK;IACL;IACK;IACL;IACa;IACL;IACd;IAET,UAAA,oBAAC,QAAD;KACE,cAAc,gBAAgB;KACV;KAEnB;IACK,CAAA;GACQ,CAAA;EACJ,CAAA;CACJ,CAAA;AAElB,CAAC;AAED,SAAS,cAAc"}
1
+ {"version":3,"file":"Markdown.mjs","names":["MarkdownRender","clsx"],"sources":["../../src/Markdown/Markdown.tsx"],"sourcesContent":["'use client';\n\nimport clsx from 'clsx';\nimport { memo, useCallback } from 'react';\n\nimport { useStableValue } from '@/hooks/useStableValue';\nimport { PreviewGroup } from '@/Image';\nimport { toDataAttributes } from '@/utils/bem';\n\nimport { MarkdownProvider } from './components/MarkdownProvider';\nimport { useDelayedAnimated } from './components/useDelayedAnimated';\nimport { markdownClasses } from './stable';\nimport { rootStyles, styles } from './style';\nimport { MarkdownRender, StreamdownRender } from './SyntaxMarkdown';\nimport { type MarkdownProps } from './type';\nimport { TypographyImpl } from './Typography';\n\nconst Markdown = memo<MarkdownProps>((props) => {\n const {\n ref,\n children = '',\n className,\n style,\n fullFeaturedCodeBlock,\n onDoubleClick,\n animated,\n enableHtmlPreview = false,\n enableLatex = true,\n enableMermaid = true,\n enableImageGallery,\n enableCustomFootnotes,\n enableGithubAlert,\n enableParseCache = false,\n enableStream = true,\n componentProps,\n rehypePluginsAhead,\n allowHtml,\n borderRadius,\n fontSize,\n headerMultiple,\n marginMultiple,\n variant = 'default',\n reactMarkdownProps,\n lineHeight,\n rehypePlugins,\n remarkPlugins,\n remarkPluginsAhead,\n components = {},\n customRender,\n showFootnotes = true,\n streamAnimationGranularity,\n streamSmoothingPreset,\n citations,\n ...rest\n } = props;\n\n const delayedAnimated = useDelayedAnimated(animated);\n\n // Stabilise structural props so an inline `componentProps={{ html:\n // {...} }}` from the caller doesn't cascade through MarkdownProvider →\n // useMarkdownComponents → react-markdown's `components` and remount the\n // entire code-block subtree (including the HtmlPreview iframe) on\n // every parent render. The deep-equal compare treats inline literals\n // as the same object as long as their structure matches. Inline\n // callbacks (`actionsRender`, custom `components`) still need\n // `useCallback` at the call site — function bodies aren't compared.\n const stableComponentProps = useStableValue(componentProps);\n const stableComponents = useStableValue(components);\n\n const Render = useCallback(\n ({\n enableStream,\n children,\n reactMarkdownProps,\n }: Pick<MarkdownProps, 'children' | 'enableStream' | 'reactMarkdownProps'>) => {\n const DefaultRender = enableStream ? StreamdownRender : MarkdownRender;\n const defaultDOM = <DefaultRender {...reactMarkdownProps}>{children}</DefaultRender>;\n return customRender ? customRender(defaultDOM, { text: children }) : defaultDOM;\n },\n [customRender],\n );\n\n return (\n <PreviewGroup enable={enableImageGallery}>\n <TypographyImpl\n borderRadius={borderRadius}\n data-code-type=\"markdown\"\n fontSize={fontSize}\n headerMultiple={headerMultiple}\n lineHeight={lineHeight}\n marginMultiple={marginMultiple}\n ref={ref}\n style={style}\n xstyle={rootStyles.root}\n className={clsx(\n variant === 'chat' && styles.chat,\n enableLatex && styles.latex,\n styles.gfm,\n markdownClasses(),\n className,\n )}\n onDoubleClick={onDoubleClick}\n {...toDataAttributes({ variant })}\n {...rest}\n >\n <MarkdownProvider\n allowHtml={allowHtml}\n animated={delayedAnimated}\n citations={citations}\n componentProps={stableComponentProps}\n components={stableComponents}\n enableCustomFootnotes={enableCustomFootnotes}\n enableGithubAlert={enableGithubAlert}\n enableHtmlPreview={enableHtmlPreview}\n enableLatex={enableLatex}\n enableMermaid={enableMermaid}\n enableParseCache={enableParseCache}\n fullFeaturedCodeBlock={fullFeaturedCodeBlock}\n rehypePlugins={rehypePlugins}\n rehypePluginsAhead={rehypePluginsAhead}\n remarkPlugins={remarkPlugins}\n remarkPluginsAhead={remarkPluginsAhead}\n showFootnotes={showFootnotes}\n streamAnimationGranularity={streamAnimationGranularity}\n streamSmoothingPreset={streamSmoothingPreset}\n variant={variant}\n >\n <Render\n enableStream={enableStream && delayedAnimated}\n reactMarkdownProps={reactMarkdownProps}\n >\n {children}\n </Render>\n </MarkdownProvider>\n </TypographyImpl>\n </PreviewGroup>\n );\n});\n\nMarkdown.displayName = 'Markdown';\n\nexport default Markdown;\n"],"mappings":";;;;;;;;;;;;;;;AAiBA,MAAM,WAAW,MAAqB,UAAU;CAC9C,MAAM,EACJ,KACA,WAAW,IACX,WACA,OACA,uBACA,eACA,UACA,oBAAoB,OACpB,cAAc,MACd,gBAAgB,MAChB,oBACA,uBACA,mBACA,mBAAmB,OACnB,eAAe,MACf,gBACA,oBACA,WACA,cACA,UACA,gBACA,gBACA,UAAU,WACV,oBACA,YACA,eACA,eACA,oBACA,aAAa,CAAC,GACd,cACA,gBAAgB,MAChB,4BACA,uBACA,WACA,GAAG,SACD;CAEJ,MAAM,kBAAkB,mBAAmB,QAAQ;CAUnD,MAAM,uBAAuB,eAAe,cAAc;CAC1D,MAAM,mBAAmB,eAAe,UAAU;CAElD,MAAM,SAAS,aACZ,EACC,cACA,UACA,yBAC6E;EAE7E,MAAM,aAAa,oBADG,eAAe,mBAAmBA,kBACrC;GAAe,GAAI;GAAqB;EAAwB,CAAA;EACnF,OAAO,eAAe,aAAa,YAAY,EAAE,MAAM,SAAS,CAAC,IAAI;CACvE,GACA,CAAC,YAAY,CACf;CAEA,OACE,oBAAC,cAAD;EAAc,QAAQ;EACpB,UAAA,oBAAC,gBAAD;GACgB;GACd,kBAAe;GACL;GACM;GACJ;GACI;GACX;GACE;GACP,QAAQ,WAAW;GACnB,WAAWC,OACT,YAAY,UAAU,OAAO,MAC7B,eAAe,OAAO,OACtB,OAAO,KACP,gBAAgB,GAChB,SACF;GACe;GACf,GAAI,iBAAiB,EAAE,QAAQ,CAAC;GAChC,GAAI;GAEJ,UAAA,oBAAC,kBAAD;IACa;IACX,UAAU;IACC;IACX,gBAAgB;IAChB,YAAY;IACW;IACJ;IACA;IACN;IACE;IACG;IACK;IACR;IACK;IACL;IACK;IACL;IACa;IACL;IACd;IAET,UAAA,oBAAC,QAAD;KACE,cAAc,gBAAgB;KACV;KAEnB;IACK,CAAA;GACQ,CAAA;EACJ,CAAA;CACJ,CAAA;AAElB,CAAC;AAED,SAAS,cAAc"}
@@ -3,15 +3,47 @@ import { useMarkdownComponents } from "../../hooks/useMarkdown/useMarkdownCompon
3
3
  import { useMarkdownContent } from "../../hooks/useMarkdown/useMarkdownContent.mjs";
4
4
  import { useMarkdownRehypePlugins } from "../../hooks/useMarkdown/useMarkdownRehypePlugins.mjs";
5
5
  import { useMarkdownRemarkPlugins } from "../../hooks/useMarkdown/useMarkdownRemarkPlugins.mjs";
6
- import { memo } from "react";
7
- import { jsx } from "react/jsx-runtime";
6
+ import { useMarkdownContext } from "../components/MarkdownProvider.mjs";
7
+ import { canUseParseCache, getParsedHast, getPipelineKey } from "./parseCache.mjs";
8
+ import { memo, useMemo } from "react";
9
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
10
+ import { toJsxRuntime } from "hast-util-to-jsx-runtime";
8
11
  import Markdown from "react-markdown";
9
12
  // src/Markdown/SyntaxMarkdown/MarkdownRender.tsx
10
13
  const MarkdownRenderer = memo(({ children, ...rest }) => {
11
- const escapedContent = useMarkdownContent(children || "");
14
+ const escapedContent = useMarkdownContent(children || "") ?? "";
12
15
  const components = useMarkdownComponents();
13
16
  const rehypePluginsList = useMarkdownRehypePlugins();
14
17
  const remarkPluginsList = useMarkdownRemarkPlugins();
18
+ const { enableParseCache } = useMarkdownContext();
19
+ const cacheable = !!enableParseCache && canUseParseCache(rest);
20
+ const { remarkRehypeOptions } = rest;
21
+ const pipeline = useMemo(() => ({
22
+ rehypePlugins: rehypePluginsList,
23
+ remarkPlugins: remarkPluginsList,
24
+ remarkRehypeOptions
25
+ }), [
26
+ rehypePluginsList,
27
+ remarkPluginsList,
28
+ remarkRehypeOptions
29
+ ]);
30
+ const pipelineKey = useMemo(() => getPipelineKey(pipeline), [pipeline]);
31
+ const tree = useMemo(() => cacheable ? getParsedHast(escapedContent, pipeline, pipelineKey) : void 0, [
32
+ cacheable,
33
+ escapedContent,
34
+ pipeline,
35
+ pipelineKey
36
+ ]);
37
+ const element = useMemo(() => tree && toJsxRuntime(tree, {
38
+ Fragment: Fragment$1,
39
+ components,
40
+ ignoreInvalidStyle: true,
41
+ jsx,
42
+ jsxs,
43
+ passKeys: true,
44
+ passNode: true
45
+ }), [tree, components]);
46
+ if (element) return element;
15
47
  return /* @__PURE__ */ jsx(Markdown, {
16
48
  ...rest,
17
49
  components,
@@ -1 +1 @@
1
- {"version":3,"file":"MarkdownRender.mjs","names":[],"sources":["../../../src/Markdown/SyntaxMarkdown/MarkdownRender.tsx"],"sourcesContent":["'use client';\n\nimport { memo, type NamedExoticComponent } from 'react';\nimport Markdown, { type Options } from 'react-markdown';\n\nimport {\n useMarkdownComponents,\n useMarkdownContent,\n useMarkdownRehypePlugins,\n useMarkdownRemarkPlugins,\n} from '@/hooks/useMarkdown';\n\nconst MarkdownRenderer: NamedExoticComponent<Options> = memo<Options>(\n ({ children, ...rest }) => {\n const escapedContent = useMarkdownContent(children || '');\n const components = useMarkdownComponents();\n const rehypePluginsList = useMarkdownRehypePlugins();\n const remarkPluginsList = useMarkdownRemarkPlugins();\n\n return (\n <Markdown\n {...rest}\n components={components}\n rehypePlugins={rehypePluginsList}\n remarkPlugins={remarkPluginsList}\n >\n {escapedContent}\n </Markdown>\n );\n },\n (prevProps, nextProps) => prevProps.children === nextProps.children,\n);\n\nexport default MarkdownRenderer;\n"],"mappings":";;;;;;;;;AAYA,MAAM,mBAAkD,MACrD,EAAE,UAAU,GAAG,WAAW;CACzB,MAAM,iBAAiB,mBAAmB,YAAY,EAAE;CACxD,MAAM,aAAa,sBAAsB;CACzC,MAAM,oBAAoB,yBAAyB;CACnD,MAAM,oBAAoB,yBAAyB;CAEnD,OACE,oBAAC,UAAD;EACE,GAAI;EACQ;EACZ,eAAe;EACf,eAAe;EAEd,UAAA;CACO,CAAA;AAEd,IACC,WAAW,cAAc,UAAU,aAAa,UAAU,QAC7D"}
1
+ {"version":3,"file":"MarkdownRender.mjs","names":["Fragment"],"sources":["../../../src/Markdown/SyntaxMarkdown/MarkdownRender.tsx"],"sourcesContent":["'use client';\n\nimport { toJsxRuntime } from 'hast-util-to-jsx-runtime';\nimport { memo, type NamedExoticComponent, useMemo } from 'react';\nimport { Fragment, jsx, jsxs } from 'react/jsx-runtime';\nimport Markdown, { type Options } from 'react-markdown';\n\nimport {\n useMarkdownComponents,\n useMarkdownContent,\n useMarkdownRehypePlugins,\n useMarkdownRemarkPlugins,\n} from '@/hooks/useMarkdown';\n\nimport { useMarkdownContext } from '../components/MarkdownProvider';\nimport { canUseParseCache, getParsedHast, getPipelineKey } from './parseCache';\n\nconst MarkdownRenderer: NamedExoticComponent<Options> = memo<Options>(\n ({ children, ...rest }) => {\n const escapedContent = useMarkdownContent(children || '') ?? '';\n const components = useMarkdownComponents();\n const rehypePluginsList = useMarkdownRehypePlugins();\n const remarkPluginsList = useMarkdownRemarkPlugins();\n\n const { enableParseCache } = useMarkdownContext();\n const cacheable = !!enableParseCache && canUseParseCache(rest);\n const { remarkRehypeOptions } = rest;\n\n const pipeline = useMemo(\n () => ({\n rehypePlugins: rehypePluginsList,\n remarkPlugins: remarkPluginsList,\n remarkRehypeOptions,\n }),\n [rehypePluginsList, remarkPluginsList, remarkRehypeOptions],\n );\n const pipelineKey = useMemo(() => getPipelineKey(pipeline), [pipeline]);\n\n // Remounts (e.g. switching conversations) reuse the parsed hast from the\n // module-level cache and only run hast → JSX with this instance's\n // `components`; see `parseCache.ts` for the cache key.\n const tree = useMemo(\n () => (cacheable ? getParsedHast(escapedContent, pipeline, pipelineKey) : undefined),\n [cacheable, escapedContent, pipeline, pipelineKey],\n );\n\n const element = useMemo(\n () =>\n tree &&\n toJsxRuntime(tree, {\n Fragment,\n components,\n ignoreInvalidStyle: true,\n jsx,\n jsxs,\n passKeys: true,\n passNode: true,\n }),\n [tree, components],\n );\n\n if (element) return element;\n\n return (\n <Markdown\n {...rest}\n components={components}\n rehypePlugins={rehypePluginsList}\n remarkPlugins={remarkPluginsList}\n >\n {escapedContent}\n </Markdown>\n );\n },\n (prevProps, nextProps) => prevProps.children === nextProps.children,\n);\n\nexport default MarkdownRenderer;\n"],"mappings":";;;;;;;;;;;;AAiBA,MAAM,mBAAkD,MACrD,EAAE,UAAU,GAAG,WAAW;CACzB,MAAM,iBAAiB,mBAAmB,YAAY,EAAE,KAAK;CAC7D,MAAM,aAAa,sBAAsB;CACzC,MAAM,oBAAoB,yBAAyB;CACnD,MAAM,oBAAoB,yBAAyB;CAEnD,MAAM,EAAE,qBAAqB,mBAAmB;CAChD,MAAM,YAAY,CAAC,CAAC,oBAAoB,iBAAiB,IAAI;CAC7D,MAAM,EAAE,wBAAwB;CAEhC,MAAM,WAAW,eACR;EACL,eAAe;EACf,eAAe;EACf;CACF,IACA;EAAC;EAAmB;EAAmB;CAAmB,CAC5D;CACA,MAAM,cAAc,cAAc,eAAe,QAAQ,GAAG,CAAC,QAAQ,CAAC;CAKtE,MAAM,OAAO,cACJ,YAAY,cAAc,gBAAgB,UAAU,WAAW,IAAI,KAAA,GAC1E;EAAC;EAAW;EAAgB;EAAU;CAAW,CACnD;CAEA,MAAM,UAAU,cAEZ,QACA,aAAa,MAAM;EACjBA,UAAAA;EACA;EACA,oBAAoB;EACpB;EACA;EACA,UAAU;EACV,UAAU;CACZ,CAAC,GACH,CAAC,MAAM,UAAU,CACnB;CAEA,IAAI,SAAS,OAAO;CAEpB,OACE,oBAAC,UAAD;EACE,GAAI;EACQ;EACZ,eAAe;EACf,eAAe;EAEd,UAAA;CACO,CAAA;AAEd,IACC,WAAW,cAAc,UAAU,aAAa,UAAU,QAC7D"}
@@ -0,0 +1,154 @@
1
+ import { defaultUrlTransform } from "react-markdown";
2
+ import { visit } from "unist-util-visit";
3
+ import { urlAttributes } from "html-url-attributes";
4
+ import remarkParse from "remark-parse";
5
+ import remarkRehype from "remark-rehype";
6
+ import { unified } from "unified";
7
+ import { VFile } from "vfile";
8
+ // src/Markdown/SyntaxMarkdown/parseCache.ts
9
+ /**
10
+ * Upper bound of cached hast trees, evicted least-recently-used first like the
11
+ * `contentCache` in `hooks/useMarkdown/utils.ts`. It is larger than that cache
12
+ * (50) because one entry is one message: switching back and forth between two
13
+ * or three ~30-message conversations should still hit, while the bound keeps
14
+ * memory flat in long sessions.
15
+ */
16
+ const PARSE_CACHE_SIZE = 100;
17
+ /**
18
+ * Module-level LRU of parsed hast trees, keyed by `<plugin key>\u0000<content>`.
19
+ *
20
+ * Why hast and not React elements: the hast tree only depends on the content
21
+ * and the remark/rehype pipeline, while the React elements also bake in the
22
+ * `components` map of the rendering instance (custom renderers, citations,
23
+ * `componentProps`, ...). Caching hast lets every mount reuse the expensive
24
+ * remark → rehype work and still run the cheap hast → JSX step with its own
25
+ * `components`, so component overrides are never served stale.
26
+ */
27
+ const parseCache = /* @__PURE__ */ new Map();
28
+ /**
29
+ * `react-markdown` options that change how the hast tree is post-processed
30
+ * before it becomes JSX. They are rarely used and may carry per-instance
31
+ * callbacks, so the cache is bypassed whenever any of them is set and the
32
+ * stock `react-markdown` path renders instead.
33
+ */
34
+ const POST_PROCESS_OPTIONS = [
35
+ "allowElement",
36
+ "allowedElements",
37
+ "disallowedElements",
38
+ "skipHtml",
39
+ "unwrapDisallowed",
40
+ "urlTransform"
41
+ ];
42
+ const canUseParseCache = (options) => POST_PROCESS_OPTIONS.every((key) => options[key] === void 0);
43
+ let nextIdentityId = 0;
44
+ const identityIds = /* @__PURE__ */ new WeakMap();
45
+ const getIdentityId = (value) => {
46
+ let id = identityIds.get(value);
47
+ if (id === void 0) {
48
+ id = ++nextIdentityId;
49
+ identityIds.set(value, id);
50
+ }
51
+ return id;
52
+ };
53
+ const isPlainObject = (value) => {
54
+ const proto = Object.getPrototypeOf(value);
55
+ return proto === Object.prototype || proto === null;
56
+ };
57
+ /**
58
+ * Serializes a plugin list (or plugin options) into a string that is stable
59
+ * across component instances:
60
+ * - functions (plugins, presets, callbacks inside options) and non-plain
61
+ * objects are keyed by identity, so two different plugins never collide;
62
+ * - arrays and plain objects are serialized structurally, so the
63
+ * `[remarkGfm, { singleTilde: false }]` tuples rebuilt by each instance's
64
+ * `useMemo` still map to the same key.
65
+ *
66
+ * The keys deliberately avoid the plugin array references themselves: every
67
+ * `Markdown` instance memoizes its own arrays, so keying on them would miss on
68
+ * every remount. Because the effective plugin list is derived from
69
+ * `enableLatex`, `enableCustomFootnotes`, `enableGithubAlert`, `allowHtml`,
70
+ * `variant` and the user-supplied plugins, serializing that list covers all
71
+ * of those settings without enumerating them here.
72
+ *
73
+ * Assumption: a plugin with the same identity and options is a pure function
74
+ * of its input. A plugin that reads external mutable state must be recreated
75
+ * (new function identity) when that state changes, which is also what
76
+ * `react-markdown` needs to re-render it.
77
+ */
78
+ const serialize = (value) => {
79
+ if (value === null || value === void 0) return String(value);
80
+ switch (typeof value) {
81
+ case "function": return `f${getIdentityId(value)}`;
82
+ case "object":
83
+ if (Array.isArray(value)) return `[${value.map(serialize).join(",")}]`;
84
+ if (!isPlainObject(value)) return `o${getIdentityId(value)}`;
85
+ return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${serialize(value[key])}`).join(",")}}`;
86
+ case "string": return JSON.stringify(value);
87
+ default: return `${typeof value}:${String(value)}`;
88
+ }
89
+ };
90
+ /** Stable key of the remark → rehype pipeline; part of the parse cache key. */
91
+ const getPipelineKey = ({ rehypePlugins, remarkPlugins, remarkRehypeOptions }) => `${serialize(remarkPlugins ?? [])}|${serialize(rehypePlugins ?? [])}|${serialize(remarkRehypeOptions ?? null)}`;
92
+ /**
93
+ * Mirrors the default (no post-process options) `post` transform of
94
+ * react-markdown 10: raw HTML nodes left by the pipeline become text, and URL
95
+ * attributes go through `defaultUrlTransform`. Both steps are idempotent, so
96
+ * the transformed tree can be cached and rendered any number of times.
97
+ *
98
+ * @see https://github.com/remarkjs/react-markdown/blob/main/lib/index.js
99
+ */
100
+ const applyDefaultPostTransform = (tree) => {
101
+ visit(tree, (node, index, parent) => {
102
+ if (node.type === "raw" && parent && typeof index === "number") {
103
+ parent.children[index] = {
104
+ type: "text",
105
+ value: node.value
106
+ };
107
+ return index;
108
+ }
109
+ if (node.type === "element") {
110
+ for (const key in urlAttributes) if (Object.hasOwn(urlAttributes, key) && Object.hasOwn(node.properties, key)) {
111
+ const test = urlAttributes[key];
112
+ if (test === null || test.includes(node.tagName)) node.properties[key] = defaultUrlTransform(String(node.properties[key] || ""));
113
+ }
114
+ }
115
+ });
116
+ };
117
+ /** Same pipeline as react-markdown's `createProcessor`. */
118
+ const parseMarkdown = (content, pipeline) => {
119
+ const processor = unified().use(remarkParse).use(pipeline.remarkPlugins ?? []).use(remarkRehype, {
120
+ ...pipeline.remarkRehypeOptions,
121
+ allowDangerousHtml: true
122
+ }).use(pipeline.rehypePlugins ?? []);
123
+ const file = new VFile();
124
+ file.value = content;
125
+ const tree = processor.runSync(processor.parse(file), file);
126
+ applyDefaultPostTransform(tree);
127
+ return tree;
128
+ };
129
+ /**
130
+ * Returns the parsed, post-transformed hast tree for `content`, reusing a
131
+ * cached tree when the same content was parsed with an equivalent pipeline.
132
+ *
133
+ * The returned tree is shared between mounts and must be treated as
134
+ * read-only by the caller and by markdown components receiving `node`.
135
+ */
136
+ const getParsedHast = (content, pipeline, pipelineKey) => {
137
+ const key = `${pipelineKey}\u0000${content}`;
138
+ const cached = parseCache.get(key);
139
+ if (cached) {
140
+ parseCache.delete(key);
141
+ parseCache.set(key, cached);
142
+ return cached;
143
+ }
144
+ const tree = parseMarkdown(content, pipeline);
145
+ if (parseCache.size >= PARSE_CACHE_SIZE) {
146
+ const oldestKey = parseCache.keys().next().value;
147
+ if (oldestKey !== void 0) parseCache.delete(oldestKey);
148
+ }
149
+ parseCache.set(key, tree);
150
+ return tree;
151
+ };
152
+ export { canUseParseCache, getParsedHast, getPipelineKey };
153
+
154
+ //# sourceMappingURL=parseCache.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseCache.mjs","names":[],"sources":["../../../src/Markdown/SyntaxMarkdown/parseCache.ts"],"sourcesContent":["import type { Root } from 'hast';\nimport { urlAttributes } from 'html-url-attributes';\nimport { defaultUrlTransform, type Options } from 'react-markdown';\nimport remarkParse from 'remark-parse';\nimport remarkRehype from 'remark-rehype';\nimport { type PluggableList, unified } from 'unified';\nimport { visit } from 'unist-util-visit';\nimport { VFile } from 'vfile';\n\n/**\n * Upper bound of cached hast trees, evicted least-recently-used first like the\n * `contentCache` in `hooks/useMarkdown/utils.ts`. It is larger than that cache\n * (50) because one entry is one message: switching back and forth between two\n * or three ~30-message conversations should still hit, while the bound keeps\n * memory flat in long sessions.\n */\nconst PARSE_CACHE_SIZE = 100;\n\n/**\n * Module-level LRU of parsed hast trees, keyed by `<plugin key>\\u0000<content>`.\n *\n * Why hast and not React elements: the hast tree only depends on the content\n * and the remark/rehype pipeline, while the React elements also bake in the\n * `components` map of the rendering instance (custom renderers, citations,\n * `componentProps`, ...). Caching hast lets every mount reuse the expensive\n * remark → rehype work and still run the cheap hast → JSX step with its own\n * `components`, so component overrides are never served stale.\n */\nconst parseCache = new Map<string, Root>();\n\n/**\n * `react-markdown` options that change how the hast tree is post-processed\n * before it becomes JSX. They are rarely used and may carry per-instance\n * callbacks, so the cache is bypassed whenever any of them is set and the\n * stock `react-markdown` path renders instead.\n */\nconst POST_PROCESS_OPTIONS = [\n 'allowElement',\n 'allowedElements',\n 'disallowedElements',\n 'skipHtml',\n 'unwrapDisallowed',\n 'urlTransform',\n] as const satisfies readonly (keyof Options)[];\n\nexport const canUseParseCache = (options: Options): boolean =>\n POST_PROCESS_OPTIONS.every((key) => options[key] === undefined);\n\nlet nextIdentityId = 0;\nconst identityIds = new WeakMap<object, number>();\n\nconst getIdentityId = (value: object): number => {\n let id = identityIds.get(value);\n if (id === undefined) {\n id = ++nextIdentityId;\n identityIds.set(value, id);\n }\n return id;\n};\n\nconst isPlainObject = (value: object): boolean => {\n const proto = Object.getPrototypeOf(value);\n return proto === Object.prototype || proto === null;\n};\n\n/**\n * Serializes a plugin list (or plugin options) into a string that is stable\n * across component instances:\n * - functions (plugins, presets, callbacks inside options) and non-plain\n * objects are keyed by identity, so two different plugins never collide;\n * - arrays and plain objects are serialized structurally, so the\n * `[remarkGfm, { singleTilde: false }]` tuples rebuilt by each instance's\n * `useMemo` still map to the same key.\n *\n * The keys deliberately avoid the plugin array references themselves: every\n * `Markdown` instance memoizes its own arrays, so keying on them would miss on\n * every remount. Because the effective plugin list is derived from\n * `enableLatex`, `enableCustomFootnotes`, `enableGithubAlert`, `allowHtml`,\n * `variant` and the user-supplied plugins, serializing that list covers all\n * of those settings without enumerating them here.\n *\n * Assumption: a plugin with the same identity and options is a pure function\n * of its input. A plugin that reads external mutable state must be recreated\n * (new function identity) when that state changes, which is also what\n * `react-markdown` needs to re-render it.\n */\nconst serialize = (value: unknown): string => {\n if (value === null || value === undefined) return String(value);\n switch (typeof value) {\n case 'function': {\n return `f${getIdentityId(value)}`;\n }\n case 'object': {\n if (Array.isArray(value)) return `[${value.map(serialize).join(',')}]`;\n if (!isPlainObject(value)) return `o${getIdentityId(value)}`;\n const entries = Object.keys(value)\n .sort()\n .map((key) => `${JSON.stringify(key)}:${serialize((value as any)[key])}`);\n return `{${entries.join(',')}}`;\n }\n case 'string': {\n return JSON.stringify(value);\n }\n default: {\n return `${typeof value}:${String(value)}`;\n }\n }\n};\n\nexport interface ParsePipeline {\n rehypePlugins?: PluggableList;\n remarkPlugins?: PluggableList;\n remarkRehypeOptions?: Options['remarkRehypeOptions'];\n}\n\n/** Stable key of the remark → rehype pipeline; part of the parse cache key. */\nexport const getPipelineKey = ({\n rehypePlugins,\n remarkPlugins,\n remarkRehypeOptions,\n}: ParsePipeline): string =>\n `${serialize(remarkPlugins ?? [])}|${serialize(rehypePlugins ?? [])}|${serialize(remarkRehypeOptions ?? null)}`;\n\n/**\n * Mirrors the default (no post-process options) `post` transform of\n * react-markdown 10: raw HTML nodes left by the pipeline become text, and URL\n * attributes go through `defaultUrlTransform`. Both steps are idempotent, so\n * the transformed tree can be cached and rendered any number of times.\n *\n * @see https://github.com/remarkjs/react-markdown/blob/main/lib/index.js\n */\nconst applyDefaultPostTransform = (tree: Root) => {\n visit(tree, (node, index, parent) => {\n if (node.type === 'raw' && parent && typeof index === 'number') {\n parent.children[index] = { type: 'text', value: node.value };\n return index;\n }\n\n if (node.type === 'element') {\n for (const key in urlAttributes) {\n if (Object.hasOwn(urlAttributes, key) && Object.hasOwn(node.properties, key)) {\n const test = urlAttributes[key];\n if (test === null || test.includes(node.tagName)) {\n node.properties[key] = defaultUrlTransform(String(node.properties[key] || ''));\n }\n }\n }\n }\n });\n};\n\n/** Same pipeline as react-markdown's `createProcessor`. */\nconst parseMarkdown = (content: string, pipeline: ParsePipeline): Root => {\n const processor = unified()\n .use(remarkParse)\n .use(pipeline.remarkPlugins ?? [])\n .use(remarkRehype, { ...pipeline.remarkRehypeOptions, allowDangerousHtml: true })\n .use(pipeline.rehypePlugins ?? []);\n\n const file = new VFile();\n file.value = content;\n\n const tree = processor.runSync(processor.parse(file), file) as Root;\n applyDefaultPostTransform(tree);\n return tree;\n};\n\n/**\n * Returns the parsed, post-transformed hast tree for `content`, reusing a\n * cached tree when the same content was parsed with an equivalent pipeline.\n *\n * The returned tree is shared between mounts and must be treated as\n * read-only by the caller and by markdown components receiving `node`.\n */\nexport const getParsedHast = (content: string, pipeline: ParsePipeline, pipelineKey: string) => {\n const key = `${pipelineKey}\\u0000${content}`;\n\n const cached = parseCache.get(key);\n if (cached) {\n // Refresh recency so frequently revisited messages stay cached.\n parseCache.delete(key);\n parseCache.set(key, cached);\n return cached;\n }\n\n const tree = parseMarkdown(content, pipeline);\n\n if (parseCache.size >= PARSE_CACHE_SIZE) {\n const oldestKey = parseCache.keys().next().value;\n if (oldestKey !== undefined) parseCache.delete(oldestKey);\n }\n parseCache.set(key, tree);\n\n return tree;\n};\n\n/** Test helper: drops every cached tree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,MAAM;EAC1B,OAAO;CACT;CAEA,MAAM,OAAO,cAAc,SAAS,QAAQ;CAE5C,IAAI,WAAW,QAAQ,kBAAkB;EACvC,MAAM,YAAY,WAAW,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC;EAC3C,IAAI,cAAc,KAAA,GAAW,WAAW,OAAO,SAAS;CAC1D;CACA,WAAW,IAAI,KAAK,IAAI;CAExB,OAAO;AACT"}
@@ -1,4 +1,4 @@
1
- import { visit } from "../../node_modules/.pnpm/unist-util-visit@5.2.0/node_modules/unist-util-visit/lib/index.mjs";
1
+ import { visit } from "unist-util-visit";
2
2
  // src/Markdown/plugins/rehypeCustomFootnotes.ts
3
3
  const rehypeCustomFootnotes = () => (tree, file) => {
4
4
  const linksData = file.data.footnoteLinks || {};
@@ -1,7 +1,7 @@
1
- import { SKIP, visitParents } from "unist-util-visit-parents";
2
1
  import { fromHtmlIsomorphic } from "hast-util-from-html-isomorphic";
3
2
  import { toText } from "hast-util-to-text";
4
3
  import katex from "katex";
4
+ import { SKIP, visitParents } from "unist-util-visit-parents";
5
5
  // src/Markdown/plugins/rehypeKatex.ts
6
6
  const emptyClasses = [];
7
7
  const rehypeKatex = (options) => (tree, file) => {
@@ -1,4 +1,4 @@
1
- import { visit } from "../../node_modules/.pnpm/unist-util-visit@5.2.0/node_modules/unist-util-visit/lib/index.mjs";
1
+ import { visit } from "unist-util-visit";
2
2
  // src/Markdown/plugins/rehypeKatexDir.ts
3
3
  const rehypeKatexDir = () => (tree) => {
4
4
  visit(tree, "element", (node) => {
@@ -1,4 +1,4 @@
1
- import { visit } from "../../node_modules/.pnpm/unist-util-visit@5.2.0/node_modules/unist-util-visit/lib/index.mjs";
1
+ import { visit } from "unist-util-visit";
2
2
  // src/Markdown/plugins/remarkBr.ts
3
3
  /**
4
4
  * Remark plugin to handle <br> and <br/> tags in markdown text
@@ -1,4 +1,4 @@
1
- import { visit } from "../../node_modules/.pnpm/unist-util-visit@5.2.0/node_modules/unist-util-visit/lib/index.mjs";
1
+ import { visit } from "unist-util-visit";
2
2
  import { gfmAutolinkLiteralFromMarkdown } from "mdast-util-gfm-autolink-literal";
3
3
  // src/Markdown/plugins/remarkCjkAutolink.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { visit } from "../../node_modules/.pnpm/unist-util-visit@5.2.0/node_modules/unist-util-visit/lib/index.mjs";
1
+ import { visit } from "unist-util-visit";
2
2
  // src/Markdown/plugins/remarkColor.ts
3
3
  /**
4
4
  * Remark plugin to handle color syntax in markdown code spans
@@ -1,4 +1,4 @@
1
- import { SKIP, visit } from "../../node_modules/.pnpm/unist-util-visit@5.2.0/node_modules/unist-util-visit/lib/index.mjs";
1
+ import { SKIP, visit } from "unist-util-visit";
2
2
  // src/Markdown/plugins/remarkCustomFootnotes.ts
3
3
  const remarkCustomFootnotes = () => (tree, file) => {
4
4
  const footnoteLinks = /* @__PURE__ */ new Map();
@@ -1,4 +1,4 @@
1
- import { visit } from "../../node_modules/.pnpm/unist-util-visit@5.2.0/node_modules/unist-util-visit/lib/index.mjs";
1
+ import { visit } from "unist-util-visit";
2
2
  // src/Markdown/plugins/remarkGfmPlus.ts
3
3
  const DEFAULT_ALLOW_HTML_TAGS = [
4
4
  "sub",
@@ -1,4 +1,4 @@
1
- import { visit } from "../../node_modules/.pnpm/unist-util-visit@5.2.0/node_modules/unist-util-visit/lib/index.mjs";
1
+ import { visit } from "unist-util-visit";
2
2
  // src/Markdown/plugins/remarkVideo.ts
3
3
  /**
4
4
  * Remark plugin to handle <video> tags in markdown text
@@ -44,6 +44,13 @@ export interface SyntaxMarkdownProps {
44
44
  enableHtmlPreview?: boolean;
45
45
  enableLatex?: boolean;
46
46
  enableMermaid?: boolean;
47
+ /**
48
+ * Reuse the parsed tree across mounts of the same content and plugins (non-streaming
49
+ * render only). Remark/rehype plugins must be pure for a given identity and options, and
50
+ * custom components must not mutate `node`, since cached trees are shared.
51
+ * @default false
52
+ */
53
+ enableParseCache?: boolean;
47
54
  enableStream?: boolean;
48
55
  fullFeaturedCodeBlock?: boolean;
49
56
  reactMarkdownProps?: Omit<Readonly<Options>, 'components' | 'rehypePlugins' | 'remarkPlugins'>;
@@ -3,6 +3,11 @@ import { TITLE } from "../style.mjs";
3
3
  import { memo } from "react";
4
4
  import { jsx, jsxs } from "react/jsx-runtime";
5
5
  // src/icons/WeCom/components/Color.tsx
6
+ const BUBBLE = "M17.326 8.158l-.003-.007a6.6 6.6 0 0 0-1.178-1.674c-1.266-1.307-3.067-2.19-5.102-2.417a9.3 9.3 0 0 0-2.124 0h-.001c-2.061.228-3.882 1.107-5.14 2.405a6.7 6.7 0 0 0-1.194 1.682A5.7 5.7 0 0 0 2 10.657c0 1.106.332 2.218.988 3.201l.006.01c.391.594 1.092 1.39 1.637 1.83l.983.793l-.208.875l.527-.267l.708-.358l.761.225c.467.137.955.227 1.517.29h.005q.515.06 1.026.059c.355 0 .724-.02 1.095-.06a9 9 0 0 0 1.346-.258c.095.7.43 1.337.932 1.81c-.658.208-1.352.358-2.061.436c-.442.048-.883.072-1.312.072q-.627 0-1.253-.072a10.7 10.7 0 0 1-1.861-.36l-2.84 1.438s-.29.131-.44.131c-.418 0-.702-.285-.702-.704c0-.252.067-.598.128-.84l.394-1.653c-.728-.586-1.563-1.544-2.052-2.287A7.76 7.76 0 0 1 0 10.658a7.7 7.7 0 0 1 .787-3.39a8.7 8.7 0 0 1 1.551-2.19c1.61-1.665 3.878-2.73 6.359-3.006a11.3 11.3 0 0 1 2.565 0c2.47.275 4.712 1.353 6.323 3.017a8.6 8.6 0 0 1 1.539 2.192c.466.945.769 1.937.769 2.978a3.06 3.06 0 0 0-2-.005c-.001-.644-.189-1.329-.564-2.09z";
7
+ const PETAL_TOP = "M21.451 15.135l-.024-.024l-.024-.018l-.024-.018l-.096-.095a4.24 4.24 0 0 1-1.169-2.192q0-.038-.006-.075l-.006-.056l-.035-.144a1.3 1.3 0 0 0-.358-.61a1.386 1.386 0 0 0-1.957 0a1.4 1.4 0 0 0 0 1.963c.191.191.418.311.668.371c.024.012.06.012.084.012q.019 0 .041.006q.023.005.042.006a4.24 4.24 0 0 1 2.231 1.186c.048.048.096.095.131.143a.323.323 0 0 0 .466 0a.35.35 0 0 0 .036-.455";
8
+ const PETAL_RIGHT = "M20.401 19.505l-.025.025c-.119.096-.31.096-.453-.036a.326.326 0 0 1 0-.467c.047-.036.094-.083.141-.13l.002-.002a4.27 4.27 0 0 0 1.187-2.28q.005-.024.006-.043c0-.024 0-.06.012-.084a1.386 1.386 0 0 1 2.326-.67a1.4 1.4 0 0 1 0 1.964c-.167.18-.382.299-.608.359l-.143.036l-.057.005q-.035.006-.075.007a4.2 4.2 0 0 0-2.183 1.173l-.095.096q-.009.01-.018.024t-.018.024";
9
+ const PETAL_BOTTOM = "M16.008 18.453l.024.024l.024.018q.015.009.024.018l.096.096a4.25 4.25 0 0 1 1.169 2.19q0 .04.006.076q.005.03.006.057l.035.143c.06.228.18.443.358.611c.537.539 1.42.539 1.957 0a1.4 1.4 0 0 0 0-1.964a1.4 1.4 0 0 0-.668-.371c-.024-.012-.06-.012-.084-.012q-.018 0-.041-.006l-.042-.006a4.25 4.25 0 0 1-2.231-1.185a1.4 1.4 0 0 1-.131-.144a.323.323 0 0 0-.466 0a.325.325 0 0 0-.036.455";
10
+ const PETAL_LEFT = "M17.047 14.095l.024-.024a.32.32 0 0 1 .453.035a.326.326 0 0 1 0 .467c-.047.036-.094.083-.141.13l-.002.002a4.27 4.27 0 0 0-1.187 2.281l-.006.042c0 .024 0 .06-.012.084a1.386 1.386 0 0 1-2.326.67a1.4 1.4 0 0 1 0-1.963c.166-.18.381-.3.608-.36l.143-.035q.026 0 .056-.006q.037-.005.075-.006a4.2 4.2 0 0 0 2.183-1.174l.096-.095l.018-.025z";
6
11
  const Icon = memo(({ size = "1em", style, ...rest }) => {
7
12
  return /* @__PURE__ */ jsxs("svg", {
8
13
  height: size,
@@ -15,10 +20,29 @@ const Icon = memo(({ size = "1em", style, ...rest }) => {
15
20
  width: size,
16
21
  xmlns: "http://www.w3.org/2000/svg",
17
22
  ...rest,
18
- children: [/* @__PURE__ */ jsx("title", { children: TITLE }), /* @__PURE__ */ jsx("path", {
19
- d: "m17.326 8.158l-.003-.007a6.6 6.6 0 0 0-1.178-1.674c-1.266-1.307-3.067-2.19-5.102-2.417a9.3 9.3 0 0 0-2.124 0h-.001c-2.061.228-3.882 1.107-5.14 2.405a6.7 6.7 0 0 0-1.194 1.682A5.7 5.7 0 0 0 2 10.657c0 1.106.332 2.218.988 3.201l.006.01c.391.594 1.092 1.39 1.637 1.83l.983.793l-.208.875l.527-.267l.708-.358l.761.225c.467.137.955.227 1.517.29h.005q.515.06 1.026.059c.355 0 .724-.02 1.095-.06a9 9 0 0 0 1.346-.258c.095.7.43 1.337.932 1.81c-.658.208-1.352.358-2.061.436c-.442.048-.883.072-1.312.072q-.627 0-1.253-.072a10.7 10.7 0 0 1-1.861-.36l-2.84 1.438s-.29.131-.44.131c-.418 0-.702-.285-.702-.704c0-.252.067-.598.128-.84l.394-1.653c-.728-.586-1.563-1.544-2.052-2.287A7.76 7.76 0 0 1 0 10.658a7.7 7.7 0 0 1 .787-3.39a8.7 8.7 0 0 1 1.551-2.19c1.61-1.665 3.878-2.73 6.359-3.006a11.3 11.3 0 0 1 2.565 0c2.47.275 4.712 1.353 6.323 3.017a8.6 8.6 0 0 1 1.539 2.192c.466.945.769 1.937.769 2.978a3.06 3.06 0 0 0-2-.005c-.001-.644-.189-1.329-.564-2.09zm4.125 6.977l-.024-.024l-.024-.018l-.024-.018l-.096-.095a4.24 4.24 0 0 1-1.169-2.192q0-.038-.006-.075l-.006-.056l-.035-.144a1.3 1.3 0 0 0-.358-.61a1.386 1.386 0 0 0-1.957 0a1.4 1.4 0 0 0 0 1.963c.191.191.418.311.668.371c.024.012.06.012.084.012q.019 0 .041.006q.023.005.042.006a4.24 4.24 0 0 1 2.231 1.186c.048.048.096.095.131.143a.323.323 0 0 0 .466 0a.35.35 0 0 0 .036-.455m-1.05 4.37l-.025.025c-.119.096-.31.096-.453-.036a.326.326 0 0 1 0-.467c.047-.036.094-.083.141-.13l.002-.002a4.27 4.27 0 0 0 1.187-2.28q.005-.024.006-.043c0-.024 0-.06.012-.084a1.386 1.386 0 0 1 2.326-.67a1.4 1.4 0 0 1 0 1.964c-.167.18-.382.299-.608.359l-.143.036l-.057.005q-.035.006-.075.007a4.2 4.2 0 0 0-2.183 1.173l-.095.096q-.009.01-.018.024t-.018.024m-4.392-1.053l.024.024l.024.018q.015.009.024.018l.096.096a4.25 4.25 0 0 1 1.169 2.19q0 .04.006.076q.005.03.006.057l.035.143c.06.228.18.443.358.611c.537.539 1.42.539 1.957 0a1.4 1.4 0 0 0 0-1.964a1.4 1.4 0 0 0-.668-.371c-.024-.012-.06-.012-.084-.012q-.018 0-.041-.006l-.042-.006a4.25 4.25 0 0 1-2.231-1.185a1.4 1.4 0 0 1-.131-.144a.323.323 0 0 0-.466 0a.325.325 0 0 0-.036.455m1.039-4.358l.024-.024a.32.32 0 0 1 .453.035a.326.326 0 0 1 0 .467c-.047.036-.094.083-.141.13l-.002.002a4.27 4.27 0 0 0-1.187 2.281l-.006.042c0 .024 0 .06-.012.084a1.386 1.386 0 0 1-2.326.67a1.4 1.4 0 0 1 0-1.963c.166-.18.381-.3.608-.36l.143-.035q.026 0 .056-.006q.037-.005.075-.006a4.2 4.2 0 0 0 2.183-1.174l.096-.095l.018-.025z",
20
- fill: "#0082EF"
21
- })]
23
+ children: [
24
+ /* @__PURE__ */ jsx("title", { children: TITLE }),
25
+ /* @__PURE__ */ jsx("path", {
26
+ d: BUBBLE,
27
+ fill: "#0082EF"
28
+ }),
29
+ /* @__PURE__ */ jsx("path", {
30
+ d: PETAL_TOP,
31
+ fill: "#2DBC00"
32
+ }),
33
+ /* @__PURE__ */ jsx("path", {
34
+ d: PETAL_RIGHT,
35
+ fill: "#0082EF"
36
+ }),
37
+ /* @__PURE__ */ jsx("path", {
38
+ d: PETAL_BOTTOM,
39
+ fill: "#FB6500"
40
+ }),
41
+ /* @__PURE__ */ jsx("path", {
42
+ d: PETAL_LEFT,
43
+ fill: "#FFCC00"
44
+ })
45
+ ]
22
46
  });
23
47
  });
24
48
  export { Icon as default };
@@ -1 +1 @@
1
- {"version":3,"file":"Color.mjs","names":[],"sources":["../../../../src/icons/WeCom/components/Color.tsx"],"sourcesContent":["'use client';\n\nimport type { IconType } from '@lobehub/icons';\nimport { memo } from 'react';\n\nimport { TITLE } from '../style';\n\n// Glyph from TDesign Icons' `logo-wecom` (MIT); notice in THIRD_PARTY_NOTICES.md.\n\nconst Icon: IconType = memo(({ size = '1em', style, ...rest }) => {\n return (\n <svg\n height={size}\n style={{ flex: 'none', lineHeight: 1, ...style }}\n viewBox=\"0 0 24 24\"\n width={size}\n xmlns=\"http://www.w3.org/2000/svg\"\n {...rest}\n >\n <title>{TITLE}</title>\n <path\n d=\"m17.326 8.158l-.003-.007a6.6 6.6 0 0 0-1.178-1.674c-1.266-1.307-3.067-2.19-5.102-2.417a9.3 9.3 0 0 0-2.124 0h-.001c-2.061.228-3.882 1.107-5.14 2.405a6.7 6.7 0 0 0-1.194 1.682A5.7 5.7 0 0 0 2 10.657c0 1.106.332 2.218.988 3.201l.006.01c.391.594 1.092 1.39 1.637 1.83l.983.793l-.208.875l.527-.267l.708-.358l.761.225c.467.137.955.227 1.517.29h.005q.515.06 1.026.059c.355 0 .724-.02 1.095-.06a9 9 0 0 0 1.346-.258c.095.7.43 1.337.932 1.81c-.658.208-1.352.358-2.061.436c-.442.048-.883.072-1.312.072q-.627 0-1.253-.072a10.7 10.7 0 0 1-1.861-.36l-2.84 1.438s-.29.131-.44.131c-.418 0-.702-.285-.702-.704c0-.252.067-.598.128-.84l.394-1.653c-.728-.586-1.563-1.544-2.052-2.287A7.76 7.76 0 0 1 0 10.658a7.7 7.7 0 0 1 .787-3.39a8.7 8.7 0 0 1 1.551-2.19c1.61-1.665 3.878-2.73 6.359-3.006a11.3 11.3 0 0 1 2.565 0c2.47.275 4.712 1.353 6.323 3.017a8.6 8.6 0 0 1 1.539 2.192c.466.945.769 1.937.769 2.978a3.06 3.06 0 0 0-2-.005c-.001-.644-.189-1.329-.564-2.09zm4.125 6.977l-.024-.024l-.024-.018l-.024-.018l-.096-.095a4.24 4.24 0 0 1-1.169-2.192q0-.038-.006-.075l-.006-.056l-.035-.144a1.3 1.3 0 0 0-.358-.61a1.386 1.386 0 0 0-1.957 0a1.4 1.4 0 0 0 0 1.963c.191.191.418.311.668.371c.024.012.06.012.084.012q.019 0 .041.006q.023.005.042.006a4.24 4.24 0 0 1 2.231 1.186c.048.048.096.095.131.143a.323.323 0 0 0 .466 0a.35.35 0 0 0 .036-.455m-1.05 4.37l-.025.025c-.119.096-.31.096-.453-.036a.326.326 0 0 1 0-.467c.047-.036.094-.083.141-.13l.002-.002a4.27 4.27 0 0 0 1.187-2.28q.005-.024.006-.043c0-.024 0-.06.012-.084a1.386 1.386 0 0 1 2.326-.67a1.4 1.4 0 0 1 0 1.964c-.167.18-.382.299-.608.359l-.143.036l-.057.005q-.035.006-.075.007a4.2 4.2 0 0 0-2.183 1.173l-.095.096q-.009.01-.018.024t-.018.024m-4.392-1.053l.024.024l.024.018q.015.009.024.018l.096.096a4.25 4.25 0 0 1 1.169 2.19q0 .04.006.076q.005.03.006.057l.035.143c.06.228.18.443.358.611c.537.539 1.42.539 1.957 0a1.4 1.4 0 0 0 0-1.964a1.4 1.4 0 0 0-.668-.371c-.024-.012-.06-.012-.084-.012q-.018 0-.041-.006l-.042-.006a4.25 4.25 0 0 1-2.231-1.185a1.4 1.4 0 0 1-.131-.144a.323.323 0 0 0-.466 0a.325.325 0 0 0-.036.455m1.039-4.358l.024-.024a.32.32 0 0 1 .453.035a.326.326 0 0 1 0 .467c-.047.036-.094.083-.141.13l-.002.002a4.27 4.27 0 0 0-1.187 2.281l-.006.042c0 .024 0 .06-.012.084a1.386 1.386 0 0 1-2.326.67a1.4 1.4 0 0 1 0-1.963c.166-.18.381-.3.608-.36l.143-.035q.026 0 .056-.006q.037-.005.075-.006a4.2 4.2 0 0 0 2.183-1.174l.096-.095l.018-.025z\"\n fill=\"#0082EF\"\n />\n </svg>\n );\n});\n\nexport default Icon;\n"],"mappings":";;;;;AASA,MAAM,OAAiB,MAAM,EAAE,OAAO,OAAO,OAAO,GAAG,WAAW;CAChE,OACE,qBAAC,OAAD;EACE,QAAQ;EACR,OAAO;GAAE,MAAM;GAAQ,YAAY;GAAG,GAAG;EAAM;EAC/C,SAAQ;EACR,OAAO;EACP,OAAM;EACN,GAAI;EANN,UAAA,CAQE,oBAAC,SAAD,EAAA,UAAQ,MAAa,CAAA,GACrB,oBAAC,QAAD;GACE,GAAE;GACF,MAAK;EACN,CAAA,CACE;;AAET,CAAC"}
1
+ {"version":3,"file":"Color.mjs","names":[],"sources":["../../../../src/icons/WeCom/components/Color.tsx"],"sourcesContent":["'use client';\n\nimport type { IconType } from '@lobehub/icons';\nimport { memo } from 'react';\n\nimport { TITLE } from '../style';\n\n// Glyph from TDesign Icons' `logo-wecom` (MIT); notice in THIRD_PARTY_NOTICES.md.\n// Split into the bubble and one subpath per petal so the petals take WeCom's brand colors\n// (sampled from the work.weixin.qq.com favicon): green top, blue right, orange bottom, yellow left.\nconst BUBBLE =\n 'M17.326 8.158l-.003-.007a6.6 6.6 0 0 0-1.178-1.674c-1.266-1.307-3.067-2.19-5.102-2.417a9.3 9.3 0 0 0-2.124 0h-.001c-2.061.228-3.882 1.107-5.14 2.405a6.7 6.7 0 0 0-1.194 1.682A5.7 5.7 0 0 0 2 10.657c0 1.106.332 2.218.988 3.201l.006.01c.391.594 1.092 1.39 1.637 1.83l.983.793l-.208.875l.527-.267l.708-.358l.761.225c.467.137.955.227 1.517.29h.005q.515.06 1.026.059c.355 0 .724-.02 1.095-.06a9 9 0 0 0 1.346-.258c.095.7.43 1.337.932 1.81c-.658.208-1.352.358-2.061.436c-.442.048-.883.072-1.312.072q-.627 0-1.253-.072a10.7 10.7 0 0 1-1.861-.36l-2.84 1.438s-.29.131-.44.131c-.418 0-.702-.285-.702-.704c0-.252.067-.598.128-.84l.394-1.653c-.728-.586-1.563-1.544-2.052-2.287A7.76 7.76 0 0 1 0 10.658a7.7 7.7 0 0 1 .787-3.39a8.7 8.7 0 0 1 1.551-2.19c1.61-1.665 3.878-2.73 6.359-3.006a11.3 11.3 0 0 1 2.565 0c2.47.275 4.712 1.353 6.323 3.017a8.6 8.6 0 0 1 1.539 2.192c.466.945.769 1.937.769 2.978a3.06 3.06 0 0 0-2-.005c-.001-.644-.189-1.329-.564-2.09z';\nconst PETAL_TOP =\n 'M21.451 15.135l-.024-.024l-.024-.018l-.024-.018l-.096-.095a4.24 4.24 0 0 1-1.169-2.192q0-.038-.006-.075l-.006-.056l-.035-.144a1.3 1.3 0 0 0-.358-.61a1.386 1.386 0 0 0-1.957 0a1.4 1.4 0 0 0 0 1.963c.191.191.418.311.668.371c.024.012.06.012.084.012q.019 0 .041.006q.023.005.042.006a4.24 4.24 0 0 1 2.231 1.186c.048.048.096.095.131.143a.323.323 0 0 0 .466 0a.35.35 0 0 0 .036-.455';\nconst PETAL_RIGHT =\n 'M20.401 19.505l-.025.025c-.119.096-.31.096-.453-.036a.326.326 0 0 1 0-.467c.047-.036.094-.083.141-.13l.002-.002a4.27 4.27 0 0 0 1.187-2.28q.005-.024.006-.043c0-.024 0-.06.012-.084a1.386 1.386 0 0 1 2.326-.67a1.4 1.4 0 0 1 0 1.964c-.167.18-.382.299-.608.359l-.143.036l-.057.005q-.035.006-.075.007a4.2 4.2 0 0 0-2.183 1.173l-.095.096q-.009.01-.018.024t-.018.024';\nconst PETAL_BOTTOM =\n 'M16.008 18.453l.024.024l.024.018q.015.009.024.018l.096.096a4.25 4.25 0 0 1 1.169 2.19q0 .04.006.076q.005.03.006.057l.035.143c.06.228.18.443.358.611c.537.539 1.42.539 1.957 0a1.4 1.4 0 0 0 0-1.964a1.4 1.4 0 0 0-.668-.371c-.024-.012-.06-.012-.084-.012q-.018 0-.041-.006l-.042-.006a4.25 4.25 0 0 1-2.231-1.185a1.4 1.4 0 0 1-.131-.144a.323.323 0 0 0-.466 0a.325.325 0 0 0-.036.455';\nconst PETAL_LEFT =\n 'M17.047 14.095l.024-.024a.32.32 0 0 1 .453.035a.326.326 0 0 1 0 .467c-.047.036-.094.083-.141.13l-.002.002a4.27 4.27 0 0 0-1.187 2.281l-.006.042c0 .024 0 .06-.012.084a1.386 1.386 0 0 1-2.326.67a1.4 1.4 0 0 1 0-1.963c.166-.18.381-.3.608-.36l.143-.035q.026 0 .056-.006q.037-.005.075-.006a4.2 4.2 0 0 0 2.183-1.174l.096-.095l.018-.025z';\n\nconst Icon: IconType = memo(({ size = '1em', style, ...rest }) => {\n return (\n <svg\n height={size}\n style={{ flex: 'none', lineHeight: 1, ...style }}\n viewBox=\"0 0 24 24\"\n width={size}\n xmlns=\"http://www.w3.org/2000/svg\"\n {...rest}\n >\n <title>{TITLE}</title>\n <path d={BUBBLE} fill=\"#0082EF\" />\n <path d={PETAL_TOP} fill=\"#2DBC00\" />\n <path d={PETAL_RIGHT} fill=\"#0082EF\" />\n <path d={PETAL_BOTTOM} fill=\"#FB6500\" />\n <path d={PETAL_LEFT} fill=\"#FFCC00\" />\n </svg>\n );\n});\n\nexport default Icon;\n"],"mappings":";;;;;AAUA,MAAM,SACJ;AACF,MAAM,YACJ;AACF,MAAM,cACJ;AACF,MAAM,eACJ;AACF,MAAM,aACJ;AAEF,MAAM,OAAiB,MAAM,EAAE,OAAO,OAAO,OAAO,GAAG,WAAW;CAChE,OACE,qBAAC,OAAD;EACE,QAAQ;EACR,OAAO;GAAE,MAAM;GAAQ,YAAY;GAAG,GAAG;EAAM;EAC/C,SAAQ;EACR,OAAO;EACP,OAAM;EACN,GAAI;EANN,UAAA;GAQE,oBAAC,SAAD,EAAA,UAAQ,MAAa,CAAA;GACrB,oBAAC,QAAD;IAAM,GAAG;IAAQ,MAAK;GAAW,CAAA;GACjC,oBAAC,QAAD;IAAM,GAAG;IAAW,MAAK;GAAW,CAAA;GACpC,oBAAC,QAAD;IAAM,GAAG;IAAa,MAAK;GAAW,CAAA;GACtC,oBAAC,QAAD;IAAM,GAAG;IAAc,MAAK;GAAW,CAAA;GACvC,oBAAC,QAAD;IAAM,GAAG;IAAY,MAAK;GAAW,CAAA;EAClC;;AAET,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "6.16.0",
3
+ "version": "6.16.2",
4
4
  "description": "Lobe UI is an open-source UI component library for building AIGC web apps",
5
5
  "keywords": [
6
6
  "lobehub",
@@ -174,7 +174,9 @@
174
174
  "emoji-mart": "^5.6.0",
175
175
  "es-toolkit": "^1.52.0",
176
176
  "hast-util-from-html-isomorphic": "^2.0.0",
177
+ "hast-util-to-jsx-runtime": "^2.3.6",
177
178
  "hast-util-to-text": "^4.0.2",
179
+ "html-url-attributes": "^3.0.1",
178
180
  "katex": "^0.18.1 || ^0.19.0",
179
181
  "leva": "^0.10.1",
180
182
  "lucide-react": "^1.55.0",
@@ -193,7 +195,10 @@
193
195
  "remark-cjk-friendly": "^2.3.2",
194
196
  "remark-gfm": "^4.0.1",
195
197
  "remark-math": "^6.0.0",
198
+ "remark-parse": "^11.0.0",
199
+ "remark-rehype": "^11.1.2",
196
200
  "unified": "^11.0.5",
201
+ "unist-util-visit": "^5.1.0",
197
202
  "unist-util-visit-parents": "^6.0.2",
198
203
  "uqr": "^0.1.3",
199
204
  "vfile": "^6.0.3",
@@ -1,289 +0,0 @@
1
- import { SKIP, visitParents } from "unist-util-visit-parents";
2
- // node_modules/.pnpm/unist-util-visit@5.2.0/node_modules/unist-util-visit/lib/index.js
3
- /**
4
- * @import {Node as UnistNode, Parent as UnistParent} from 'unist'
5
- * @import {
6
- * InclusiveDescendant,
7
- * Matches,
8
- * Visitors as ParentsVisitors,
9
- * VisitorResult,
10
- * VisitorResultExit
11
- * } from 'unist-util-visit-parents'
12
- */
13
- /**
14
- * @typedef {Exclude<import('unist-util-is').Test, undefined> | undefined} Test
15
- * Test from `unist-util-is`.
16
- *
17
- * Note: we have remove and add `undefined`, because otherwise when generating
18
- * automatic `.d.ts` files, TS tries to flatten paths from a local perspective,
19
- * which doesn’t work when publishing on npm.
20
- */
21
- /**
22
- * @typedef {(
23
- * Node extends UnistParent
24
- * ? Node extends {children: Array<infer Children>}
25
- * ? Child extends Children ? Node : never
26
- * : never
27
- * : never
28
- * )} InternalParent
29
- * Collect nodes that can be parents of `Child`.
30
- * @template {UnistNode} Node
31
- * All node types in a tree.
32
- * @template {UnistNode} Child
33
- * Node to search for.
34
- */
35
- /**
36
- * @typedef {InternalParent<InclusiveDescendant<Tree>, Child>} Parent
37
- * Collect nodes in `Tree` that can be parents of `Child`.
38
- * @template {UnistNode} Tree
39
- * All node types in a tree.
40
- * @template {UnistNode} Child
41
- * Node to search for.
42
- */
43
- /**
44
- * @callback Visitor
45
- * Handle a node (matching `test`, if given) before its children.
46
- *
47
- * Like `Visitor` in `unist-util-visit-parents`,
48
- * but with `index` and `parent` instead of `parents`.
49
- * @param {Visited} node
50
- * Found node.
51
- * @param {Visited extends UnistNode ? number | undefined : never} index
52
- * Index of `node` in `parent`,
53
- * or `undefined` for the tree itself.
54
- * @param {Ancestor extends UnistParent ? Ancestor | undefined : never} parent
55
- * Parent of `node`,
56
- * or `undefined` for the tree itself.
57
- * @returns {VisitorResult}
58
- * What to do next.
59
- * @template {UnistNode} [Visited=UnistNode]
60
- * Visited node type.
61
- * @template {UnistParent} [Ancestor=UnistParent]
62
- * Ancestor type.
63
- */
64
- /**
65
- * @callback VisitorExit
66
- * Handle a node (matching `test`, if given) after its children.
67
- *
68
- * Like `VisitorExit` in `unist-util-visit-parents`,
69
- * but with `index` and `parent` instead of `parents`.
70
- * @param {Visited} node
71
- * Found node.
72
- * @param {Visited extends UnistNode ? number | undefined : never} index
73
- * Index of `node` in `parent`,
74
- * or `undefined` for the tree itself.
75
- * @param {Ancestor extends UnistParent ? Ancestor | undefined : never} parent
76
- * Parent of `node`,
77
- * or `undefined` for the tree itself.
78
- * @returns {VisitorResultExit}
79
- * What to do next.
80
- * @template {UnistNode} [Visited=UnistNode]
81
- * Visited node type.
82
- * @template {UnistParent} [Ancestor=UnistParent]
83
- * Ancestor type.
84
- */
85
- /**
86
- * @template {UnistNode} [Visited=UnistNode]
87
- * Visited node type.
88
- * @template {UnistParent} [Ancestor=UnistParent]
89
- * Ancestor type.
90
- * @typedef Visitors
91
- * Handle nodes when entering and exiting them.
92
- *
93
- * Like `Visitors` in `unist-util-visit-parents`.
94
- * @property {Visitor<Visited, Ancestor> | null | undefined} [enter]
95
- * Handle a node before its children (optional).
96
- * @property {VisitorExit<Visited, Ancestor>} exit
97
- * Handle a node after its children.
98
- */
99
- /**
100
- * @typedef {Visitor<Visited, Parent<Ancestor, Visited>>} BuildVisitorFromMatch
101
- * Build a typed `Visitor` function from a node and all possible parents.
102
- *
103
- * It will infer which values are passed as `node` and which as `parent`.
104
- * @template {UnistNode} Visited
105
- * Node type.
106
- * @template {UnistParent} Ancestor
107
- * Parent type.
108
- */
109
- /**
110
- * @typedef {(
111
- * BuildVisitorFromMatch<
112
- * Matches<Descendant, Check>,
113
- * Extract<Descendant, UnistParent>
114
- * >
115
- * )} BuildVisitorFromDescendants
116
- * Build a typed `Visitor` function from a list of descendants and a test.
117
- *
118
- * It will infer which values are passed as `node` and which as `parent`.
119
- * @template {UnistNode} Descendant
120
- * Node type.
121
- * @template {Test} Check
122
- * Test type.
123
- */
124
- /**
125
- * @typedef {(
126
- * BuildVisitorFromDescendants<
127
- * InclusiveDescendant<Tree>,
128
- * Check
129
- * >
130
- * )} BuildVisitor
131
- * Build a typed `Visitor` function from a tree and a test.
132
- *
133
- * It will infer which values are passed as `node` and which as `parent`.
134
- * @template {UnistNode} [Tree=UnistNode]
135
- * Node type.
136
- * @template {Test} [Check=Test]
137
- * Test type.
138
- */
139
- /**
140
- * @typedef {(
141
- * Visitors<
142
- * Matches<InclusiveDescendant<Tree>, Check>,
143
- * Parent<
144
- * Extract<InclusiveDescendant<Tree>, UnistParent>,
145
- * Matches<InclusiveDescendant<Tree>, Check>
146
- * >
147
- * >
148
- * )} BuildVisitors
149
- * Build typed `Visitors` from a tree and a test.
150
- *
151
- * It will infer which values are passed as `node` and which as `parent`.
152
- * @template {UnistNode} [Tree=UnistNode]
153
- * Node type.
154
- * @template {Test} [Check=Test]
155
- * Test type.
156
- */
157
- /**
158
- * Visit nodes.
159
- *
160
- * This algorithm performs *depth-first* *tree traversal* in *preorder*
161
- * (**NLR**) or if `reverse` is given,
162
- * in *reverse preorder* (**NRL**).
163
- * An `exit` visitor is called in *postorder* (**LRN**)
164
- * or if `reverse` is given, in *reverse postorder* (**RLN**).
165
- *
166
- * You can choose which nodes are visited by passing a `test`.
167
- * For complex tests, you should test yourself in a visitor, as it will be
168
- * faster and will have improved type information.
169
- *
170
- * Walking the tree is an intensive task.
171
- * Make use of the return values of the visitor when possible.
172
- * Instead of walking a tree multiple times, walk it once, use `unist-util-is`
173
- * to check if a node matches, and then perform different operations.
174
- *
175
- * You can change the tree.
176
- * Changes inside a node made when entering it are walked,
177
- * changes made when exiting it are not.
178
- * See `Visitor` and `VisitorExit` for more info.
179
- *
180
- * @overload
181
- * @param {Tree} tree
182
- * Tree to traverse.
183
- * @param {Check} check
184
- * `unist-util-is`-compatible test.
185
- * @param {BuildVisitor<Tree, Check> | BuildVisitors<Tree, Check>} visitors
186
- * Handle each node when entering it,
187
- * or `{enter, exit}` to also handle it when exiting it.
188
- * @param {boolean | null | undefined} [reverse]
189
- * Walk children from last to first;
190
- * for `enter`, reverse preorder (NRL) instead of preorder (NLR);
191
- * for `exit`, reverse postorder (RLN) instead of postorder (LRN).
192
- * @returns {undefined}
193
- * Nothing.
194
- *
195
- * @overload
196
- * @param {Tree} tree
197
- * Tree to traverse.
198
- * @param {BuildVisitor<Tree> | BuildVisitors<Tree>} visitors
199
- * Handle each node when entering it,
200
- * or `{enter, exit}` to also handle it when exiting it.
201
- * @param {boolean | null | undefined} [reverse]
202
- * Walk children from last to first;
203
- * for `enter`, reverse preorder (NRL) instead of preorder (NLR);
204
- * for `exit`, reverse postorder (RLN) instead of postorder (LRN).
205
- * @returns {undefined}
206
- * Nothing.
207
- *
208
- * @param {UnistNode} tree
209
- * Tree to traverse.
210
- * @param {Visitor | Visitors | Test} testOrEnterOrVisitors
211
- * `unist-util-is`-compatible test, `enter`, or `visitors`.
212
- * @param {Visitor | Visitors | boolean | null | undefined} [enterOrVisitorsOrReverse]
213
- * `enter`, `visitors`, or `reverse` after a test.
214
- * @param {boolean | null | undefined} [maybeReverse]
215
- * Walk children from last to first;
216
- * for `enter`, reverse preorder (NRL) instead of preorder (NLR);
217
- * for `exit`, reverse postorder (RLN) instead of postorder (LRN).
218
- * @returns {undefined}
219
- * Nothing.
220
- *
221
- * @template {UnistNode} Tree
222
- * Node type.
223
- * @template {Test} Check
224
- * `unist-util-is`-compatible test.
225
- */
226
- function visit(tree, testOrEnterOrVisitors, enterOrVisitorsOrReverse, maybeReverse) {
227
- /** @type {Test} */
228
- let check;
229
- /** @type {Visitor | Visitors} */
230
- let visitors;
231
- /** @type {boolean | null | undefined} */
232
- let reverse;
233
- if (typeof enterOrVisitorsOrReverse === "function" || enterOrVisitorsOrReverse && typeof enterOrVisitorsOrReverse === "object") {
234
- check = testOrEnterOrVisitors;
235
- visitors = enterOrVisitorsOrReverse;
236
- reverse = maybeReverse;
237
- } else {
238
- visitors = testOrEnterOrVisitors;
239
- reverse = enterOrVisitorsOrReverse;
240
- }
241
- if (typeof visitors === "function") visitParents(tree, check, wrap(visitors), reverse);
242
- else visitParents(tree, check, wrapVisitors(visitors), reverse);
243
- }
244
- /**
245
- * Turn `visit` visitors into `visitParents` visitors.
246
- *
247
- * @param {Visitors} visitors
248
- * Visitors for `visit`.
249
- * @returns {ParentsVisitors}
250
- * Visitors for `visitParents`.
251
- */
252
- function wrapVisitors(visitors) {
253
- if (!visitors || typeof visitors !== "object") return visitors;
254
- return {
255
- enter: typeof visitors.enter === "function" ? wrap(visitors.enter) : visitors.enter,
256
- exit: typeof visitors.exit === "function" ? wrap(visitors.exit) : visitors.exit
257
- };
258
- }
259
- /**
260
- * Turn a `visit` visitor into a `visitParents` one.
261
- *
262
- * @template {VisitorResult} Result
263
- * Result type.
264
- * @param {(node: UnistNode, index: number | undefined, parent: UnistParent | undefined) => Result} visitor
265
- * Visitor for `visit`.
266
- * @returns {(node: UnistNode, parents: Array<UnistParent>, index: number | undefined) => Result}
267
- * Visitor for `visitParents`.
268
- */
269
- function wrap(visitor) {
270
- return overload;
271
- /**
272
- * Call `visitor` with `index` and `parent` instead of `parents`.
273
- *
274
- * @param {UnistNode} node
275
- * Visited node.
276
- * @param {Array<UnistParent>} parents
277
- * Ancestors of `node`.
278
- * @param {number | undefined} index
279
- * Index of `node` in its parent.
280
- * @returns {Result}
281
- * What to do next.
282
- */
283
- function overload(node, parents, index) {
284
- return visitor(node, index, parents[parents.length - 1]);
285
- }
286
- }
287
- export { SKIP, visit };
288
-
289
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../../../../../node_modules/.pnpm/unist-util-visit@5.2.0/node_modules/unist-util-visit/lib/index.js"],"sourcesContent":["/**\n * @import {Node as UnistNode, Parent as UnistParent} from 'unist'\n * @import {\n * InclusiveDescendant,\n * Matches,\n * Visitors as ParentsVisitors,\n * VisitorResult,\n * VisitorResultExit\n * } from 'unist-util-visit-parents'\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 * 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 * @callback Visitor\n * Handle a node (matching `test`, if given) before its children.\n *\n * Like `Visitor` in `unist-util-visit-parents`,\n * but with `index` and `parent` instead of `parents`.\n * @param {Visited} node\n * Found node.\n * @param {Visited extends UnistNode ? number | undefined : never} index\n * Index of `node` in `parent`,\n * or `undefined` for the tree itself.\n * @param {Ancestor extends UnistParent ? Ancestor | undefined : never} parent\n * Parent of `node`,\n * or `undefined` for the tree itself.\n * @returns {VisitorResult}\n * What to do next.\n * @template {UnistNode} [Visited=UnistNode]\n * Visited node type.\n * @template {UnistParent} [Ancestor=UnistParent]\n * Ancestor type.\n */\n\n/**\n * @callback VisitorExit\n * Handle a node (matching `test`, if given) after its children.\n *\n * Like `VisitorExit` in `unist-util-visit-parents`,\n * but with `index` and `parent` instead of `parents`.\n * @param {Visited} node\n * Found node.\n * @param {Visited extends UnistNode ? number | undefined : never} index\n * Index of `node` in `parent`,\n * or `undefined` for the tree itself.\n * @param {Ancestor extends UnistParent ? Ancestor | undefined : never} parent\n * Parent of `node`,\n * or `undefined` for the tree itself.\n * @returns {VisitorResultExit}\n * What to do next.\n * @template {UnistNode} [Visited=UnistNode]\n * Visited node type.\n * @template {UnistParent} [Ancestor=UnistParent]\n * Ancestor type.\n */\n\n/**\n * @template {UnistNode} [Visited=UnistNode]\n * Visited node type.\n * @template {UnistParent} [Ancestor=UnistParent]\n * Ancestor type.\n * @typedef Visitors\n * Handle nodes when entering and exiting them.\n *\n * Like `Visitors` in `unist-util-visit-parents`.\n * @property {Visitor<Visited, Ancestor> | null | undefined} [enter]\n * Handle a node before its children (optional).\n * @property {VisitorExit<Visited, Ancestor>} exit\n * Handle a node after its children.\n */\n\n/**\n * @typedef {Visitor<Visited, Parent<Ancestor, Visited>>} BuildVisitorFromMatch\n * Build a typed `Visitor` function from a node and all possible parents.\n *\n * It will infer which values are passed as `node` and which as `parent`.\n * @template {UnistNode} Visited\n * Node type.\n * @template {UnistParent} Ancestor\n * Parent type.\n */\n\n/**\n * @typedef {(\n * BuildVisitorFromMatch<\n * Matches<Descendant, Check>,\n * Extract<Descendant, UnistParent>\n * >\n * )} BuildVisitorFromDescendants\n * Build a typed `Visitor` function from a list of descendants and a test.\n *\n * It will infer which values are passed as `node` and which as `parent`.\n * @template {UnistNode} Descendant\n * Node type.\n * @template {Test} Check\n * Test type.\n */\n\n/**\n * @typedef {(\n * BuildVisitorFromDescendants<\n * InclusiveDescendant<Tree>,\n * Check\n * >\n * )} 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 `parent`.\n * @template {UnistNode} [Tree=UnistNode]\n * Node type.\n * @template {Test} [Check=Test]\n * Test type.\n */\n\n/**\n * @typedef {(\n * Visitors<\n * Matches<InclusiveDescendant<Tree>, Check>,\n * Parent<\n * Extract<InclusiveDescendant<Tree>, UnistParent>,\n * Matches<InclusiveDescendant<Tree>, Check>\n * >\n * >\n * )} BuildVisitors\n * Build typed `Visitors` from a tree and a test.\n *\n * It will infer which values are passed as `node` and which as `parent`.\n * @template {UnistNode} [Tree=UnistNode]\n * Node type.\n * @template {Test} [Check=Test]\n * Test type.\n */\n\nimport {visitParents} from 'unist-util-visit-parents'\n\nexport {CONTINUE, EXIT, SKIP} from 'unist-util-visit-parents'\n\n/**\n * Visit nodes.\n *\n * This algorithm performs *depth-first* *tree traversal* in *preorder*\n * (**NLR**) or if `reverse` is given,\n * in *reverse preorder* (**NRL**).\n * An `exit` visitor is called in *postorder* (**LRN**)\n * or if `reverse` is given, in *reverse postorder* (**RLN**).\n *\n * You can choose which nodes are visited by passing a `test`.\n * For complex tests, you should test yourself in a 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 * Changes inside a node made when entering it are walked,\n * changes made when exiting it are not.\n * See `Visitor` and `VisitorExit` for more info.\n *\n * @overload\n * @param {Tree} tree\n * Tree to traverse.\n * @param {Check} check\n * `unist-util-is`-compatible test.\n * @param {BuildVisitor<Tree, Check> | BuildVisitors<Tree, Check>} visitors\n * Handle each node when entering it,\n * or `{enter, exit}` to also handle it when exiting it.\n * @param {boolean | null | undefined} [reverse]\n * Walk children from last to first;\n * for `enter`, reverse preorder (NRL) instead of preorder (NLR);\n * for `exit`, reverse postorder (RLN) instead of postorder (LRN).\n * @returns {undefined}\n * Nothing.\n *\n * @overload\n * @param {Tree} tree\n * Tree to traverse.\n * @param {BuildVisitor<Tree> | BuildVisitors<Tree>} visitors\n * Handle each node when entering it,\n * or `{enter, exit}` to also handle it when exiting it.\n * @param {boolean | null | undefined} [reverse]\n * Walk children from last to first;\n * for `enter`, reverse preorder (NRL) instead of preorder (NLR);\n * for `exit`, reverse postorder (RLN) instead of postorder (LRN).\n * @returns {undefined}\n * Nothing.\n *\n * @param {UnistNode} tree\n * Tree to traverse.\n * @param {Visitor | Visitors | Test} testOrEnterOrVisitors\n * `unist-util-is`-compatible test, `enter`, or `visitors`.\n * @param {Visitor | Visitors | boolean | null | undefined} [enterOrVisitorsOrReverse]\n * `enter`, `visitors`, or `reverse` after a test.\n * @param {boolean | null | undefined} [maybeReverse]\n * Walk children from last to first;\n * for `enter`, reverse preorder (NRL) instead of preorder (NLR);\n * for `exit`, reverse postorder (RLN) instead of postorder (LRN).\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 visit(\n tree,\n testOrEnterOrVisitors,\n enterOrVisitorsOrReverse,\n maybeReverse\n) {\n /** @type {Test} */\n let check\n /** @type {Visitor | Visitors} */\n let visitors\n /** @type {boolean | null | undefined} */\n let reverse\n\n // Third parameter is an enter visitor or a visitors object, so expect a `test` too.\n if (\n typeof enterOrVisitorsOrReverse === 'function' ||\n (enterOrVisitorsOrReverse && typeof enterOrVisitorsOrReverse === 'object')\n ) {\n check = /** @type {Test} */ (testOrEnterOrVisitors)\n visitors = enterOrVisitorsOrReverse\n reverse = maybeReverse\n }\n // Assume no test.\n else {\n visitors = /** @type {Visitor | Visitors} */ (testOrEnterOrVisitors)\n reverse = enterOrVisitorsOrReverse\n }\n\n if (typeof visitors === 'function') {\n visitParents(tree, check, wrap(visitors), reverse)\n } else {\n visitParents(tree, check, wrapVisitors(visitors), reverse)\n }\n}\n\n/**\n * Turn `visit` visitors into `visitParents` visitors.\n *\n * @param {Visitors} visitors\n * Visitors for `visit`.\n * @returns {ParentsVisitors}\n * Visitors for `visitParents`.\n */\nfunction wrapVisitors(visitors) {\n // Pass anything else straight to `visitParents` to get its errors.\n if (!visitors || typeof visitors !== 'object') return visitors\n\n return {\n enter:\n typeof visitors.enter === 'function'\n ? wrap(visitors.enter)\n : visitors.enter,\n exit:\n typeof visitors.exit === 'function' ? wrap(visitors.exit) : visitors.exit\n }\n}\n\n/**\n * Turn a `visit` visitor into a `visitParents` one.\n *\n * @template {VisitorResult} Result\n * Result type.\n * @param {(node: UnistNode, index: number | undefined, parent: UnistParent | undefined) => Result} visitor\n * Visitor for `visit`.\n * @returns {(node: UnistNode, parents: Array<UnistParent>, index: number | undefined) => Result}\n * Visitor for `visitParents`.\n */\nfunction wrap(visitor) {\n return overload\n\n /**\n * Call `visitor` with `index` and `parent` instead of `parents`.\n *\n * @param {UnistNode} node\n * Visited node.\n * @param {Array<UnistParent>} parents\n * Ancestors of `node`.\n * @param {number | undefined} index\n * Index of `node` in its parent.\n * @returns {Result}\n * What to do next.\n */\n function overload(node, parents, index) {\n return visitor(node, index, parents[parents.length - 1])\n }\n}\n"],"ignoreList":[0],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8OA,SAAgB,MACd,MACA,uBACA,0BACA,cACA;;CAEA,IAAI;;CAEJ,IAAI;;CAEJ,IAAI;CAGJ,IACE,OAAO,6BAA6B,cACnC,4BAA4B,OAAO,6BAA6B,UACjE;EACA,QAA6B;EAC7B,WAAW;EACX,UAAU;CACZ,OAEK;EACH,WAA8C;EAC9C,UAAU;CACZ;CAEA,IAAI,OAAO,aAAa,YACtB,aAAa,MAAM,OAAO,KAAK,QAAQ,GAAG,OAAO;MAEjD,aAAa,MAAM,OAAO,aAAa,QAAQ,GAAG,OAAO;AAE7D;;;;;;;;;AAUA,SAAS,aAAa,UAAU;CAE9B,IAAI,CAAC,YAAY,OAAO,aAAa,UAAU,OAAO;CAEtD,OAAO;EACL,OACE,OAAO,SAAS,UAAU,aACtB,KAAK,SAAS,KAAK,IACnB,SAAS;EACf,MACE,OAAO,SAAS,SAAS,aAAa,KAAK,SAAS,IAAI,IAAI,SAAS;CACzE;AACF;;;;;;;;;;;AAYA,SAAS,KAAK,SAAS;CACrB,OAAO;;;;;;;;;;;;;CAcP,SAAS,SAAS,MAAM,SAAS,OAAO;EACtC,OAAO,QAAQ,MAAM,OAAO,QAAQ,QAAQ,SAAS,EAAE;CACzD;AACF"}