react-ai-renderer 0.1.11 → 0.1.14

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/dist/index.d.ts CHANGED
@@ -6,6 +6,7 @@ interface ComponentData$1 {
6
6
  props?: Record<string, any>;
7
7
  children?: ComponentData$1[] | string;
8
8
  selfClosing?: boolean;
9
+ isComplete?: boolean;
9
10
  }
10
11
  interface BaseComponentHandler {
11
12
  name: string;
@@ -13,7 +14,16 @@ interface BaseComponentHandler {
13
14
  }
14
15
  interface ComponentHandler extends BaseComponentHandler {
15
16
  selfClosing: boolean;
17
+ /** 组件渲染过程中的钩子(当 isComplete 为 false 时调用) */
18
+ onRenderProcess?: (item: ComponentData$1, scope: any) => void;
19
+ /** 组件渲染完成后的钩子(当 isComplete 为 true 时调用) */
20
+ onRenderFinished?: (item: ComponentData$1, scope: any) => void;
21
+ /** @deprecated 使用 onRenderProcess 替代 */
16
22
  onRender?: (item: ComponentData$1, scope: any) => void;
23
+ /** 自定义占位组件,可以是 React 组件、React 元素、字符串或返回 React 元素的函数 */
24
+ placeholder?: React.ComponentType<any> | React.ReactElement | string | ((componentName: string) => React.ReactElement);
25
+ /** 组件的显示标签,用于在占位组件中显示 */
26
+ label?: string;
17
27
  }
18
28
  interface ParserState {
19
29
  position: number;
@@ -45,6 +55,13 @@ interface ReactAIRendererProps {
45
55
  children?: string;
46
56
  /** 组件处理器数组 */
47
57
  componentHandlers?: ComponentHandler[];
58
+ /** MdxLayout 相关配置 */
59
+ /** 是否注入 GitHub Markdown 样式 */
60
+ useGithubStyles?: boolean;
61
+ /** MdxLayout 的自定义类名 */
62
+ mdxLayoutClassName?: string;
63
+ /** MdxLayout 的自定义样式 */
64
+ mdxLayoutStyle?: React.CSSProperties;
48
65
  /** 其他传递给组件的属性 */
49
66
  [key: string]: any;
50
67
  }
@@ -69,12 +86,25 @@ interface ToolCallProps {
69
86
  }
70
87
  declare const ToolCall: React.FC<ToolCallProps>;
71
88
 
89
+ interface MdxLayoutProps {
90
+ children: React.ReactNode;
91
+ className?: string;
92
+ style?: React.CSSProperties;
93
+ /**
94
+ * 是否注入 GitHub Markdown 样式
95
+ * @default true
96
+ */
97
+ useGithubStyles?: boolean;
98
+ }
99
+ declare function MdxLayout({ children, className, style, useGithubStyles }: MdxLayoutProps): React.JSX.Element;
100
+
72
101
  interface ComponentData {
73
102
  type: "text" | "component";
74
103
  value: string;
75
104
  props?: Record<string, any>;
76
105
  children?: ComponentData[] | string;
77
106
  selfClosing?: boolean;
107
+ isComplete?: boolean;
78
108
  }
79
109
  declare class MDXStreamingParser {
80
110
  private registeredComponents;
@@ -89,6 +119,6 @@ declare class MDXStreamingParser {
89
119
  reset(): void;
90
120
  }
91
121
 
92
- declare function ReactAIRenderer({ content, scope, components, children, componentHandlers }: ReactAIRendererProps): React.JSX.Element;
122
+ declare function ReactAIRenderer({ content, scope, components, children, componentHandlers, useGithubStyles, mdxLayoutClassName, mdxLayoutStyle }: ReactAIRendererProps): React.JSX.Element;
93
123
 
94
- export { ComponentData$1 as ComponentData, ComponentHandler, MDXStreamingParser, ParseResult, ParserState, ReactAIRendererProps, ReactMarkdownProps, Think, ThinkProps, ToolCall, ToolCallProps, ReactAIRenderer as default };
124
+ export { ComponentData$1 as ComponentData, ComponentHandler, MDXStreamingParser, MdxLayout, MdxLayoutProps, ParseResult, ParserState, ReactAIRendererProps, ReactMarkdownProps, Think, ThinkProps, ToolCall, ToolCallProps, ReactAIRenderer as default };