@vvfx/sdk 0.2.2-beta.16 → 0.2.2-beta.17
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/config.d.ts +5 -0
- package/dist/html-overlay/anchor-navigation-runtime.d.ts +1 -0
- package/dist/html-overlay/manager.d.ts +12 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +258 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +258 -31
- package/dist/index.mjs.map +1 -1
- package/dist/sdk.d.ts +25 -0
- package/dist/types.d.ts +60 -0
- package/package.json +1 -1
package/dist/config.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { CardHTML } from './types';
|
|
|
4
4
|
import type { CardItem } from './sdk-item/card-item';
|
|
5
5
|
export type SDKMode = 'editor' | 'template';
|
|
6
6
|
export type CardTypeHTMLResolver = (item: CardItem) => CardHTML | undefined;
|
|
7
|
+
export type CardAutoHeightAnchor = 'top' | 'center';
|
|
7
8
|
/**
|
|
8
9
|
* @description SDK功能配置
|
|
9
10
|
*/
|
|
@@ -147,6 +148,10 @@ export type CardTypeConfig = {
|
|
|
147
148
|
* @description 是否根据 HTML 挂载内容的自然高度自动更新卡片高度
|
|
148
149
|
*/
|
|
149
150
|
autoHeight?: boolean;
|
|
151
|
+
/**
|
|
152
|
+
* @description autoHeight 更新卡片高度时的锚点。top 保持上边缘不动,center 保持中心点不动。未配置时默认 top。
|
|
153
|
+
*/
|
|
154
|
+
autoHeightAnchor?: CardAutoHeightAnchor;
|
|
150
155
|
/**
|
|
151
156
|
* @description HTML 内容是否跟随卡片 scale 缩放,关闭后 HTML 按最终显示尺寸重新布局
|
|
152
157
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function withCardHTMLAnchorNavigationGuard(html: string, allowAnchorNavigation?: boolean): string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Box2 } from '../math';
|
|
2
2
|
import { type SnapdomOptions } from '@zumer/snapdom';
|
|
3
|
-
import type { CardTypeConfig } from '../config';
|
|
3
|
+
import type { CardAutoHeightAnchor, CardTypeConfig } from '../config';
|
|
4
4
|
import type { EventEmitter } from '../shared';
|
|
5
5
|
import type { SDKEvents } from '../sdk';
|
|
6
6
|
import { type SDKItem } from '../sdk-item';
|
|
@@ -11,6 +11,10 @@ type CardRasterizeOptions = {
|
|
|
11
11
|
pixelRatio?: number;
|
|
12
12
|
snapdomOptions?: SnapdomOptions;
|
|
13
13
|
};
|
|
14
|
+
type SetCardItemHeightOptions = {
|
|
15
|
+
anchor: CardAutoHeightAnchor;
|
|
16
|
+
previousHeight: number;
|
|
17
|
+
};
|
|
14
18
|
type HTMLOverlayManagerOptions = {
|
|
15
19
|
container: HTMLElement;
|
|
16
20
|
emitter: EventEmitter<SDKEvents>;
|
|
@@ -25,7 +29,7 @@ type HTMLOverlayManagerOptions = {
|
|
|
25
29
|
translation: [number, number];
|
|
26
30
|
}) => void;
|
|
27
31
|
viewportFit: (box: Box2) => void;
|
|
28
|
-
setCardItemHeight: (id: string, height: number) => void;
|
|
32
|
+
setCardItemHeight: (id: string, height: number, options: SetCardItemHeightOptions) => void;
|
|
29
33
|
getSelectedItemIds: () => string[];
|
|
30
34
|
getPreSelectedItemId: () => string | undefined;
|
|
31
35
|
getSelectionEdgeStyle: () => {
|
|
@@ -55,6 +59,9 @@ export declare class HTMLOverlayManager {
|
|
|
55
59
|
dispose(): void;
|
|
56
60
|
scheduleRender(): void;
|
|
57
61
|
invalidateCardHTML(id: string): void;
|
|
62
|
+
getHtmlCardWindow(id: string): Window | null | undefined;
|
|
63
|
+
patchCardHTML(id: string, patch: unknown): boolean;
|
|
64
|
+
dispatchHtmlCardEvent(id: string, type: string, detail?: unknown): boolean;
|
|
58
65
|
rasterizeCard(id: string, options: CardRasterizeOptions): Promise<string | undefined>;
|
|
59
66
|
private initEvents;
|
|
60
67
|
private initDOMEvents;
|
|
@@ -106,8 +113,10 @@ export declare class HTMLOverlayManager {
|
|
|
106
113
|
private getEditingFitZoom;
|
|
107
114
|
private isEventInsideOverlay;
|
|
108
115
|
private renderOverlayHTML;
|
|
116
|
+
private createPatchContext;
|
|
109
117
|
private observeContentInteractionZones;
|
|
110
118
|
private applyHTMLRootConfig;
|
|
119
|
+
private makeSelectionOverlayTransparent;
|
|
111
120
|
private renderOverlayContent;
|
|
112
121
|
private chainCleanups;
|
|
113
122
|
private cleanupOverlayContent;
|
|
@@ -122,6 +131,7 @@ export declare class HTMLOverlayManager {
|
|
|
122
131
|
private getChildrenNaturalHeight;
|
|
123
132
|
private cleanupAutoHeight;
|
|
124
133
|
private applyAutoHeight;
|
|
134
|
+
private getAutoHeightAnchor;
|
|
125
135
|
private getAutoHeightItemHeight;
|
|
126
136
|
private isAutoHeightMessage;
|
|
127
137
|
private isAutoHeightEnabled;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export type { SDKOptions, SDKInputParam, PageData, PageProperty, ViewProperty, ActiveData, ViewParam, BaseItemProperty, SpriteItemProperty, TextItemProperty, VideoItemProperty, GeneratorItemProperty, FrameItemProperty, FrameLayoutMode, SpriteCreateInfo, TextCreateInfo, GroupCreateInfo, VideoCreateInfo, GeneratorCreateInfo, EffectsCreateInfo, FrameCreateInfo, CardCreateInfo, CardItemProperty, CardItemTransformInfo, CardHTML, CardHTMLContent, CardHTMLInlineContent, CardHTMLDOMRendererContent, CardHTMLDocumentContent, CardHTMLDocumentMessage, CardHTMLShellContent, CardHTMLShellRenderer, CardHTMLShellRendererContext, CardHTMLShellRendererResult, CardHTMLDOMRenderer, CardHTMLContentCleanup, CardHTMLRenderCleanup, CardHTMLRootConfig, CardHTMLRootStyle, ItemCreateInfo, } from './types';
|
|
2
|
-
export type { SDKConfig, SDKMode, CardTypeConfig, CardConfig, CardTypeHTMLResolver, } from './config';
|
|
1
|
+
export type { SDKOptions, SDKInputParam, PageData, PageProperty, ViewProperty, ActiveData, ViewParam, BaseItemProperty, SpriteItemProperty, TextItemProperty, VideoItemProperty, GeneratorItemProperty, FrameItemProperty, FrameLayoutMode, SpriteCreateInfo, TextCreateInfo, GroupCreateInfo, VideoCreateInfo, GeneratorCreateInfo, EffectsCreateInfo, FrameCreateInfo, CardCreateInfo, CardItemProperty, CardItemTransformInfo, CardHTML, CardHTMLContent, CardHTMLInlineContent, CardHTMLDOMRendererContent, CardHTMLDocumentContent, CardHTMLDocumentMessage, CardHTMLShellContent, CardHTMLShellRenderer, CardHTMLShellRendererContext, CardHTMLShellRendererResult, CardHTMLDOMRenderer, CardHTMLContentCleanup, CardHTMLRenderCleanup, CardHTMLPatchContext, CardHTMLPatchHandler, CardHTMLWindowEventMessage, CardHTMLRootConfig, CardHTMLRootStyle, ItemCreateInfo, } from './types';
|
|
2
|
+
export type { SDKConfig, SDKMode, CardTypeConfig, CardConfig, CardAutoHeightAnchor, CardTypeHTMLResolver, } from './config';
|
|
3
3
|
export type { SDKItem } from './sdk-item';
|
|
4
4
|
export { BaseItem, SpriteItem, TextItem, VideoItem, GroupItem, GeneratorItem, EffectsItem, FrameItem, CardItem, isBaseItem, isSpriteItem, isTextItem, isVideoItem, isGroupItem, isGeneratorItem, isEffectsItem, isFrameItem, isCardItem, SDKItemType, } from './sdk-item';
|
|
5
5
|
export type { SDKItemOptions, SpriteItemOptions, TextItemOptions, VideoItemOptions, GroupItemOptions, GeneratorItemOptions, EffectsItemOptions, FrameItemOptions, CardItemOptions, } from './sdk-item';
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: TODO
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 赤芍,何即,不择,意绮
|
|
6
|
-
* Version: v0.2.2-beta.
|
|
6
|
+
* Version: v0.2.2-beta.17
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import * as EFFECTS from '@galacean/effects';
|
|
@@ -91691,6 +91691,17 @@ function withCardHTMLViewportStyle(html) {
|
|
|
91691
91691
|
return "<!doctype html><html><head>" + viewportStyle + "</head><body>" + html + "</body></html>";
|
|
91692
91692
|
}
|
|
91693
91693
|
|
|
91694
|
+
function withCardHTMLAnchorNavigationGuard(html, allowAnchorNavigation) {
|
|
91695
|
+
if (allowAnchorNavigation === true) {
|
|
91696
|
+
return html;
|
|
91697
|
+
}
|
|
91698
|
+
var script = "\n<script data-vvfx-card-html-anchor-navigation-guard>\n(() => {\n document.addEventListener('click', event => {\n const target = event.target;\n if (!(target instanceof Element)) {\n return;\n }\n\n const anchor = target.closest('a[href]');\n if (!anchor) {\n return;\n }\n\n event.preventDefault();\n }, true);\n})();\n</script>";
|
|
91699
|
+
if (/<\/body>/i.test(html)) {
|
|
91700
|
+
return html.replace(/<\/body>/i, "" + script + "</body>");
|
|
91701
|
+
}
|
|
91702
|
+
return "" + html + script;
|
|
91703
|
+
}
|
|
91704
|
+
|
|
91694
91705
|
function renderDocumentContent(overlay, content, options) {
|
|
91695
91706
|
var _files_get;
|
|
91696
91707
|
var iframe = document.createElement('iframe');
|
|
@@ -91709,7 +91720,7 @@ function renderDocumentContent(overlay, content, options) {
|
|
|
91709
91720
|
iframe.setAttribute('sandbox', content.sandbox);
|
|
91710
91721
|
}
|
|
91711
91722
|
var entryHtml = (_files_get = files.get(entry)) != null ? _files_get : '';
|
|
91712
|
-
iframe.srcdoc = withCardHTMLAutoHeightBridge(withCardHTMLViewportStyle(transformHTMLDocument(entry, entryHtml, createFileUrl)), options == null ? void 0 : options.autoHeightId);
|
|
91723
|
+
iframe.srcdoc = withCardHTMLAutoHeightBridge(withCardHTMLAnchorNavigationGuard(withCardHTMLViewportStyle(transformHTMLDocument(entry, entryHtml, createFileUrl)), content.allowAnchorNavigation), options == null ? void 0 : options.autoHeightId);
|
|
91713
91724
|
overlay.appendChild(iframe);
|
|
91714
91725
|
return function() {
|
|
91715
91726
|
messageCleanup();
|
|
@@ -91868,6 +91879,30 @@ var EDITING_VIEWPORT_PADDING = 48;
|
|
|
91868
91879
|
var EDITING_VIEWPORT_BOX_SCALE = 1.1;
|
|
91869
91880
|
var AUTO_HEIGHT_EPSILON = 0.5;
|
|
91870
91881
|
var CARD_RASTERIZE_READY_TIMEOUT = 3000;
|
|
91882
|
+
var CARD_HTML_EVENT_MESSAGE_SOURCE = 'vvfx-card-html-event';
|
|
91883
|
+
var requestHTMLOverlayFrame = function requestHTMLOverlayFrame(callback) {
|
|
91884
|
+
if (typeof requestAnimationFrame === 'function') {
|
|
91885
|
+
try {
|
|
91886
|
+
return requestAnimationFrame(callback);
|
|
91887
|
+
} catch (unused) {
|
|
91888
|
+
// Some non-browser test runtimes install a RAF polyfill that depends on window.
|
|
91889
|
+
}
|
|
91890
|
+
}
|
|
91891
|
+
return setTimeout(function() {
|
|
91892
|
+
callback(Date.now());
|
|
91893
|
+
}, 16);
|
|
91894
|
+
};
|
|
91895
|
+
var cancelHTMLOverlayFrame = function cancelHTMLOverlayFrame(frame) {
|
|
91896
|
+
if (typeof cancelAnimationFrame === 'function') {
|
|
91897
|
+
try {
|
|
91898
|
+
cancelAnimationFrame(frame);
|
|
91899
|
+
return;
|
|
91900
|
+
} catch (unused) {
|
|
91901
|
+
// Fall back to clearTimeout for frames created by requestHTMLOverlayFrame.
|
|
91902
|
+
}
|
|
91903
|
+
}
|
|
91904
|
+
clearTimeout(frame);
|
|
91905
|
+
};
|
|
91871
91906
|
var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
91872
91907
|
function HTMLOverlayManager(options) {
|
|
91873
91908
|
var _this = this;
|
|
@@ -91940,7 +91975,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
91940
91975
|
return;
|
|
91941
91976
|
}
|
|
91942
91977
|
if (_this.contentInteractionFrame !== undefined) {
|
|
91943
|
-
|
|
91978
|
+
cancelHTMLOverlayFrame(_this.contentInteractionFrame);
|
|
91944
91979
|
_this.contentInteractionFrame = undefined;
|
|
91945
91980
|
}
|
|
91946
91981
|
_this.pendingContentInteractionEvent = undefined;
|
|
@@ -92001,11 +92036,11 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
92001
92036
|
_proto.dispose = function dispose() {
|
|
92002
92037
|
var _this_state_layer;
|
|
92003
92038
|
if (this.state.updateFrame !== undefined) {
|
|
92004
|
-
|
|
92039
|
+
cancelHTMLOverlayFrame(this.state.updateFrame);
|
|
92005
92040
|
this.state.updateFrame = undefined;
|
|
92006
92041
|
}
|
|
92007
92042
|
if (this.contentInteractionFrame !== undefined) {
|
|
92008
|
-
|
|
92043
|
+
cancelHTMLOverlayFrame(this.contentInteractionFrame);
|
|
92009
92044
|
this.contentInteractionFrame = undefined;
|
|
92010
92045
|
}
|
|
92011
92046
|
this.pendingContentInteractionEvent = undefined;
|
|
@@ -92035,7 +92070,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
92035
92070
|
});
|
|
92036
92071
|
this.state.autoHeightCleanups.clear();
|
|
92037
92072
|
this.state.autoHeightFrames.forEach(function(frame) {
|
|
92038
|
-
|
|
92073
|
+
cancelHTMLOverlayFrame(frame);
|
|
92039
92074
|
});
|
|
92040
92075
|
this.state.autoHeightFrames.clear();
|
|
92041
92076
|
this.eventCleanups.forEach(function(cleanup) {
|
|
@@ -92054,9 +92089,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
92054
92089
|
_proto.scheduleRender = function scheduleRender() {
|
|
92055
92090
|
var _this = this;
|
|
92056
92091
|
if (this.state.updateFrame !== undefined) {
|
|
92057
|
-
|
|
92092
|
+
cancelHTMLOverlayFrame(this.state.updateFrame);
|
|
92058
92093
|
}
|
|
92059
|
-
this.state.updateFrame =
|
|
92094
|
+
this.state.updateFrame = requestHTMLOverlayFrame(function() {
|
|
92060
92095
|
_this.state.updateFrame = undefined;
|
|
92061
92096
|
_this.render();
|
|
92062
92097
|
});
|
|
@@ -92065,6 +92100,40 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
92065
92100
|
this.cleanupOverlayContent(id);
|
|
92066
92101
|
this.invalidateContentInteractionZones(id);
|
|
92067
92102
|
};
|
|
92103
|
+
_proto.getHtmlCardWindow = function getHtmlCardWindow(id) {
|
|
92104
|
+
var contentOverlay = this.state.contentElements.get(id);
|
|
92105
|
+
var iframe = contentOverlay == null ? void 0 : contentOverlay.querySelector('iframe');
|
|
92106
|
+
return iframe == null ? void 0 : iframe.contentWindow;
|
|
92107
|
+
};
|
|
92108
|
+
_proto.patchCardHTML = function patchCardHTML(id, patch) {
|
|
92109
|
+
var html = this.state.contents.get(id);
|
|
92110
|
+
if (!html) {
|
|
92111
|
+
return false;
|
|
92112
|
+
}
|
|
92113
|
+
var patchHandler = html.content.patch;
|
|
92114
|
+
if (!patchHandler) {
|
|
92115
|
+
return false;
|
|
92116
|
+
}
|
|
92117
|
+
var context = this.createPatchContext(id, html);
|
|
92118
|
+
return patchHandler(patch, context) !== false;
|
|
92119
|
+
};
|
|
92120
|
+
_proto.dispatchHtmlCardEvent = function dispatchHtmlCardEvent(id, type, detail) {
|
|
92121
|
+
var targetWindow = this.getHtmlCardWindow(id);
|
|
92122
|
+
try {
|
|
92123
|
+
if (!targetWindow || typeof targetWindow.postMessage !== 'function') {
|
|
92124
|
+
return false;
|
|
92125
|
+
}
|
|
92126
|
+
targetWindow.postMessage({
|
|
92127
|
+
detail: detail,
|
|
92128
|
+
payload: detail,
|
|
92129
|
+
source: CARD_HTML_EVENT_MESSAGE_SOURCE,
|
|
92130
|
+
type: type
|
|
92131
|
+
}, '*');
|
|
92132
|
+
return true;
|
|
92133
|
+
} catch (unused) {
|
|
92134
|
+
return false;
|
|
92135
|
+
}
|
|
92136
|
+
};
|
|
92068
92137
|
_proto.rasterizeCard = function rasterizeCard(id, options) {
|
|
92069
92138
|
return _async_to_generator(function() {
|
|
92070
92139
|
var contentOverlay, capture, _ref, _options_pixelRatio, image, error;
|
|
@@ -92072,7 +92141,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
92072
92141
|
switch(_state.label){
|
|
92073
92142
|
case 0:
|
|
92074
92143
|
if (this.state.updateFrame !== undefined) {
|
|
92075
|
-
|
|
92144
|
+
cancelHTMLOverlayFrame(this.state.updateFrame);
|
|
92076
92145
|
this.state.updateFrame = undefined;
|
|
92077
92146
|
}
|
|
92078
92147
|
this.render();
|
|
@@ -92239,13 +92308,10 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
92239
92308
|
var overlay = _this.getOrCreateOverlay(item.id, parentOverlay, elements);
|
|
92240
92309
|
var contentOverlay = _this.getOrCreateContentOverlay(item.id, overlay);
|
|
92241
92310
|
var selectionOverlay = _this.getOrCreateSelectionOverlay(item.id, selectionLayer);
|
|
92242
|
-
if (!_this.state.contents.has(item.id)) {
|
|
92243
|
-
_this.renderOverlayHTML(item.id, contentOverlay, html);
|
|
92244
|
-
}
|
|
92245
|
-
_this.applyHTMLRootConfig(overlay, html);
|
|
92246
92311
|
var offsetX = frameBox && !frameBox.isEmpty() ? frameBox.min.x : 0;
|
|
92247
92312
|
var offsetY = frameBox && !frameBox.isEmpty() ? frameBox.min.y : 0;
|
|
92248
92313
|
var boxStyle = getCardOverlayBoxStyle(itemBox, item.property.width, item.property.height, offsetX, offsetY, _this.isAutoScaleEnabled(item));
|
|
92314
|
+
_this.applyHTMLRootConfig(overlay, html);
|
|
92249
92315
|
overlay.style.left = boxStyle.left;
|
|
92250
92316
|
overlay.style.top = boxStyle.top;
|
|
92251
92317
|
overlay.style.width = boxStyle.width;
|
|
@@ -92260,8 +92326,12 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
92260
92326
|
selectionOverlay.style.transform = selectionBoxStyle.transform;
|
|
92261
92327
|
selectionOverlay.style.transformOrigin = '0 0';
|
|
92262
92328
|
_this.applyHTMLRootConfig(selectionOverlay, html);
|
|
92329
|
+
_this.makeSelectionOverlayTransparent(selectionOverlay);
|
|
92263
92330
|
_this.syncOverlaySelection(item.id, overlay, selectionOverlay);
|
|
92264
92331
|
_this.syncContentScale(item.id, boxStyle.contentWidth, boxStyle.contentHeight);
|
|
92332
|
+
if (!_this.state.contents.has(item.id)) {
|
|
92333
|
+
_this.renderOverlayHTML(item.id, contentOverlay, html);
|
|
92334
|
+
}
|
|
92265
92335
|
_this.syncAutoHeight(item.id, _this.isAutoHeightEnabled(item));
|
|
92266
92336
|
_this.syncContentInteraction(item.id);
|
|
92267
92337
|
});
|
|
@@ -92501,14 +92571,20 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
92501
92571
|
if (this.contentInteractionFrame !== undefined) {
|
|
92502
92572
|
return;
|
|
92503
92573
|
}
|
|
92504
|
-
|
|
92505
|
-
|
|
92506
|
-
|
|
92507
|
-
|
|
92508
|
-
|
|
92509
|
-
|
|
92510
|
-
|
|
92511
|
-
|
|
92574
|
+
try {
|
|
92575
|
+
this.contentInteractionFrame = requestAnimationFrame(function() {
|
|
92576
|
+
_this.contentInteractionFrame = undefined;
|
|
92577
|
+
var pendingEvent = _this.pendingContentInteractionEvent;
|
|
92578
|
+
_this.pendingContentInteractionEvent = undefined;
|
|
92579
|
+
if (pendingEvent) {
|
|
92580
|
+
_this.syncActiveContentInteraction(pendingEvent);
|
|
92581
|
+
}
|
|
92582
|
+
});
|
|
92583
|
+
} catch (unused) {
|
|
92584
|
+
this.contentInteractionFrame = undefined;
|
|
92585
|
+
this.pendingContentInteractionEvent = undefined;
|
|
92586
|
+
this.syncActiveContentInteraction(event);
|
|
92587
|
+
}
|
|
92512
92588
|
};
|
|
92513
92589
|
_proto.setActiveContentInteraction = function setActiveContentInteraction(zone) {
|
|
92514
92590
|
var _this = this;
|
|
@@ -92932,6 +93008,20 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
92932
93008
|
});
|
|
92933
93009
|
this.state.contents.set(id, html);
|
|
92934
93010
|
};
|
|
93011
|
+
_proto.createPatchContext = function createPatchContext(id, html) {
|
|
93012
|
+
var _this = this;
|
|
93013
|
+
return {
|
|
93014
|
+
id: id,
|
|
93015
|
+
html: html,
|
|
93016
|
+
content: html.content,
|
|
93017
|
+
container: this.state.contentMountElements.get(id),
|
|
93018
|
+
contentWindow: this.getHtmlCardWindow(id),
|
|
93019
|
+
refresh: function refresh() {
|
|
93020
|
+
_this.invalidateCardHTML(id);
|
|
93021
|
+
_this.scheduleRender();
|
|
93022
|
+
}
|
|
93023
|
+
};
|
|
93024
|
+
};
|
|
92935
93025
|
_proto.observeContentInteractionZones = function observeContentInteractionZones(id, contentContainer) {
|
|
92936
93026
|
var _this = this;
|
|
92937
93027
|
var _this_state_contentInteractionZoneCleanups_get;
|
|
@@ -92991,6 +93081,10 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
92991
93081
|
});
|
|
92992
93082
|
});
|
|
92993
93083
|
};
|
|
93084
|
+
_proto.makeSelectionOverlayTransparent = function makeSelectionOverlayTransparent(selectionOverlay) {
|
|
93085
|
+
selectionOverlay.style.background = 'transparent';
|
|
93086
|
+
selectionOverlay.style.backgroundColor = 'transparent';
|
|
93087
|
+
};
|
|
92994
93088
|
_proto.renderOverlayContent = function renderOverlayContent(overlay, content, options) {
|
|
92995
93089
|
var _this = this;
|
|
92996
93090
|
switch(content.kind){
|
|
@@ -93005,7 +93099,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
93005
93099
|
entry: 'index.html',
|
|
93006
93100
|
files: {
|
|
93007
93101
|
'index.html': content.html
|
|
93008
|
-
}
|
|
93102
|
+
},
|
|
93103
|
+
allowAnchorNavigation: content.allowAnchorNavigation,
|
|
93104
|
+
sandbox: content.sandbox
|
|
93009
93105
|
}, {
|
|
93010
93106
|
autoHeightId: (options == null ? void 0 : options.autoHeight) ? options.id : undefined,
|
|
93011
93107
|
onAutoHeight: (options == null ? void 0 : options.autoHeight) ? function(height) {
|
|
@@ -93183,7 +93279,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
93183
93279
|
if (this.state.autoHeightFrames.has(id)) {
|
|
93184
93280
|
return;
|
|
93185
93281
|
}
|
|
93186
|
-
var frame =
|
|
93282
|
+
var frame = requestHTMLOverlayFrame(function() {
|
|
93187
93283
|
_this.state.autoHeightFrames.delete(id);
|
|
93188
93284
|
_this.measureAutoHeight(id);
|
|
93189
93285
|
});
|
|
@@ -93267,7 +93363,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
93267
93363
|
}
|
|
93268
93364
|
var frame = this.state.autoHeightFrames.get(id);
|
|
93269
93365
|
if (frame !== undefined) {
|
|
93270
|
-
|
|
93366
|
+
cancelHTMLOverlayFrame(frame);
|
|
93271
93367
|
this.state.autoHeightFrames.delete(id);
|
|
93272
93368
|
}
|
|
93273
93369
|
};
|
|
@@ -93285,7 +93381,18 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
93285
93381
|
if (Math.abs(nextHeight - item.property.height) <= AUTO_HEIGHT_EPSILON) {
|
|
93286
93382
|
return;
|
|
93287
93383
|
}
|
|
93288
|
-
this.options.setCardItemHeight(id, nextHeight
|
|
93384
|
+
this.options.setCardItemHeight(id, nextHeight, {
|
|
93385
|
+
anchor: this.getAutoHeightAnchor(item),
|
|
93386
|
+
previousHeight: item.property.height
|
|
93387
|
+
});
|
|
93388
|
+
};
|
|
93389
|
+
_proto.getAutoHeightAnchor = function getAutoHeightAnchor(item) {
|
|
93390
|
+
var _ref;
|
|
93391
|
+
var _this_options_resolveCardTypeConfig;
|
|
93392
|
+
if (!isCardItem(item)) {
|
|
93393
|
+
return 'top';
|
|
93394
|
+
}
|
|
93395
|
+
return (_ref = (_this_options_resolveCardTypeConfig = this.options.resolveCardTypeConfig(item)) == null ? void 0 : _this_options_resolveCardTypeConfig.autoHeightAnchor) != null ? _ref : 'top';
|
|
93289
93396
|
};
|
|
93290
93397
|
_proto.getAutoHeightItemHeight = function getAutoHeightItemHeight(item, contentHeight) {
|
|
93291
93398
|
if (!isCardItem(item) || this.isAutoScaleEnabled(item)) {
|
|
@@ -93371,7 +93478,7 @@ function formatCssNumber(value) {
|
|
|
93371
93478
|
}
|
|
93372
93479
|
function nextAnimationFrame() {
|
|
93373
93480
|
return new Promise(function(resolve) {
|
|
93374
|
-
|
|
93481
|
+
requestHTMLOverlayFrame(function() {
|
|
93375
93482
|
resolve();
|
|
93376
93483
|
});
|
|
93377
93484
|
});
|
|
@@ -93940,12 +94047,29 @@ var SDK = /*#__PURE__*/ function() {
|
|
|
93940
94047
|
bottom: HTML_CARD_EDITING_VIEWPORT_PADDING
|
|
93941
94048
|
}, box);
|
|
93942
94049
|
},
|
|
93943
|
-
setCardItemHeight: function setCardItemHeight(id, height) {
|
|
94050
|
+
setCardItemHeight: function setCardItemHeight(id, height, options) {
|
|
94051
|
+
var item = _this.getSDKItem(id);
|
|
94052
|
+
if (!isCardItem(item) || options.anchor === 'center') {
|
|
94053
|
+
void _this.setItemProperty({
|
|
94054
|
+
itemId: id,
|
|
94055
|
+
type: SDKItemType.CARD,
|
|
94056
|
+
propertyName: 'height',
|
|
94057
|
+
propertyValue: height
|
|
94058
|
+
});
|
|
94059
|
+
return;
|
|
94060
|
+
}
|
|
94061
|
+
var _item_property_position = item.property.position, x = _item_property_position[0], y = _item_property_position[1];
|
|
94062
|
+
var deltaY = (height - options.previousHeight) / 2;
|
|
93944
94063
|
void _this.setItemProperty({
|
|
93945
94064
|
itemId: id,
|
|
93946
94065
|
type: SDKItemType.CARD,
|
|
93947
|
-
|
|
93948
|
-
|
|
94066
|
+
property: {
|
|
94067
|
+
height: height,
|
|
94068
|
+
position: [
|
|
94069
|
+
x,
|
|
94070
|
+
y + deltaY
|
|
94071
|
+
]
|
|
94072
|
+
}
|
|
93949
94073
|
});
|
|
93950
94074
|
},
|
|
93951
94075
|
getSelectedItemIds: function getSelectedItemIds() {
|
|
@@ -94079,7 +94203,7 @@ var SDK = /*#__PURE__*/ function() {
|
|
|
94079
94203
|
_this._gestureHandler.dispose();
|
|
94080
94204
|
setTimeout(function() {
|
|
94081
94205
|
return _async_to_generator(function() {
|
|
94082
|
-
var _this_pageData, _this_pageData1,
|
|
94206
|
+
var itemExtension, _this_pageData, _this_pageData1, createInfos;
|
|
94083
94207
|
return _ts_generator(this, function(_state) {
|
|
94084
94208
|
switch(_state.label){
|
|
94085
94209
|
case 0:
|
|
@@ -94088,6 +94212,10 @@ var SDK = /*#__PURE__*/ function() {
|
|
|
94088
94212
|
this._gestureHandler = new GestureHandler(this._container);
|
|
94089
94213
|
this.syncCanvasLayerOrder();
|
|
94090
94214
|
itemExtension = {};
|
|
94215
|
+
if (!(SDK.config.mode === 'template')) return [
|
|
94216
|
+
3,
|
|
94217
|
+
2
|
|
94218
|
+
];
|
|
94091
94219
|
(_this_pageData = this.pageData) == null ? void 0 : _this_pageData.items.forEach(function(item) {
|
|
94092
94220
|
itemExtension[item.id] = item.getAllExtension();
|
|
94093
94221
|
});
|
|
@@ -94103,6 +94231,20 @@ var SDK = /*#__PURE__*/ function() {
|
|
|
94103
94231
|
item.setExtensions(extension);
|
|
94104
94232
|
}
|
|
94105
94233
|
});
|
|
94234
|
+
return [
|
|
94235
|
+
3,
|
|
94236
|
+
4
|
|
94237
|
+
];
|
|
94238
|
+
case 2:
|
|
94239
|
+
createInfos = this.getItemCreateInfos();
|
|
94240
|
+
return [
|
|
94241
|
+
4,
|
|
94242
|
+
this.runByCreateInfos(createInfos)
|
|
94243
|
+
];
|
|
94244
|
+
case 3:
|
|
94245
|
+
_state.sent();
|
|
94246
|
+
_state.label = 4;
|
|
94247
|
+
case 4:
|
|
94106
94248
|
this._eventEmitter.emit('viewRebuildFinish');
|
|
94107
94249
|
return [
|
|
94108
94250
|
2
|
|
@@ -94952,6 +95094,55 @@ var SDK = /*#__PURE__*/ function() {
|
|
|
94952
95094
|
});
|
|
94953
95095
|
}).call(this);
|
|
94954
95096
|
};
|
|
95097
|
+
_proto.runByCreateInfos = function runByCreateInfos(createInfos) {
|
|
95098
|
+
return _async_to_generator(function() {
|
|
95099
|
+
var _this__pageData_activeData_view, _this__pageData_activeData_view1, viewSize, scene, targetViewProperty;
|
|
95100
|
+
return _ts_generator(this, function(_state) {
|
|
95101
|
+
switch(_state.label){
|
|
95102
|
+
case 0:
|
|
95103
|
+
assertExist$1(this._pageData, 'You must call SDK#run() first');
|
|
95104
|
+
this._pageData.property.zoom = 1;
|
|
95105
|
+
this._pageData.property.translation = [
|
|
95106
|
+
0,
|
|
95107
|
+
0
|
|
95108
|
+
];
|
|
95109
|
+
this._pageDataUtils.init();
|
|
95110
|
+
return [
|
|
95111
|
+
4,
|
|
95112
|
+
this._gestureHandler.init(this._pageDataUtils, this._eventEmitter)
|
|
95113
|
+
];
|
|
95114
|
+
case 1:
|
|
95115
|
+
_state.sent();
|
|
95116
|
+
viewSize = [
|
|
95117
|
+
this._playerContainer.offsetWidth,
|
|
95118
|
+
this._playerContainer.offsetHeight
|
|
95119
|
+
];
|
|
95120
|
+
scene = getBasicScene(viewSize);
|
|
95121
|
+
targetViewProperty = this.getViewProperty((_this__pageData_activeData_view = this._pageData.activeData.view) != null ? _this__pageData_activeData_view : 0);
|
|
95122
|
+
if (targetViewProperty) {
|
|
95123
|
+
targetViewProperty.scene = scene;
|
|
95124
|
+
}
|
|
95125
|
+
return [
|
|
95126
|
+
4,
|
|
95127
|
+
this._pageDataUtils.loadScene((_this__pageData_activeData_view1 = this._pageData.activeData.view) != null ? _this__pageData_activeData_view1 : 0)
|
|
95128
|
+
];
|
|
95129
|
+
case 2:
|
|
95130
|
+
_state.sent();
|
|
95131
|
+
return [
|
|
95132
|
+
4,
|
|
95133
|
+
this.addItemByCreateInfos(createInfos)
|
|
95134
|
+
];
|
|
95135
|
+
case 3:
|
|
95136
|
+
_state.sent();
|
|
95137
|
+
this._pageDataUtils.refreshPageTime(this._pageData.time);
|
|
95138
|
+
this._eventEmitter.emit('pageDataChange', this.pageData);
|
|
95139
|
+
return [
|
|
95140
|
+
2
|
|
95141
|
+
];
|
|
95142
|
+
}
|
|
95143
|
+
});
|
|
95144
|
+
}).call(this);
|
|
95145
|
+
};
|
|
94955
95146
|
_proto.reloadPageDataByScene = function reloadPageDataByScene(scene) {
|
|
94956
95147
|
return _async_to_generator(function() {
|
|
94957
95148
|
var _ref, _this__pageData_activeData_view, _ref1, _ref2, _loadScene_compositions_find, _this_player_getCompositions_, _this_player_getCompositions_1, loadScene, response, error;
|
|
@@ -95646,7 +95837,11 @@ var SDK = /*#__PURE__*/ function() {
|
|
|
95646
95837
|
return item.id;
|
|
95647
95838
|
})) != null ? _ref : [];
|
|
95648
95839
|
ids.forEach(function(id) {
|
|
95649
|
-
var
|
|
95840
|
+
var _this__pageDataUtils_getItemCreateInfo;
|
|
95841
|
+
var _this_pageData_items_find, _this_pageData;
|
|
95842
|
+
var createInfo = (_this__pageDataUtils_getItemCreateInfo = _this._pageDataUtils.getItemCreateInfo(id, true)) != null ? _this__pageDataUtils_getItemCreateInfo : (_this_pageData = _this.pageData) == null ? void 0 : (_this_pageData_items_find = _this_pageData.items.find(function(item) {
|
|
95843
|
+
return item.id === id;
|
|
95844
|
+
})) == null ? void 0 : _this_pageData_items_find.toCreateInfo(true);
|
|
95650
95845
|
if (createInfo) {
|
|
95651
95846
|
createInfos.push(createInfo);
|
|
95652
95847
|
}
|
|
@@ -96184,6 +96379,38 @@ var SDK = /*#__PURE__*/ function() {
|
|
|
96184
96379
|
return true;
|
|
96185
96380
|
};
|
|
96186
96381
|
/**
|
|
96382
|
+
* @description 获取指定 HTML 卡片当前 iframe 的 window。
|
|
96383
|
+
* @description 仅 inline/document 或自行渲染 iframe 的 DOM 内容会返回 window。
|
|
96384
|
+
* @param id 卡片元素 ID
|
|
96385
|
+
* @returns HTML iframe window
|
|
96386
|
+
*/ _proto.getHtmlCardWindow = function getHtmlCardWindow(id) {
|
|
96387
|
+
var _this__htmlOverlayManager;
|
|
96388
|
+
return (_this__htmlOverlayManager = this._htmlOverlayManager) == null ? void 0 : _this__htmlOverlayManager.getHtmlCardWindow(id);
|
|
96389
|
+
};
|
|
96390
|
+
/**
|
|
96391
|
+
* @description 向指定 HTML 卡片发送增量 patch。
|
|
96392
|
+
* @description 当卡片内容配置了 CardHTMLPatchHandler 时,可用于局部更新 HTML,而不必整卡 refresh。
|
|
96393
|
+
* @param id 卡片元素 ID
|
|
96394
|
+
* @param patch patch 负载,由卡片内容自己的 patch handler 解释
|
|
96395
|
+
* @returns 是否被 patch handler 处理
|
|
96396
|
+
*/ _proto.patchCardHTML = function patchCardHTML(id, patch) {
|
|
96397
|
+
var _ref;
|
|
96398
|
+
var _this__htmlOverlayManager;
|
|
96399
|
+
return (_ref = (_this__htmlOverlayManager = this._htmlOverlayManager) == null ? void 0 : _this__htmlOverlayManager.patchCardHTML(id, patch)) != null ? _ref : false;
|
|
96400
|
+
};
|
|
96401
|
+
/**
|
|
96402
|
+
* @description 向指定 HTML 卡片 iframe 派发事件。
|
|
96403
|
+
* @description 通过 postMessage 投递事件,跨源/同源行为一致,消息 source 为 vvfx-card-html-event。
|
|
96404
|
+
* @param id 卡片元素 ID
|
|
96405
|
+
* @param type 事件名称
|
|
96406
|
+
* @param detail 事件 detail
|
|
96407
|
+
* @returns 是否成功派发或投递
|
|
96408
|
+
*/ _proto.dispatchHtmlCardEvent = function dispatchHtmlCardEvent(id, type, detail) {
|
|
96409
|
+
var _ref;
|
|
96410
|
+
var _this__htmlOverlayManager;
|
|
96411
|
+
return (_ref = (_this__htmlOverlayManager = this._htmlOverlayManager) == null ? void 0 : _this__htmlOverlayManager.dispatchHtmlCardEvent(id, type, detail)) != null ? _ref : false;
|
|
96412
|
+
};
|
|
96413
|
+
/**
|
|
96187
96414
|
* @description 创建卡片元素
|
|
96188
96415
|
* @description 底层以透明 SpriteItem 形式渲染,支持 cardType 属性
|
|
96189
96416
|
* @param createInfo 卡片创建信息
|