@vvfx/sdk 0.2.1 → 0.2.2-beta.2

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.
@@ -0,0 +1 @@
1
+ export {};
@@ -1,6 +1,9 @@
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;
4
7
  /**
5
8
  * @description SDK功能配置
6
9
  */
@@ -136,6 +139,10 @@ export type CardTypeConfig = {
136
139
  * @description TransformGizmo 左上角展示的 icon URL
137
140
  */
138
141
  iconUrl: string;
142
+ /**
143
+ * @description 卡片类型对应的运行时 HTML 渲染配置;函数不会进入序列化数据,恢复时由 cardType 动态解析。
144
+ */
145
+ html?: CardTypeHTMLResolver;
139
146
  };
140
147
  /**
141
148
  * @description 卡片元素参数配置
@@ -146,7 +153,7 @@ export type CardConfig = {
146
153
  */
147
154
  backgroundColor: [number, number, number, number];
148
155
  /**
149
- * @description 注册的卡片类型列表,支持动态配置
156
+ * @description 注册的卡片类型列表,支持通过 registerCardType/registerCardTypes 动态配置
150
157
  * 每个条目包含 type 标识、显示名称和图标 URL
151
158
  */
152
159
  cardTypes: CardTypeConfig[];
@@ -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;
@@ -3,6 +3,7 @@ import { type SnapdomOptions } from '@zumer/snapdom';
3
3
  import type { EventEmitter } from '../shared';
4
4
  import type { SDKEvents } from '../sdk';
5
5
  import { type SDKItem } from '../sdk-item';
6
+ import type { CardHTML } from '../types';
6
7
  type CardRasterizeOptions = {
7
8
  width: number;
8
9
  height: number;
@@ -24,6 +25,7 @@ type HTMLOverlayManagerOptions = {
24
25
  }) => void;
25
26
  viewportFit: (box: Box2) => void;
26
27
  setCardItemHeight: (id: string, height: number) => void;
28
+ resolveCardHTML: (item: SDKItem) => CardHTML | undefined;
27
29
  };
28
30
  export declare class HTMLOverlayManager {
29
31
  private options;
@@ -52,6 +54,7 @@ export declare class HTMLOverlayManager {
52
54
  private getOrCreateContentOverlay;
53
55
  private createContentScaleOverlay;
54
56
  private syncContentScale;
57
+ private requestAutoHeightFromIframes;
55
58
  private syncContentInteraction;
56
59
  private syncShellInteraction;
57
60
  private enterEditing;
@@ -64,6 +67,7 @@ export declare class HTMLOverlayManager {
64
67
  private cleanupOverlayContent;
65
68
  private removeOverlay;
66
69
  private syncAutoHeight;
70
+ private ensureAutoHeightMode;
67
71
  private createAutoHeightObserver;
68
72
  private scheduleAutoHeightMeasure;
69
73
  private measureAutoHeight;
@@ -72,6 +76,7 @@ export declare class HTMLOverlayManager {
72
76
  private getChildrenNaturalHeight;
73
77
  private cleanupAutoHeight;
74
78
  private applyAutoHeight;
79
+ private getAutoHeightItemHeight;
75
80
  private isAutoHeightMessage;
76
81
  }
77
82
  export {};
@@ -0,0 +1 @@
1
+ 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;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,4 @@
1
- import type { CardItemProperty, CardCreateInfo, CardHTML } from '../types';
1
+ import type { CardItemProperty, CardCreateInfo } from '../types';
2
2
  import { SDKItemType, type CardItemOptions } from './types';
3
3
  import { BaseItem } from './base-item';
4
4
  /**
@@ -21,11 +21,6 @@ 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);
29
24
  /**
30
25
  * @description 位置
31
26
  */
package/dist/src/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, 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, CardHTML, 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 } from './sdk-item';
13
+ import { SDKItem, type CardItem } 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';
@@ -507,6 +507,12 @@ export declare class SDK {
507
507
  * @returns 是否已注册
508
508
  */
509
509
  isCardTypeRegistered(type: string): boolean;
510
+ /**
511
+ * @description 按 cardType 从注册表解析卡片的 HTML 渲染配置。
512
+ * @param item 卡片元素
513
+ * @returns HTML 渲染配置
514
+ */
515
+ resolveCardHTML(item: CardItem): CardHTML | undefined;
510
516
  /**
511
517
  * @description 创建卡片元素
512
518
  * @description 底层以透明 SpriteItem 形式渲染,支持 cardType 属性
@@ -222,7 +222,7 @@ export type CardHTML = {
222
222
  */
223
223
  export type CardItemProperty = BaseItemProperty & {
224
224
  /**
225
- * @description 卡片类型(动态配置,需在 SDK.config.itemConfig.cardConfig.cardTypes 中注册)
225
+ * @description 卡片类型(动态配置,需通过 SDK.registerCardType/registerCardTypes 注册)
226
226
  */
227
227
  cardType: string;
228
228
  /**
@@ -230,9 +230,9 @@ export type CardItemProperty = BaseItemProperty & {
230
230
  */
231
231
  autoHeight?: boolean;
232
232
  /**
233
- * @description HTML 覆盖层配置;存在该字段时由 DOM overlay 渲染
233
+ * @description HTML 内容是否跟随卡片 scale 缩放,关闭后 HTML 按最终显示尺寸重新布局
234
234
  */
235
- html?: CardHTML;
235
+ autoScale?: boolean;
236
236
  };
237
237
  /**
238
238
  * @description Frame 画板元素布局模式
@@ -927,7 +927,7 @@ export type CardItemTransformInfo = {
927
927
  size: [number, number];
928
928
  };
929
929
  /**
930
- * @description 卡片类型(动态配置,需在 SDK.config.itemConfig.cardConfig.cardTypes 中注册)
930
+ * @description 卡片类型(动态配置,需通过 SDK.registerCardType/registerCardTypes 注册)
931
931
  */
932
932
  export type CardType = string;
933
933
  /**
@@ -974,6 +974,10 @@ export type CardCreateInfo = {
974
974
  * @description 是否根据 HTML 挂载内容的自然高度自动更新卡片高度
975
975
  */
976
976
  autoHeight?: boolean;
977
+ /**
978
+ * @description HTML 内容是否跟随卡片 scale 缩放,关闭后 HTML 按最终显示尺寸重新布局
979
+ */
980
+ autoScale?: boolean;
977
981
  /**
978
982
  * @description 卡片元素位置
979
983
  */
@@ -986,10 +990,6 @@ export type CardCreateInfo = {
986
990
  * @description 卡片元素缩放
987
991
  */
988
992
  scale?: [number, number];
989
- /**
990
- * @description HTML 覆盖层配置;存在该字段时由 DOM overlay 渲染
991
- */
992
- html?: CardHTML;
993
993
  };
994
994
  };
995
995
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vvfx/sdk",
3
3
  "description": "TODO",
4
- "version": "0.2.1",
4
+ "version": "0.2.2-beta.2",
5
5
  "main": "./dist/index.mjs",
6
6
  "module": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
@@ -15,15 +15,6 @@
15
15
  "require": "./dist/index.mjs"
16
16
  }
17
17
  },
18
- "scripts": {
19
- "prebuild": "pnpm clean",
20
- "build": "pnpm build:declaration && pnpm build:module",
21
- "build:module": "rollup -c --bundleConfigAsCjs",
22
- "build:declaration": "tsc -d --emitDeclarationOnly",
23
- "clean": "rimraf dist *.tsbuildinfo",
24
- "test": "vitest run",
25
- "prepublishOnly": "pnpm build"
26
- },
27
18
  "dependencies": {
28
19
  "@ffmpeg/ffmpeg": "0.12.15",
29
20
  "@ffmpeg/util": "0.12.2",
@@ -72,5 +63,13 @@
72
63
  "publishConfig": {
73
64
  "access": "public",
74
65
  "registry": "https://registry.npmjs.org"
66
+ },
67
+ "scripts": {
68
+ "prebuild": "pnpm clean",
69
+ "build": "pnpm build:declaration && pnpm build:module",
70
+ "build:module": "rollup -c --bundleConfigAsCjs",
71
+ "build:declaration": "tsc -d --emitDeclarationOnly",
72
+ "clean": "rimraf dist *.tsbuildinfo",
73
+ "test": "vitest run"
75
74
  }
76
- }
75
+ }