react-ai-renderer 0.1.15 → 0.1.17
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.cjs +699 -68
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +49 -5
- package/dist/index.js +699 -68
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* 骨架图配置接口
|
|
5
|
+
*/
|
|
6
|
+
interface SkeletonConfig {
|
|
7
|
+
/** 自定义骨架图组件 */
|
|
8
|
+
component?: React.ComponentType<SkeletonProps>;
|
|
9
|
+
/** 自定义骨架图元素 */
|
|
10
|
+
element?: React.ReactElement;
|
|
11
|
+
/** 自定义骨架图生成函数 */
|
|
12
|
+
generator?: (props: SkeletonProps) => React.ReactElement;
|
|
13
|
+
/** 是否启用自动生成 */
|
|
14
|
+
autoGenerate?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* 骨架图组件的属性
|
|
18
|
+
*/
|
|
19
|
+
interface SkeletonProps {
|
|
20
|
+
componentName: string;
|
|
21
|
+
componentData?: ComponentData$1;
|
|
22
|
+
props?: Record<string, any>;
|
|
23
|
+
style?: React.CSSProperties;
|
|
24
|
+
}
|
|
25
|
+
|
|
3
26
|
interface ComponentData$1 {
|
|
4
27
|
type: "text" | "component";
|
|
5
28
|
value: string;
|
|
@@ -20,11 +43,32 @@ interface ComponentHandler extends BaseComponentHandler {
|
|
|
20
43
|
onRenderFinished?: (item: ComponentData$1, scope: any) => void;
|
|
21
44
|
/** @deprecated 使用 onRenderProcess 替代 */
|
|
22
45
|
onRender?: (item: ComponentData$1, scope: any) => void;
|
|
23
|
-
/**
|
|
24
|
-
|
|
46
|
+
/** 自定义加载组件,可以是 React 组件、React 元素、字符串、布尔值或返回 React 元素的函数 */
|
|
47
|
+
loader?: React.ComponentType<any> | React.ReactElement | string | boolean | ((componentName: string) => React.ReactElement);
|
|
48
|
+
/** 骨架图配置,用于在加载时显示骨架图。如果未提供且 loader 也未提供,将自动根据组件名称生成骨架图 */
|
|
49
|
+
skeleton?: SkeletonConfig;
|
|
25
50
|
/** 组件的显示标签,用于在占位组件中显示 */
|
|
26
51
|
label?: string;
|
|
27
52
|
}
|
|
53
|
+
/** 增强模式的组件配置 */
|
|
54
|
+
interface EnhancedComponentConfig {
|
|
55
|
+
/** 组件本身 */
|
|
56
|
+
value: React.ComponentType<any>;
|
|
57
|
+
/** 组件的显示标签 */
|
|
58
|
+
label?: string;
|
|
59
|
+
/** 自定义加载组件,可以是 React 组件、React 元素、字符串、布尔值或返回 React 元素的函数 */
|
|
60
|
+
loader?: React.ComponentType<any> | React.ReactElement | string | boolean | ((componentName: string) => React.ReactElement);
|
|
61
|
+
/** 骨架图配置,用于在加载时显示骨架图。如果未提供且 loader 也未提供,将自动根据组件名称生成骨架图 */
|
|
62
|
+
skeleton?: SkeletonConfig;
|
|
63
|
+
/** 组件渲染完成后的钩子 */
|
|
64
|
+
onRenderFinished?: (item: ComponentData$1, scope: any) => void;
|
|
65
|
+
/** 组件渲染过程中的钩子 */
|
|
66
|
+
onRenderProcess?: (item: ComponentData$1, scope: any) => void;
|
|
67
|
+
/** 是否自闭合 */
|
|
68
|
+
selfClosing?: boolean;
|
|
69
|
+
}
|
|
70
|
+
/** 组件值类型:可以是组件本身,也可以是增强配置对象 */
|
|
71
|
+
type ComponentValue = React.ComponentType<any> | EnhancedComponentConfig;
|
|
28
72
|
interface ParserState {
|
|
29
73
|
position: number;
|
|
30
74
|
stack: ComponentData$1[];
|
|
@@ -49,8 +93,8 @@ interface ReactAIRendererProps {
|
|
|
49
93
|
content?: string;
|
|
50
94
|
/** 作用域对象,用于传递变量和函数给组件 */
|
|
51
95
|
scope?: Record<string, any>;
|
|
52
|
-
/**
|
|
53
|
-
components?: Record<string,
|
|
96
|
+
/** 自定义组件映射,支持普通模式(组件)和增强模式(配置对象) */
|
|
97
|
+
components?: Record<string, ComponentValue>;
|
|
54
98
|
/** 子元素,作为 content 的替代方案 */
|
|
55
99
|
children?: string;
|
|
56
100
|
/** 组件处理器数组 */
|
|
@@ -121,4 +165,4 @@ declare class MDXStreamingParser {
|
|
|
121
165
|
|
|
122
166
|
declare function ReactAIRenderer({ content, scope, components, children, componentHandlers, useGithubStyles, mdxLayoutClassName, mdxLayoutStyle }: ReactAIRendererProps): React.JSX.Element;
|
|
123
167
|
|
|
124
|
-
export { ComponentData$1 as ComponentData, ComponentHandler, MDXStreamingParser, MdxLayout, MdxLayoutProps, ParseResult, ParserState, ReactAIRendererProps, ReactMarkdownProps, Think, ThinkProps, ToolCall, ToolCallProps, ReactAIRenderer as default };
|
|
168
|
+
export { ComponentData$1 as ComponentData, ComponentHandler, ComponentValue, EnhancedComponentConfig, MDXStreamingParser, MdxLayout, MdxLayoutProps, ParseResult, ParserState, ReactAIRendererProps, ReactMarkdownProps, Think, ThinkProps, ToolCall, ToolCallProps, ReactAIRenderer as default };
|