react-ai-renderer 0.1.17 → 0.1.18
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 +16 -7
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -148,10 +148,11 @@ const componentHandlers = [
|
|
|
148
148
|
name: 'Button',
|
|
149
149
|
component: Button,
|
|
150
150
|
selfClosing: false,
|
|
151
|
-
|
|
152
|
-
console.log('Button
|
|
153
|
-
|
|
154
|
-
|
|
151
|
+
onRenderProcess: (item, scope) => {
|
|
152
|
+
console.log('Button 组件渲染中...');
|
|
153
|
+
},
|
|
154
|
+
onRenderFinished: (item, scope) => {
|
|
155
|
+
console.log('Button 组件渲染完成');
|
|
155
156
|
}
|
|
156
157
|
}
|
|
157
158
|
];
|
|
@@ -195,14 +196,22 @@ const componentHandlers = [
|
|
|
195
196
|
name: 'MyComponent',
|
|
196
197
|
component: MyComponent,
|
|
197
198
|
selfClosing: false,
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
199
|
+
onRenderProcess: (item, scope) => {
|
|
200
|
+
console.log('组件渲染中:', item);
|
|
201
|
+
},
|
|
202
|
+
onRenderFinished: (item, scope) => {
|
|
203
|
+
console.log('组件渲染完成:', item);
|
|
201
204
|
}
|
|
202
205
|
}
|
|
203
206
|
];
|
|
204
207
|
```
|
|
205
208
|
|
|
209
|
+
**生命周期钩子说明:**
|
|
210
|
+
|
|
211
|
+
- `onRenderProcess`: 在组件流式渲染过程中触发,适用于处理渐进式渲染逻辑
|
|
212
|
+
- `onRenderFinished`: 在组件完全渲染完成后触发,适用于执行后续动作如状态更新、请求发送等
|
|
213
|
+
- `onRender`: (向后兼容)如果未定义 `onRenderProcess`,会在渲染过程中调用此钩子
|
|
214
|
+
|
|
206
215
|
## ⚡ 性能优势
|
|
207
216
|
|
|
208
217
|
### 实时渲染
|
package/dist/index.cjs
CHANGED
|
@@ -785,7 +785,8 @@ var MDXStreamingParser = /** @class */function () {
|
|
|
785
785
|
return "\"".concat(inner, "\"");
|
|
786
786
|
});
|
|
787
787
|
// 2. 为对象键名添加引号(如果还没有引号)
|
|
788
|
-
|
|
788
|
+
// 修复:使用 \p{L} 匹配 Unicode 字母(包括中文),使用 u 标志
|
|
789
|
+
jsonValue = jsonValue.replace(/([{,]\s*)([\p{L}_$][\p{L}\p{N}_$]*)\s*:/gu, '$1"$2":');
|
|
789
790
|
// 3. 处理属性值中的模板字符串
|
|
790
791
|
jsonValue = jsonValue.replace(/`([^`]*)`/g, function (match, p1) {
|
|
791
792
|
return JSON.stringify(p1);
|