@steedos-widgets/antd 6.10.52-beta.10 → 6.10.52-beta.12
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/antd.umd.js +61 -26
- package/dist/assets.json +5 -5
- package/package.json +8 -4
package/dist/antd.umd.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
2
|
(function (global, factory) {
|
|
3
|
-
(typeof exports === "undefined" ? "undefined" : _typeof(exports)) === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('antd'), require('react-dom'), require('liquidjs')) : typeof define === 'function' && define.amd ? define(['exports', 'react', 'antd', 'react-dom', 'liquidjs'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.BuilderAntd = {}, global.React, global.antd, global.ReactDOM, global.liquidjs));
|
|
4
|
-
})(this, function (exports, React, antd, reactDom, liquidjs) {
|
|
3
|
+
(typeof exports === "undefined" ? "undefined" : _typeof(exports)) === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('antd'), require('react-dom'), require('liquidjs'), require('lodash')) : typeof define === 'function' && define.amd ? define(['exports', 'react', 'antd', 'react-dom', 'liquidjs', 'lodash'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.BuilderAntd = {}, global.React, global.antd, global.ReactDOM, global.liquidjs, global._));
|
|
4
|
+
})(this, function (exports, React, antd, reactDom, liquidjs, lodash) {
|
|
5
5
|
var global = window;
|
|
6
6
|
function _interopDefaultLegacy(e) {
|
|
7
7
|
return e && _typeof(e) === 'object' && 'default' in e ? e : {
|
|
@@ -447,6 +447,10 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
447
447
|
mountNodes = _e[0],
|
|
448
448
|
setMountNodes = _e[1];
|
|
449
449
|
var containerRef = React.useRef(null);
|
|
450
|
+
// 防抖的数据状态,用于减少 HTML 重建频率
|
|
451
|
+
// 保持最新 data 的引用,供脚本使用
|
|
452
|
+
var dataRef = React.useRef(data);
|
|
453
|
+
dataRef.current = data;
|
|
450
454
|
// 用于存储脚本清理函数的引用,以便在组件卸载或更新时清理副作用
|
|
451
455
|
var scriptCleanupsRef = React.useRef([]);
|
|
452
456
|
var finalPartials = React.useMemo(function () {
|
|
@@ -542,8 +546,9 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
542
546
|
});
|
|
543
547
|
return liq;
|
|
544
548
|
}, []);
|
|
545
|
-
|
|
546
|
-
var
|
|
549
|
+
// Track previous values for comparison (初始化为 undefined 以确保首次渲染)
|
|
550
|
+
var prevPartialsRef = React.useRef(undefined);
|
|
551
|
+
var prevParsedTemplatesRef = React.useRef(undefined);
|
|
547
552
|
React.useEffect(function () {
|
|
548
553
|
// console.log('template', template)
|
|
549
554
|
var isMounted = true;
|
|
@@ -571,27 +576,37 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
571
576
|
isMounted = false;
|
|
572
577
|
};
|
|
573
578
|
}, [engine, template]);
|
|
574
|
-
// 2. Liquid 渲染 HTML
|
|
579
|
+
// 2. Liquid 渲染 HTML(仅在模板或 partials 变化时,不在数据变化时重新渲染)
|
|
575
580
|
React.useEffect(function () {
|
|
576
|
-
|
|
581
|
+
// 跳过空模板或未解析的模板(parsedTemplates 为 null、undefined 或空数组时)
|
|
582
|
+
if (!parsedTemplates || parsedTemplates.length === 0) return;
|
|
583
|
+
// 检查 parsedTemplates 是否发生变化(模板重新解析时需要强制渲染)
|
|
584
|
+
var templatesChanged = prevParsedTemplatesRef.current !== parsedTemplates;
|
|
585
|
+
// 只在 partials 实际变化时才重新渲染
|
|
586
|
+
// 但如果 parsedTemplates 变化了(模板重新解析),必须渲染
|
|
587
|
+
// 注意:不再依赖 data 变化来重新渲染 HTML,data 变化只更新 Portal 组件
|
|
588
|
+
if (!templatesChanged && lodash.isEqual(prevPartialsRef.current, finalPartials)) {
|
|
589
|
+
return;
|
|
590
|
+
}
|
|
591
|
+
prevPartialsRef.current = finalPartials;
|
|
592
|
+
prevParsedTemplatesRef.current = parsedTemplates;
|
|
577
593
|
var isMounted = true;
|
|
578
|
-
|
|
594
|
+
// Don't clear schemas here - let them accumulate and be overwritten
|
|
595
|
+
// Clearing causes race conditions with Portal detection
|
|
596
|
+
// inlineSchemasRef.current = {};
|
|
597
|
+
// 使用当前 data 进行初始渲染 - HTML 结构不会因为数据变化而重新渲染
|
|
598
|
+
// Portal 组件会通过 props 获取实时数据更新
|
|
579
599
|
var contextData = _assign(_assign({}, flattenObjectChain(data)), {
|
|
580
600
|
__registerInlineSchema: function __registerInlineSchema(id, schema) {
|
|
581
601
|
inlineSchemasRef.current[id] = schema;
|
|
582
602
|
}
|
|
583
603
|
});
|
|
584
|
-
// console.debug('[Liquid] Start render with context:', parsedTemplates, contextData);
|
|
585
604
|
engine.render(parsedTemplates, contextData).then(function (result) {
|
|
586
605
|
if (isMounted) {
|
|
587
|
-
//
|
|
588
|
-
setHtml(function (prev) {
|
|
589
|
-
return prev !== result ? result : prev;
|
|
590
|
-
});
|
|
606
|
+
setHtml(result); // Always set to ensure Portal detection runs with fresh schemas
|
|
591
607
|
setError(null);
|
|
592
608
|
}
|
|
593
609
|
})["catch"](function (err) {
|
|
594
|
-
// console.log(`render error: `, template, contextData)
|
|
595
610
|
if (isMounted) {
|
|
596
611
|
console.error("Liquid Render Error:", err);
|
|
597
612
|
setError(err);
|
|
@@ -600,7 +615,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
600
615
|
return function () {
|
|
601
616
|
isMounted = false;
|
|
602
617
|
};
|
|
603
|
-
}, [engine, parsedTemplates,
|
|
618
|
+
}, [engine, parsedTemplates, finalPartials]); // 移除 data 依赖,只在模板变化时重新渲染
|
|
604
619
|
// 3. Portals 挂载检测
|
|
605
620
|
React.useEffect(function () {
|
|
606
621
|
if (!containerRef.current) return;
|
|
@@ -608,18 +623,30 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
608
623
|
var elements = containerRef.current.querySelectorAll('[data-amis-partial]');
|
|
609
624
|
elements.forEach(function (el) {
|
|
610
625
|
var key = el.getAttribute('data-amis-partial');
|
|
611
|
-
|
|
626
|
+
var hasInlineSchema = key && inlineSchemasRef.current[key];
|
|
627
|
+
var hasPartialSchema = key && partialsRef.current[key];
|
|
628
|
+
if (key && (hasInlineSchema || hasPartialSchema)) {
|
|
612
629
|
nodes[key] = el;
|
|
613
630
|
}
|
|
614
631
|
});
|
|
615
|
-
//
|
|
616
|
-
//
|
|
632
|
+
// 每次 html 变化都需要更新 DOM 节点引用,因为 dangerouslySetInnerHTML 会销毁并重建节点
|
|
633
|
+
// 但仅在节点实际变化时更新,避免不必要的 Portal 重新创建
|
|
617
634
|
setMountNodes(function (prev) {
|
|
618
635
|
var prevKeys = Object.keys(prev).sort().join(',');
|
|
619
636
|
var newKeys = Object.keys(nodes).sort().join(',');
|
|
620
|
-
|
|
621
|
-
//
|
|
622
|
-
|
|
637
|
+
var keysChanged = prevKeys !== newKeys;
|
|
638
|
+
// 仅在 keys 实际变化时更新(新增或删除了 Portal 挂载点)
|
|
639
|
+
if (keysChanged) {
|
|
640
|
+
return nodes;
|
|
641
|
+
}
|
|
642
|
+
// Keys 相同但 html 变了,需要更新 DOM 节点引用(dangerouslySetInnerHTML 销毁重建了节点)
|
|
643
|
+
// 但不能创建新对象,否则会触发 Portal useMemo 重新执行
|
|
644
|
+
// 所以我们更新 prev 对象中的节点引用
|
|
645
|
+
Object.keys(nodes).forEach(function (key) {
|
|
646
|
+
if (prev[key] !== nodes[key]) {
|
|
647
|
+
prev[key] = nodes[key];
|
|
648
|
+
}
|
|
649
|
+
});
|
|
623
650
|
return prev;
|
|
624
651
|
});
|
|
625
652
|
}, [html]);
|
|
@@ -628,18 +655,25 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
628
655
|
return Object.keys(mountNodes).map(function (key) {
|
|
629
656
|
var domNode = mountNodes[key];
|
|
630
657
|
var schema = inlineSchemasRef.current[key] || partialsRef.current[key];
|
|
631
|
-
if (!schema || !domNode)
|
|
658
|
+
if (!schema || !domNode) {
|
|
659
|
+
return null;
|
|
660
|
+
}
|
|
632
661
|
try {
|
|
633
662
|
return reactDom.createPortal(React__default["default"].createElement(ErrorBoundary, {
|
|
634
663
|
fallback: null
|
|
635
664
|
}, amisRender("partial-".concat(key), schema, {
|
|
636
|
-
data:
|
|
637
|
-
})), domNode
|
|
665
|
+
data: dataRef.current
|
|
666
|
+
})), domNode, key // 使用稳定的 key 基于 Partial ID
|
|
667
|
+
);
|
|
638
668
|
} catch (e) {
|
|
669
|
+
console.error('[Liquid] Portal creation error:', {
|
|
670
|
+
key: key,
|
|
671
|
+
error: e
|
|
672
|
+
});
|
|
639
673
|
return null;
|
|
640
674
|
}
|
|
641
675
|
});
|
|
642
|
-
}, [mountNodes,
|
|
676
|
+
}, [mountNodes, finalPartials, amisRender]); // Removed data dependency - use dataRef to avoid Portal recreation on data changes
|
|
643
677
|
// ==================================================================================
|
|
644
678
|
// 5. 核心逻辑:顺序加载器 (等待外部脚本加载完再执行内联脚本)
|
|
645
679
|
// ==================================================================================
|
|
@@ -723,7 +757,8 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
723
757
|
var debugName = "steedos-liquid-".concat(Math.random().toString(36).slice(2), ".js");
|
|
724
758
|
var debuggableCode = code + "\n//# sourceURL=".concat(debugName);
|
|
725
759
|
var func = new Function('data', 'dom', 'doAction', 'dispatchEvent', debuggableCode);
|
|
726
|
-
|
|
760
|
+
// 使用 dataRef.current 获取最新的 data
|
|
761
|
+
var cleanupResult = func(dataRef.current, scriptNode.parentElement, doAction, dispatchEvent);
|
|
727
762
|
if (typeof cleanupResult === 'function') {
|
|
728
763
|
scriptCleanupsRef.current.push(cleanupResult);
|
|
729
764
|
}
|
|
@@ -745,7 +780,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
745
780
|
return cleanup && cleanup();
|
|
746
781
|
});
|
|
747
782
|
};
|
|
748
|
-
}, [html
|
|
783
|
+
}, [html]); // 仅依赖 html 变化,不依赖 data 变化
|
|
749
784
|
if (error) {
|
|
750
785
|
return React__default["default"].createElement("div", {
|
|
751
786
|
className: "liquid-amis-container flex flex-col w-full overflow-auto p-4 ".concat(className || '')
|
package/dist/assets.json
CHANGED
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
{
|
|
32
32
|
"package": "@steedos-widgets/antd",
|
|
33
33
|
"urls": [
|
|
34
|
-
"https://unpkg.com/@steedos-widgets/antd@6.10.52-beta.
|
|
35
|
-
"https://unpkg.com/@steedos-widgets/antd@6.10.52-beta.
|
|
34
|
+
"https://unpkg.com/@steedos-widgets/antd@6.10.52-beta.12/dist/antd.umd.js",
|
|
35
|
+
"https://unpkg.com/@steedos-widgets/antd@6.10.52-beta.12/dist/antd.umd.css"
|
|
36
36
|
],
|
|
37
37
|
"library": "BuilderAntd"
|
|
38
38
|
}
|
|
@@ -43,10 +43,10 @@
|
|
|
43
43
|
"npm": {
|
|
44
44
|
"package": "@steedos-widgets/antd"
|
|
45
45
|
},
|
|
46
|
-
"url": "https://unpkg.com/@steedos-widgets/antd@6.10.52-beta.
|
|
46
|
+
"url": "https://unpkg.com/@steedos-widgets/antd@6.10.52-beta.12/dist/meta.js",
|
|
47
47
|
"urls": {
|
|
48
|
-
"default": "https://unpkg.com/@steedos-widgets/antd@6.10.52-beta.
|
|
49
|
-
"design": "https://unpkg.com/@steedos-widgets/antd@6.10.52-beta.
|
|
48
|
+
"default": "https://unpkg.com/@steedos-widgets/antd@6.10.52-beta.12/dist/meta.js",
|
|
49
|
+
"design": "https://unpkg.com/@steedos-widgets/antd@6.10.52-beta.12/dist/meta.js"
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
]
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steedos-widgets/antd",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "6.10.52-beta.
|
|
4
|
+
"version": "6.10.52-beta.12",
|
|
5
5
|
"main": "dist/antd.cjs.js",
|
|
6
6
|
"module": "dist/antd.esm.js",
|
|
7
7
|
"unpkg": "dist/antd.umd.js",
|
|
@@ -25,11 +25,13 @@
|
|
|
25
25
|
"@rollup/plugin-commonjs": "^29.0.0",
|
|
26
26
|
"@rollup/plugin-node-resolve": "^13.1.3",
|
|
27
27
|
"@rollup/plugin-typescript": "^8.4.0",
|
|
28
|
+
"@types/lodash": "^4.17.23",
|
|
28
29
|
"@types/react": "^18.0.8",
|
|
29
30
|
"@types/react-dom": "^18.0.6",
|
|
30
31
|
"antd": "^5.29.2",
|
|
31
32
|
"react": "18.2.0",
|
|
32
33
|
"react-dom": "18.2.0",
|
|
34
|
+
"rimraf": "^6.1.2",
|
|
33
35
|
"rollup": "^2.79.2",
|
|
34
36
|
"rollup-plugin-alias": "^2.2.0",
|
|
35
37
|
"rollup-plugin-external-globals": "^0.6.1",
|
|
@@ -45,10 +47,12 @@
|
|
|
45
47
|
"rollup-plugin-svg": "^2.0.0",
|
|
46
48
|
"rollup-plugin-terser": "^7.0.2",
|
|
47
49
|
"rollup-plugin-tslib-resolve-id": "^0.0.0",
|
|
48
|
-
"rollup-plugin-visualizer": "^5.8.0"
|
|
50
|
+
"rollup-plugin-visualizer": "^5.8.0",
|
|
51
|
+
"typescript": "^5.9.3"
|
|
49
52
|
},
|
|
50
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "7ed47ff7681033700651da8f172016a44ed7389e",
|
|
51
54
|
"dependencies": {
|
|
52
|
-
"liquidjs": "^10.24.0"
|
|
55
|
+
"liquidjs": "^10.24.0",
|
|
56
|
+
"lodash": "^4.17.23"
|
|
53
57
|
}
|
|
54
58
|
}
|