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 CHANGED
@@ -148,10 +148,11 @@ const componentHandlers = [
148
148
  name: 'Button',
149
149
  component: Button,
150
150
  selfClosing: false,
151
- onRender: (item, scope) => {
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
- onRender: (item, scope) => {
199
- // 组件渲染完成后的回调
200
- console.log('组件已渲染:', item);
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
- jsonValue = jsonValue.replace(/([{,]\s*)([a-zA-Z_$][a-zA-Z0-9_$]*)\s*:/g, '$1"$2":');
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);