react-ai-renderer 0.1.19 → 0.1.21
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/README.md +20 -2
- package/dist/client.cjs +66670 -0
- package/dist/client.cjs.map +1 -0
- package/dist/client.d.ts +138 -0
- package/dist/client.js +66649 -0
- package/dist/client.js.map +1 -0
- package/dist/index.cjs +233 -112
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +233 -112
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -148,11 +148,14 @@ const componentHandlers = [
|
|
|
148
148
|
name: 'Button',
|
|
149
149
|
component: Button,
|
|
150
150
|
selfClosing: false,
|
|
151
|
+
onRenderStart: (item, scope) => {
|
|
152
|
+
console.log('Button 组件开始渲染:', item);
|
|
153
|
+
},
|
|
151
154
|
onRenderProcess: (item, scope) => {
|
|
152
|
-
console.log('Button
|
|
155
|
+
console.log('Button 组件渲染中:', item);
|
|
153
156
|
},
|
|
154
157
|
onRenderFinished: (item, scope) => {
|
|
155
|
-
console.log('Button
|
|
158
|
+
console.log('Button 组件渲染完成:', item);
|
|
156
159
|
}
|
|
157
160
|
}
|
|
158
161
|
];
|
|
@@ -196,6 +199,9 @@ const componentHandlers = [
|
|
|
196
199
|
name: 'MyComponent',
|
|
197
200
|
component: MyComponent,
|
|
198
201
|
selfClosing: false,
|
|
202
|
+
onRenderStart: (item, scope) => {
|
|
203
|
+
console.log('组件开始渲染:', item);
|
|
204
|
+
},
|
|
199
205
|
onRenderProcess: (item, scope) => {
|
|
200
206
|
console.log('组件渲染中:', item);
|
|
201
207
|
},
|
|
@@ -206,12 +212,24 @@ const componentHandlers = [
|
|
|
206
212
|
];
|
|
207
213
|
```
|
|
208
214
|
|
|
215
|
+
**ComponentHandler 配置项:**
|
|
216
|
+
|
|
217
|
+
- `name`: 组件名称,用于匹配 MDX 中的标签名
|
|
218
|
+
- `component`: React 组件引用
|
|
219
|
+
- `selfClosing`: 是否为自闭合标签(如 `<Image />`)
|
|
220
|
+
|
|
209
221
|
**生命周期钩子说明:**
|
|
210
222
|
|
|
223
|
+
- `onRenderStart`: 在组件开始渲染时立即触发,此时组件已被解析但尚未生成渲染内容
|
|
211
224
|
- `onRenderProcess`: 在组件流式渲染过程中触发,适用于处理渐进式渲染逻辑
|
|
212
225
|
- `onRenderFinished`: 在组件完全渲染完成后触发,适用于执行后续动作如状态更新、请求发送等
|
|
213
226
|
- `onRender`: (向后兼容)如果未定义 `onRenderProcess`,会在渲染过程中调用此钩子
|
|
214
227
|
|
|
228
|
+
**钩子参数:**
|
|
229
|
+
|
|
230
|
+
- `item`: 组件数据对象,包含 `type`、`value`(组件名)、`props`、`children`、`isComplete` 等属性
|
|
231
|
+
- `scope`: 传递给组件的作用域对象
|
|
232
|
+
|
|
215
233
|
## ⚡ 性能优势
|
|
216
234
|
|
|
217
235
|
### 实时渲染
|