@vvfx/sdk 0.2.2-beta.9 → 0.2.3

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 CHANGED
@@ -1,9 +1,6 @@
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';
5
3
  export type SDKMode = 'editor' | 'template';
6
- export type CardTypeHTMLResolver = (item: CardItem) => CardHTML | undefined;
7
4
  /**
8
5
  * @description SDK功能配置
9
6
  */
@@ -139,26 +136,6 @@ export type CardTypeConfig = {
139
136
  * @description TransformGizmo 左上角展示的 icon URL
140
137
  */
141
138
  iconUrl: string;
142
- /**
143
- * @description 卡片类型对应的运行时 HTML 渲染配置;函数不会进入序列化数据,恢复时由 cardType 动态解析。
144
- */
145
- html?: CardTypeHTMLResolver;
146
- /**
147
- * @description 是否根据 HTML 挂载内容的自然高度自动更新卡片高度
148
- */
149
- autoHeight?: boolean;
150
- /**
151
- * @description HTML 内容是否跟随卡片 scale 缩放,关闭后 HTML 按最终显示尺寸重新布局
152
- */
153
- autoScale?: boolean;
154
- /**
155
- * @description 是否启用编辑态交互。未配置时默认 true;只有显式 false 时,卡片默认直接交互且不进入编辑态。
156
- */
157
- editable?: boolean;
158
- /**
159
- * @description HTML 内容中可在非编辑态直接响应事件的额外 CSS 选择器;会与 SDK 默认交互选择器合并。
160
- */
161
- htmlInteractionSelectors?: string[];
162
139
  };
163
140
  /**
164
141
  * @description 卡片元素参数配置
@@ -169,7 +146,7 @@ export type CardConfig = {
169
146
  */
170
147
  backgroundColor: [number, number, number, number];
171
148
  /**
172
- * @description 注册的卡片类型列表,支持通过 registerCardType/registerCardTypes 动态配置
149
+ * @description 注册的卡片类型列表,支持动态配置
173
150
  * 每个条目包含 type 标识、显示名称和图标 URL
174
151
  */
175
152
  cardTypes: CardTypeConfig[];
@@ -28,7 +28,7 @@ export declare class MaskGizmo extends Gizmo {
28
28
  private _config;
29
29
  private boxGraphics;
30
30
  type: GizmoType;
31
- mode: 'paint' | 'erase';
31
+ mode: 'paint' | 'erase' | 'box-erase' | 'box-paint';
32
32
  /**
33
33
  * 蒙版工具独立的撤销重做实例
34
34
  */
@@ -37,6 +37,10 @@ export declare class MaskGizmo extends Gizmo {
37
37
  * 存储绘画开始前的数据,用于 undoRedo
38
38
  */
39
39
  private _oldLines;
40
+ /**
41
+ * 框选擦除进行中标记(按下到松开之间),用于实时选框描边的显示控制
42
+ */
43
+ private _isBoxErasing;
40
44
  /**
41
45
  * 鼠标状态绘制结果
42
46
  */
@@ -52,9 +56,17 @@ export declare class MaskGizmo extends Gizmo {
52
56
  set config(config: Partial<MaskGizmoConfig>);
53
57
  /**
54
58
  * 设置模式
55
- * @param mode 模式类型:'paint' 表示涂抹,'erase' 表示擦除
59
+ * @param mode 模式类型:'paint' 笔刷涂抹、'erase' 笔刷逐笔擦除、'box-erase' 框选擦除、'box-paint' 框选涂抹
60
+ */
61
+ setMode(mode: 'paint' | 'erase' | 'box-erase' | 'box-paint'): void;
62
+ /**
63
+ * @description 判断点是否在包围盒内
64
+ */
65
+ private _isPointInBox;
66
+ /**
67
+ * @description 将屏幕坐标转换为包围盒内的归一化坐标 [0,1](钳制在范围内)
56
68
  */
57
- setMode(mode: 'paint' | 'erase'): void;
69
+ private _toNormalized;
58
70
  initialize(): void;
59
71
  preparationAction(event: MouseEvent): GizmoType | undefined;
60
72
  preAction(event: MouseEvent): GizmoType | undefined;
@@ -85,6 +85,10 @@ export type MaskResult = {
85
85
  brushSize: number;
86
86
  points: Vector2[];
87
87
  type?: 'paint' | 'erase';
88
+ /**
89
+ * @description 形状类型:'stroke' 折线(默认),'rect' 矩形框选(points=[起点, 终点])
90
+ */
91
+ shape?: 'stroke' | 'rect';
88
92
  }[];
89
93
  };
90
94
  /**
@@ -396,7 +400,7 @@ export type InsertPosition = {
396
400
  siblingId?: string;
397
401
  };
398
402
  export type GizmoType = 'null' | 'selector' | 'transform' | 'control' | 'adsorption' | 'preference' | 'picture-cut' | 'text' | 'mask' | 'loading' | 'picture-expand' | 'sprite-text-edit' | 'icon' | 'item-create';
399
- export type GestureCursorType = 'normal' | 'rotation' | 'scale' | 'text-rotation' | 'circle' | 'hand' | 'active-hand' | 'pointer' | 'text-create' | 'frame-create';
403
+ export type GestureCursorType = 'normal' | 'rotation' | 'scale' | 'text-rotation' | 'circle' | 'hand' | 'active-hand' | 'pointer' | 'text-create' | 'frame-create' | 'box-select';
400
404
  export type TransformType = 'null' | 'translation' | 'rotation' | 'scale';
401
405
  export type GestureHandlerInteractType = 'select' | 'hand';
402
406
  export type ControlGizmoInteractionType = 'mouse' | 'wheel';
@@ -107,7 +107,7 @@ export declare class GestureHandler {
107
107
  closeMaskGizmo(): void;
108
108
  setMaskGizmoConfig(config: Partial<MaskGizmoConfig>): void;
109
109
  getMask(): string | null | undefined;
110
- setMaskGizmoMode(mode: 'paint' | 'erase'): void;
110
+ setMaskGizmoMode(mode: 'paint' | 'erase' | 'box-erase' | 'box-paint'): void;
111
111
  openLoadingGizmo(id: string, options?: {
112
112
  loadingBox?: Box2;
113
113
  clearSelected?: boolean;
@@ -4,15 +4,10 @@ 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
- };
11
7
  export type CardHTMLAutoHeightOptions = {
12
8
  autoHeightId?: string;
13
9
  onAutoHeight?: (height: number) => void;
14
10
  };
15
11
  export declare function createAutoHeightMessageListener(iframe: HTMLIFrameElement, options?: CardHTMLAutoHeightOptions): CardHTMLRenderCleanup;
16
12
  export declare function isCardHTMLAutoHeightMessage(data: unknown, id: string): data is CardHTMLAutoHeightMessage;
17
- export declare function requestCardHTMLAutoHeight(iframe: HTMLIFrameElement, id: string): void;
18
13
  export declare function withCardHTMLAutoHeightBridge(html: string, id?: string): string;
@@ -1,10 +1,8 @@
1
1
  import type { Box2 } from '../math';
2
2
  import { type SnapdomOptions } from '@zumer/snapdom';
3
- import type { CardTypeConfig } from '../config';
4
3
  import type { EventEmitter } from '../shared';
5
4
  import type { SDKEvents } from '../sdk';
6
5
  import { type SDKItem } from '../sdk-item';
7
- import type { CardHTML } from '../types';
8
6
  type CardRasterizeOptions = {
9
7
  width: number;
10
8
  height: number;
@@ -26,35 +24,15 @@ type HTMLOverlayManagerOptions = {
26
24
  }) => void;
27
25
  viewportFit: (box: Box2) => void;
28
26
  setCardItemHeight: (id: string, height: number) => void;
29
- getSelectedItemIds: () => string[];
30
- getPreSelectedItemId: () => string | undefined;
31
- getSelectionEdgeStyle: () => {
32
- color: number;
33
- alpha: number;
34
- width: number;
35
- };
36
- getPreSelectionEdgeStyle: () => {
37
- color: number;
38
- alpha: number;
39
- width: number;
40
- };
41
- getCanvasEventTarget?: () => HTMLElement | undefined;
42
- resolveCardHTML: (item: SDKItem) => CardHTML | undefined;
43
- resolveCardTypeConfig: (item: SDKItem) => CardTypeConfig | undefined;
44
27
  };
45
28
  export declare class HTMLOverlayManager {
46
29
  private options;
47
30
  private eventCleanups;
48
- private htmlRootConfigCleanups;
49
- private pendingContentInteractionEvent?;
50
- private contentInteractionFrame?;
51
31
  private state;
52
32
  constructor(options: HTMLOverlayManagerOptions);
53
33
  attach(): void;
54
- get layerElement(): HTMLElement | undefined;
55
34
  dispose(): void;
56
35
  scheduleRender(): void;
57
- invalidateCardHTML(id: string): void;
58
36
  rasterizeCard(id: string, options: CardRasterizeOptions): Promise<string | undefined>;
59
37
  private initEvents;
60
38
  private initDOMEvents;
@@ -62,58 +40,30 @@ export declare class HTMLOverlayManager {
62
40
  private handleContainerMouseDown;
63
41
  private handleContainerMouseMove;
64
42
  private handleContainerMouseLeave;
65
- private isMouseLeaveWithinContainer;
66
- private handleContainerContextMenu;
67
- private isHTMLContextMenuEvent;
68
43
  private handleViewportTransform;
69
44
  private render;
70
45
  private syncOverlayOrder;
71
- private getOrCreateSelectionLayer;
72
46
  private renderFrameOverlays;
73
47
  private getOrCreateFrameOverlay;
74
48
  private getOrCreateOverlay;
75
- private getOrCreateSelectionOverlay;
76
- private syncOverlaySelection;
77
- private getSelectionBoxShadow;
78
- private getPreSelectionBoxShadow;
79
49
  private getHTMLCardIdByEvent;
80
50
  private getHoverShellInteractiveIdByEvent;
81
- private syncActiveContentInteraction;
82
- private scheduleActiveContentInteractionSync;
83
- private setActiveContentInteraction;
84
- private shouldKeepActiveContentInteractionForFocusedElement;
85
- private resolveHTMLInteractionTarget;
86
- private getActiveSubtreeInteractionAtEvent;
87
- private resolveContentInteractionZone;
88
- private getContentInteractionZones;
89
- private getContentInteractiveSelector;
90
- private isContentInteractionDisabled;
91
- private getContentInteractionZoneMode;
92
- private invalidateContentInteractionZones;
93
- private observeContentInteractionZoneResizes;
94
51
  private getLayerPoint;
95
52
  private getOrCreateContentOverlay;
96
53
  private createContentScaleOverlay;
97
54
  private syncContentScale;
98
- private requestAutoHeightFromIframes;
99
55
  private syncContentInteraction;
100
- private syncContentInteractionZones;
101
- private clearContentInteractionState;
102
56
  private syncShellInteraction;
103
57
  private enterEditing;
104
58
  private exitEditing;
105
- private isEditableCard;
106
59
  private getEditingFitZoom;
107
60
  private isEventInsideOverlay;
108
61
  private renderOverlayHTML;
109
- private observeContentInteractionZones;
110
- private applyHTMLRootConfig;
111
62
  private renderOverlayContent;
112
63
  private chainCleanups;
113
64
  private cleanupOverlayContent;
114
65
  private removeOverlay;
115
66
  private syncAutoHeight;
116
- private ensureAutoHeightMode;
117
67
  private createAutoHeightObserver;
118
68
  private scheduleAutoHeightMeasure;
119
69
  private measureAutoHeight;
@@ -122,9 +72,6 @@ export declare class HTMLOverlayManager {
122
72
  private getChildrenNaturalHeight;
123
73
  private cleanupAutoHeight;
124
74
  private applyAutoHeight;
125
- private getAutoHeightItemHeight;
126
75
  private isAutoHeightMessage;
127
- private isAutoHeightEnabled;
128
- private isAutoScaleEnabled;
129
76
  }
130
77
  export {};
@@ -4,11 +4,9 @@ export type CardOverlayBoxStyle = {
4
4
  top: string;
5
5
  width: string;
6
6
  height: string;
7
- contentWidth: number;
8
- contentHeight: number;
9
7
  transform: string;
10
8
  };
11
- export declare function getCardOverlayBoxStyle(box: Box2, width: number, height: number, offsetX?: number, offsetY?: number, _autoScale?: boolean): CardOverlayBoxStyle;
9
+ export declare function getCardOverlayBoxStyle(box: Box2, width: number, height: number, offsetX?: number, offsetY?: number): CardOverlayBoxStyle;
12
10
  export declare function isPointInCardOverlayBox(box: Box2, point: {
13
11
  x: number;
14
12
  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, 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, ItemCreateInfo, } from './types';
2
+ export type { CardTypeConfig, CardConfig } 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';