@vvfx/sdk 0.2.3 → 0.2.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/config.d.ts +29 -1
- package/dist/html-overlay/anchor-navigation-runtime.d.ts +1 -0
- package/dist/html-overlay/auto-height-runtime.d.ts +5 -0
- package/dist/html-overlay/manager.d.ts +66 -1
- package/dist/html-overlay/overlay-transform.d.ts +3 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1241 -227
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1241 -227
- package/dist/index.mjs.map +1 -1
- package/dist/layer-order.d.ts +7 -0
- package/dist/sdk-item/card-item.d.ts +2 -6
- package/dist/sdk.d.ts +47 -2
- package/dist/types.d.ts +77 -18
- package/dist/utils/page-data-utils.d.ts +11 -0
- package/package.json +2 -2
package/dist/config.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { ExportMediaInitOptions } from './exporter';
|
|
2
2
|
import { GlobalLayoutMode } from './utils';
|
|
3
|
+
import type { CardHTML } from './types';
|
|
4
|
+
import type { CardItem } from './sdk-item/card-item';
|
|
3
5
|
export type SDKMode = 'editor' | 'template';
|
|
6
|
+
export type CardTypeHTMLResolver = (item: CardItem) => CardHTML | undefined;
|
|
7
|
+
export type CardAutoHeightAnchor = 'top' | 'center';
|
|
4
8
|
/**
|
|
5
9
|
* @description SDK功能配置
|
|
6
10
|
*/
|
|
@@ -136,6 +140,30 @@ export type CardTypeConfig = {
|
|
|
136
140
|
* @description TransformGizmo 左上角展示的 icon URL
|
|
137
141
|
*/
|
|
138
142
|
iconUrl: string;
|
|
143
|
+
/**
|
|
144
|
+
* @description 卡片类型对应的运行时 HTML 渲染配置;函数不会进入序列化数据,恢复时由 cardType 动态解析。
|
|
145
|
+
*/
|
|
146
|
+
html?: CardTypeHTMLResolver;
|
|
147
|
+
/**
|
|
148
|
+
* @description 是否根据 HTML 挂载内容的自然高度自动更新卡片高度
|
|
149
|
+
*/
|
|
150
|
+
autoHeight?: boolean;
|
|
151
|
+
/**
|
|
152
|
+
* @description autoHeight 更新卡片高度时的锚点。top 保持上边缘不动,center 保持中心点不动。未配置时默认 top。
|
|
153
|
+
*/
|
|
154
|
+
autoHeightAnchor?: CardAutoHeightAnchor;
|
|
155
|
+
/**
|
|
156
|
+
* @description HTML 内容是否跟随卡片 scale 缩放,关闭后 HTML 按最终显示尺寸重新布局
|
|
157
|
+
*/
|
|
158
|
+
autoScale?: boolean;
|
|
159
|
+
/**
|
|
160
|
+
* @description 是否启用编辑态交互。未配置时默认 true;只有显式 false 时,卡片默认直接交互且不进入编辑态。
|
|
161
|
+
*/
|
|
162
|
+
editable?: boolean;
|
|
163
|
+
/**
|
|
164
|
+
* @description HTML 内容中可在非编辑态直接响应事件的额外 CSS 选择器;会与 SDK 默认交互选择器合并。
|
|
165
|
+
*/
|
|
166
|
+
htmlInteractionSelectors?: string[];
|
|
139
167
|
};
|
|
140
168
|
/**
|
|
141
169
|
* @description 卡片元素参数配置
|
|
@@ -146,7 +174,7 @@ export type CardConfig = {
|
|
|
146
174
|
*/
|
|
147
175
|
backgroundColor: [number, number, number, number];
|
|
148
176
|
/**
|
|
149
|
-
* @description
|
|
177
|
+
* @description 注册的卡片类型列表,支持通过 registerCardType/registerCardTypes 动态配置
|
|
150
178
|
* 每个条目包含 type 标识、显示名称和图标 URL
|
|
151
179
|
*/
|
|
152
180
|
cardTypes: CardTypeConfig[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function withCardHTMLAnchorNavigationGuard(html: string, allowAnchorNavigation?: boolean): string;
|
|
@@ -4,10 +4,15 @@ export type CardHTMLAutoHeightMessage = {
|
|
|
4
4
|
id: string;
|
|
5
5
|
height: number;
|
|
6
6
|
};
|
|
7
|
+
export type CardHTMLAutoHeightRequest = {
|
|
8
|
+
source: 'vvfx-card-html-auto-height-request';
|
|
9
|
+
id: string;
|
|
10
|
+
};
|
|
7
11
|
export type CardHTMLAutoHeightOptions = {
|
|
8
12
|
autoHeightId?: string;
|
|
9
13
|
onAutoHeight?: (height: number) => void;
|
|
10
14
|
};
|
|
11
15
|
export declare function createAutoHeightMessageListener(iframe: HTMLIFrameElement, options?: CardHTMLAutoHeightOptions): CardHTMLRenderCleanup;
|
|
12
16
|
export declare function isCardHTMLAutoHeightMessage(data: unknown, id: string): data is CardHTMLAutoHeightMessage;
|
|
17
|
+
export declare function requestCardHTMLAutoHeight(iframe: HTMLIFrameElement, id: string): void;
|
|
13
18
|
export declare function withCardHTMLAutoHeightBridge(html: string, id?: string): string;
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import type { Box2 } from '../math';
|
|
2
2
|
import { type SnapdomOptions } from '@zumer/snapdom';
|
|
3
|
+
import type { CardAutoHeightAnchor, CardTypeConfig } from '../config';
|
|
3
4
|
import type { EventEmitter } from '../shared';
|
|
4
5
|
import type { SDKEvents } from '../sdk';
|
|
5
6
|
import { type SDKItem } from '../sdk-item';
|
|
7
|
+
import type { CardHTML } from '../types';
|
|
6
8
|
type CardRasterizeOptions = {
|
|
7
9
|
width: number;
|
|
8
10
|
height: number;
|
|
9
11
|
pixelRatio?: number;
|
|
10
12
|
snapdomOptions?: SnapdomOptions;
|
|
11
13
|
};
|
|
14
|
+
type SetCardItemHeightOptions = {
|
|
15
|
+
anchor: CardAutoHeightAnchor;
|
|
16
|
+
previousHeight: number;
|
|
17
|
+
};
|
|
12
18
|
type HTMLOverlayManagerOptions = {
|
|
13
19
|
container: HTMLElement;
|
|
14
20
|
emitter: EventEmitter<SDKEvents>;
|
|
@@ -23,47 +29,102 @@ type HTMLOverlayManagerOptions = {
|
|
|
23
29
|
translation: [number, number];
|
|
24
30
|
}) => void;
|
|
25
31
|
viewportFit: (box: Box2) => void;
|
|
26
|
-
setCardItemHeight: (id: string, height: number) => void;
|
|
32
|
+
setCardItemHeight: (id: string, height: number, options: SetCardItemHeightOptions) => void;
|
|
33
|
+
getSelectedItemIds: () => string[];
|
|
34
|
+
setSelectedItemIds: (ids: string[]) => void;
|
|
35
|
+
getPreSelectedItemId: () => string | undefined;
|
|
36
|
+
getSelectionEdgeStyle: () => {
|
|
37
|
+
color: number;
|
|
38
|
+
alpha: number;
|
|
39
|
+
width: number;
|
|
40
|
+
};
|
|
41
|
+
getPreSelectionEdgeStyle: () => {
|
|
42
|
+
color: number;
|
|
43
|
+
alpha: number;
|
|
44
|
+
width: number;
|
|
45
|
+
};
|
|
46
|
+
getCanvasEventTarget?: () => HTMLElement | undefined;
|
|
47
|
+
resolveCardHTML: (item: SDKItem) => CardHTML | undefined;
|
|
48
|
+
resolveCardTypeConfig: (item: SDKItem) => CardTypeConfig | undefined;
|
|
27
49
|
};
|
|
28
50
|
export declare class HTMLOverlayManager {
|
|
29
51
|
private options;
|
|
30
52
|
private eventCleanups;
|
|
53
|
+
private htmlRootConfigCleanups;
|
|
54
|
+
private pendingContentInteractionEvent?;
|
|
55
|
+
private contentInteractionFrame?;
|
|
31
56
|
private state;
|
|
32
57
|
constructor(options: HTMLOverlayManagerOptions);
|
|
33
58
|
attach(): void;
|
|
59
|
+
get layerElement(): HTMLElement | undefined;
|
|
34
60
|
dispose(): void;
|
|
35
61
|
scheduleRender(): void;
|
|
62
|
+
invalidateCardHTML(id: string): void;
|
|
63
|
+
getHtmlCardWindow(id: string): Window | null | undefined;
|
|
64
|
+
patchCardHTML(id: string, patch: unknown): boolean;
|
|
65
|
+
dispatchHtmlCardEvent(id: string, type: string, detail?: unknown): boolean;
|
|
36
66
|
rasterizeCard(id: string, options: CardRasterizeOptions): Promise<string | undefined>;
|
|
37
67
|
private initEvents;
|
|
38
68
|
private initDOMEvents;
|
|
39
69
|
private handleContainerDoubleClick;
|
|
40
70
|
private handleContainerMouseDown;
|
|
71
|
+
private selectHTMLInteractionCard;
|
|
41
72
|
private handleContainerMouseMove;
|
|
42
73
|
private handleContainerMouseLeave;
|
|
74
|
+
private isMouseLeaveWithinContainer;
|
|
75
|
+
private handleContainerContextMenu;
|
|
76
|
+
private isHTMLContextMenuEvent;
|
|
43
77
|
private handleViewportTransform;
|
|
44
78
|
private render;
|
|
45
79
|
private syncOverlayOrder;
|
|
80
|
+
private getOrCreateSelectionLayer;
|
|
46
81
|
private renderFrameOverlays;
|
|
47
82
|
private getOrCreateFrameOverlay;
|
|
48
83
|
private getOrCreateOverlay;
|
|
84
|
+
private getOrCreateSelectionOverlay;
|
|
85
|
+
private syncOverlaySelection;
|
|
86
|
+
private getSelectionBoxShadow;
|
|
87
|
+
private getPreSelectionBoxShadow;
|
|
49
88
|
private getHTMLCardIdByEvent;
|
|
50
89
|
private getHoverShellInteractiveIdByEvent;
|
|
90
|
+
private syncActiveContentInteraction;
|
|
91
|
+
private scheduleActiveContentInteractionSync;
|
|
92
|
+
private setActiveContentInteraction;
|
|
93
|
+
private shouldKeepActiveContentInteractionForFocusedElement;
|
|
94
|
+
private resolveHTMLInteractionTarget;
|
|
95
|
+
private getActiveSubtreeInteractionAtEvent;
|
|
96
|
+
private resolveContentInteractionZone;
|
|
97
|
+
private getContentInteractionZones;
|
|
98
|
+
private getContentInteractiveSelector;
|
|
99
|
+
private isContentInteractionDisabled;
|
|
100
|
+
private getContentInteractionZoneMode;
|
|
101
|
+
private invalidateContentInteractionZones;
|
|
102
|
+
private observeContentInteractionZoneResizes;
|
|
51
103
|
private getLayerPoint;
|
|
52
104
|
private getOrCreateContentOverlay;
|
|
53
105
|
private createContentScaleOverlay;
|
|
54
106
|
private syncContentScale;
|
|
107
|
+
private requestAutoHeightFromIframes;
|
|
55
108
|
private syncContentInteraction;
|
|
109
|
+
private syncContentInteractionZones;
|
|
110
|
+
private clearContentInteractionState;
|
|
56
111
|
private syncShellInteraction;
|
|
57
112
|
private enterEditing;
|
|
58
113
|
private exitEditing;
|
|
114
|
+
private isEditableCard;
|
|
59
115
|
private getEditingFitZoom;
|
|
60
116
|
private isEventInsideOverlay;
|
|
61
117
|
private renderOverlayHTML;
|
|
118
|
+
private createPatchContext;
|
|
119
|
+
private observeContentInteractionZones;
|
|
120
|
+
private applyHTMLRootConfig;
|
|
121
|
+
private makeSelectionOverlayTransparent;
|
|
62
122
|
private renderOverlayContent;
|
|
63
123
|
private chainCleanups;
|
|
64
124
|
private cleanupOverlayContent;
|
|
65
125
|
private removeOverlay;
|
|
66
126
|
private syncAutoHeight;
|
|
127
|
+
private ensureAutoHeightMode;
|
|
67
128
|
private createAutoHeightObserver;
|
|
68
129
|
private scheduleAutoHeightMeasure;
|
|
69
130
|
private measureAutoHeight;
|
|
@@ -72,6 +133,10 @@ export declare class HTMLOverlayManager {
|
|
|
72
133
|
private getChildrenNaturalHeight;
|
|
73
134
|
private cleanupAutoHeight;
|
|
74
135
|
private applyAutoHeight;
|
|
136
|
+
private getAutoHeightAnchor;
|
|
137
|
+
private getAutoHeightItemHeight;
|
|
75
138
|
private isAutoHeightMessage;
|
|
139
|
+
private isAutoHeightEnabled;
|
|
140
|
+
private isAutoScaleEnabled;
|
|
76
141
|
}
|
|
77
142
|
export {};
|
|
@@ -4,9 +4,11 @@ export type CardOverlayBoxStyle = {
|
|
|
4
4
|
top: string;
|
|
5
5
|
width: string;
|
|
6
6
|
height: string;
|
|
7
|
+
contentWidth: number;
|
|
8
|
+
contentHeight: number;
|
|
7
9
|
transform: string;
|
|
8
10
|
};
|
|
9
|
-
export declare function getCardOverlayBoxStyle(box: Box2, width: number, height: number, offsetX?: number, offsetY?: number): CardOverlayBoxStyle;
|
|
11
|
+
export declare function getCardOverlayBoxStyle(box: Box2, width: number, height: number, offsetX?: number, offsetY?: number, _autoScale?: boolean): CardOverlayBoxStyle;
|
|
10
12
|
export declare function isPointInCardOverlayBox(box: Box2, point: {
|
|
11
13
|
x: number;
|
|
12
14
|
y: number;
|
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, ItemCreateInfo, } from './types';
|
|
2
|
-
export type { CardTypeConfig, CardConfig } 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';
|