react-ai-renderer 0.1.16 → 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
@@ -10,7 +10,6 @@ var RemarkGfm = require('remark-gfm');
10
10
  var mdx = require('@mdx-js/mdx');
11
11
  var RehypeKatex = require('rehype-katex');
12
12
  var RehypeHighlight = require('rehype-highlight');
13
- var RehypeRaw = require('rehype-raw');
14
13
 
15
14
  function _interopNamespaceDefault(e) {
16
15
  var n = Object.create(null);
@@ -786,7 +785,8 @@ var MDXStreamingParser = /** @class */function () {
786
785
  return "\"".concat(inner, "\"");
787
786
  });
788
787
  // 2. 为对象键名添加引号(如果还没有引号)
789
- 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":');
790
790
  // 3. 处理属性值中的模板字符串
791
791
  jsonValue = jsonValue.replace(/`([^`]*)`/g, function (match, p1) {
792
792
  return JSON.stringify(p1);
@@ -58359,13 +58359,13 @@ function renderText(textContent, scope, registeredComponents) {
58359
58359
  children: textContent,
58360
58360
  components: registeredComponents,
58361
58361
  remarkPlugins: [RemarkMath, RemarkGfm, RemarkBreaks],
58362
- rehypePlugins: [RehypeRaw, RehypeKatex, [RehypeHighlight, {
58362
+ rehypePlugins: [RehypeKatex, [RehypeHighlight, {
58363
58363
  detect: false,
58364
58364
  ignoreMissing: true,
58365
58365
  plainText: ['mermaid'] // 将mermaid作为纯文本处理,避免被错误高亮
58366
58366
  }]],
58367
58367
  remarkRehypeOptions: {
58368
- allowDangerousHtml: true // 允许处理 HTML 标签
58368
+ allowDangerousHtml: false // 允许处理 HTML 标签
58369
58369
  }
58370
58370
  })];
58371
58371
  });
@@ -58625,10 +58625,523 @@ function MdxLayout(_a) {
58625
58625
  });
58626
58626
  }
58627
58627
 
58628
+ function generateSkeletonByComponentName(componentName, props, style) {
58629
+ var _a, _b;
58630
+ var baseStyle = __assign({
58631
+ borderRadius: '8px',
58632
+ backgroundColor: '#f3f4f6'
58633
+ }, style);
58634
+ // 根据组件名称模式匹配生成不同的骨架图
58635
+ var name = componentName.toLowerCase();
58636
+ // 图表类组件
58637
+ if (name.includes('chart') || name.includes('graph') || name.includes('plot')) {
58638
+ return /*#__PURE__*/runtime.jsxs("div", {
58639
+ style: __assign(__assign({}, baseStyle), {
58640
+ padding: '24px',
58641
+ minHeight: (props === null || props === void 0 ? void 0 : props.height) ? "".concat(props.height, "px") : '300px',
58642
+ display: 'flex',
58643
+ flexDirection: 'column',
58644
+ gap: '12px'
58645
+ }),
58646
+ children: [/*#__PURE__*/runtime.jsxs("div", {
58647
+ style: {
58648
+ display: 'flex',
58649
+ justifyContent: 'space-between',
58650
+ alignItems: 'center',
58651
+ marginBottom: '8px'
58652
+ },
58653
+ children: [/*#__PURE__*/runtime.jsx("div", {
58654
+ style: {
58655
+ width: '120px',
58656
+ height: '20px',
58657
+ backgroundColor: '#e5e7eb',
58658
+ borderRadius: '4px'
58659
+ }
58660
+ }), /*#__PURE__*/runtime.jsx("div", {
58661
+ style: {
58662
+ width: '80px',
58663
+ height: '16px',
58664
+ backgroundColor: '#e5e7eb',
58665
+ borderRadius: '4px'
58666
+ }
58667
+ })]
58668
+ }), /*#__PURE__*/runtime.jsx("div", {
58669
+ style: {
58670
+ flex: 1,
58671
+ display: 'flex',
58672
+ alignItems: 'flex-end',
58673
+ gap: '8px',
58674
+ height: '200px'
58675
+ },
58676
+ children: Array.from({
58677
+ length: 8
58678
+ }).map(function (_, i) {
58679
+ return /*#__PURE__*/runtime.jsx("div", {
58680
+ style: {
58681
+ flex: 1,
58682
+ height: "".concat(Math.random() * 60 + 40, "%"),
58683
+ backgroundColor: '#d1d5db',
58684
+ borderRadius: '4px 4px 0 0',
58685
+ animation: 'pulse 1.5s ease-in-out infinite',
58686
+ animationDelay: "".concat(i * 0.1, "s")
58687
+ }
58688
+ }, i);
58689
+ })
58690
+ }), /*#__PURE__*/runtime.jsx("div", {
58691
+ style: {
58692
+ display: 'flex',
58693
+ gap: '12px',
58694
+ marginTop: '8px'
58695
+ },
58696
+ children: Array.from({
58697
+ length: 3
58698
+ }).map(function (_, i) {
58699
+ return /*#__PURE__*/runtime.jsxs("div", {
58700
+ style: {
58701
+ display: 'flex',
58702
+ alignItems: 'center',
58703
+ gap: '6px'
58704
+ },
58705
+ children: [/*#__PURE__*/runtime.jsx("div", {
58706
+ style: {
58707
+ width: '12px',
58708
+ height: '12px',
58709
+ backgroundColor: '#d1d5db',
58710
+ borderRadius: '2px'
58711
+ }
58712
+ }), /*#__PURE__*/runtime.jsx("div", {
58713
+ style: {
58714
+ width: '60px',
58715
+ height: '12px',
58716
+ backgroundColor: '#e5e7eb',
58717
+ borderRadius: '2px'
58718
+ }
58719
+ })]
58720
+ }, i);
58721
+ })
58722
+ }), /*#__PURE__*/runtime.jsx("style", {
58723
+ children: "\n @keyframes pulse {\n 0%, 100% { opacity: 1; }\n 50% { opacity: 0.5; }\n }\n "
58724
+ })]
58725
+ });
58726
+ }
58727
+ // 表格类组件
58728
+ if (name.includes('table') || name.includes('grid')) {
58729
+ var rowCount_1 = (props === null || props === void 0 ? void 0 : props.rows) || 5;
58730
+ var colCount_1 = (props === null || props === void 0 ? void 0 : props.columns) || 4;
58731
+ return /*#__PURE__*/runtime.jsxs("div", {
58732
+ style: __assign(__assign({}, baseStyle), {
58733
+ padding: '16px',
58734
+ overflow: 'hidden'
58735
+ }),
58736
+ children: [/*#__PURE__*/runtime.jsxs("div", {
58737
+ style: {
58738
+ marginBottom: '12px'
58739
+ },
58740
+ children: [/*#__PURE__*/runtime.jsx("div", {
58741
+ style: {
58742
+ width: '150px',
58743
+ height: '20px',
58744
+ backgroundColor: '#e5e7eb',
58745
+ borderRadius: '4px',
58746
+ marginBottom: '8px'
58747
+ }
58748
+ }), /*#__PURE__*/runtime.jsx("div", {
58749
+ style: {
58750
+ width: '200px',
58751
+ height: '16px',
58752
+ backgroundColor: '#e5e7eb',
58753
+ borderRadius: '4px'
58754
+ }
58755
+ })]
58756
+ }), /*#__PURE__*/runtime.jsxs("div", {
58757
+ style: {
58758
+ border: '1px solid #e5e7eb',
58759
+ borderRadius: '4px',
58760
+ overflow: 'hidden'
58761
+ },
58762
+ children: [/*#__PURE__*/runtime.jsx("div", {
58763
+ style: {
58764
+ display: 'grid',
58765
+ gridTemplateColumns: "repeat(".concat(colCount_1, ", 1fr)"),
58766
+ backgroundColor: '#f9fafb',
58767
+ borderBottom: '1px solid #e5e7eb'
58768
+ },
58769
+ children: Array.from({
58770
+ length: colCount_1
58771
+ }).map(function (_, i) {
58772
+ return /*#__PURE__*/runtime.jsx("div", {
58773
+ style: {
58774
+ padding: '12px',
58775
+ borderRight: i < colCount_1 - 1 ? '1px solid #e5e7eb' : 'none'
58776
+ },
58777
+ children: /*#__PURE__*/runtime.jsx("div", {
58778
+ style: {
58779
+ width: '80%',
58780
+ height: '16px',
58781
+ backgroundColor: '#d1d5db',
58782
+ borderRadius: '2px'
58783
+ }
58784
+ })
58785
+ }, i);
58786
+ })
58787
+ }), Array.from({
58788
+ length: rowCount_1
58789
+ }).map(function (_, rowIndex) {
58790
+ return /*#__PURE__*/runtime.jsx("div", {
58791
+ style: {
58792
+ display: 'grid',
58793
+ gridTemplateColumns: "repeat(".concat(colCount_1, ", 1fr)"),
58794
+ borderBottom: rowIndex < rowCount_1 - 1 ? '1px solid #e5e7eb' : 'none'
58795
+ },
58796
+ children: Array.from({
58797
+ length: colCount_1
58798
+ }).map(function (_, colIndex) {
58799
+ return /*#__PURE__*/runtime.jsx("div", {
58800
+ style: {
58801
+ padding: '12px',
58802
+ borderRight: colIndex < colCount_1 - 1 ? '1px solid #e5e7eb' : 'none'
58803
+ },
58804
+ children: /*#__PURE__*/runtime.jsx("div", {
58805
+ style: {
58806
+ width: "".concat(Math.random() * 40 + 60, "%"),
58807
+ height: '14px',
58808
+ backgroundColor: '#e5e7eb',
58809
+ borderRadius: '2px'
58810
+ }
58811
+ })
58812
+ }, colIndex);
58813
+ })
58814
+ }, rowIndex);
58815
+ })]
58816
+ })]
58817
+ });
58818
+ }
58819
+ // 卡片类组件
58820
+ if (name.includes('card')) {
58821
+ return /*#__PURE__*/runtime.jsxs("div", {
58822
+ style: __assign(__assign({}, baseStyle), {
58823
+ padding: '20px',
58824
+ minHeight: '200px'
58825
+ }),
58826
+ children: [/*#__PURE__*/runtime.jsx("div", {
58827
+ style: {
58828
+ width: '60%',
58829
+ height: '24px',
58830
+ backgroundColor: '#e5e7eb',
58831
+ borderRadius: '4px',
58832
+ marginBottom: '16px'
58833
+ }
58834
+ }), /*#__PURE__*/runtime.jsx("div", {
58835
+ style: {
58836
+ width: '100%',
58837
+ height: '16px',
58838
+ backgroundColor: '#e5e7eb',
58839
+ borderRadius: '4px',
58840
+ marginBottom: '8px'
58841
+ }
58842
+ }), /*#__PURE__*/runtime.jsx("div", {
58843
+ style: {
58844
+ width: '90%',
58845
+ height: '16px',
58846
+ backgroundColor: '#e5e7eb',
58847
+ borderRadius: '4px',
58848
+ marginBottom: '8px'
58849
+ }
58850
+ }), /*#__PURE__*/runtime.jsx("div", {
58851
+ style: {
58852
+ width: '70%',
58853
+ height: '16px',
58854
+ backgroundColor: '#e5e7eb',
58855
+ borderRadius: '4px',
58856
+ marginBottom: '16px'
58857
+ }
58858
+ }), /*#__PURE__*/runtime.jsxs("div", {
58859
+ style: {
58860
+ display: 'flex',
58861
+ gap: '8px',
58862
+ marginTop: '16px'
58863
+ },
58864
+ children: [/*#__PURE__*/runtime.jsx("div", {
58865
+ style: {
58866
+ width: '80px',
58867
+ height: '32px',
58868
+ backgroundColor: '#d1d5db',
58869
+ borderRadius: '4px'
58870
+ }
58871
+ }), /*#__PURE__*/runtime.jsx("div", {
58872
+ style: {
58873
+ width: '80px',
58874
+ height: '32px',
58875
+ backgroundColor: '#d1d5db',
58876
+ borderRadius: '4px'
58877
+ }
58878
+ })]
58879
+ })]
58880
+ });
58881
+ }
58882
+ // 列表类组件
58883
+ if (name.includes('list') || name.includes('todo')) {
58884
+ var itemCount_1 = ((_a = props === null || props === void 0 ? void 0 : props.items) === null || _a === void 0 ? void 0 : _a.length) || (props === null || props === void 0 ? void 0 : props.count) || 3;
58885
+ return /*#__PURE__*/runtime.jsx("div", {
58886
+ style: __assign(__assign({}, baseStyle), {
58887
+ padding: '16px'
58888
+ }),
58889
+ children: Array.from({
58890
+ length: itemCount_1
58891
+ }).map(function (_, i) {
58892
+ return /*#__PURE__*/runtime.jsxs("div", {
58893
+ style: {
58894
+ display: 'flex',
58895
+ alignItems: 'center',
58896
+ gap: '12px',
58897
+ marginBottom: i < itemCount_1 - 1 ? '12px' : '0',
58898
+ paddingBottom: i < itemCount_1 - 1 ? '12px' : '0',
58899
+ borderBottom: i < itemCount_1 - 1 ? '1px solid #e5e7eb' : 'none'
58900
+ },
58901
+ children: [/*#__PURE__*/runtime.jsx("div", {
58902
+ style: {
58903
+ width: '20px',
58904
+ height: '20px',
58905
+ backgroundColor: '#d1d5db',
58906
+ borderRadius: '4px',
58907
+ flexShrink: 0
58908
+ }
58909
+ }), /*#__PURE__*/runtime.jsxs("div", {
58910
+ style: {
58911
+ flex: 1
58912
+ },
58913
+ children: [/*#__PURE__*/runtime.jsx("div", {
58914
+ style: {
58915
+ width: "".concat(Math.random() * 30 + 60, "%"),
58916
+ height: '16px',
58917
+ backgroundColor: '#e5e7eb',
58918
+ borderRadius: '4px',
58919
+ marginBottom: '6px'
58920
+ }
58921
+ }), /*#__PURE__*/runtime.jsx("div", {
58922
+ style: {
58923
+ width: "".concat(Math.random() * 40 + 40, "%"),
58924
+ height: '14px',
58925
+ backgroundColor: '#e5e7eb',
58926
+ borderRadius: '4px'
58927
+ }
58928
+ })]
58929
+ })]
58930
+ }, i);
58931
+ })
58932
+ });
58933
+ }
58934
+ // 表单类组件
58935
+ if (name.includes('form') || name.includes('input') || name.includes('select')) {
58936
+ var fieldCount_1 = ((_b = props === null || props === void 0 ? void 0 : props.fields) === null || _b === void 0 ? void 0 : _b.length) || 3;
58937
+ return /*#__PURE__*/runtime.jsxs("div", {
58938
+ style: __assign(__assign({}, baseStyle), {
58939
+ padding: '20px'
58940
+ }),
58941
+ children: [Array.from({
58942
+ length: fieldCount_1
58943
+ }).map(function (_, i) {
58944
+ return /*#__PURE__*/runtime.jsxs("div", {
58945
+ style: {
58946
+ marginBottom: i < fieldCount_1 - 1 ? '20px' : '0'
58947
+ },
58948
+ children: [/*#__PURE__*/runtime.jsx("div", {
58949
+ style: {
58950
+ width: '100px',
58951
+ height: '14px',
58952
+ backgroundColor: '#e5e7eb',
58953
+ borderRadius: '2px',
58954
+ marginBottom: '8px'
58955
+ }
58956
+ }), /*#__PURE__*/runtime.jsx("div", {
58957
+ style: {
58958
+ width: '100%',
58959
+ height: '40px',
58960
+ backgroundColor: '#f3f4f6',
58961
+ border: '1px solid #e5e7eb',
58962
+ borderRadius: '4px'
58963
+ }
58964
+ })]
58965
+ }, i);
58966
+ }), /*#__PURE__*/runtime.jsxs("div", {
58967
+ style: {
58968
+ display: 'flex',
58969
+ gap: '12px',
58970
+ marginTop: '20px'
58971
+ },
58972
+ children: [/*#__PURE__*/runtime.jsx("div", {
58973
+ style: {
58974
+ width: '100px',
58975
+ height: '36px',
58976
+ backgroundColor: '#d1d5db',
58977
+ borderRadius: '4px'
58978
+ }
58979
+ }), /*#__PURE__*/runtime.jsx("div", {
58980
+ style: {
58981
+ width: '100px',
58982
+ height: '36px',
58983
+ backgroundColor: '#e5e7eb',
58984
+ borderRadius: '4px'
58985
+ }
58986
+ })]
58987
+ })]
58988
+ });
58989
+ }
58990
+ // 图片/媒体类组件
58991
+ if (name.includes('image') || name.includes('img') || name.includes('video') || name.includes('media')) {
58992
+ return /*#__PURE__*/runtime.jsx("div", {
58993
+ style: __assign(__assign({}, baseStyle), {
58994
+ padding: '16px',
58995
+ display: 'flex',
58996
+ alignItems: 'center',
58997
+ justifyContent: 'center',
58998
+ minHeight: (props === null || props === void 0 ? void 0 : props.height) ? "".concat(props.height, "px") : '200px'
58999
+ }),
59000
+ children: /*#__PURE__*/runtime.jsx("div", {
59001
+ style: {
59002
+ width: '100%',
59003
+ height: '100%',
59004
+ backgroundColor: '#e5e7eb',
59005
+ borderRadius: '8px',
59006
+ display: 'flex',
59007
+ alignItems: 'center',
59008
+ justifyContent: 'center'
59009
+ },
59010
+ children: /*#__PURE__*/runtime.jsx("div", {
59011
+ style: {
59012
+ width: '48px',
59013
+ height: '48px',
59014
+ backgroundColor: '#d1d5db',
59015
+ borderRadius: '50%',
59016
+ display: 'flex',
59017
+ alignItems: 'center',
59018
+ justifyContent: 'center'
59019
+ },
59020
+ children: /*#__PURE__*/runtime.jsx("div", {
59021
+ style: {
59022
+ width: '24px',
59023
+ height: '24px',
59024
+ backgroundColor: '#9ca3af',
59025
+ borderRadius: '4px'
59026
+ }
59027
+ })
59028
+ })
59029
+ })
59030
+ });
59031
+ }
59032
+ // 默认骨架图
59033
+ return /*#__PURE__*/runtime.jsxs("div", {
59034
+ style: __assign(__assign({}, baseStyle), {
59035
+ padding: '24px',
59036
+ minHeight: '120px',
59037
+ display: 'flex',
59038
+ flexDirection: 'column',
59039
+ gap: '12px',
59040
+ alignItems: 'center',
59041
+ justifyContent: 'center'
59042
+ }),
59043
+ children: [/*#__PURE__*/runtime.jsxs("div", {
59044
+ style: {
59045
+ width: '100%',
59046
+ maxWidth: '400px'
59047
+ },
59048
+ children: [/*#__PURE__*/runtime.jsx("div", {
59049
+ style: {
59050
+ width: '60%',
59051
+ height: '20px',
59052
+ backgroundColor: '#e5e7eb',
59053
+ borderRadius: '4px',
59054
+ marginBottom: '12px'
59055
+ }
59056
+ }), /*#__PURE__*/runtime.jsx("div", {
59057
+ style: {
59058
+ width: '100%',
59059
+ height: '16px',
59060
+ backgroundColor: '#e5e7eb',
59061
+ borderRadius: '4px',
59062
+ marginBottom: '8px'
59063
+ }
59064
+ }), /*#__PURE__*/runtime.jsx("div", {
59065
+ style: {
59066
+ width: '90%',
59067
+ height: '16px',
59068
+ backgroundColor: '#e5e7eb',
59069
+ borderRadius: '4px',
59070
+ marginBottom: '8px'
59071
+ }
59072
+ }), /*#__PURE__*/runtime.jsx("div", {
59073
+ style: {
59074
+ width: '75%',
59075
+ height: '16px',
59076
+ backgroundColor: '#e5e7eb',
59077
+ borderRadius: '4px'
59078
+ }
59079
+ })]
59080
+ }), /*#__PURE__*/runtime.jsxs("div", {
59081
+ style: {
59082
+ display: 'flex',
59083
+ gap: '8px',
59084
+ marginTop: '12px'
59085
+ },
59086
+ children: [/*#__PURE__*/runtime.jsx("div", {
59087
+ style: {
59088
+ width: '60px',
59089
+ height: '32px',
59090
+ backgroundColor: '#d1d5db',
59091
+ borderRadius: '4px'
59092
+ }
59093
+ }), /*#__PURE__*/runtime.jsx("div", {
59094
+ style: {
59095
+ width: '60px',
59096
+ height: '32px',
59097
+ backgroundColor: '#d1d5db',
59098
+ borderRadius: '4px'
59099
+ }
59100
+ })]
59101
+ })]
59102
+ });
59103
+ }
59104
+ /**
59105
+ * 创建骨架图组件
59106
+ */
59107
+ function createSkeletonComponent(componentName, componentData, skeletonConfig, style) {
59108
+ // 如果提供了自定义骨架图组件
59109
+ if (skeletonConfig === null || skeletonConfig === void 0 ? void 0 : skeletonConfig.component) {
59110
+ var SkeletonComponent = skeletonConfig.component;
59111
+ return /*#__PURE__*/runtime.jsx(SkeletonComponent, {
59112
+ componentName: componentName,
59113
+ componentData: componentData,
59114
+ props: componentData === null || componentData === void 0 ? void 0 : componentData.props,
59115
+ style: style
59116
+ });
59117
+ }
59118
+ // 如果提供了自定义骨架图元素
59119
+ if (skeletonConfig === null || skeletonConfig === void 0 ? void 0 : skeletonConfig.element) {
59120
+ return skeletonConfig.element;
59121
+ }
59122
+ // 如果提供了自定义生成函数
59123
+ if (skeletonConfig === null || skeletonConfig === void 0 ? void 0 : skeletonConfig.generator) {
59124
+ return skeletonConfig.generator({
59125
+ componentName: componentName,
59126
+ componentData: componentData,
59127
+ props: componentData === null || componentData === void 0 ? void 0 : componentData.props,
59128
+ style: style
59129
+ });
59130
+ }
59131
+ // 如果启用了自动生成,或者没有提供任何配置
59132
+ if ((skeletonConfig === null || skeletonConfig === void 0 ? void 0 : skeletonConfig.autoGenerate) !== false) {
59133
+ return generateSkeletonByComponentName(componentName, componentData === null || componentData === void 0 ? void 0 : componentData.props, style);
59134
+ }
59135
+ // 默认返回空
59136
+ return /*#__PURE__*/runtime.jsx(React.Fragment, {});
59137
+ }
59138
+
58628
59139
  var ComponentPlaceholder = function (_a) {
58629
59140
  var componentName = _a.componentName,
58630
59141
  style = _a.style,
58631
- loader = _a.loader;
59142
+ loader = _a.loader,
59143
+ skeleton = _a.skeleton,
59144
+ componentData = _a.componentData;
58632
59145
  // 如果有自定义加载内容,优先使用
58633
59146
  if (loader) {
58634
59147
  // 如果是布尔值 true,使用默认样式
@@ -58680,6 +59193,19 @@ var ComponentPlaceholder = function (_a) {
58680
59193
  }
58681
59194
  }
58682
59195
  }
59196
+ // 如果没有 loader,尝试使用骨架图
59197
+ if (skeleton || !loader) {
59198
+ try {
59199
+ var skeletonElement = createSkeletonComponent(componentName, componentData, skeleton, style);
59200
+ // 如果骨架图生成成功且不是空元素,使用骨架图
59201
+ if (skeletonElement && /*#__PURE__*/React.isValidElement(skeletonElement)) {
59202
+ return skeletonElement;
59203
+ }
59204
+ } catch (e) {
59205
+ // 如果骨架图生成失败,继续使用默认占位内容
59206
+ console.warn('Failed to generate skeleton:', e);
59207
+ }
59208
+ }
58683
59209
  // 默认占位内容
58684
59210
  return /*#__PURE__*/runtime.jsxs("div", {
58685
59211
  style: __assign({