@vvfx/sdk 0.1.19-alpha.9 → 0.2.0

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.
Files changed (102) hide show
  1. package/LICENSE +22 -0
  2. package/dist/index.js +96633 -14
  3. package/dist/index.js.map +1 -0
  4. package/dist/index.mjs +96736 -0
  5. package/dist/index.mjs.map +1 -0
  6. package/dist/src/config.d.ts +855 -0
  7. package/dist/src/exporter/config.d.ts +18 -0
  8. package/dist/src/exporter/const.d.ts +71 -0
  9. package/dist/src/exporter/export-media.d.ts +68 -0
  10. package/dist/src/exporter/exporter.d.ts +22 -0
  11. package/dist/src/exporter/index.d.ts +2 -0
  12. package/dist/src/exporter/types.d.ts +194 -0
  13. package/dist/src/exporter/utils.d.ts +22 -0
  14. package/dist/src/exporter/wav-audio.d.ts +27 -0
  15. package/dist/src/gesture-handler/gizmo/adsorption-gizmo.d.ts +68 -0
  16. package/dist/src/gesture-handler/gizmo/control-gizmo.d.ts +67 -0
  17. package/dist/src/gesture-handler/gizmo/gizmo.d.ts +59 -0
  18. package/dist/src/gesture-handler/gizmo/icon-gizmo.d.ts +44 -0
  19. package/dist/src/gesture-handler/gizmo/index.d.ts +6 -0
  20. package/dist/src/gesture-handler/gizmo/item-create-gizmo.d.ts +43 -0
  21. package/dist/src/gesture-handler/gizmo/loading-gizmo.d.ts +48 -0
  22. package/dist/src/gesture-handler/gizmo/mask-gizmo.d.ts +113 -0
  23. package/dist/src/gesture-handler/gizmo/picture-cut-gizmo.d.ts +94 -0
  24. package/dist/src/gesture-handler/gizmo/picture-expand-gizmo.d.ts +57 -0
  25. package/dist/src/gesture-handler/gizmo/preference-gizmo.d.ts +32 -0
  26. package/dist/src/gesture-handler/gizmo/selector-gizmo.d.ts +101 -0
  27. package/dist/src/gesture-handler/gizmo/sprite-text-edit-gizmo.d.ts +36 -0
  28. package/dist/src/gesture-handler/gizmo/text-gizmo.d.ts +128 -0
  29. package/dist/src/gesture-handler/gizmo/transform-gizmo.d.ts +233 -0
  30. package/dist/src/gesture-handler/gizmo/type.d.ts +402 -0
  31. package/dist/src/gesture-handler/index.d.ts +3 -0
  32. package/dist/src/gesture-handler/src/gesture-handler.d.ts +143 -0
  33. package/dist/src/gesture-handler/src/icons.d.ts +7 -0
  34. package/dist/src/gesture-handler/utils.d.ts +2 -0
  35. package/dist/src/html-overlay/auto-height-runtime.d.ts +13 -0
  36. package/dist/src/html-overlay/document-runtime.d.ts +4 -0
  37. package/dist/src/html-overlay/document-transform.d.ts +7 -0
  38. package/dist/src/html-overlay/dom-order.d.ts +1 -0
  39. package/dist/src/html-overlay/host-message-runtime.d.ts +3 -0
  40. package/dist/src/html-overlay/html-viewport-style.d.ts +1 -0
  41. package/dist/src/html-overlay/index.d.ts +1 -0
  42. package/dist/src/html-overlay/manager.d.ts +77 -0
  43. package/dist/src/html-overlay/mime-utils.d.ts +2 -0
  44. package/dist/src/html-overlay/overlay-transform.d.ts +13 -0
  45. package/dist/src/html-overlay/path-utils.d.ts +8 -0
  46. package/dist/src/html-overlay/shell-runtime.d.ts +6 -0
  47. package/dist/src/index.d.ts +14 -0
  48. package/dist/src/math/box2.d.ts +166 -0
  49. package/dist/src/math/circle.d.ts +82 -0
  50. package/dist/src/math/euler.d.ts +20 -0
  51. package/dist/src/math/index.d.ts +13 -0
  52. package/dist/src/math/line2.d.ts +93 -0
  53. package/dist/src/math/line3.d.ts +17 -0
  54. package/dist/src/math/matrix4.d.ts +28 -0
  55. package/dist/src/math/plane.d.ts +14 -0
  56. package/dist/src/math/quaternion.d.ts +3 -0
  57. package/dist/src/math/ray-caster.d.ts +10 -0
  58. package/dist/src/math/ray.d.ts +18 -0
  59. package/dist/src/math/type.d.ts +32 -0
  60. package/dist/src/math/utils.d.ts +19 -0
  61. package/dist/src/math/vector2.d.ts +30 -0
  62. package/dist/src/math/vector3.d.ts +29 -0
  63. package/dist/src/screen-shot/index.d.ts +1 -0
  64. package/dist/src/screen-shot/screen-shot.d.ts +35 -0
  65. package/dist/src/sdk-item/base-item.d.ts +126 -0
  66. package/dist/src/sdk-item/card-item.d.ts +67 -0
  67. package/dist/src/sdk-item/effects-item.d.ts +70 -0
  68. package/dist/src/sdk-item/frame-item.d.ts +112 -0
  69. package/dist/src/sdk-item/generator-item.d.ts +86 -0
  70. package/dist/src/sdk-item/group-item.d.ts +57 -0
  71. package/dist/src/sdk-item/index.d.ts +36 -0
  72. package/dist/src/sdk-item/sprite-item.d.ts +67 -0
  73. package/dist/src/sdk-item/text-item.d.ts +107 -0
  74. package/dist/src/sdk-item/types.d.ts +153 -0
  75. package/dist/src/sdk-item/video-item.d.ts +87 -0
  76. package/dist/src/sdk.d.ts +589 -0
  77. package/dist/src/service/UndoRedo.d.ts +48 -0
  78. package/dist/src/shared/index.d.ts +1 -0
  79. package/dist/src/shared/player.d.ts +9 -0
  80. package/dist/src/size-adapte/index.d.ts +1 -0
  81. package/dist/src/size-adapte/size-adapt.d.ts +28 -0
  82. package/dist/src/types.d.ts +1298 -0
  83. package/dist/src/utils/background-manager.d.ts +72 -0
  84. package/dist/src/utils/common-utils.d.ts +28 -0
  85. package/dist/src/utils/index.d.ts +8 -0
  86. package/dist/src/utils/interaction-utils.d.ts +60 -0
  87. package/dist/src/utils/json-data-utils.d.ts +165 -0
  88. package/dist/src/utils/layout-utils.d.ts +219 -0
  89. package/dist/src/utils/page-data-utils.d.ts +372 -0
  90. package/dist/src/utils/player-data-utils.d.ts +11 -0
  91. package/dist/src/utils/types.d.ts +114 -0
  92. package/dist/src/wireframe/common/box.d.ts +1 -0
  93. package/dist/src/wireframe/common/dashed-line.d.ts +1 -0
  94. package/dist/src/wireframe/common/line.d.ts +1 -0
  95. package/dist/src/wireframe/common/pixi-ext.d.ts +11 -0
  96. package/dist/src/wireframe/common/pixi.d.ts +18 -0
  97. package/dist/src/wireframe/index.d.ts +4 -0
  98. package/package.json +42 -22
  99. package/dist/index.cjs +0 -14
  100. package/dist/index.d.cts +0 -3555
  101. package/dist/index.d.ts +0 -3555
  102. package/dist/index.global.js +0 -333
@@ -0,0 +1,372 @@
1
+ import { SDK, SDKEvents } from '../sdk';
2
+ import type { Player, EventEmitter, Composition } from '../shared';
3
+ import { VFXItem } from '../shared';
4
+ import type { SetItemPropertyParam, SpriteCreateInfo, GroupCreateInfo, TextCreateInfo, ViewportFitShiftParam, ItemCreateInfo, VideoCreateInfo, AsyncSpriteCreateInfo, AsyncVideoCreateInfo, GeneratorCreateInfo, EffectsCreateInfo, FrameCreateInfo, PageAutoLayoutParam, CardCreateInfo } from '../types';
5
+ import type { SDKItem } from '../sdk-item';
6
+ import { ItemOrderAction } from '../types';
7
+ import { InteractionUtils } from './interaction-utils';
8
+ import { spec } from '../shared';
9
+ import { Box2, Matrix4, Vector2, Vector3 } from '../math';
10
+ import { MoveItemTransformOptions } from './json-data-utils';
11
+ import { AlignType, DistributeType } from './types';
12
+ import { SDKItemType } from '../sdk-item/types';
13
+ type ScreenShotCardRasterizer = (cardCreateInfo: CardCreateInfo) => Promise<string | undefined>;
14
+ export declare class PageDataUtils {
15
+ private sdk;
16
+ player: Player;
17
+ container: HTMLElement;
18
+ emitter: EventEmitter<SDKEvents>;
19
+ interactionUtils: InteractionUtils;
20
+ constructor(player: Player, container: HTMLElement, emitter: EventEmitter<SDKEvents>, sdk: SDK);
21
+ init(): void;
22
+ getPageData(): import("..").PageData | undefined;
23
+ getCurrentComposition(): Composition;
24
+ isItemSelected(id: string): boolean;
25
+ getItemEditEnable(id: string): boolean;
26
+ getItemShow(id: string): boolean;
27
+ addSelectedItems(ids: string[]): void;
28
+ removeSelectedItems(ids: string[]): void;
29
+ clearSelectedItems(emitChange?: boolean): void;
30
+ getSelectedItems(): SDKItem[];
31
+ addPreSelectedItem(id: string): void;
32
+ clearPreSelectedItem(): void;
33
+ getPreSelectedItem(): SDKItem | undefined;
34
+ addLoadingItems(ids: string[]): void;
35
+ removeLoadingItems(ids: string[]): void;
36
+ clearLoadingItems(): void;
37
+ getLoadingItems(): SDKItem[];
38
+ getSDKItem(id: string): SDKItem | undefined;
39
+ getPlayerSizeByParent(parentSize: [number, number], sceneSize: [number, number]): readonly [number, number];
40
+ loadScene(id: number): Promise<void>;
41
+ refreshPageTime(number: number): void;
42
+ pageZoom(shift: number, center?: Vector2, ignoreClamp?: boolean): void;
43
+ setPageZoom(targetZoom: number, center?: Vector2, ignoreClamp?: boolean): void;
44
+ refreshInteractionParam(): void;
45
+ pageMove(shift: Vector2): void;
46
+ setPageMove(targetTranslation: Vector2): void;
47
+ /**
48
+ * @description 设置当前相机视图矩阵
49
+ * @param matrix 视图矩阵
50
+ */
51
+ setCurrenCameraViewportMatrix(matrix: Matrix4): void;
52
+ rotateItem(id: string, shift: Vector3, ignoreEvent?: boolean): void;
53
+ moveItem(id: string, shift: Vector3, ignoreEvent?: boolean): void;
54
+ scaleItem(id: string, shift: Vector3, ignoreEvent?: boolean): void;
55
+ /**
56
+ * @description 触发卡片元素变换事件,返回视口坐标系中的位置与大小
57
+ * @param ids 指定卡片元素 ID(不传则返回所有卡片元素)
58
+ */
59
+ private emitCardItemTransformChange;
60
+ scaleTextItemWidth(id: string, scalar: number): void;
61
+ scaleTextItem(id: string, scalar: number): void;
62
+ getItemTransformById(id: string): {
63
+ matrix: Matrix4;
64
+ parentMatrix: Matrix4;
65
+ };
66
+ addSDKItemsByItems(result: SDKItem[], playerItems: VFXItem[], id?: string): void;
67
+ getFilterItemIds(): (string | undefined)[];
68
+ createSDKItemByPlayerItem(playerItem: VFXItem, parentId?: string): SDKItem;
69
+ /**
70
+ * @description 根据 spec.ItemType 创建 SDKItem(内部辅助方法)
71
+ * @param itemType spec.ItemType
72
+ * @param baseOptions 基础选项
73
+ * @param property 属性
74
+ * @returns SDKItem 实例
75
+ */
76
+ private createSDKItemBySpecType;
77
+ getViewBoxById(id: string): Box2;
78
+ getItemViewAnchor(id: string): Vector2 | undefined;
79
+ getChildrenPlayerItems(item?: VFXItem): VFXItem[];
80
+ getChildrenSceneItemIds(id: string, scene: spec.JSONScene): string[];
81
+ getViewBoxByPlayerItem(item: VFXItem, childrenItem: VFXItem[]): Box2;
82
+ getViewportLeftTopPosition(): Vector2;
83
+ getViewportByViewPoint(point: Vector2): Vector2;
84
+ /**
85
+ * @description 设置元素属性(支持单个元素的单/多属性设置)
86
+ * @param param 设置参数,支持两种场景:
87
+ * 1. 单个元素单个属性: { itemId, type, propertyName, propertyValue }
88
+ * 2. 单个元素多个属性: { itemId, type, property }
89
+ */
90
+ setItemProperty<T extends SDKItemType>(param: SetItemPropertyParam<T>): Promise<void>;
91
+ /**
92
+ * @description 场景 1: 设置单个元素的单个属性
93
+ */
94
+ private setSingleItemSingleProperty;
95
+ /**
96
+ * @description 场景 2: 设置单个元素的多个属性
97
+ */
98
+ private setSingleItemMultipleProperties;
99
+ /**
100
+ * @description 更新 PlayerItem 的属性
101
+ * @param itemId 元素ID
102
+ * @param propertyName 属性名
103
+ * @param propertyValue 属性值
104
+ */
105
+ private updatePlayerItemProperty;
106
+ /**
107
+ * @description 更新 PlayerItem 的基础属性
108
+ */
109
+ private updatePlayerItemBaseProperty;
110
+ /**
111
+ * @description 更新 PlayerItem 的 Property 属性
112
+ */
113
+ private updatePlayerItemPropertyAttribute;
114
+ /**
115
+ * @description 更新 JSON Scene 中 Item 的属性
116
+ * @param itemId 元素ID
117
+ * @param propertyName 属性名
118
+ * @param propertyValue 属性值
119
+ */
120
+ private updateJSONItemProperty;
121
+ /**
122
+ * @description 更新 Scene 中 Item 的基础属性
123
+ */
124
+ private updateSceneItemBaseProperty;
125
+ /**
126
+ * @description 更新 Scene 中 Item 的 Property 属性
127
+ */
128
+ updateSceneItemPropertyAttribute(scene: spec.JSONScene, itemId: string, propertyName: string, propertyValue: any): void;
129
+ setSpriteSize(id: string, size: [number, number]): void;
130
+ transformSceneItem(id: string, property: 'position' | 'rotation' | 'scale', shift: [number, number, number]): void;
131
+ refreshSDKItem(id: string): void;
132
+ /**
133
+ * @description 更新已有 SDKItem 的属性(而不是替换整个对象)
134
+ * @param sdkItem 需要更新的 SDKItem
135
+ * @param playerItem 对应的 Player VFXItem
136
+ */
137
+ updateSDKItemFromPlayerItem(sdkItem: SDKItem, playerItem: VFXItem): void;
138
+ getPlayerItemById(id?: string): VFXItem | undefined;
139
+ getPixelSizeByWorldSize(worldSize: spec.vec3, item: VFXItem): spec.vec2;
140
+ getWorldSizeByPixelSize(pixelSize: spec.vec2): spec.vec2;
141
+ /**
142
+ * @private
143
+ * @description 获取当前激活的场景
144
+ */
145
+ private getActiveTargetScene;
146
+ /**
147
+ * @description 获取场景主合成的 previewSize
148
+ * @param scene 可选,未传时取当前激活视图场景
149
+ * @returns 主合成的 previewSize;场景/主合成/previewSize 任一不存在时返回 undefined
150
+ */
151
+ getSceneSize(scene?: spec.JSONScene): Vector2 | undefined;
152
+ /**
153
+ * @private
154
+ * @description 刷新场景和页面数据
155
+ */
156
+ private refreshSceneAndPageData;
157
+ addSpriteItem(spriteInfo: AsyncSpriteCreateInfo, asyncMode: true, targetScene?: spec.JSONScene): Promise<string>;
158
+ addSpriteItem(spriteInfo: SpriteCreateInfo, asyncMode: false, targetScene?: spec.JSONScene): Promise<string>;
159
+ /**
160
+ * @description 添加卡片元素
161
+ * @description 底层以透明 SpriteItem 形式渲染,不传 textureId
162
+ * @param cardInfo 卡片创建信息
163
+ * @param targetScene 目标场景(可选)
164
+ * @returns 元素 id
165
+ */
166
+ addCardItem(cardInfo: CardCreateInfo, targetScene?: spec.JSONScene): string | undefined;
167
+ addGroupItem(groupInfo: GroupCreateInfo, targetScene?: spec.JSONScene): string | undefined;
168
+ addTextItem(textInfo: TextCreateInfo, targetScene?: spec.JSONScene): Promise<string | undefined>;
169
+ addVideoItem(videoInfo: AsyncVideoCreateInfo, asyncMode: true, targetScene?: spec.JSONScene): Promise<string>;
170
+ addVideoItem(videoInfo: VideoCreateInfo, asyncMode: false, targetScene?: spec.JSONScene): Promise<string>;
171
+ /**
172
+ * @description 添加生成器元素
173
+ * @param createInfo 生成器创建信息
174
+ * @param targetScene 目标场景
175
+ * @returns 元素ID
176
+ */
177
+ addGeneratorItem(createInfo: GeneratorCreateInfo, targetScene?: spec.JSONScene): string;
178
+ /**
179
+ * @description 设置生成器资源,将生成器转换为对应的元素(SpriteItem 或 VideoItem)
180
+ * @param id 生成器元素ID
181
+ * @param resourceUrl 资源地址
182
+ * @returns 新的元素ID
183
+ */
184
+ setGeneratorResource(id: string, resourceUrl: string): Promise<string>;
185
+ /**
186
+ * @description 将视频生成器转换为视频元素
187
+ * @param id 视频生成器元素ID
188
+ * @param videoUrl 视频资源地址
189
+ * @returns 新的视频元素ID
190
+ * @deprecated 使用 setGeneratorResource 替代
191
+ */
192
+ convertVideoGeneratorToVideo(id: string, videoUrl: string): Promise<string>;
193
+ /**
194
+ * @description 删除元素
195
+ * @param id 元素id
196
+ */
197
+ deleteItem(id: string): void;
198
+ /**
199
+ * @description 统一的元素认父函数,根据父节点类型自动选择处理逻辑
200
+ * @param itemId 子元素ID
201
+ * @param parentId 父元素ID
202
+ * @param targetScene 目标场景(可选,默认当前场景)
203
+ * @returns 是否认父成功
204
+ */
205
+ setItemParentUnified(itemId: string, parentId: string, targetScene?: spec.JSONScene): boolean;
206
+ /**
207
+ * @description 将元素设置到空节点/组下
208
+ * @param itemId 子元素ID
209
+ * @param parentId 父节点ID(必须是空节点/组)
210
+ * @param targetScene 目标场景
211
+ * @private
212
+ */
213
+ private setItemParentToGroup;
214
+ /**
215
+ */
216
+ setItemParent(id: string, parentId: string, targetScene?: spec.JSONScene): void;
217
+ deleteItemParent(id: string, parentId: string, targetScene?: spec.JSONScene): void;
218
+ /**
219
+ * @description 将元素移动到 Frame 中
220
+ * @param itemIds 要移动的元素ID列表
221
+ * @param frameId 目标 Frame ID
222
+ */
223
+ moveItemsToFrame(itemIds: string[], frameId: string): void;
224
+ /**
225
+ * @description 移动单个元素到 Frame(仅 JSON 层,Player 层在 reLoad 后重建)
226
+ * @private
227
+ */
228
+ private moveSingleJSONItemToFrame;
229
+ /**
230
+ * @description 移动单个元素到 Frame(保持 parentId)
231
+ * @param itemId 元素ID
232
+ * @param frameItem 目标 Frame
233
+ * @param options 变换选项
234
+ * @param mainScene 主场景
235
+ * @param parentId 要保持的父节点ID
236
+ * @private
237
+ */
238
+ private moveSingleJSONItemToFrameWithParent;
239
+ /**
240
+ * @description 收集元素及其所有子元素(递归处理嵌套组)
241
+ * @param itemIds 初始元素ID列表
242
+ * @returns 包含所有子元素的ID列表
243
+ * @private
244
+ */
245
+ private collectItemsWithChildren;
246
+ private moveSinglePlayerItemToFrame;
247
+ /**
248
+ * @description 将元素从 Frame 中移出到主场景
249
+ * @param itemIds 要移动的元素ID列表
250
+ * @param frameId 源 Frame ID(可选,如果不传则从第一个元素的 parentId 推断)
251
+ */
252
+ moveItemsOutOfFrame(itemIds: string[]): void;
253
+ /**
254
+ * @description 移动单个元素从 Frame 到主场景(仅 JSON 层)
255
+ * @private
256
+ */
257
+ private moveSingleJSONItemOutOfFrame;
258
+ private moveSinglePlayerItemOutOfFrame;
259
+ setItemName(id: string, name: string, targetScene?: spec.JSONScene): void;
260
+ get undoRedo(): import("../service/UndoRedo").UndoRedo;
261
+ saveUndoRedoOldData(): void;
262
+ pushUndoRedoData(): void;
263
+ getItemCreateInfo(id: string, withParent?: boolean): GroupCreateInfo | SpriteCreateInfo | TextCreateInfo | VideoCreateInfo | GeneratorCreateInfo | EffectsCreateInfo | FrameCreateInfo | CardCreateInfo | undefined;
264
+ getChildrenIds(id: string): string[];
265
+ createScreenShotSceneByIds(idInfo: string | string[], rasterizeCard?: ScreenShotCardRasterizer): Promise<any>;
266
+ createSceneByCreateInfos(createInfos: ItemCreateInfo[], sceneSize?: spec.vec2, name?: string, scenePosition?: spec.vec2): spec.JSONScene;
267
+ /**
268
+ * @description 更新元素在图片中的顺序(仅在同级元素之间)
269
+ * @param id 元素ID
270
+ * @param action 排序操作类型
271
+ */
272
+ updateItemOrder(id: string, action: ItemOrderAction): void;
273
+ private isPluginItem;
274
+ private refreshItemRenderOrder;
275
+ /**
276
+ * @description 根据 composition.items 的顺序重新排列 pageData.items
277
+ * @param composition 当前场景
278
+ */
279
+ private syncPageDataItemsOrder;
280
+ getViewProperty(id?: number): import("..").ViewProperty | undefined;
281
+ viewportFit(shiftParam?: ViewportFitShiftParam, box?: Box2): void;
282
+ getItemBoxById(idInfo: string): Box2;
283
+ getItemBoxById(idInfo: string[]): Box2[];
284
+ setItemFontFamily(id: string, fontFamilyName: string, url: string): Promise<void>;
285
+ changeItemPropertyByCreateInfo(itemCreateInfo: ItemCreateInfo | ItemCreateInfo[]): Promise<void>;
286
+ getViewBoxByBox(box: Box2): Box2;
287
+ playVideoItem(id?: string): void;
288
+ pauseVideoItem(id?: string): void;
289
+ playEffectsItem(id?: string): void;
290
+ pauseEffectsItem(id?: string): void;
291
+ setEffectsResource(id: string, effects: string): void;
292
+ /**
293
+ * @description 根据元素创建信息获取包围盒
294
+ * @param createInfo 元素创建信息
295
+ * @returns 包围盒
296
+ */
297
+ getBoundingBoxByCreateInfo(createInfo: ItemCreateInfo): Box2;
298
+ /**
299
+ * @description 根据元素创建信息组获取包围盒
300
+ * @param createInfos 元素创建信息组
301
+ * @returns 包围盒
302
+ */
303
+ getBoundingBoxByCreateInfos(createInfos: ItemCreateInfo[]): Box2;
304
+ getVideoItemPlayTime(id: string): number;
305
+ setVideoItemPlayTime(id: string, time: number): void;
306
+ getEffectsItemPlayTime(id: string): number | undefined;
307
+ setEffectsItemPlayTime(id: string, time: number): void;
308
+ getPixelPositionByViewPosition(viewPosition: Vector2): Vector2;
309
+ getItemParentScale(id: string): Vector3;
310
+ getJSONItem(id: string): spec.VFXItemData | undefined;
311
+ getJSONComponent(id: string): spec.ComponentData | undefined;
312
+ getTextOriginSize(id: string): {
313
+ size: spec.vec2;
314
+ isPublishScene: boolean;
315
+ };
316
+ asyncAddItemByCreateInfos(createInfos: ItemCreateInfo[]): Promise<string[]>;
317
+ addItemByCreateInfos(createInfos: ItemCreateInfo[]): Promise<string[]>;
318
+ addEffectsItem(createInfo: EffectsCreateInfo, targetScene?: spec.JSONScene): Promise<string | undefined>;
319
+ /**
320
+ * @description 添加画板元素
321
+ * @param createInfo 画板创建信息
322
+ * @param targetScene 目标场景
323
+ * @returns 元素ID
324
+ */
325
+ addFrameItem(createInfo: FrameCreateInfo, targetScene?: spec.JSONScene): Promise<string>;
326
+ makeItemAlign(type: AlignType, ids?: string[]): void;
327
+ makeItemDistribute(type: DistributeType, ids?: string[]): void;
328
+ setItemLockState(id: string, state: boolean): void;
329
+ getItemLockState(id: string): boolean;
330
+ /**
331
+ * @description 计算元素在新父节点下保持世界绝对 transform 不变时所需的局部 transform
332
+ * @param itemId 要移动的元素 ID
333
+ * @param targetParentVFXItem 目标父 VFXItem(移入 Frame 时为 compositionItem,移出 Frame 时为 composition.rootItem)
334
+ */
335
+ getItemTransformUnderParent(itemId: string, targetParentVFXItem: VFXItem): MoveItemTransformOptions | undefined;
336
+ /**
337
+ * @description 修改画板元素大小
338
+ * @param id 元素id
339
+ * @param size 目标大小 [width, height]
340
+ * @param translation 位置偏移补偿(可选,用于保持拖拽角点固定)
341
+ */
342
+ resizeFrameItem(id: string, size: spec.vec2, translation?: Vector3): void;
343
+ /**
344
+ * @description 对 FrameItem 执行自动布局(Shelf 算法)
345
+ * @param frameId Frame 元素 ID
346
+ */
347
+ applyFrameAutoLayout(frameId: string): void;
348
+ /**
349
+ * @description 将 layout-utils 的 AutoLayoutResult 结果记录到 layoutInfos
350
+ * @param frameId Frame 元素 ID
351
+ * @param layoutResult autoLayout 函数返回的结果
352
+ */
353
+ private recordLayoutInfosFromAutoLayoutResult;
354
+ /**
355
+ * @description 刷新画板子元素
356
+ * @param id 画板元素id
357
+ */
358
+ refreshFrameChildren(id: string): void;
359
+ autoLayoutPage(param?: PageAutoLayoutParam): Promise<void>;
360
+ /**
361
+ * @description 计算选中元素排布的锚点偏移:保持原始包围盒左上角位置不变
362
+ * @param layoutElements 参与排布的元素列表
363
+ * @param layoutBoundingBox 排布算法输出的包围盒
364
+ */
365
+ private getPartialLayoutAnchor;
366
+ /**
367
+ * @description 计算全量排布的锚点偏移:以视口中心为锚点
368
+ * @param layoutBoundingBox 排布算法输出的包围盒
369
+ */
370
+ private getGlobalLayoutAnchor;
371
+ }
372
+ export {};
@@ -0,0 +1,11 @@
1
+ import { Composition, VFXItem, Constructor, Component, spec } from '@galacean/effects';
2
+ export declare class DefaultVFXItems {
3
+ static createEmpty(composition: Composition, parent?: null, name?: string): VFXItem;
4
+ static createSprite(composition: Composition, parent?: null, name?: string): VFXItem;
5
+ static createText(composition: Composition, parent?: null, name?: string): VFXItem;
6
+ static createVideo(composition: Composition, parent?: null, name?: string): VFXItem;
7
+ static createEffects(composition: Composition, effects: string | spec.JSONScene, parent?: null, urlname?: string): Promise<VFXItem>;
8
+ }
9
+ export declare class VFXItemFactory {
10
+ static createVFXItem(composition: Composition, parent?: null, name?: string, ...types: Constructor<Component>[]): VFXItem;
11
+ }
@@ -0,0 +1,114 @@
1
+ import type { Matrix4, Vector2, Vector3 } from '../math';
2
+ import { spec } from '../shared';
3
+ /**
4
+ * @description 交互状态视图信息
5
+ */
6
+ export type ViewInteractionParam = {
7
+ /**
8
+ * @description 视口宽度 - 红框区域像素大小
9
+ */
10
+ width: number;
11
+ /**
12
+ * @description 视口高度 - 红框区域像素大小
13
+ */
14
+ height: number;
15
+ /**
16
+ * @description 视口缩放比例
17
+ */
18
+ scale: number;
19
+ /**
20
+ * @description 视口位移信息
21
+ */
22
+ translation: Vector2;
23
+ /**
24
+ * @description 标尺宽度
25
+ */
26
+ rulerWidth: number;
27
+ };
28
+ /**
29
+ * @description 交互状态相机信息
30
+ */
31
+ export type CameraInteractionParam = {
32
+ /**
33
+ * @description 位置
34
+ */
35
+ position: Vector3;
36
+ /**
37
+ * @description 旋转角度
38
+ */
39
+ rotation: Vector3;
40
+ /**
41
+ * @description 视野初始中心
42
+ */
43
+ focusPosition: Vector3;
44
+ /**
45
+ * @description 视野初始角度
46
+ */
47
+ focusRotation: Vector3;
48
+ /**
49
+ * @description 投影矩阵
50
+ */
51
+ viewProjectionMatrix: Matrix4;
52
+ /**
53
+ * @description 逆投影矩阵
54
+ */
55
+ inverseViewProjectionMatrix: Matrix4;
56
+ };
57
+ export declare const SafeConstraint: {
58
+ topAdsorption: string;
59
+ leftAdsorption: string;
60
+ rightAdsorption: string;
61
+ bottomAdsorption: string;
62
+ centerAdsorption: string;
63
+ bottomCenterAdsorption: string;
64
+ };
65
+ export type ItemJSONInfo = {
66
+ item: spec.VFXItemData;
67
+ components: spec.ComponentData[];
68
+ tracks: any[];
69
+ playableAssets: any[];
70
+ };
71
+ export type AlignType = 'left' | 'right' | 'horizontal-center' | 'top' | 'bottom' | 'vertical-center';
72
+ export type DistributeType = 'vertical-spacing' | 'horizontal-spacing';
73
+ /**
74
+ * @description 背景类型预设配置
75
+ */
76
+ export type BackgroundPreset = {
77
+ /**
78
+ * @description 背景颜色
79
+ */
80
+ color?: string;
81
+ /**
82
+ * @description 背景图片/渐变
83
+ */
84
+ image?: string;
85
+ /**
86
+ * @description 背景重复方式
87
+ */
88
+ repeat?: string;
89
+ /**
90
+ * @description 背景位置
91
+ */
92
+ position?: string;
93
+ /**
94
+ * @description 背景大小
95
+ */
96
+ size?: string;
97
+ };
98
+ /**
99
+ * @description 背景网格配置
100
+ */
101
+ export type BackgroundGridConfig = {
102
+ /**
103
+ * @description 基础网格大小(像素)
104
+ */
105
+ baseSize: number;
106
+ /**
107
+ * @description 缩放循环阈值(默认 2,即 2x 时重置)
108
+ */
109
+ zoomCycle: number;
110
+ /**
111
+ * @description 最小网格大小限制
112
+ */
113
+ minSize: number;
114
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ import type { Line2 } from '../../math';
2
+ import type { Box2 } from '../../math/box2';
3
+ import { type Point } from './pixi';
4
+ declare module '@pixi/graphics' {
5
+ interface Graphics {
6
+ fillBox(box: Box2): void;
7
+ drawBox(box: Box2): void;
8
+ drawLine(line: Line2 | Point[]): void;
9
+ drawDashLine(toX: number, toY: number, dash: number, gap: number): void;
10
+ }
11
+ }
@@ -0,0 +1,18 @@
1
+ import '@pixi/polyfill';
2
+ import * as utils from '@pixi/utils';
3
+ import { Application } from '@pixi/app';
4
+ import type { IApplicationOptions, IApplicationPlugin } from '@pixi/app';
5
+ export * from '@pixi/constants';
6
+ export * from '@pixi/core';
7
+ export * from '@pixi/display';
8
+ export * from '@pixi/graphics';
9
+ export * from '@pixi/loaders';
10
+ export * from '@pixi/interaction';
11
+ export * from '@pixi/math';
12
+ export * from '@pixi/runner';
13
+ export * from '@pixi/sprite';
14
+ export * from '@pixi/text';
15
+ export * from '@pixi/ticker';
16
+ export * from '@pixi/settings';
17
+ export { utils, Application };
18
+ export type { IApplicationOptions, IApplicationPlugin };
@@ -0,0 +1,4 @@
1
+ export * from './common/box';
2
+ export * from './common/line';
3
+ export * from './common/dashed-line';
4
+ export * from './common/pixi';
package/package.json CHANGED
@@ -1,38 +1,38 @@
1
1
  {
2
2
  "name": "@vvfx/sdk",
3
- "description": "VVFX 开放 SDK",
4
- "version": "0.1.19-alpha.9",
5
- "type": "module",
6
- "main": "./dist/index.cjs",
3
+ "description": "TODO",
4
+ "version": "0.2.0",
5
+ "main": "./dist/index.mjs",
7
6
  "module": "./dist/index.js",
8
7
  "types": "./dist/index.d.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
9
11
  "exports": {
10
12
  ".": {
11
13
  "types": "./dist/index.d.ts",
12
14
  "import": "./dist/index.js",
13
- "require": "./dist/index.cjs"
15
+ "require": "./dist/index.mjs"
14
16
  }
15
17
  },
16
- "files": [
17
- "dist"
18
- ],
19
- "publishConfig": {
20
- "access": "public"
21
- },
22
18
  "scripts": {
23
- "build": "tsup",
24
- "dev": "tsup --watch",
25
- "check": "tsc -b ./tsconfig.json"
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
26
  },
27
27
  "dependencies": {
28
28
  "@ffmpeg/ffmpeg": "0.12.15",
29
29
  "@ffmpeg/util": "0.12.2",
30
- "@galacean/effects": "^2.9.0-alpha.1",
31
- "@galacean/effects-plugin-rich-text": "^2.9.0-alpha.1",
32
- "@galacean/effects-plugin-model": "^2.9.0-alpha.1",
33
- "@galacean/effects-plugin-multimedia": "^2.9.0-alpha.1",
34
- "@galacean/effects-plugin-spine": "^2.9.0-alpha.1",
35
- "@galacean/effects-plugin-ffd": "^2.9.0-alpha.1",
30
+ "@galacean/effects": "^2.9.0",
31
+ "@galacean/effects-plugin-ffd": "2.9.0",
32
+ "@galacean/effects-plugin-model": "2.9.0",
33
+ "@galacean/effects-plugin-multimedia": "2.9.0",
34
+ "@galacean/effects-plugin-rich-text": "2.9.0",
35
+ "@galacean/effects-plugin-spine": "2.9.0",
36
36
  "@pixi/app": "^6.5.10",
37
37
  "@pixi/constants": "^6.5.10",
38
38
  "@pixi/core": "^6.5.10",
@@ -50,7 +50,27 @@
50
50
  "@pixi/text": "^6.5.10",
51
51
  "@pixi/ticker": "^6.5.10",
52
52
  "@pixi/utils": "^6.5.10",
53
- "jszip": "^3.10.1"
53
+ "@progress/jszip-esm": "^1.0.4",
54
+ "@zumer/snapdom": "^2.12.0"
54
55
  },
55
- "devDependencies": {}
56
+ "contributors": [
57
+ {
58
+ "name": "赤芍"
59
+ },
60
+ {
61
+ "name": "何即"
62
+ },
63
+ {
64
+ "name": "不择"
65
+ },
66
+ {
67
+ "name": "意绮"
68
+ }
69
+ ],
70
+ "author": "Ant Group CO., Ltd.",
71
+ "license": "MIT",
72
+ "publishConfig": {
73
+ "access": "public",
74
+ "registry": "https://registry.npmjs.org"
75
+ }
56
76
  }