@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.
@@ -1,4 +1,4 @@
1
- import type { CardItemProperty, CardCreateInfo } from '../types';
1
+ import type { CardItemProperty, CardCreateInfo, CardHTML } from '../types';
2
2
  import { SDKItemType, type CardItemOptions } from './types';
3
3
  import { BaseItem } from './base-item';
4
4
  /**
@@ -21,6 +21,11 @@ export declare class CardItem extends BaseItem {
21
21
  */
22
22
  get cardType(): string;
23
23
  set cardType(value: string);
24
+ /**
25
+ * @description HTML 覆盖层配置
26
+ */
27
+ get html(): CardHTML | undefined;
28
+ set html(value: CardHTML | undefined);
24
29
  /**
25
30
  * @description 位置
26
31
  */
@@ -16,6 +16,8 @@ export declare class TextItem extends BaseItem {
16
16
  */
17
17
  property: TextItemProperty;
18
18
  constructor(options: TextItemOptions);
19
+ get pixelWidth(): number;
20
+ get pixelHeight(): number;
19
21
  /**
20
22
  * @description 文本内容
21
23
  */
package/dist/sdk.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Player, spec } from './shared';
2
- import type { SDKInputParam, PageConfig, PageData, SetItemPropertyParam, ViewProperty, ViewParam, ExportParam, SDKBackgroundType, SpriteCreateInfo, GroupCreateInfo, ItemCreateInfo, TextCreateInfo, ViewportFitShiftParam, SceneCreaetInfo, VideoCreateInfo, GeneratorCreateInfo, GeneratorResource, VideoGeneratorResource, SpriteGeneratorResource, EffectsCreateInfo, FrameCreateInfo, CardCreateInfo, CardHTML, CardItemTransformInfo, PageAutoLayoutParam } from './types';
2
+ import type { SDKInputParam, PageConfig, PageData, SetItemPropertyParam, ViewProperty, ViewParam, ExportParam, SDKBackgroundType, SpriteCreateInfo, GroupCreateInfo, ItemCreateInfo, TextCreateInfo, ViewportFitShiftParam, SceneCreaetInfo, VideoCreateInfo, GeneratorCreateInfo, GeneratorResource, VideoGeneratorResource, SpriteGeneratorResource, EffectsCreateInfo, FrameCreateInfo, CardCreateInfo, CardItemTransformInfo, PageAutoLayoutParam } from './types';
3
3
  import { SDKItemType } from './sdk-item/types';
4
4
  import type { CardTypeConfig } from './config';
5
5
  import { ItemOrderAction } from './types';
@@ -10,7 +10,7 @@ import { Box2, Vector2 } from './math';
10
10
  import { GizmoOperation, Operation, UndoRedo } from './service/UndoRedo';
11
11
  import { GestureHandlerInteractType, GizmoType, ItemCreateType, SpriteTextInitParam } from './gesture-handler/gizmo';
12
12
  import { AlignType, DistributeType } from './utils/types';
13
- import { SDKItem, type CardItem } from './sdk-item';
13
+ import { SDKItem } from './sdk-item';
14
14
  import type { LoadingGizmoItemOptions, LoadingGizmoTip } from './gesture-handler/gizmo/loading-gizmo';
15
15
  import type { MaskUndoRedoData } from './gesture-handler/gizmo/mask-gizmo';
16
16
  import type { PictureCutUndoRedoData } from './gesture-handler/gizmo/picture-cut-gizmo';
@@ -99,7 +99,6 @@ export declare class SDK {
99
99
  on: <E extends "progress" | "loadingItemChange" | "selectedItemChange" | "preSelectedItemChange" | "selectedViewChange" | "pageDataChange" | "zoomChange" | "itemPropertyChange" | "exportProgress" | "exportDone" | "exportComplete" | "sdkConfigChange" | "cutBoxChange" | "expandBoxChange" | "textInput" | "undoRedoChange" | "maskGizmoUndoRedoChange" | "pictureCutGizmoUndoRedoChange" | "viewportTransform" | "itemOnDragStart" | "itemOnDrag" | "itemOnDragEnd" | "spriteTextClick" | "videoPlay" | "itemCreate" | "cardItemTransformChange" | "viewLost" | "viewRebuildFinish">(eventName: E, listener: import("@galacean/effects").EventEmitterListener<SDKEvents[E]>, options?: import("@galacean/effects").EventEmitterOptions) => () => void;
100
100
  initPlayer(mode: SDKMode): void;
101
101
  setSDKMode(mode: SDKMode): void;
102
- private syncCanvasLayerOrder;
103
102
  private getInitParam;
104
103
  private initExporter;
105
104
  private initSDK;
@@ -309,9 +308,9 @@ export declare class SDK {
309
308
  setMaskGizmoConfig(config: Partial<MaskGizmoConfig>): void;
310
309
  /**
311
310
  * @description 设置蒙版工具模式
312
- * @param mode 模式类型:'paint' 表示涂抹,'erase' 表示擦除
311
+ * @param mode 模式类型:'paint' 笔刷涂抹、'erase' 笔刷逐笔擦除、'box-erase' 框选擦除、'box-paint' 框选涂抹
313
312
  */
314
- setMaskGizmoMode(mode: 'paint' | 'erase'): void;
313
+ setMaskGizmoMode(mode: 'paint' | 'erase' | 'box-erase' | 'box-paint'): void;
315
314
  /**
316
315
  * 撤销蒙版操作
317
316
  * @returns 是否成功撤销
@@ -508,25 +507,6 @@ export declare class SDK {
508
507
  * @returns 是否已注册
509
508
  */
510
509
  isCardTypeRegistered(type: string): boolean;
511
- /**
512
- * @description 按 cardType 从注册表解析卡片的 HTML 渲染配置。
513
- * @param item 卡片元素
514
- * @returns HTML 渲染配置
515
- */
516
- resolveCardHTML(item: CardItem): CardHTML | undefined;
517
- /**
518
- * @description 按 cardType 从注册表解析卡片类型配置。
519
- * @param item 卡片元素
520
- * @returns 卡片类型配置
521
- */
522
- resolveCardTypeConfig(item: CardItem): CardTypeConfig | undefined;
523
- /**
524
- * @description 重新解析并挂载指定卡片的 HTML 内容。
525
- * @description 当 inline/document 内容依赖 extension 或外部状态变化时,可调用此方法刷新 DOM。
526
- * @param id 卡片元素 ID
527
- * @returns 是否成功触发刷新
528
- */
529
- refreshCardHTML(id: string): boolean;
530
510
  /**
531
511
  * @description 创建卡片元素
532
512
  * @description 底层以透明 SpriteItem 形式渲染,支持 cardType 属性
package/dist/types.d.ts CHANGED
@@ -204,17 +204,6 @@ export type CardHTMLShellContent = {
204
204
  */
205
205
  render: CardHTMLShellRenderer;
206
206
  };
207
- export type CardHTMLRootStyle = Record<string, string | number | undefined>;
208
- export type CardHTMLRootConfig = {
209
- /**
210
- * @description 追加到 HTML 内容根节点的 className。
211
- */
212
- className?: string;
213
- /**
214
- * @description 应用到 HTML 内容根节点的内联样式。
215
- */
216
- style?: CardHTMLRootStyle;
217
- };
218
207
  /**
219
208
  * @description Card HTML 覆盖层配置。
220
209
  */
@@ -227,19 +216,23 @@ export type CardHTML = {
227
216
  * @description HTML 外壳,用于定制承载 content 的容器。
228
217
  */
229
218
  shell?: CardHTMLShellContent;
230
- /**
231
- * @description HTML 内容根节点样式配置,用于按内容实例设置 className 或内联 style。
232
- */
233
- root?: CardHTMLRootConfig;
234
219
  };
235
220
  /**
236
221
  * @description Card 卡片元素属性
237
222
  */
238
223
  export type CardItemProperty = BaseItemProperty & {
239
224
  /**
240
- * @description 卡片类型(动态配置,需通过 SDK.registerCardType/registerCardTypes 注册)
225
+ * @description 卡片类型(动态配置,需在 SDK.config.itemConfig.cardConfig.cardTypes 中注册)
241
226
  */
242
227
  cardType: string;
228
+ /**
229
+ * @description 是否根据 HTML 挂载内容的自然高度自动更新卡片高度
230
+ */
231
+ autoHeight?: boolean;
232
+ /**
233
+ * @description HTML 覆盖层配置;存在该字段时由 DOM overlay 渲染
234
+ */
235
+ html?: CardHTML;
243
236
  };
244
237
  /**
245
238
  * @description Frame 画板元素布局模式
@@ -475,6 +468,10 @@ export type PageAutoLayoutParam = {
475
468
  * @description 自动布局间隔
476
469
  */
477
470
  gap?: number;
471
+ /**
472
+ * 视图自适应偏移参数
473
+ */
474
+ shift?: ViewportFitShiftParam;
478
475
  };
479
476
  /**
480
477
  * @description 页面配置
@@ -934,7 +931,7 @@ export type CardItemTransformInfo = {
934
931
  size: [number, number];
935
932
  };
936
933
  /**
937
- * @description 卡片类型(动态配置,需通过 SDK.registerCardType/registerCardTypes 注册)
934
+ * @description 卡片类型(动态配置,需在 SDK.config.itemConfig.cardConfig.cardTypes 中注册)
938
935
  */
939
936
  export type CardType = string;
940
937
  /**
@@ -977,6 +974,10 @@ export type CardCreateInfo = {
977
974
  * @description 卡片元素像素高度
978
975
  */
979
976
  height: number;
977
+ /**
978
+ * @description 是否根据 HTML 挂载内容的自然高度自动更新卡片高度
979
+ */
980
+ autoHeight?: boolean;
980
981
  /**
981
982
  * @description 卡片元素位置
982
983
  */
@@ -989,6 +990,10 @@ export type CardCreateInfo = {
989
990
  * @description 卡片元素缩放
990
991
  */
991
992
  scale?: [number, number];
993
+ /**
994
+ * @description HTML 覆盖层配置;存在该字段时由 DOM overlay 渲染
995
+ */
996
+ html?: CardHTML;
992
997
  };
993
998
  };
994
999
  /**
@@ -88,10 +88,6 @@ export declare class PageDataUtils {
88
88
  * 2. 单个元素多个属性: { itemId, type, property }
89
89
  */
90
90
  setItemProperty<T extends SDKItemType>(param: SetItemPropertyParam<T>): Promise<void>;
91
- /**
92
- * @description 设置元素extension字段
93
- */
94
- setItemExtension(itemId: string, extension: Record<string, any>): void;
95
91
  /**
96
92
  * @description 场景 1: 设置单个元素的单个属性
97
93
  */
@@ -288,6 +284,15 @@ export declare class PageDataUtils {
288
284
  setItemFontFamily(id: string, fontFamilyName: string, url: string): Promise<void>;
289
285
  changeItemPropertyByCreateInfo(itemCreateInfo: ItemCreateInfo | ItemCreateInfo[]): Promise<void>;
290
286
  getViewBoxByBox(box: Box2): Box2;
287
+ /**
288
+ * @description 快照当前所有视频元素的播放状态(播放/暂停 + 当前播放进度),用于属性刷新后恢复,
289
+ * 避免设置属性导致全量视频被自动播放或进度被重置回 0s
290
+ */
291
+ private snapshotVideoPlayStates;
292
+ /**
293
+ * @description 按快照恢复视频元素的播放状态(先 pause 再 seek,最后按原状态 play/pause,避免进度抖动)
294
+ */
295
+ private restoreVideoPlayStates;
291
296
  playVideoItem(id?: string): void;
292
297
  pauseVideoItem(id?: string): void;
293
298
  playEffectsItem(id?: string): void;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vvfx/sdk",
3
3
  "description": "TODO",
4
- "version": "0.2.2-beta.9",
4
+ "version": "0.2.3",
5
5
  "main": "./dist/index.mjs",
6
6
  "module": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
@@ -68,7 +68,7 @@
68
68
  "prebuild": "pnpm clean",
69
69
  "build": "pnpm build:declaration && pnpm build:module",
70
70
  "build:module": "rollup -c --bundleConfigAsCjs",
71
- "build:declaration": "tsc -p tsconfig.build.json",
71
+ "build:declaration": "tsc -d --emitDeclarationOnly",
72
72
  "clean": "rimraf dist *.tsbuildinfo",
73
73
  "test": "vitest run"
74
74
  }
@@ -1,7 +0,0 @@
1
- export type SDKCanvasLayers = {
2
- container: HTMLElement;
3
- playerContainer?: HTMLElement;
4
- htmlOverlayLayer?: HTMLElement;
5
- gestureCanvas?: HTMLElement;
6
- };
7
- export declare function orderSDKCanvasLayers({ container, playerContainer, htmlOverlayLayer, gestureCanvas, }: SDKCanvasLayers): void;