@vvfx/artis 0.0.1-alpha.3 → 0.0.1-alpha.4
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/helper/html-overlay/html-card-service.d.ts +1 -2
- package/dist/index.cjs +5 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +5 -26
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: 智能画布
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 赤芍,何即,不择,意绮
|
|
6
|
-
* Version: v0.0.1-alpha.
|
|
6
|
+
* Version: v0.0.1-alpha.4
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
function _define_property$1(obj, key, value) {
|
|
@@ -134825,7 +134825,7 @@ const CARD_HTML_EVENT_MESSAGE_SOURCE = 'vvfx-card-html-event';
|
|
|
134825
134825
|
this.state.autoHeightModes.set(id, content.kind === 'inline' || content.kind === 'document' ? 'message' : 'measure');
|
|
134826
134826
|
}
|
|
134827
134827
|
/**
|
|
134828
|
-
* 为卡片挂载 Resize/Mutation
|
|
134828
|
+
* 为卡片挂载 Resize/Mutation 观察,返回清理函数
|
|
134829
134829
|
* @param id 卡片 ID
|
|
134830
134830
|
* @returns 注销观察与监听的清理函数
|
|
134831
134831
|
*/ createAutoHeightObserver(id) {
|
|
@@ -134858,25 +134858,12 @@ const CARD_HTML_EVENT_MESSAGE_SOURCE = 'vvfx-card-html-event';
|
|
|
134858
134858
|
mutationObserver.disconnect();
|
|
134859
134859
|
});
|
|
134860
134860
|
};
|
|
134861
|
-
// 2. 观察宿主挂载点,并为每个 iframe
|
|
134861
|
+
// 2. 观察宿主挂载点,并为每个 iframe 建立加载同步与同源文档观察。
|
|
134862
134862
|
const mount = this.state.contentMountElements.get(id);
|
|
134863
134863
|
observeElement(mount);
|
|
134864
134864
|
mount?.querySelectorAll('iframe').forEach((iframe)=>{
|
|
134865
134865
|
/**
|
|
134866
|
-
*
|
|
134867
|
-
* @param event 跨文档高度消息
|
|
134868
|
-
*/ const handleAutoHeightMessage = (event)=>{
|
|
134869
|
-
if (event.source !== iframe.contentWindow || !this.isAutoHeightMessage(event.data, id)) {
|
|
134870
|
-
return;
|
|
134871
|
-
}
|
|
134872
|
-
this.applyAutoHeight(id, event.data.height);
|
|
134873
|
-
};
|
|
134874
|
-
window.addEventListener('message', handleAutoHeightMessage);
|
|
134875
|
-
cleanupFns.push(()=>{
|
|
134876
|
-
window.removeEventListener('message', handleAutoHeightMessage);
|
|
134877
|
-
});
|
|
134878
|
-
/**
|
|
134879
|
-
* 在同源 iframe 就绪后解除文档高度约束,并接入自然高度观察。
|
|
134866
|
+
* 在同源 iframe 就绪后接入自然高度观察。
|
|
134880
134867
|
*/ const syncIframeDocument = ()=>{
|
|
134881
134868
|
let doc = null;
|
|
134882
134869
|
try {
|
|
@@ -134887,12 +134874,6 @@ const CARD_HTML_EVENT_MESSAGE_SOURCE = 'vvfx-card-html-event';
|
|
|
134887
134874
|
if (!doc) {
|
|
134888
134875
|
return;
|
|
134889
134876
|
}
|
|
134890
|
-
doc.documentElement.style.height = 'auto';
|
|
134891
|
-
doc.documentElement.style.minHeight = '0';
|
|
134892
|
-
if (doc.body) {
|
|
134893
|
-
doc.body.style.height = 'auto';
|
|
134894
|
-
doc.body.style.minHeight = '0';
|
|
134895
|
-
}
|
|
134896
134877
|
observeElement(doc.documentElement);
|
|
134897
134878
|
observeElement(doc.body);
|
|
134898
134879
|
this.scheduleAutoHeightMeasure(id);
|
|
@@ -134903,7 +134884,7 @@ const CARD_HTML_EVENT_MESSAGE_SOURCE = 'vvfx-card-html-event';
|
|
|
134903
134884
|
});
|
|
134904
134885
|
syncIframeDocument();
|
|
134905
134886
|
});
|
|
134906
|
-
// 3.
|
|
134887
|
+
// 3. 向调用方返回统一释放入口,确保观察器随内容卸载。
|
|
134907
134888
|
return ()=>{
|
|
134908
134889
|
cleanupFns.forEach((cleanup)=>{
|
|
134909
134890
|
cleanup();
|
|
@@ -135102,7 +135083,6 @@ const CARD_HTML_EVENT_MESSAGE_SOURCE = 'vvfx-card-html-event';
|
|
|
135102
135083
|
* @internal 由 BaseArtis 装配。
|
|
135103
135084
|
*/ constructor(options){
|
|
135104
135085
|
_define_property$1(this, "options", void 0);
|
|
135105
|
-
_define_property$1(this, "isAutoHeightMessage", void 0);
|
|
135106
135086
|
_define_property$1(this, "eventCleanups", void 0);
|
|
135107
135087
|
_define_property$1(this, "htmlRootConfigCleanups", void 0);
|
|
135108
135088
|
_define_property$1(this, "pendingContentInteractionEvent", void 0);
|
|
@@ -135129,7 +135109,6 @@ const CARD_HTML_EVENT_MESSAGE_SOURCE = 'vvfx-card-html-event';
|
|
|
135129
135109
|
* @param event 容器捕获到的上下文菜单事件
|
|
135130
135110
|
*/ _define_property$1(this, "handleContainerContextMenu", void 0);
|
|
135131
135111
|
this.options = options;
|
|
135132
|
-
this.isAutoHeightMessage = isCardHTMLAutoHeightMessage;
|
|
135133
135112
|
this.eventCleanups = [];
|
|
135134
135113
|
this.htmlRootConfigCleanups = new WeakMap();
|
|
135135
135114
|
this.state = {
|