@vvfx/sdk 0.1.19-alpha.8 → 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 -3485
  101. package/dist/index.d.ts +0 -3485
  102. package/dist/index.global.js +0 -333
@@ -0,0 +1,1298 @@
1
+ import type { spec } from './shared';
2
+ import { SizeAdaptDirection } from './size-adapte';
3
+ import type { ExportMediaItemOptions } from './exporter';
4
+ import { SDKItemType } from './sdk-item/types';
5
+ import { SDKItem } from './sdk-item';
6
+ import { GlobalLayoutMode } from './utils';
7
+ export type BaseItemProperty = {
8
+ position: [number, number];
9
+ rotation: [number, number, number];
10
+ scale: [number, number];
11
+ width: number;
12
+ height: number;
13
+ };
14
+ export type SpriteItemProperty = BaseItemProperty & {
15
+ image: string;
16
+ };
17
+ export type GroupItemProperty = BaseItemProperty & {
18
+ children: string[];
19
+ };
20
+ export type TextItemProperty = BaseItemProperty & {
21
+ fontFamily: string;
22
+ color: [number, number, number, number];
23
+ fontWeight: spec.TextWeight;
24
+ text: string;
25
+ textAlign: spec.TextAlignment;
26
+ fontSize: number;
27
+ fontStyle: spec.FontStyle;
28
+ lineHeight: number;
29
+ outlineColor?: spec.vec4;
30
+ outlineWidth?: number;
31
+ /**
32
+ * @description 描边开关
33
+ */
34
+ outlineEnabled?: boolean;
35
+ /**
36
+ * @description 文本字间距
37
+ */
38
+ letterSpacing?: number;
39
+ fontUrl?: string;
40
+ };
41
+ export type VideoItemProperty = BaseItemProperty & {
42
+ video: string;
43
+ /**
44
+ * @description 是否静音
45
+ */
46
+ muted?: boolean;
47
+ /**
48
+ * @description 是否为透明视频
49
+ */
50
+ transparent?: boolean;
51
+ /**
52
+ * @description 播放速率
53
+ */
54
+ playbackRate?: number;
55
+ /**
56
+ * @description 音量
57
+ */
58
+ volume?: number;
59
+ };
60
+ /**
61
+ * @description Generator 表单属性
62
+ */
63
+ export type GeneratorItemProperty = BaseItemProperty & {
64
+ /**
65
+ * @description 生成器类型
66
+ */
67
+ generatorType: 'image' | 'video';
68
+ };
69
+ export type EffectsItemProperty = BaseItemProperty & {
70
+ effects: string;
71
+ children?: string[];
72
+ };
73
+ /**
74
+ * @description Card HTML 覆盖层清理函数。
75
+ */
76
+ export type CardHTMLRenderCleanup = () => void;
77
+ /**
78
+ * @description Card HTML 内容清理函数。SDK 会传入当前内容挂载容器。
79
+ */
80
+ export type CardHTMLContentCleanup = (container: HTMLElement) => void;
81
+ /**
82
+ * @description Card HTML 覆盖层 DOM 渲染函数。SDK 会传入 overlay 容器;卸载逻辑请使用 content.cleanup。
83
+ */
84
+ export type CardHTMLDOMRenderer = (container: HTMLElement) => void;
85
+ /**
86
+ * @description Card HTML 单文件字符串内容。SDK 会通过 iframe srcdoc 渲染。
87
+ */
88
+ export type CardHTMLInlineContent = {
89
+ /**
90
+ * @description 内容类型标识
91
+ */
92
+ kind: 'inline';
93
+ /**
94
+ * @description HTML 字符串内容
95
+ */
96
+ html: string;
97
+ /**
98
+ * @description 内容卸载时调用的清理函数;SDK 会传入当前内容挂载容器。
99
+ */
100
+ cleanup?: CardHTMLContentCleanup;
101
+ };
102
+ /**
103
+ * @description Card HTML DOM 渲染内容。用于挂载 React/Vue/原生 DOM 等组件。
104
+ */
105
+ export type CardHTMLDOMRendererContent = {
106
+ /**
107
+ * @description 内容类型标识
108
+ */
109
+ kind: 'dom';
110
+ /**
111
+ * @description DOM 挂载目标。host 为宿主 DOM,iframe 为隔离文档 DOM;默认 host。
112
+ */
113
+ target?: 'host' | 'iframe';
114
+ /**
115
+ * @description DOM 渲染函数
116
+ */
117
+ render: CardHTMLDOMRenderer;
118
+ /**
119
+ * @description 内容卸载时调用的清理函数;SDK 会传入 render 接收到的同一个容器。
120
+ */
121
+ cleanup?: CardHTMLContentCleanup;
122
+ };
123
+ /**
124
+ * @description Card HTML 文档到宿主的消息。仅当 allowHostMessaging 为 true 时 SDK 才会接收。
125
+ */
126
+ export type CardHTMLDocumentMessage = {
127
+ /**
128
+ * @description 消息来源标识,必须为 vvfx-card-html。
129
+ */
130
+ source: 'vvfx-card-html';
131
+ /**
132
+ * @description 业务消息类型。
133
+ */
134
+ type: string;
135
+ /**
136
+ * @description 业务消息负载。
137
+ */
138
+ payload?: unknown;
139
+ };
140
+ /**
141
+ * @description Card HTML 文档内容。用于承载完整 HTML 页面或多文件 HTML 产物。
142
+ */
143
+ export type CardHTMLDocumentContent = {
144
+ /**
145
+ * @description 内容类型标识
146
+ */
147
+ kind: 'document';
148
+ /**
149
+ * @description 入口文件路径,例如 index.html
150
+ */
151
+ entry: string;
152
+ /**
153
+ * @description 文件内容表,key 为相对路径,value 为文件内容
154
+ */
155
+ files: Record<string, string>;
156
+ /**
157
+ * @description 资源解析基准路径,用于后续处理远程或本地资源引用
158
+ */
159
+ baseUrl?: string;
160
+ /**
161
+ * @description iframe sandbox 配置;true/undefined 使用 SDK 默认沙箱 allow-scripts;false 不加 sandbox,风险较高,不建议用于不可信内容。
162
+ */
163
+ sandbox?: boolean | string;
164
+ /**
165
+ * @description 是否允许 iframe 通过 postMessage 与宿主通信;默认 false。
166
+ */
167
+ allowHostMessaging?: boolean;
168
+ /**
169
+ * @description iframe 消息回调。仅接收来自当前 iframe 且 source 为 vvfx-card-html 的消息。
170
+ */
171
+ onMessage?: (message: CardHTMLDocumentMessage) => void;
172
+ /**
173
+ * @description 内容卸载时调用的清理函数;SDK 会传入当前内容挂载容器。
174
+ */
175
+ cleanup?: CardHTMLContentCleanup;
176
+ };
177
+ /**
178
+ * @description Card HTML 覆盖层内容。
179
+ */
180
+ export type CardHTMLContent = CardHTMLInlineContent | CardHTMLDOMRendererContent | CardHTMLDocumentContent;
181
+ export type CardHTMLShellRendererResult = HTMLElement | {
182
+ contentContainer: HTMLElement;
183
+ cleanup?: CardHTMLRenderCleanup;
184
+ };
185
+ export type CardHTMLShellRendererContext = {
186
+ /**
187
+ * @description 当前 shell 承载的 HTML 内容。
188
+ */
189
+ content: CardHTMLContent;
190
+ };
191
+ export type CardHTMLShellRenderer = (container: HTMLElement, context: CardHTMLShellRendererContext) => CardHTMLShellRendererResult;
192
+ /**
193
+ * @description Card HTML 外壳内容。用于定制承载 HTML 内容的容器。
194
+ */
195
+ export type CardHTMLShellContent = {
196
+ /**
197
+ * @description 内容类型标识
198
+ */
199
+ kind: 'dom';
200
+ /**
201
+ * @description DOM 外壳渲染函数,必须返回用于挂载 content 的容器。
202
+ * @description shell 内需要在非编辑态响应 hover/click 的控件,可标记 data-vvfx-html-shell-interactive="true"。
203
+ * @description SDK 会在该控件上同步 data-vvfx-html-shell-interactive-hover 与 data-vvfx-html-shell-interactive-active 状态;具体 UI 展示和业务行为由 shell 自行实现。
204
+ */
205
+ render: CardHTMLShellRenderer;
206
+ };
207
+ /**
208
+ * @description Card HTML 覆盖层配置。
209
+ */
210
+ export type CardHTML = {
211
+ /**
212
+ * @description HTML 内容,承接 inline/dom/document 等内容类型。
213
+ */
214
+ content: CardHTMLContent;
215
+ /**
216
+ * @description HTML 外壳,用于定制承载 content 的容器。
217
+ */
218
+ shell?: CardHTMLShellContent;
219
+ };
220
+ /**
221
+ * @description Card 卡片元素属性
222
+ */
223
+ export type CardItemProperty = BaseItemProperty & {
224
+ /**
225
+ * @description 卡片类型(动态配置,需在 SDK.config.itemConfig.cardConfig.cardTypes 中注册)
226
+ */
227
+ cardType: string;
228
+ /**
229
+ * @description 是否根据 HTML 挂载内容的自然高度自动更新卡片高度
230
+ */
231
+ autoHeight?: boolean;
232
+ /**
233
+ * @description HTML 覆盖层配置;存在该字段时由 DOM overlay 渲染
234
+ */
235
+ html?: CardHTML;
236
+ };
237
+ /**
238
+ * @description Frame 画板元素布局模式
239
+ */
240
+ export declare enum FrameLayoutMode {
241
+ AUTO = "auto",
242
+ FREE = "free"
243
+ }
244
+ /**
245
+ * @description 自动布局配置
246
+ */
247
+ export type AutoLayoutConfig = {
248
+ /**
249
+ * @description 单行最大宽度(像素),超过后自动换行。未设置时不限制
250
+ */
251
+ maxRowWidth?: number;
252
+ /**
253
+ * @description 最大行数限制。未设置时不限制
254
+ */
255
+ maxRowCount?: number;
256
+ };
257
+ /**
258
+ * @description 元素在自动布局中的位置信息
259
+ */
260
+ export type LayoutInfo = {
261
+ /**
262
+ * @description 所在行号(可为小数)
263
+ * 整数部分:主行号(0, 1, 2...)
264
+ * 小数部分:分行后的子行号(如 1.5 表示第1行的第5个子行)
265
+ * 仅支持两层(即小数部分为 0-9)
266
+ */
267
+ row: number;
268
+ /**
269
+ * @description 所在列号(必须为整数)
270
+ */
271
+ column: number;
272
+ /**
273
+ * @description 元素在布局中的位置(相对于画板左上角,可选)
274
+ */
275
+ position?: [number, number];
276
+ };
277
+ /**
278
+ * @description Frame 画板元素属性
279
+ */
280
+ export type FrameItemProperty = BaseItemProperty & {
281
+ /**
282
+ * @description 布局模式: auto - 自动布局, free - 自由布局
283
+ */
284
+ layoutMode: FrameLayoutMode;
285
+ /**
286
+ * @description 子元素ID数组
287
+ */
288
+ children: string[];
289
+ /**
290
+ * @description 自动布局配置
291
+ */
292
+ autoLayoutConfig?: AutoLayoutConfig;
293
+ /**
294
+ * @description 子元素布局位置信息(用于自动布局)
295
+ * key: 子元素ID, value: 元素的位置信息
296
+ */
297
+ layoutInfos?: Record<string, LayoutInfo>;
298
+ };
299
+ /**
300
+ * @description BaseItem 基础属性键名
301
+ */
302
+ export type BaseItemPropertyKey = 'name' | 'duration' | 'delay' | 'endBehavior' | 'visible' | 'isLocked' | 'parentId';
303
+ /**
304
+ * @description BaseItem 基础属性值类型映射
305
+ */
306
+ export type BaseItemPropertyValueMap = {
307
+ name: string;
308
+ duration: number;
309
+ delay: number;
310
+ endBehavior: spec.EndBehavior;
311
+ visible: boolean;
312
+ isLocked: boolean;
313
+ parentId?: string;
314
+ };
315
+ /**
316
+ * @description Item 类型与 Property 类型的映射
317
+ */
318
+ export type ItemPropertyMap = {
319
+ [SDKItemType.SPRITE]: SpriteItemProperty;
320
+ [SDKItemType.TEXT]: TextItemProperty;
321
+ [SDKItemType.VIDEO]: VideoItemProperty;
322
+ [SDKItemType.GROUP]: GroupItemProperty;
323
+ [SDKItemType.GENERATOR]: GeneratorItemProperty;
324
+ [SDKItemType.EFFECTS]: EffectsItemProperty;
325
+ [SDKItemType.FRAME]: FrameItemProperty;
326
+ [SDKItemType.CARD]: CardItemProperty;
327
+ };
328
+ /**
329
+ * @description 场景1:单个元素单个属性设置
330
+ * 支持设置 BaseItem 基础属性或具体 Item 类型的 property 属性
331
+ */
332
+ export type SetSingleItemSinglePropertyParam<T extends SDKItemType = SDKItemType> = {
333
+ itemId: string;
334
+ type: T;
335
+ propertyName: BaseItemPropertyKey;
336
+ propertyValue: BaseItemPropertyValueMap[BaseItemPropertyKey];
337
+ } | {
338
+ itemId: string;
339
+ type: T;
340
+ propertyName: keyof ItemPropertyMap[T];
341
+ propertyValue: ItemPropertyMap[T][keyof ItemPropertyMap[T]];
342
+ };
343
+ /**
344
+ * @description 场景2:单个元素多个属性设置
345
+ * 同时设置多个 BaseItem 属性或 property 属性
346
+ */
347
+ export type SetSingleItemMultiplePropertiesParam<T extends SDKItemType = SDKItemType> = {
348
+ itemId: string;
349
+ type: T;
350
+ property: Partial<Record<BaseItemPropertyKey, BaseItemPropertyValueMap[BaseItemPropertyKey]>> & Partial<Record<keyof ItemPropertyMap[T], ItemPropertyMap[T][keyof ItemPropertyMap[T]]>>;
351
+ };
352
+ /**
353
+ * @description 设置元素属性的统一参数类型
354
+ * 支持两种场景:单元素单属性、单元素多属性
355
+ */
356
+ export type SetItemPropertyParam<T extends SDKItemType = SDKItemType> = SetSingleItemSinglePropertyParam<T> | SetSingleItemMultiplePropertiesParam<T>;
357
+ export type SDKOptions = {
358
+ /** 导出视频时,是否开启转码日志 */
359
+ loggerInExportVideoTranscoding?: boolean;
360
+ };
361
+ export type SDKInputParam = SDKTemplateInputParam | SDKEditorInputParam;
362
+ /**
363
+ * @description SDK入参
364
+ */
365
+ export type SDKTemplateInputParam = {
366
+ /**
367
+ * @description JSON地址
368
+ */
369
+ scene: string | spec.JSONScene;
370
+ /**
371
+ * @description SDK模式 - 模板编辑模式
372
+ */
373
+ mode: 'template';
374
+ /**
375
+ * @description 视图参数
376
+ */
377
+ viewParams?: ViewParam[];
378
+ /**
379
+ * @description 页面属性
380
+ */
381
+ options: PageOptions;
382
+ };
383
+ export type SDKEditorInputParam = {
384
+ /**
385
+ * @description SDK模式 - 编辑器模式
386
+ */
387
+ mode: 'editor';
388
+ };
389
+ export type SDKInitParam = {
390
+ scene: spec.JSONScene;
391
+ /**
392
+ * @description 视图参数
393
+ */
394
+ viewParams: ViewParam[];
395
+ /**
396
+ * @description 页面属性
397
+ */
398
+ options: PageOptions;
399
+ };
400
+ /**
401
+ * @description 页面属性
402
+ */
403
+ export type PageOptions = {
404
+ /**
405
+ * @description 同步模式开关
406
+ */
407
+ asyncMode: boolean;
408
+ /**
409
+ * @description 安全区展示开关
410
+ */
411
+ safeAreaPreview: boolean;
412
+ /**
413
+ * @description 吸附开关
414
+ */
415
+ adsorption: boolean;
416
+ };
417
+ /**
418
+ * @description 页面数据
419
+ */
420
+ export type PageData = {
421
+ /**
422
+ * @description 基础场景数据
423
+ */
424
+ scene: spec.JSONScene;
425
+ /**
426
+ * @description 页面属性
427
+ */
428
+ property: PageProperty;
429
+ /**
430
+ * @description 视图属性
431
+ */
432
+ viewProperties: ViewProperty[];
433
+ /**
434
+ * @description 活跃数据
435
+ */
436
+ activeData: ActiveData;
437
+ /**
438
+ * @description 元素数据
439
+ */
440
+ items: SDKItem[];
441
+ /**
442
+ * @description 视图当前时间
443
+ */
444
+ time: number;
445
+ /**
446
+ * @description 是否处于播放态
447
+ */
448
+ playing: boolean;
449
+ };
450
+ /**
451
+ * @description 页面自动布局参数
452
+ */
453
+ export type PageAutoLayoutParam = {
454
+ /**
455
+ * @description 自动布局模式
456
+ */
457
+ mode?: GlobalLayoutMode;
458
+ /**
459
+ * @description 选中元素【无输入值时,页面内所有元素排布】
460
+ * 如果是选中元素自动排布,则保证包围盒左上角点位置相同
461
+ */
462
+ ids?: string[];
463
+ /**
464
+ * @description 排布后是否聚焦元素,默认开启
465
+ */
466
+ focus?: boolean;
467
+ /**
468
+ * @description 自动布局间隔
469
+ */
470
+ gap?: number;
471
+ };
472
+ /**
473
+ * @description 页面配置
474
+ */
475
+ export type PageConfig = {
476
+ /**
477
+ * @description 出血区域展示开关
478
+ */
479
+ safeAreaPreview: boolean;
480
+ /**
481
+ * @description 缩放值
482
+ */
483
+ zoom: number;
484
+ /**
485
+ * @description 吸附开关
486
+ */
487
+ adsorption: boolean;
488
+ /**
489
+ * @description 同步开关
490
+ */
491
+ asyncMode: boolean;
492
+ /**
493
+ * @description 画布移动
494
+ */
495
+ translation: spec.vec2;
496
+ };
497
+ /**
498
+ * @description 页面属性
499
+ */
500
+ export type PageProperty = {
501
+ /**
502
+ * @description 出血区域展示开关
503
+ */
504
+ safeAreaPreview: boolean;
505
+ /**
506
+ * @description 缩放值
507
+ */
508
+ zoom: number;
509
+ /**
510
+ * @description 偏移值
511
+ */
512
+ translation: [number, number];
513
+ /**
514
+ * @description 吸附开关
515
+ */
516
+ adsorption: boolean;
517
+ /**
518
+ * @description 同步开关
519
+ */
520
+ asyncMode: boolean;
521
+ };
522
+ /**
523
+ * @description 视图创建参数
524
+ */
525
+ export type ViewParam = {
526
+ /**
527
+ * @description 页面尺寸
528
+ */
529
+ size?: [number, number];
530
+ /**
531
+ * @description 出血区参数
532
+ */
533
+ safeArea?: [number, number, number, number];
534
+ /**
535
+ * @description 自适应方向 - 默认根据视图宽高决定
536
+ */
537
+ adaptionDirection?: SizeAdaptDirection;
538
+ /**
539
+ * @description 自定义出血区 - 用于展示
540
+ */
541
+ previewSafeAreas?: PreviewSafeAreaParam[];
542
+ /**
543
+ * @description 导出参数
544
+ */
545
+ export: ExportParam;
546
+ };
547
+ /**
548
+ * @description 导出参数
549
+ */
550
+ export type ExportParam = {
551
+ /**
552
+ * @description 视频名称
553
+ */
554
+ name?: string;
555
+ } & Omit<ExportMediaItemOptions, 'scene' | 'size'>;
556
+ /**
557
+ * @description 视图属性
558
+ */
559
+ export type ViewProperty = {
560
+ /**
561
+ * @description 视图ID
562
+ */
563
+ id: number;
564
+ /**
565
+ * @description 视图宽高
566
+ */
567
+ size: [number, number];
568
+ /**
569
+ * @description 出血区数据
570
+ */
571
+ safeArea: [number, number, number, number];
572
+ /**
573
+ * @description 自定义出血区数据
574
+ */
575
+ previewSafeAreas: PreviewSafeAreaParam[];
576
+ /**
577
+ * @description 视图场景数据
578
+ */
579
+ scene: spec.JSONScene;
580
+ /**
581
+ * @description 导出参数
582
+ */
583
+ export: ExportParam;
584
+ /**
585
+ * @description 忽略交互 - 仅供展示
586
+ */
587
+ ignoreInteraction: boolean;
588
+ };
589
+ /**
590
+ * @description 自定义出血区数据
591
+ */
592
+ export type PreviewSafeAreaParam = {
593
+ /**
594
+ * @description 出血区包围盒 [left top width height]
595
+ */
596
+ box: [number, number, number, number];
597
+ /**
598
+ * @description 出血区色块颜色 默认为 [255, 255, 255, 0.3]
599
+ */
600
+ color?: [number, number, number, number];
601
+ /**
602
+ * @description 出血区图像
603
+ */
604
+ url?: string;
605
+ /**
606
+ * @description 出血区是否可见
607
+ */
608
+ visible?: boolean;
609
+ };
610
+ /**
611
+ * @description 页面活跃数据
612
+ */
613
+ export type ActiveData = {
614
+ /**
615
+ * @description 视图ID
616
+ */
617
+ view?: number;
618
+ /**
619
+ * @description 选中元素
620
+ */
621
+ selectedItems: string[];
622
+ /**
623
+ * @description 预选中元素
624
+ */
625
+ preSelectedItem?: string;
626
+ /**
627
+ * @description 执行中元素
628
+ */
629
+ loadingItems?: string[];
630
+ };
631
+ /**
632
+ * @description Generator 扩展配置
633
+ * 用于 GeneratorMetadataManager 返回的数据格式
634
+ */
635
+ export type GeneratorExtension = {
636
+ /**
637
+ * @description 扩展类型标识
638
+ */
639
+ type: 'generator';
640
+ /**
641
+ * @description Generator 子类型
642
+ */
643
+ generatorType: 'sprite' | 'video';
644
+ /**
645
+ * @description 填充颜色 [r, g, b, a],范围 0-1
646
+ */
647
+ fillColor: [number, number, number, number];
648
+ /**
649
+ * @description 图标 URL
650
+ */
651
+ iconUrl: string;
652
+ };
653
+ export type SDKBackgroundType = 'color' | 'image' | 'chess-board' | 'dot-board';
654
+ /**
655
+ * @description 图层创建信息
656
+ */
657
+ export type SpriteCreateInfo = {
658
+ type: SDKItemType.SPRITE;
659
+ /**
660
+ * @description 图层名称
661
+ */
662
+ name?: string;
663
+ /**
664
+ * @description 元素id
665
+ */
666
+ id?: string;
667
+ /**
668
+ * @description 父节点id
669
+ */
670
+ parentId?: string;
671
+ /**
672
+ * @description 扩展属性
673
+ */
674
+ extension?: Record<string, any>;
675
+ /**
676
+ * @description 元素属性
677
+ */
678
+ property: {
679
+ /**
680
+ * @description 图片资源地址 | 数据
681
+ */
682
+ image?: string;
683
+ /**
684
+ * @description 图层像素宽度
685
+ */
686
+ width: number;
687
+ /**
688
+ * @description 图层像素高度
689
+ */
690
+ height: number;
691
+ /**
692
+ * @description 元素位置
693
+ */
694
+ position: [number, number];
695
+ /**
696
+ * @description 元素旋转 z | [x, y, z]
697
+ */
698
+ rotation?: number | [number, number, number];
699
+ /**
700
+ * @description 元素缩放
701
+ */
702
+ scale?: [number, number];
703
+ };
704
+ };
705
+ /**
706
+ * @description 组 元素创建信息
707
+ */
708
+ export type GroupCreateInfo = {
709
+ type: SDKItemType.GROUP;
710
+ /**
711
+ * @description 元素id
712
+ */
713
+ id?: string;
714
+ /**
715
+ * @description 父节点id
716
+ */
717
+ parentId?: string;
718
+ /**
719
+ * @description 元素名称
720
+ */
721
+ name?: string;
722
+ /**
723
+ * @description 扩展属性
724
+ */
725
+ extension?: Record<string, any>;
726
+ /**
727
+ * @description 元素属性
728
+ */
729
+ property: {
730
+ /**
731
+ * @description 元素位置
732
+ */
733
+ position?: [number, number];
734
+ /**
735
+ * @description 元素旋转 z | [x, y, z]
736
+ */
737
+ rotation?: number | [number, number, number];
738
+ /**
739
+ * @description 元素缩放
740
+ */
741
+ scale?: [number, number];
742
+ /**
743
+ * @description 子元素id
744
+ */
745
+ children: string[];
746
+ };
747
+ };
748
+ /**
749
+ * @description 文本创建信息
750
+ */
751
+ export type TextCreateInfo = {
752
+ type: SDKItemType.TEXT;
753
+ /**
754
+ * @description 元素id
755
+ */
756
+ id?: string;
757
+ /**
758
+ * @description 父节点id
759
+ */
760
+ parentId?: string;
761
+ /**
762
+ * @description 元素名称
763
+ */
764
+ name?: string;
765
+ /**
766
+ * @description 扩展属性
767
+ */
768
+ extension?: Record<string, any>;
769
+ /**
770
+ * @description 元素属性
771
+ */
772
+ property: {
773
+ /**
774
+ * @description 文本宽度
775
+ */
776
+ width: number;
777
+ /**
778
+ * @description 文本高度
779
+ */
780
+ height?: number;
781
+ /**
782
+ * @description 元素位置
783
+ */
784
+ position: [number, number];
785
+ /**
786
+ * @description 元素旋转 z | [x, y, z]
787
+ */
788
+ rotation?: number | [number, number, number];
789
+ /**
790
+ * @description 元素缩放
791
+ */
792
+ scale?: [number, number];
793
+ /**
794
+ * @description 单行高度
795
+ */
796
+ lineHeight: number;
797
+ /**
798
+ * @description 字体名称
799
+ */
800
+ fontFamily: string;
801
+ /**
802
+ * @description 文字大小
803
+ */
804
+ fontSize: number;
805
+ /**
806
+ * @description 字重
807
+ */
808
+ fontWeight?: spec.TextWeight;
809
+ /**
810
+ * @description 字体格式
811
+ */
812
+ fontStyle?: spec.FontStyle;
813
+ /**
814
+ * @description 对齐方式
815
+ */
816
+ textAlign?: spec.TextAlignment;
817
+ /**
818
+ * @description 文本信息
819
+ */
820
+ text: string;
821
+ /**
822
+ * @description 填充色
823
+ */
824
+ color: spec.vec4;
825
+ /**
826
+ * @description 描边色
827
+ */
828
+ outlineColor?: spec.vec4;
829
+ /**
830
+ * @description 描边宽度
831
+ */
832
+ outlineWidth?: number;
833
+ /**
834
+ * @description 描边开关
835
+ */
836
+ outlineEnabled?: boolean;
837
+ /**
838
+ * @description 字体文件地址
839
+ */
840
+ fontUrl?: string;
841
+ /**
842
+ * @description 文本字间距
843
+ */
844
+ letterSpacing?: number;
845
+ };
846
+ };
847
+ /**
848
+ * @description 视频创建信息
849
+ */
850
+ export type VideoCreateInfo = {
851
+ type: SDKItemType.VIDEO;
852
+ /**
853
+ * @description 视频名称
854
+ */
855
+ name?: string;
856
+ /**
857
+ * @description 元素id
858
+ */
859
+ id?: string;
860
+ /**
861
+ * @description 父节点id
862
+ */
863
+ parentId?: string;
864
+ /**
865
+ * @description 扩展属性
866
+ */
867
+ extension?: Record<string, any>;
868
+ /**
869
+ * @description 元素属性
870
+ */
871
+ property: {
872
+ /**
873
+ * @description 视频资源地址 | 数据
874
+ */
875
+ video?: string;
876
+ /**
877
+ * @description 视频元素像素宽度
878
+ */
879
+ width: number;
880
+ /**
881
+ * @description 视频元素像素高度
882
+ */
883
+ height: number;
884
+ /**
885
+ * @description 视频元素位置
886
+ */
887
+ position: [number, number];
888
+ /**
889
+ * @description 视频元素旋转 z | [x, y, z]
890
+ */
891
+ rotation?: number | [number, number, number];
892
+ /**
893
+ * @description 视频元素缩放
894
+ */
895
+ scale?: [number, number];
896
+ /**
897
+ * @description 是否静音
898
+ */
899
+ muted?: boolean;
900
+ /**
901
+ * @description 是否为透明视频
902
+ */
903
+ transparent?: boolean;
904
+ /**
905
+ * @description 播放速率
906
+ */
907
+ playbackRate?: number;
908
+ /**
909
+ * @description 音量
910
+ */
911
+ volume?: number;
912
+ };
913
+ };
914
+ /**
915
+ * @description 卡片元素变换信息(视口坐标系)
916
+ */
917
+ export type CardItemTransformInfo = {
918
+ /** 卡片元素 ID */
919
+ id: string;
920
+ /** 卡片元素名称 */
921
+ name: string;
922
+ /** 卡片类型 */
923
+ cardType: string;
924
+ /** 视口坐标系中的左上角位置 [x, y] */
925
+ position: [number, number];
926
+ /** 视口坐标系中的宽高 [width, height] */
927
+ size: [number, number];
928
+ };
929
+ /**
930
+ * @description 卡片类型(动态配置,需在 SDK.config.itemConfig.cardConfig.cardTypes 中注册)
931
+ */
932
+ export type CardType = string;
933
+ /**
934
+ * @description 卡片创建信息
935
+ */
936
+ export type CardCreateInfo = {
937
+ /**
938
+ * @description 元素类型 - 卡片
939
+ */
940
+ type: SDKItemType.CARD;
941
+ /**
942
+ * @description 元素名称
943
+ */
944
+ name?: string;
945
+ /**
946
+ * @description 元素id
947
+ */
948
+ id?: string;
949
+ /**
950
+ * @description 父元素id
951
+ */
952
+ parentId?: string;
953
+ /**
954
+ * @description 扩展属性
955
+ */
956
+ extension?: Record<string, any>;
957
+ /**
958
+ * @description 元素属性
959
+ */
960
+ property: {
961
+ /**
962
+ * @description 卡片类型
963
+ */
964
+ cardType: CardType;
965
+ /**
966
+ * @description 卡片元素像素宽度
967
+ */
968
+ width: number;
969
+ /**
970
+ * @description 卡片元素像素高度
971
+ */
972
+ height: number;
973
+ /**
974
+ * @description 是否根据 HTML 挂载内容的自然高度自动更新卡片高度
975
+ */
976
+ autoHeight?: boolean;
977
+ /**
978
+ * @description 卡片元素位置
979
+ */
980
+ position: [number, number];
981
+ /**
982
+ * @description 卡片元素旋转 z | [x, y, z]
983
+ */
984
+ rotation?: number | [number, number, number];
985
+ /**
986
+ * @description 卡片元素缩放
987
+ */
988
+ scale?: [number, number];
989
+ /**
990
+ * @description HTML 覆盖层配置;存在该字段时由 DOM overlay 渲染
991
+ */
992
+ html?: CardHTML;
993
+ };
994
+ };
995
+ /**
996
+ * @description 生成器类型
997
+ */
998
+ export type GeneratorType = 'image' | 'video';
999
+ /**
1000
+ * @description 生成器创建信息
1001
+ */
1002
+ export type GeneratorCreateInfo = {
1003
+ /**
1004
+ * @description 元素类型 - 生成器
1005
+ */
1006
+ type: SDKItemType.GENERATOR;
1007
+ /**
1008
+ * @description 元素名称
1009
+ */
1010
+ name?: string;
1011
+ /**
1012
+ * @description 元素id
1013
+ */
1014
+ id?: string;
1015
+ /**
1016
+ * @description 父元素id
1017
+ */
1018
+ parentId?: string;
1019
+ /**
1020
+ * @description 扩展属性
1021
+ */
1022
+ extension?: Record<string, any>;
1023
+ /**
1024
+ * @description 元素属性
1025
+ */
1026
+ property: {
1027
+ /**
1028
+ * @description 生成器类型
1029
+ */
1030
+ generatorType: GeneratorType;
1031
+ /**
1032
+ * @description 生成器元素像素宽度
1033
+ */
1034
+ width: number;
1035
+ /**
1036
+ * @description 生成器元素像素高度
1037
+ */
1038
+ height: number;
1039
+ /**
1040
+ * @description 生成器元素位置
1041
+ */
1042
+ position: [number, number];
1043
+ /**
1044
+ * @description 生成器元素旋转 z | [x, y, z]
1045
+ */
1046
+ rotation?: number | [number, number, number];
1047
+ /**
1048
+ * @description 生成器元素缩放
1049
+ */
1050
+ scale?: [number, number];
1051
+ };
1052
+ };
1053
+ /**
1054
+ * @description 图片生成器资源信息
1055
+ */
1056
+ export type SpriteGeneratorResource = {
1057
+ /**
1058
+ * @description 资源地址
1059
+ */
1060
+ url: string;
1061
+ /**
1062
+ * @description 资源尺寸
1063
+ */
1064
+ size?: spec.vec2;
1065
+ /**
1066
+ * @description 目标生成器元素 ID(必填)
1067
+ */
1068
+ itemId: string;
1069
+ /**
1070
+ * @description 扩展属性
1071
+ */
1072
+ extension?: Record<string, any>;
1073
+ };
1074
+ /**
1075
+ * @description 视频生成器资源信息
1076
+ */
1077
+ export type VideoGeneratorResource = {
1078
+ /**
1079
+ * @description 资源地址
1080
+ */
1081
+ url: string;
1082
+ /**
1083
+ * @description 资源尺寸
1084
+ */
1085
+ size?: spec.vec2;
1086
+ /**
1087
+ * @description 是否静音(仅用于视频)
1088
+ */
1089
+ muted?: boolean;
1090
+ /**
1091
+ * @description 是否为透明视频(仅用于视频)
1092
+ */
1093
+ transparent?: boolean;
1094
+ /**
1095
+ * @description 播放速率(仅用于视频)
1096
+ */
1097
+ playbackRate?: number;
1098
+ /**
1099
+ * @description 音量(仅用于视频)
1100
+ */
1101
+ volume?: number;
1102
+ /**
1103
+ * @description 目标生成器元素 ID(必填)
1104
+ */
1105
+ itemId: string;
1106
+ /**
1107
+ * @description 扩展属性
1108
+ */
1109
+ extension?: Record<string, any>;
1110
+ };
1111
+ export type GeneratorResource = SpriteGeneratorResource | VideoGeneratorResource;
1112
+ /**
1113
+ * @description 生成器样式配置
1114
+ */
1115
+ export type GeneratorStyleConfig = {
1116
+ /**
1117
+ * @description 填充颜色 [r, g, b, a],范围 0-1
1118
+ */
1119
+ fillColor?: spec.vec4;
1120
+ /**
1121
+ * @description 图标 URL
1122
+ */
1123
+ iconUrl?: string;
1124
+ };
1125
+ export type EffectsCreateInfo = {
1126
+ /**
1127
+ * @description 元素类型 - 特效
1128
+ */
1129
+ type: SDKItemType.EFFECTS;
1130
+ /**
1131
+ * @description 元素名称
1132
+ */
1133
+ name?: string;
1134
+ /**
1135
+ * @description 元素id
1136
+ */
1137
+ id?: string;
1138
+ /**
1139
+ * @description 父元素id
1140
+ */
1141
+ parentId?: string;
1142
+ property: {
1143
+ /**
1144
+ * @description 动效像素宽度
1145
+ */
1146
+ width?: number;
1147
+ /**
1148
+ * @description 动效像素高度
1149
+ */
1150
+ height?: number;
1151
+ /**
1152
+ * @description 生成器位置
1153
+ */
1154
+ position: spec.vec2;
1155
+ /**
1156
+ * @description 旋转角度
1157
+ */
1158
+ rotation?: number | [number, number, number];
1159
+ /**
1160
+ * @description 缩放
1161
+ */
1162
+ scale?: spec.vec2;
1163
+ /**
1164
+ * @description 动效资源地址
1165
+ */
1166
+ effects: string;
1167
+ };
1168
+ /**
1169
+ * @description 扩展属性
1170
+ */
1171
+ extension?: Record<string, any>;
1172
+ };
1173
+ export type AsyncSpriteCreateInfo = SpriteCreateInfo & {
1174
+ textureId: string;
1175
+ };
1176
+ export type AsyncVideoCreateInfo = VideoCreateInfo & {
1177
+ textureId: string;
1178
+ };
1179
+ /**
1180
+ * @description Frame 画板元素创建信息
1181
+ */
1182
+ export type FrameCreateInfo = {
1183
+ /**
1184
+ * @description 元素类型 - 画板
1185
+ */
1186
+ type: SDKItemType.FRAME;
1187
+ /**
1188
+ * @description 元素名称
1189
+ */
1190
+ name?: string;
1191
+ /**
1192
+ * @description 元素id
1193
+ */
1194
+ id?: string;
1195
+ /**
1196
+ * @description 父元素id
1197
+ */
1198
+ parentId?: string;
1199
+ /**
1200
+ * @description 元素属性
1201
+ */
1202
+ property: {
1203
+ /**
1204
+ * @description 画板像素宽度
1205
+ */
1206
+ width: number;
1207
+ /**
1208
+ * @description 画板像素高度
1209
+ */
1210
+ height: number;
1211
+ /**
1212
+ * @description 画板位置
1213
+ */
1214
+ position: [number, number];
1215
+ /**
1216
+ * @description 画板旋转 z | [x, y, z]
1217
+ */
1218
+ rotation?: number | [number, number, number];
1219
+ /**
1220
+ * @description 画板缩放
1221
+ */
1222
+ scale?: [number, number];
1223
+ /**
1224
+ * @description 布局模式: 'auto' | 'free'
1225
+ */
1226
+ layoutMode?: FrameLayoutMode;
1227
+ /**
1228
+ * @description 子元素序号
1229
+ */
1230
+ children: string[];
1231
+ /**
1232
+ * @description 自动布局配置
1233
+ */
1234
+ autoLayoutConfig?: AutoLayoutConfig;
1235
+ /**
1236
+ * @description 子元素布局位置信息(用于自动布局)
1237
+ * key: 子元素ID, value: 元素的位置信息
1238
+ */
1239
+ layoutInfos?: Record<string, LayoutInfo>;
1240
+ };
1241
+ /**
1242
+ * @description 扩展属性
1243
+ */
1244
+ extension?: Record<string, any>;
1245
+ };
1246
+ export type ItemCreateInfo = GroupCreateInfo | SpriteCreateInfo | TextCreateInfo | VideoCreateInfo | GeneratorCreateInfo | EffectsCreateInfo | FrameCreateInfo | CardCreateInfo;
1247
+ export type AsyncItemCreateInfo = GroupCreateInfo | TextCreateInfo | AsyncSpriteCreateInfo | AsyncVideoCreateInfo;
1248
+ /**
1249
+ * @description 场景创建信息
1250
+ */
1251
+ export type SceneCreaetInfo = {
1252
+ /**
1253
+ * @description 场景名称
1254
+ */
1255
+ name: string;
1256
+ /**
1257
+ * @description 场景大小
1258
+ */
1259
+ size: spec.vec2;
1260
+ };
1261
+ export declare enum ItemOrderAction {
1262
+ BringToFront = 0,
1263
+ SendToBack = 1,
1264
+ BringForward = 2,
1265
+ SendBackward = 3
1266
+ }
1267
+ /**
1268
+ * @description 视图自适应偏移参数
1269
+ */
1270
+ export type ViewportFitShiftParam = {
1271
+ /**
1272
+ * @description 左偏移
1273
+ */
1274
+ left?: number;
1275
+ /**
1276
+ * @description 右偏移
1277
+ */
1278
+ right?: number;
1279
+ /**
1280
+ * @description 上偏移
1281
+ */
1282
+ top?: number;
1283
+ /**
1284
+ * @description 下偏移
1285
+ */
1286
+ bottom?: number;
1287
+ };
1288
+ export type TextureInfo = {
1289
+ id: string;
1290
+ url: string;
1291
+ type: 'image' | 'video';
1292
+ };
1293
+ export type LoadTextureInfo = {
1294
+ id: string;
1295
+ textureId: string;
1296
+ url: string;
1297
+ type: 'image' | 'video';
1298
+ };