@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
package/dist/index.d.ts DELETED
@@ -1,3485 +0,0 @@
1
- import * as _galacean_effects from '@galacean/effects';
2
- import { math, spec, Player } from '@galacean/effects';
3
- export { generateGUID, spec } from '@galacean/effects';
4
- import { Point } from '@pixi/constants';
5
-
6
- /**
7
- * @class 二维线段
8
- */
9
- declare class Line2 {
10
- start: Vector2;
11
- end: Vector2;
12
- constructor(start?: Vector2, end?: Vector2);
13
- /**
14
- * 设置二维线段
15
- * @param {Vector2} start 线段起点
16
- * @param {Vector2} end 线段终点
17
- * @returns {Line2} 二维线段
18
- */
19
- set(start: Vector2, end: Vector2): this;
20
- /**
21
- * 复制二维线段
22
- * @param {Line2} line 复制对象
23
- * @returns {Line2} 复制结果
24
- */
25
- copyFrom(line: Line2): this;
26
- /**
27
- * 二维线段求方向
28
- * @returns {Vector2} 二维线段方向
29
- */
30
- direction(): Vector2;
31
- /**
32
- * 二维线段求中点
33
- * @param {Vector2} [target=new Vector2()] 目标保存对象
34
- * @returns {Vector2} 二维线段中点
35
- */
36
- getCenter(target?: Vector2): Vector2;
37
- /**
38
- * 二维线段向量值
39
- * @param {Vector2} [target=new Vector2()] 目标保存对象
40
- * @returns {Vector2} 二维线段向量值
41
- */
42
- delta(target?: Vector2): Vector2;
43
- /**
44
- * 二维线段欧式距离平方(应用于计算)
45
- * @returns {number} 计算结果
46
- */
47
- distanceSq(): number;
48
- /**
49
- * 二维线段欧式距离
50
- * @returns {number} 计算结果
51
- */
52
- distance(): number;
53
- /**
54
- * 求二维线段比例点
55
- * @param {number} t 比例值
56
- * @param {Vector2} target 目标保存对象
57
- * @returns {Vector2} 比例点结果
58
- */
59
- at(t: number, target?: Vector2): Vector2;
60
- /**
61
- * 求点与线段的最短距离
62
- * @param {Vector2} point 二维空间点
63
- * @param {boolean} clampToLine 是否限制于线段内
64
- * @returns {number} 距离结果
65
- */
66
- closestPointToPointParameter(point: Vector2, clampToLine: boolean): number;
67
- /**
68
- * 求点与线段的最近交点
69
- * @param {Vector2} point 二维空间点
70
- * @param {boolean} clampToLine 是否限制于线段内
71
- * @param {Vector2} target 目标保存对象
72
- * @returns {Vector2} 最近交点
73
- */
74
- closestPointToPoint(point: Vector2, clampToLine: boolean, target?: Vector2): Vector2;
75
- /**
76
- * 二维线段判等
77
- * @param {Line2} line 二维线段
78
- * @returns {boolean} 判等结果
79
- */
80
- equals(line: Line2): boolean;
81
- /**
82
- * 克隆二维线段
83
- * @returns {Line2} 克隆结果
84
- */
85
- clone(): Line2;
86
- /**
87
- * 二维线段求长度
88
- * @returns {number} 长度
89
- */
90
- length(): number;
91
- /**
92
- * 二维线段判断相交
93
- * @param {Line2} other 二维线段
94
- * @returns {boolean} 相交判断结果
95
- */
96
- crossWithLine(other: Line2): boolean;
97
- }
98
-
99
- declare class Vector2 extends math.Vector2 {
100
- subtract(other: Vector2): this;
101
- toViewCoordinate(width: number, height: number): this;
102
- clone(): Vector2;
103
- distanceTo(other: Vector2): number;
104
- scaleByCenter(scalar: Vector2, anchor?: Vector2): this;
105
- round(precision?: number): this;
106
- /**
107
- * 点到直线的最短距离
108
- * @returns {{d: number, t: number}} d表示距离,t表示最近点在直线的比例
109
- */
110
- distanceToLine(line: Line2): {
111
- d: number;
112
- t: number;
113
- };
114
- /**
115
- * 二维向量与x轴夹角
116
- * @returns {number} 弧度值
117
- */
118
- angle(): number;
119
- /**
120
- * 二维点绕点旋转
121
- * @param {Vec2} center 旋转中心
122
- * @param {number} angle 旋转角度
123
- * @returns {Vec2} 旋转结果
124
- */
125
- rotateAround(center: Vector2, angle: number): this;
126
- }
127
-
128
- /**
129
- * @class 二维包围盒
130
- */
131
- declare class Box2 {
132
- /**
133
- * @member {Vector2[]} corners 二维包围盒角点
134
- */
135
- corners: Vector2[];
136
- min: Vector2;
137
- max: Vector2;
138
- /**
139
- * 构造函数,传入值为空时表示空包围盒
140
- * @param {Vector2} [min=new Vector2(Infinity, Infinity)] 最小点
141
- * @param {Vector2} [max=new Vector2(-Infinity, -Infinity)] 最大点
142
- */
143
- constructor(min?: Vector2, max?: Vector2);
144
- /**
145
- * 通过最大最小点设置二维包围盒
146
- * @param {Vector2} min 最小点
147
- * @param {Vector2} max 最大点
148
- * @returns {Box2} 二维包围盒
149
- */
150
- set(min: Vector2, max: Vector2): this;
151
- /**
152
- * 通过角点设置二维包围盒
153
- * @param {Vector2[]} vecArray 二维空间点数组
154
- * @returns {Box2} 二维包围盒
155
- */
156
- setFromVec2Array(vecArray: Vector2[]): this;
157
- /**
158
- * 通过屏幕坐标点设置二维包围盒 - 点为屏幕坐标点,x正方向为右,y正方向为向上
159
- * @param vecArray 屏幕坐标点
160
- */
161
- setFromVec2ArrayWithOutCorners(vecArray: Vector2[]): this;
162
- /**
163
- * 通过中心与大小设置二维包围盒
164
- * @param {Vector2} center 二维中心点
165
- * @param {Vector2} size 二维大小
166
- * @returns {Box2} 二维包围盒
167
- */
168
- setFromCenterAndSize(center: Vector2, size: Vector2): this;
169
- /**
170
- * 克隆二维包围盒
171
- * @returns {Box2} 克隆结果
172
- */
173
- clone(): Box2;
174
- /**
175
- * 复制二维包围盒
176
- * @param {Box2} box 二维包围盒
177
- * @returns {Box2} 复制结果
178
- */
179
- copyFrom(box: Box2): this;
180
- /**
181
- * 二维包围盒置空
182
- * @returns {Box2} 置空结果
183
- */
184
- makeEmpty(): this;
185
- /**
186
- * 二维包围盒判空
187
- * @returns {boolean} 判空结果
188
- */
189
- isEmpty(): boolean;
190
- /**
191
- * 获取二维包围盒角点
192
- * @returns {Vector2[]} 二维包围盒角点
193
- */
194
- getCorners(): Vector2[];
195
- /**
196
- * 获取二维包围盒中心点
197
- * @param {Vector2} [target=new Vector2()] 目标点(用以存放二维包围盒中心点)
198
- * @returns {Vector2} 二维包围盒中心点
199
- */
200
- getCenter(target?: Vector2): Vector2;
201
- /**
202
- * 获取二维包围盒大小
203
- * @param {Vector2} [target=new Vector2()] 目标向量(用以存放二维包围盒大小)
204
- * @returns {Vector2} 二维包围盒大小
205
- */
206
- getSize(target?: Vector2): Vector2;
207
- /**
208
- * 通过二维空间点扩展二维包围盒
209
- * @param {Vector2} point 二维空间点
210
- * @returns {Box2} 扩展包围盒
211
- */
212
- expandByPoint(point: Vector2): this;
213
- /**
214
- * 通过向量扩展二维包围盒
215
- * @param {Vector2} vector 二维向量
216
- * @returns {Box2} 扩展结果
217
- */
218
- expandByVector(vector: Vector2): this;
219
- /**
220
- * 通过大小扩展二维包围盒
221
- * @param {number} scalar 扩展大小
222
- * @returns {Box2} 扩展结果
223
- */
224
- expandByScalar(scalar: number): this;
225
- /**
226
- * 判断二维包围盒是否包含二维空间点
227
- * @param {Vector2} point 二维空间点
228
- * @param {boolean} [isOrthogonal=true] 包围盒正交判断(默认为true)
229
- * @returns {boolean} 点包含判断结果
230
- */
231
- containsPoint(point: Vector2, isOrthogonal?: boolean): boolean;
232
- /**
233
- * 判断二维包围盒包含关系(if this contains other)
234
- * @param {Box2} box 其它包围盒
235
- * @returns {boolean} 二维包围盒包含判断结果
236
- */
237
- containsBox(box: Box2): boolean;
238
- /**
239
- * 获取点以包围盒左上角顶点为原点的相对位置
240
- * @param {Vector2} point 指定二维空间点
241
- * @param {Vector2} [target=new Vector2()] 目标空间点
242
- * @returns {Vector2} 计算结果空间点
243
- */
244
- getParameter(point: Vector2, target?: Vector2): Vector2;
245
- /**
246
- * 求点与二维包围盒的最近点
247
- * @param {Vector2} point 二维空间点
248
- * @param {Vector2} [target=new Vector2()] 结果点
249
- * @returns {Vector2} 二维空间点
250
- */
251
- clampPoint(point: Vector2, target?: Vector2): Vector2;
252
- /**
253
- * 求点到二维包围盒的距离
254
- * @param {Vector2} point 二维空间点
255
- * @returns {number} 距离
256
- */
257
- distanceToPoint(point: Vector2): number;
258
- /**
259
- * 二维包围盒求交集
260
- * @param {Box2} box 二维包围盒
261
- * @returns {Box2} 求交结果
262
- */
263
- intersect(box: Box2): this;
264
- /**
265
- * 二维包围盒求并集
266
- * @param {Box2} box 二维包围盒
267
- * @returns {Box2} 求并结果
268
- */
269
- union(target: Box2 | Vector2): this;
270
- /**
271
- * 二维包围盒位移
272
- * @param {Vector2} offset 位移向量
273
- * @returns {Box2} 位移结果
274
- */
275
- translate(offset: Vector2): this;
276
- scale(scalar: number | Vector2, anchor?: Vector2): this;
277
- /**
278
- * 二维包围盒判等
279
- * @param {Box2} box 二维包围盒
280
- * @returns {boolean} 判等结果
281
- */
282
- equals(box: Box2): boolean;
283
- /**
284
- * 判断二维包围盒相交关系(if this intersect other)
285
- * @param {Box2} box 二维包围盒
286
- * @param {boolean} [isOrthogonal=true] 正交判断(当前包围盒)
287
- * @returns {boolean} 相交判断结果
288
- */
289
- intersectsBox(box: Box2, isOrthogonal?: boolean): boolean;
290
- rotate(angle: number, center?: Vector2): this;
291
- }
292
-
293
- type SizeAdaptDirection = 'x' | 'y';
294
-
295
- declare const MEDIA_TYPE: {
296
- readonly APNG: "APNG";
297
- readonly MP4: "MP4";
298
- readonly WebM: "WebM";
299
- readonly Images: "Images";
300
- readonly WebP: "WebP";
301
- readonly GIF: "GIF";
302
- readonly AlphaMaskVideo: "AlphaMaskVideo";
303
- };
304
- /**
305
- * GIF 压缩参数
306
- * 核心通过参数 flags + palettegen + paletteuse 实现
307
- * highest: lanczos + max_colors=256 + dither=bayer
308
- * high: bicubic + max_colors=200 + dither=bayer
309
- * medium: bilinear + max_colors=64 + dither=bayer
310
- * low: neighbor + max_colors=32 + dither=none
311
- */
312
- declare const GIF_QUALITY_TO_FFMPEG_ARGS: {
313
- highest: string;
314
- high: string;
315
- medium: string;
316
- low: string;
317
- };
318
-
319
- declare global {
320
- interface Window {
321
- /**
322
- * @description 创建 WebP Core 实例
323
- */
324
- createWebPCore: (config: any) => Promise<Img2WebPCore>;
325
- }
326
- }
327
- type FileBuffer = ArrayBuffer | Uint8Array;
328
- type MediaType = typeof MEDIA_TYPE[keyof typeof MEDIA_TYPE];
329
- type FS = {
330
- writeFile: (path: string, data: Uint8Array | string) => void;
331
- readFile(path: string, opts: {
332
- encoding: 'binary';
333
- flags?: string | undefined;
334
- }): Uint8Array;
335
- readFile(path: string, opts: {
336
- encoding: 'utf8';
337
- flags?: string | undefined;
338
- }): string;
339
- readFile(path: string, opts?: {
340
- flags?: string | undefined;
341
- }): Uint8Array;
342
- unlink: (path: string) => void;
343
- quit: () => void;
344
- };
345
- type Pointer = number;
346
- type Img2WebPCore = {
347
- FS: FS;
348
- run: (...args: string[]) => number;
349
- cwrap: (ident: string, returnType: string, argTypes: string[]) => ((argc: number, argv: Pointer) => number);
350
- _malloc: (size: number) => Pointer;
351
- writeAsciiToMemory: (str: string, buffer: number, dontAddNull?: boolean) => void;
352
- setValue: (ptr: number, value: any, type: string, noSafe?: boolean) => void;
353
- };
354
- type ExportMediaInitOptions = {
355
- /**
356
- * 导出类型
357
- */
358
- mediaType: MediaType;
359
- /**
360
- * 额外画布,导出透明视频时使用
361
- */
362
- extraCanvas?: HTMLCanvasElement | null;
363
- /**
364
- * 是否打印转码过程中的日志,仅在导出 MP4/AlphaMaskVideo 时有效, 默认 false
365
- * 供开发调试使用
366
- */
367
- loggerInTranscoding?: boolean;
368
- /**
369
- * ffmpeg 转码是否开启多线程,默认 false,确保环境支持 SharedArrayBuffer
370
- */
371
- multiThreading?: boolean;
372
- /**
373
- * 是否输出 buffer,默认 false
374
- */
375
- isOutputBuffer?: boolean;
376
- };
377
- type MP4Config = {
378
- /**
379
- * @description MP4 导出时是否需要导出最后一帧 PNG
380
- */
381
- isExportLastFrameJPEG?: boolean;
382
- };
383
- type GifConfig = {
384
- /**
385
- * @description GIF 导出时的帧率
386
- */
387
- fps?: number;
388
- /**
389
- * @description GIF 导出时的缩放比例
390
- * 默认 '-1:-1', 表示不缩放
391
- * 例如 '100:-1', 表示宽度 100,高度自动
392
- * 例如 '-1:100', 表示宽度自动,高度 100
393
- */
394
- scale?: string;
395
- /**
396
- * @description GIF 导出时的质量
397
- * 默认 'highest'
398
- * 可选 'highest', 'high', 'medium', 'low'
399
- */
400
- quality?: keyof typeof GIF_QUALITY_TO_FFMPEG_ARGS;
401
- };
402
- type ApngConfig = {
403
- /**
404
- * @description APNG 导出时的帧率
405
- */
406
- fps?: number;
407
- /**
408
- * @description APNG 导出时的缩放比例
409
- * 默认 '-1:-1', 表示不缩放
410
- * 例如 '100:-1', 表示宽度 100,高度自动
411
- * 例如 '-1:100', 表示宽度自动,高度 100
412
- */
413
- scale?: string;
414
- /**
415
- * @description APNG 导出时的质量
416
- * 默认 'highest'
417
- * 可选 'highest', 'high', 'medium', 'low'
418
- */
419
- quality?: keyof typeof GIF_QUALITY_TO_FFMPEG_ARGS;
420
- };
421
- type ExportMediaItemOptions = {
422
- /**
423
- * 尺寸
424
- */
425
- size: [number, number];
426
- /**
427
- * 动效资源
428
- */
429
- scene: spec.JSONScene;
430
- /**
431
- * 视频时长,目前仅在导出 MP4 / AlphaMaskVideo 时有效,默认取动效资源时长
432
- */
433
- time?: number;
434
- /**
435
- * 是否生成音轨,默认 false,仅在导出 MP4 时有效
436
- */
437
- audioEnable?: boolean;
438
- /**
439
- * 帧率, 默认 30
440
- */
441
- fps?: number;
442
- /**
443
- * 是否循环,默认 true
444
- */
445
- loop?: boolean;
446
- /**
447
- * 视频背景颜色,默认 #000000
448
- */
449
- backgroundColor?: string;
450
- /**
451
- * 导出 MP4 时,设置的导出配置
452
- */
453
- mp4Config?: MP4Config;
454
- /**
455
- * 导出 GIF 时,设置的导出配置
456
- */
457
- gifConfig?: GifConfig;
458
- /**
459
- * 导出 APNG 时,设置的导出配置
460
- */
461
- apngConfig?: ApngConfig;
462
- };
463
- type ExportMediaItemDownloadInfo = {
464
- /**
465
- * @description 导出文件夹名称
466
- */
467
- folderName: string;
468
- /**
469
- * @description 导出视频名称
470
- */
471
- name: string;
472
- };
473
- type ExportItemParams = ExportMediaItemOptions & ExportMediaItemDownloadInfo;
474
- type ExportParams = ExportItemParams[];
475
- type Buffers = FileBuffer[] | undefined;
476
- type Extras = (FileBuffer | null)[] | null | undefined;
477
-
478
- /**
479
- * @description SDKItem 基础选项接口
480
- * @description 支持扩展属性,允许添加任意额外属性
481
- */
482
- type SDKItemOptions = {
483
- /**
484
- * @description 元素ID
485
- */
486
- id: string;
487
- /**
488
- * @description 元素名称
489
- */
490
- name: string;
491
- /**
492
- * @description 父节点ID
493
- */
494
- parentId?: string;
495
- /**
496
- * @description 子元素ID列表
497
- */
498
- children?: string[];
499
- /**
500
- * @description 元素生命周期
501
- */
502
- duration?: number;
503
- /**
504
- * @description 元素生命周期延时
505
- */
506
- delay?: number;
507
- /**
508
- * @description 可视状态
509
- */
510
- visible?: boolean;
511
- /**
512
- * @description 元素结束行为
513
- */
514
- endBehavior?: spec.EndBehavior;
515
- /**
516
- * @description 是否处于锁定状态
517
- */
518
- isLocked?: boolean;
519
- /**
520
- * @description 关键属性是否可编辑
521
- */
522
- isCoreEditable: boolean;
523
- /**
524
- * @description 扩展属性存储(属性名 -> 属性值)
525
- */
526
- extension?: Record<string, any>;
527
- /**
528
- * @description 允许任意额外属性(用于兼容旧代码)
529
- */
530
- [extraProp: string]: any;
531
- };
532
- /**
533
- * @description Sprite SDKItem 选项
534
- */
535
- type SpriteItemOptions = SDKItemOptions & {
536
- /**
537
- * @description 元素属性
538
- */
539
- property?: Partial<SpriteItemProperty>;
540
- };
541
- /**
542
- * @description Text SDKItem 选项
543
- */
544
- type TextItemOptions = SDKItemOptions & {
545
- /**
546
- * @description 元素属性
547
- */
548
- property?: Partial<TextItemProperty>;
549
- };
550
- /**
551
- * @description Video SDKItem 选项
552
- */
553
- type VideoItemOptions = SDKItemOptions & {
554
- /**
555
- * @description 元素属性
556
- */
557
- property?: Partial<VideoItemProperty>;
558
- };
559
- /**
560
- * @description Group SDKItem 选项(空节点/组)
561
- */
562
- type GroupItemOptions = SDKItemOptions & {
563
- /**
564
- * @description 元素属性
565
- */
566
- property?: Partial<GroupItemProperty>;
567
- };
568
- /**
569
- * @description Generator SDKItem 选项(资源生成器)
570
- * @description 支持 image 和 video 两种生成器类型
571
- * @description 使用 GeneratorItemProperty 包含 generatorType
572
- */
573
- type GeneratorItemOptions = SDKItemOptions & {
574
- /**
575
- * @description 元素属性(包含 generatorType)
576
- */
577
- property?: Partial<GeneratorItemProperty>;
578
- };
579
- type EffectsItemOptions = SDKItemOptions & {
580
- property?: Partial<EffectsItemProperty>;
581
- };
582
- /**
583
- * @description Frame 画板元素 SDKItem 选项
584
- */
585
- type FrameItemOptions = SDKItemOptions & {
586
- /**
587
- * @description 元素属性
588
- */
589
- property?: Partial<FrameItemProperty>;
590
- };
591
- /**
592
- * @description SDKItem 类型(独立于 spec.ItemType)
593
- * @description 包含所有 SDK 层级的元素类型,包括虚拟类型如 generator
594
- */
595
- declare enum SDKItemType {
596
- SPRITE = "sprite",
597
- TEXT = "text",
598
- VIDEO = "video",
599
- GROUP = "group",
600
- GENERATOR = "generator",
601
- EFFECTS = "effects",
602
- FRAME = "frame"
603
- }
604
-
605
- /**
606
- * @description SDKItem 抽象基类
607
- * @description 支持属性扩展,允许添加任意自定义属性
608
- */
609
- declare abstract class BaseItem {
610
- /**
611
- * @description 元素ID
612
- */
613
- id: string;
614
- /**
615
- * @description 元素名称
616
- */
617
- name: string;
618
- /**
619
- * @description 父节点ID
620
- */
621
- parentId?: string;
622
- /**
623
- * @description 元素生命周期
624
- */
625
- duration: number;
626
- /**
627
- * @description 元素生命周期延时
628
- */
629
- delay: number;
630
- /**
631
- * @description 元素结束行为
632
- */
633
- endBehavior: spec.EndBehavior;
634
- /**
635
- * @description 是否可见
636
- */
637
- visible: boolean;
638
- /**
639
- * @description 是否处于锁定状态
640
- */
641
- isLocked: boolean;
642
- /**
643
- * @description 核心数据是否支持编辑
644
- */
645
- isCoreEditable: boolean;
646
- /**
647
- * @description 扩展属性存储(与 property 同级)
648
- */
649
- extension: Map<string, any>;
650
- /**
651
- * @description 元素类型(由子类实现)
652
- * @description 支持 spec.ItemType 或扩展的 SDKItemType
653
- */
654
- abstract readonly type: SDKItemType;
655
- /**
656
- * @description 元素属性(由子类实现)
657
- */
658
- abstract readonly property: BaseItemProperty;
659
- constructor(options: SDKItemOptions);
660
- /**
661
- * @description 设置扩展属性
662
- * @param key 属性名
663
- * @param value 属性值
664
- */
665
- setExtension(key: string, value: any): void;
666
- /**
667
- * @description 获取扩展属性
668
- * @param key 属性名
669
- * @returns 属性值
670
- */
671
- getExtension(key: string): any;
672
- /**
673
- * @description 检查是否存在指定扩展属性
674
- * @param key 属性名
675
- * @returns 是否存在
676
- */
677
- hasExtension(key: string): boolean;
678
- /**
679
- * @description 删除扩展属性
680
- * @param key 属性名
681
- * @returns 是否删除成功
682
- */
683
- deleteExtension(key: string): boolean;
684
- /**
685
- * @description 获取所有扩展属性的键名列表
686
- * @returns 键名数组
687
- */
688
- getExtensionKeys(): string[];
689
- /**
690
- * @description 获取所有扩展属性
691
- * @returns 扩展属性对象
692
- */
693
- getAllExtension(): Record<string, any>;
694
- /**
695
- * @description 批量设置扩展属性
696
- * @param extensions 扩展属性对象
697
- */
698
- setExtensions(extensions: Record<string, any>): void;
699
- /**
700
- * @description 清空所有扩展属性
701
- */
702
- clearExtension(): void;
703
- /**
704
- * @description 转换为 CreateInfo(用于元素复制/导出)
705
- * @param withParent 是否包含父节点ID
706
- * @returns CreateInfo 对象
707
- */
708
- abstract toCreateInfo(withParent?: boolean): ItemCreateInfo;
709
- /**
710
- * @description 克隆 SDKItem
711
- * @returns 新的 SDKItem 实例
712
- */
713
- abstract clone(): BaseItem;
714
- /**
715
- * @description 获取基础属性的 JSON 对象,转换为普通对象(用于序列化)
716
- * @returns 普通对象
717
- */
718
- toJSON(): Record<string, any>;
719
- }
720
- /**
721
- * @description 类型守卫函数:检查对象是否是 BaseItem
722
- * @param obj 要检查的对象
723
- * @returns 是否是 BaseItem 实例
724
- */
725
- declare function isBaseItem(obj: any): obj is BaseItem;
726
-
727
- /**
728
- * @description 图片元素 SDKItem 类
729
- * @description 支持属性扩展
730
- */
731
- declare class SpriteItem extends BaseItem {
732
- /**
733
- * @description 元素类型
734
- */
735
- readonly type = SDKItemType.SPRITE;
736
- /**
737
- * @description 元素属性
738
- */
739
- property: SpriteItemProperty;
740
- constructor(options: SpriteItemOptions);
741
- /**
742
- * @description 图片地址
743
- */
744
- get image(): string;
745
- set image(value: string);
746
- /**
747
- * @description 位置
748
- */
749
- get position(): [number, number];
750
- set position(value: [number, number]);
751
- get width(): number;
752
- set width(value: number);
753
- get height(): number;
754
- set height(value: number);
755
- /**
756
- * @description 旋转(二维旋转角度)
757
- */
758
- get rotation(): number;
759
- set rotation(value: number);
760
- /**
761
- * @description 完整旋转(包含 x, y, z)
762
- */
763
- get fullRotation(): [number, number, number];
764
- set fullRotation(value: [number, number, number]);
765
- /**
766
- * @description 是否正在编辑关键属性
767
- * @deprecated 该属性即将废弃,使用 isCoreEditable 代替
768
- */
769
- get keyPropertyEditing(): boolean;
770
- set keyPropertyEditing(value: boolean);
771
- /**
772
- * @description 转换为 CreateInfo
773
- * @param withParent 是否包含父节点ID
774
- */
775
- toCreateInfo(withParent?: boolean): SpriteCreateInfo;
776
- /**
777
- * @description 克隆 SDKItem
778
- */
779
- clone(): SpriteItem;
780
- /**
781
- * @description 创建包含扩展属性的 CreateInfo
782
- * @param withParent 是否包含父节点ID
783
- * @param extraProps 额外的属性
784
- */
785
- toCreateInfoWithExtensions(withParent?: boolean, extraProps?: Record<string, any>): SpriteCreateInfo;
786
- }
787
- /**
788
- * @description 类型守卫:检查是否是 SpriteItem
789
- */
790
- declare function isSpriteItem(obj: any): obj is SpriteItem;
791
-
792
- /**
793
- * @description 文本元素 SDKItem 类
794
- * @description 支持属性扩展
795
- */
796
- declare class TextItem extends BaseItem {
797
- /**
798
- * @description 元素类型
799
- */
800
- readonly type = SDKItemType.TEXT;
801
- /**
802
- * @description 元素属性
803
- */
804
- property: TextItemProperty;
805
- constructor(options: TextItemOptions);
806
- /**
807
- * @description 文本内容
808
- */
809
- get text(): string;
810
- set text(value: string);
811
- /**
812
- * @description 字体名称
813
- */
814
- get fontFamily(): string;
815
- set fontFamily(value: string);
816
- /**
817
- * @description 字号
818
- */
819
- get fontSize(): number;
820
- set fontSize(value: number);
821
- /**
822
- * @description 字重
823
- */
824
- get fontWeight(): spec.TextWeight;
825
- set fontWeight(value: spec.TextWeight);
826
- /**
827
- * @description 字体样式
828
- */
829
- get fontStyle(): spec.FontStyle;
830
- set fontStyle(value: spec.FontStyle);
831
- /**
832
- * @description 文本对齐方式
833
- */
834
- get textAlign(): spec.TextAlignment;
835
- set textAlign(value: spec.TextAlignment);
836
- /**
837
- * @description 文本颜色 [r, g, b, a]
838
- */
839
- get color(): [number, number, number, number];
840
- set color(value: [number, number, number, number]);
841
- /**
842
- * @description 文本宽度
843
- */
844
- get width(): number;
845
- set width(value: number);
846
- /**
847
- * @description 行高
848
- */
849
- get lineHeight(): number;
850
- set lineHeight(value: number);
851
- /**
852
- * @description 文本高度
853
- */
854
- get height(): number;
855
- set height(value: number);
856
- /**
857
- * @description 描边颜色
858
- */
859
- get outlineColor(): spec.vec4 | undefined;
860
- set outlineColor(value: spec.vec4 | undefined);
861
- /**
862
- * @description 描边宽度
863
- */
864
- get outlineWidth(): number | undefined;
865
- set outlineWidth(value: number | undefined);
866
- /**
867
- * @description 描边开关
868
- */
869
- get outlineEnabled(): boolean;
870
- set outlineEnabled(value: boolean);
871
- /**
872
- * @description 位置
873
- */
874
- get position(): [number, number];
875
- set position(value: [number, number]);
876
- /**
877
- * @description 旋转(二维旋转角度)
878
- */
879
- get rotation(): number;
880
- set rotation(value: number);
881
- /**
882
- * @description 转换为 CreateInfo
883
- * @param withParent 是否包含父节点ID
884
- */
885
- toCreateInfo(withParent?: boolean): TextCreateInfo;
886
- /**
887
- * @description 克隆 SDKItem
888
- */
889
- clone(): TextItem;
890
- }
891
- /**
892
- * @description 类型守卫:检查是否是 TextItem
893
- */
894
- declare function isTextItem(obj: any): obj is TextItem;
895
-
896
- /**
897
- * @description 视频元素 SDKItem 类
898
- * @description 支持属性扩展
899
- */
900
- declare class VideoItem extends BaseItem {
901
- /**
902
- * @description 元素类型
903
- */
904
- readonly type = SDKItemType.VIDEO;
905
- /**
906
- * @description 元素属性
907
- */
908
- property: VideoItemProperty;
909
- constructor(options: VideoItemOptions);
910
- /**
911
- * @description 视频地址
912
- */
913
- get video(): string;
914
- set video(value: string);
915
- /**
916
- * @description 位置
917
- */
918
- get position(): [number, number];
919
- set position(value: [number, number]);
920
- /**
921
- * @description 宽度
922
- */
923
- get width(): number;
924
- set width(value: number);
925
- /**
926
- * @description 高度
927
- */
928
- get height(): number;
929
- set height(value: number);
930
- /**
931
- * @description 旋转(二维旋转角度)
932
- */
933
- get rotation(): number;
934
- set rotation(value: number);
935
- /**
936
- * @description 完整旋转(包含 x, y, z)
937
- */
938
- get fullRotation(): [number, number, number];
939
- set fullRotation(value: [number, number, number]);
940
- /**
941
- * @description 是否正在编辑关键属性
942
- * @deprecated 该属性即将废弃,使用 isCoreEditable 代替
943
- */
944
- get keyPropertyEditing(): boolean;
945
- set keyPropertyEditing(value: boolean);
946
- /**
947
- * @description 是否静音
948
- */
949
- get muted(): boolean;
950
- set muted(state: boolean);
951
- /**
952
- * @description 是否为透明视频
953
- */
954
- get transparent(): boolean;
955
- set transparent(state: boolean);
956
- /**
957
- * @description 播放音量
958
- */
959
- get volume(): number;
960
- set volume(value: number);
961
- /**
962
- * @description 播放速率
963
- */
964
- get playbackRate(): number;
965
- set playbackRate(value: number);
966
- /**
967
- * @description 转换为 CreateInfo
968
- * @param withParent 是否包含父节点ID
969
- */
970
- toCreateInfo(withParent?: boolean): VideoCreateInfo;
971
- /**
972
- * @description 克隆 SDKItem
973
- */
974
- clone(): VideoItem;
975
- }
976
- /**
977
- * @description 类型守卫:检查是否是 VideoItem
978
- */
979
- declare function isVideoItem(obj: any): obj is VideoItem;
980
-
981
- /**
982
- * @description 空节点/组 SDKItem 类
983
- * @description 支持属性扩展
984
- */
985
- declare class GroupItem extends BaseItem {
986
- /**
987
- * @description 元素类型
988
- */
989
- readonly type = SDKItemType.GROUP;
990
- /**
991
- * @description 元素属性
992
- */
993
- property: GroupItemProperty;
994
- constructor(options: GroupItemOptions);
995
- /**
996
- * @description 位置
997
- */
998
- get position(): [number, number];
999
- set position(value: [number, number]);
1000
- /**
1001
- * @description 大小
1002
- */
1003
- get scale(): [number, number];
1004
- set scale(value: [number, number]);
1005
- /**
1006
- * @description 旋转(二维旋转角度)
1007
- */
1008
- get rotation(): number;
1009
- set rotation(value: number);
1010
- /**
1011
- * @description 完整旋转(包含 x, y, z)
1012
- */
1013
- get fullRotation(): [number, number, number];
1014
- set fullRotation(value: [number, number, number]);
1015
- /**
1016
- * @description 是否正在编辑关键属性
1017
- * @deprecated 该属性即将废弃,使用 isCoreEditable 代替
1018
- */
1019
- get keyPropertyEditing(): boolean;
1020
- set keyPropertyEditing(value: boolean);
1021
- /**
1022
- * @description 转换为 CreateInfo
1023
- * @param withParent 是否包含父节点ID
1024
- */
1025
- toCreateInfo(withParent?: boolean): GroupCreateInfo;
1026
- /**
1027
- * @description 克隆 SDKItem
1028
- */
1029
- clone(): GroupItem;
1030
- }
1031
- /**
1032
- * @description 类型守卫:检查是否是 GroupItem
1033
- */
1034
- declare function isGroupItem(obj: any): obj is GroupItem;
1035
-
1036
- /**
1037
- * @description 资源生成器元素 SDKItem 类
1038
- * @description 支持 image 和 video 两种生成器类型
1039
- * @description 在 Player 中以透明 SpriteItem 形式渲染
1040
- * @description 支持属性扩展,可转换为 SpriteItem 或 VideoItem
1041
- */
1042
- declare class GeneratorItem extends BaseItem {
1043
- /**
1044
- * @description 元素类型(独立类型,不属于 spec.ItemType)
1045
- */
1046
- readonly type = SDKItemType.GENERATOR;
1047
- /**
1048
- * @description 元素属性(包含 generatorType)
1049
- */
1050
- property: GeneratorItemProperty;
1051
- constructor(options: GeneratorItemOptions);
1052
- /**
1053
- * @description 生成器类型
1054
- */
1055
- get generatorType(): 'image' | 'video';
1056
- set generatorType(value: 'image' | 'video');
1057
- /**
1058
- * @description 图片地址(生成器返回空)
1059
- */
1060
- get image(): string;
1061
- set image(_value: string);
1062
- /**
1063
- * @description 位置
1064
- */
1065
- get position(): [number, number];
1066
- set position(value: [number, number]);
1067
- /**
1068
- * @description 宽度
1069
- */
1070
- get width(): number;
1071
- set width(value: number);
1072
- /**
1073
- * @description 高度
1074
- */
1075
- get height(): number;
1076
- set height(value: number);
1077
- /**
1078
- * @description 旋转(二维旋转角度)
1079
- */
1080
- get rotation(): number;
1081
- set rotation(value: number);
1082
- /**
1083
- * @description 完整旋转(包含 x, y, z)
1084
- */
1085
- get fullRotation(): [number, number, number];
1086
- set fullRotation(value: [number, number, number]);
1087
- /**
1088
- * @description 是否正在编辑关键属性
1089
- * @deprecated 该属性即将废弃,使用 isCoreEditable 代替
1090
- */
1091
- get keyPropertyEditing(): boolean;
1092
- set keyPropertyEditing(value: boolean);
1093
- /**
1094
- * @description 转换为 GeneratorCreateInfo
1095
- * @param withParent 是否包含父节点ID
1096
- */
1097
- toCreateInfo(withParent?: boolean): GeneratorCreateInfo;
1098
- /**
1099
- * @description 转换为 VideoCreateInfo(用于转换为视频元素)
1100
- * @param videoUrl 视频资源地址
1101
- * @param withParent 是否包含父节点ID
1102
- */
1103
- toVideoCreateInfo(videoUrl: string, withParent?: boolean): VideoCreateInfo;
1104
- /**
1105
- * @description 转换为 SpriteCreateInfo(用于转换为图片元素)
1106
- * @param imageUrl 图片资源地址
1107
- * @param withParent 是否包含父节点ID
1108
- */
1109
- toSpriteCreateInfo(imageUrl: string, withParent?: boolean): SpriteCreateInfo;
1110
- /**
1111
- * @description 克隆 SDKItem
1112
- */
1113
- clone(): GeneratorItem;
1114
- }
1115
- /**
1116
- * @description 类型守卫:检查是否是 GeneratorItem
1117
- */
1118
- declare function isGeneratorItem(obj: any): obj is GeneratorItem;
1119
-
1120
- /**
1121
- * @description 特效产物 元素 SDKItem 类
1122
- */
1123
- declare class EffectsItem extends BaseItem {
1124
- /**
1125
- * @description 元素类型(独立类型,不属于 spec.ItemType)
1126
- */
1127
- readonly type = SDKItemType.EFFECTS;
1128
- /**
1129
- * @description 元素属性
1130
- */
1131
- property: EffectsItemProperty;
1132
- constructor(options: EffectsItemOptions);
1133
- /**
1134
- * @description 特效资源地址
1135
- */
1136
- get effects(): string;
1137
- set effects(value: string);
1138
- /**
1139
- * @description 位置
1140
- */
1141
- get position(): [number, number];
1142
- set position(value: [number, number]);
1143
- /**
1144
- * @description 宽度
1145
- */
1146
- get width(): number;
1147
- set width(value: number);
1148
- /**
1149
- * @description 高度
1150
- */
1151
- get height(): number;
1152
- set height(value: number);
1153
- /**
1154
- * @description 旋转(二维旋转角度)
1155
- */
1156
- get rotation(): number;
1157
- set rotation(value: number);
1158
- /**
1159
- * @description 完整旋转(包含 x, y, z)
1160
- */
1161
- get fullRotation(): [number, number, number];
1162
- set fullRotation(value: [number, number, number]);
1163
- /**
1164
- * @description 是否正在编辑关键属性
1165
- * @deprecated 该属性即将废弃,使用 isCoreEditable 代替
1166
- */
1167
- get keyPropertyEditing(): boolean;
1168
- set keyPropertyEditing(value: boolean);
1169
- /**
1170
- * @description 转换为 EffectsCreateInfo
1171
- * @param withParent 是否包含父节点ID
1172
- */
1173
- toCreateInfo(withParent?: boolean): EffectsCreateInfo;
1174
- /**
1175
- * @description 克隆 SDKItem
1176
- */
1177
- clone(): EffectsItem;
1178
- }
1179
- /**
1180
- * @description 类型守卫:检查是否是 EffectsItem
1181
- */
1182
- declare function isEffectsItem(obj: any): obj is EffectsItem;
1183
-
1184
- /**
1185
- * @description 画板/框架元素 SDKItem 类
1186
- * @description 支持自动布局和自由布局两种模式
1187
- * @description 底层以 composition 形式渲染
1188
- */
1189
- declare class FrameItem extends BaseItem {
1190
- /**
1191
- * @description 元素类型
1192
- */
1193
- readonly type = SDKItemType.FRAME;
1194
- /**
1195
- * @description 预合成元素ID
1196
- */
1197
- subCompositionId: string;
1198
- /**
1199
- * @description 元素属性
1200
- */
1201
- property: FrameItemProperty;
1202
- constructor(options: FrameItemOptions);
1203
- /**
1204
- * @description 子元素ID列表(只读)
1205
- */
1206
- get children(): readonly string[];
1207
- /**
1208
- * @description 布局模式
1209
- */
1210
- get layoutMode(): FrameLayoutMode;
1211
- set layoutMode(value: FrameLayoutMode);
1212
- /**
1213
- * @description 位置
1214
- */
1215
- get position(): [number, number];
1216
- set position(value: [number, number]);
1217
- /**
1218
- * @description 宽度
1219
- */
1220
- get width(): number;
1221
- set width(value: number);
1222
- /**
1223
- * @description 高度
1224
- */
1225
- get height(): number;
1226
- set height(value: number);
1227
- /**
1228
- * @description 缩放
1229
- */
1230
- get scale(): [number, number];
1231
- set scale(value: [number, number]);
1232
- /**
1233
- * @description 旋转(二维旋转角度)
1234
- */
1235
- get rotation(): number;
1236
- set rotation(value: number);
1237
- /**
1238
- * @description 完整旋转(包含 x, y, z)
1239
- */
1240
- get fullRotation(): [number, number, number];
1241
- set fullRotation(value: [number, number, number]);
1242
- /**
1243
- * @description 添加子元素
1244
- * @param itemId 子元素ID
1245
- * @returns 是否添加成功
1246
- */
1247
- addChild(itemId: string): boolean;
1248
- /**
1249
- * @description 批量添加子元素
1250
- * @param itemIds 子元素ID列表
1251
- */
1252
- addChildren(itemIds: string[]): void;
1253
- /**
1254
- * @description 移除子元素
1255
- * @param itemId 子元素ID
1256
- * @returns 是否移除成功
1257
- */
1258
- removeChild(itemId: string): boolean;
1259
- /**
1260
- * @description 批量移除子元素
1261
- * @param itemIds 子元素ID列表
1262
- */
1263
- removeChildren(itemIds: string[]): void;
1264
- /**
1265
- * @description 是否包含指定子元素
1266
- * @param itemId 子元素ID
1267
- */
1268
- hasChild(itemId: string): boolean;
1269
- /**
1270
- * @description 清空所有子元素
1271
- */
1272
- clearChildren(): void;
1273
- /**
1274
- * @description 转换为 FrameCreateInfo
1275
- * @param withParent 是否包含父节点ID
1276
- */
1277
- toCreateInfo(withParent?: boolean): FrameCreateInfo;
1278
- /**
1279
- * @description 克隆 SDKItem
1280
- */
1281
- clone(): FrameItem;
1282
- }
1283
- /**
1284
- * @description 类型守卫:检查是否是 FrameItem
1285
- */
1286
- declare function isFrameItem(obj: any): obj is FrameItem;
1287
-
1288
- /**
1289
- * @description 根据 item type 创建对应的 SDKItem 实例
1290
- * @param type 元素类型
1291
- * @param options SDKItem 选项
1292
- * @returns SDKItem 实例
1293
- */
1294
- declare function createSDKItem(type: spec.ItemType, options: SDKItemOptions): BaseItem;
1295
- /**
1296
- * @description SDKItem 类型联合
1297
- * @description 用于替换原来的 SDKItem type
1298
- */
1299
- type SDKItem = SpriteItem | TextItem | VideoItem | GroupItem | GeneratorItem | EffectsItem | FrameItem;
1300
-
1301
- type BaseItemProperty = {
1302
- position: [number, number];
1303
- rotation: [number, number, number];
1304
- scale: [number, number];
1305
- width: number;
1306
- height: number;
1307
- };
1308
- type SpriteItemProperty = BaseItemProperty & {
1309
- image: string;
1310
- };
1311
- type GroupItemProperty = BaseItemProperty & {
1312
- children: string[];
1313
- };
1314
- type TextItemProperty = BaseItemProperty & {
1315
- fontFamily: string;
1316
- color: [number, number, number, number];
1317
- fontWeight: spec.TextWeight;
1318
- text: string;
1319
- textAlign: spec.TextAlignment;
1320
- fontSize: number;
1321
- fontStyle: spec.FontStyle;
1322
- lineHeight: number;
1323
- outlineColor?: spec.vec4;
1324
- outlineWidth?: number;
1325
- /**
1326
- * @description 描边开关
1327
- */
1328
- outlineEnabled?: boolean;
1329
- fontUrl?: string;
1330
- };
1331
- type VideoItemProperty = BaseItemProperty & {
1332
- video: string;
1333
- /**
1334
- * @description 是否静音
1335
- */
1336
- muted?: boolean;
1337
- /**
1338
- * @description 是否为透明视频
1339
- */
1340
- transparent?: boolean;
1341
- /**
1342
- * @description 播放速率
1343
- */
1344
- playbackRate?: number;
1345
- /**
1346
- * @description 音量
1347
- */
1348
- volume?: number;
1349
- };
1350
- /**
1351
- * @description Generator 表单属性
1352
- */
1353
- type GeneratorItemProperty = BaseItemProperty & {
1354
- /**
1355
- * @description 生成器类型
1356
- */
1357
- generatorType: 'image' | 'video';
1358
- };
1359
- type EffectsItemProperty = BaseItemProperty & {
1360
- effects: string;
1361
- children?: string[];
1362
- };
1363
- /**
1364
- * @description Frame 画板元素布局模式
1365
- */
1366
- declare enum FrameLayoutMode {
1367
- AUTO = "auto",
1368
- FREE = "free"
1369
- }
1370
- /**
1371
- * @description Frame 画板元素属性
1372
- */
1373
- type FrameItemProperty = BaseItemProperty & {
1374
- /**
1375
- * @description 布局模式: auto - 自动布局, free - 自由布局
1376
- */
1377
- layoutMode: FrameLayoutMode;
1378
- /**
1379
- * @description 子元素ID数组
1380
- */
1381
- children: string[];
1382
- };
1383
- /**
1384
- * @description BaseItem 基础属性键名
1385
- */
1386
- type BaseItemPropertyKey = 'name' | 'duration' | 'delay' | 'endBehavior' | 'visible' | 'isLocked' | 'parentId';
1387
- /**
1388
- * @description BaseItem 基础属性值类型映射
1389
- */
1390
- type BaseItemPropertyValueMap = {
1391
- name: string;
1392
- duration: number;
1393
- delay: number;
1394
- endBehavior: spec.EndBehavior;
1395
- visible: boolean;
1396
- isLocked: boolean;
1397
- parentId?: string;
1398
- };
1399
- /**
1400
- * @description Item 类型与 Property 类型的映射
1401
- */
1402
- type ItemPropertyMap = {
1403
- [SDKItemType.SPRITE]: SpriteItemProperty;
1404
- [SDKItemType.TEXT]: TextItemProperty;
1405
- [SDKItemType.VIDEO]: VideoItemProperty;
1406
- [SDKItemType.GROUP]: GroupItemProperty;
1407
- [SDKItemType.GENERATOR]: GeneratorItemProperty;
1408
- [SDKItemType.EFFECTS]: EffectsItemProperty;
1409
- [SDKItemType.FRAME]: FrameItemProperty;
1410
- };
1411
- /**
1412
- * @description 场景1:单个元素单个属性设置
1413
- * 支持设置 BaseItem 基础属性或具体 Item 类型的 property 属性
1414
- */
1415
- type SetSingleItemSinglePropertyParam<T extends SDKItemType = SDKItemType> = {
1416
- itemId: string;
1417
- type: T;
1418
- propertyName: BaseItemPropertyKey;
1419
- propertyValue: BaseItemPropertyValueMap[BaseItemPropertyKey];
1420
- } | {
1421
- itemId: string;
1422
- type: T;
1423
- propertyName: keyof ItemPropertyMap[T];
1424
- propertyValue: ItemPropertyMap[T][keyof ItemPropertyMap[T]];
1425
- };
1426
- /**
1427
- * @description 场景2:单个元素多个属性设置
1428
- * 同时设置多个 BaseItem 属性或 property 属性
1429
- */
1430
- type SetSingleItemMultiplePropertiesParam<T extends SDKItemType = SDKItemType> = {
1431
- itemId: string;
1432
- type: T;
1433
- property: Partial<Record<BaseItemPropertyKey, BaseItemPropertyValueMap[BaseItemPropertyKey]>> & Partial<Record<keyof ItemPropertyMap[T], ItemPropertyMap[T][keyof ItemPropertyMap[T]]>>;
1434
- };
1435
- /**
1436
- * @description 设置元素属性的统一参数类型
1437
- * 支持两种场景:单元素单属性、单元素多属性
1438
- */
1439
- type SetItemPropertyParam<T extends SDKItemType = SDKItemType> = SetSingleItemSinglePropertyParam<T> | SetSingleItemMultiplePropertiesParam<T>;
1440
- type SDKOptions = {
1441
- /** 导出视频时,是否开启转码日志 */
1442
- loggerInExportVideoTranscoding?: boolean;
1443
- };
1444
- type SDKInputParam = SDKTemplateInputParam | SDKEditorInputParam;
1445
- /**
1446
- * @description SDK入参
1447
- */
1448
- type SDKTemplateInputParam = {
1449
- /**
1450
- * @description JSON地址
1451
- */
1452
- scene: string | spec.JSONScene;
1453
- /**
1454
- * @description SDK模式 - 模板编辑模式
1455
- */
1456
- mode: 'template';
1457
- /**
1458
- * @description 视图参数
1459
- */
1460
- viewParams?: ViewParam[];
1461
- /**
1462
- * @description 页面属性
1463
- */
1464
- options: PageOptions;
1465
- };
1466
- type SDKEditorInputParam = {
1467
- /**
1468
- * @description SDK模式 - 编辑器模式
1469
- */
1470
- mode: 'editor';
1471
- };
1472
- /**
1473
- * @description 页面属性
1474
- */
1475
- type PageOptions = {
1476
- /**
1477
- * @description 同步模式开关
1478
- */
1479
- asyncMode: boolean;
1480
- /**
1481
- * @description 安全区展示开关
1482
- */
1483
- safeAreaPreview: boolean;
1484
- /**
1485
- * @description 吸附开关
1486
- */
1487
- adsorption: boolean;
1488
- };
1489
- /**
1490
- * @description 页面数据
1491
- */
1492
- type PageData = {
1493
- /**
1494
- * @description 基础场景数据
1495
- */
1496
- scene: spec.JSONScene;
1497
- /**
1498
- * @description 页面属性
1499
- */
1500
- property: PageProperty;
1501
- /**
1502
- * @description 视图属性
1503
- */
1504
- viewProperties: ViewProperty[];
1505
- /**
1506
- * @description 活跃数据
1507
- */
1508
- activeData: ActiveData;
1509
- /**
1510
- * @description 元素数据
1511
- */
1512
- items: SDKItem[];
1513
- /**
1514
- * @description 视图当前时间
1515
- */
1516
- time: number;
1517
- /**
1518
- * @description 是否处于播放态
1519
- */
1520
- playing: boolean;
1521
- };
1522
- /**
1523
- * @description 页面配置
1524
- */
1525
- type PageConfig$1 = {
1526
- /**
1527
- * @description 出血区域展示开关
1528
- */
1529
- safeAreaPreview: boolean;
1530
- /**
1531
- * @description 缩放值
1532
- */
1533
- zoom: number;
1534
- /**
1535
- * @description 吸附开关
1536
- */
1537
- adsorption: boolean;
1538
- /**
1539
- * @description 同步开关
1540
- */
1541
- asyncMode: boolean;
1542
- /**
1543
- * @description 画布移动
1544
- */
1545
- translation: spec.vec2;
1546
- };
1547
- /**
1548
- * @description 页面属性
1549
- */
1550
- type PageProperty = {
1551
- /**
1552
- * @description 出血区域展示开关
1553
- */
1554
- safeAreaPreview: boolean;
1555
- /**
1556
- * @description 缩放值
1557
- */
1558
- zoom: number;
1559
- /**
1560
- * @description 偏移值
1561
- */
1562
- translation: [number, number];
1563
- /**
1564
- * @description 吸附开关
1565
- */
1566
- adsorption: boolean;
1567
- /**
1568
- * @description 同步开关
1569
- */
1570
- asyncMode: boolean;
1571
- };
1572
- /**
1573
- * @description 视图创建参数
1574
- */
1575
- type ViewParam = {
1576
- /**
1577
- * @description 页面尺寸
1578
- */
1579
- size?: [number, number];
1580
- /**
1581
- * @description 出血区参数
1582
- */
1583
- safeArea?: [number, number, number, number];
1584
- /**
1585
- * @description 自适应方向 - 默认根据视图宽高决定
1586
- */
1587
- adaptionDirection?: SizeAdaptDirection;
1588
- /**
1589
- * @description 自定义出血区 - 用于展示
1590
- */
1591
- previewSafeAreas?: PreviewSafeAreaParam[];
1592
- /**
1593
- * @description 导出参数
1594
- */
1595
- export: ExportParam;
1596
- };
1597
- /**
1598
- * @description 导出参数
1599
- */
1600
- type ExportParam = {
1601
- /**
1602
- * @description 视频名称
1603
- */
1604
- name?: string;
1605
- } & Omit<ExportMediaItemOptions, 'scene' | 'size'>;
1606
- /**
1607
- * @description 视图属性
1608
- */
1609
- type ViewProperty = {
1610
- /**
1611
- * @description 视图ID
1612
- */
1613
- id: number;
1614
- /**
1615
- * @description 视图宽高
1616
- */
1617
- size: [number, number];
1618
- /**
1619
- * @description 出血区数据
1620
- */
1621
- safeArea: [number, number, number, number];
1622
- /**
1623
- * @description 自定义出血区数据
1624
- */
1625
- previewSafeAreas: PreviewSafeAreaParam[];
1626
- /**
1627
- * @description 视图场景数据
1628
- */
1629
- scene: spec.JSONScene;
1630
- /**
1631
- * @description 导出参数
1632
- */
1633
- export: ExportParam;
1634
- /**
1635
- * @description 忽略交互 - 仅供展示
1636
- */
1637
- ignoreInteraction: boolean;
1638
- };
1639
- /**
1640
- * @description 自定义出血区数据
1641
- */
1642
- type PreviewSafeAreaParam = {
1643
- /**
1644
- * @description 出血区包围盒 [left top width height]
1645
- */
1646
- box: [number, number, number, number];
1647
- /**
1648
- * @description 出血区色块颜色 默认为 [255, 255, 255, 0.3]
1649
- */
1650
- color?: [number, number, number, number];
1651
- /**
1652
- * @description 出血区图像
1653
- */
1654
- url?: string;
1655
- /**
1656
- * @description 出血区是否可见
1657
- */
1658
- visible?: boolean;
1659
- };
1660
- /**
1661
- * @description 页面活跃数据
1662
- */
1663
- type ActiveData = {
1664
- /**
1665
- * @description 视图ID
1666
- */
1667
- view?: number;
1668
- /**
1669
- * @description 选中元素
1670
- */
1671
- selectedItems: string[];
1672
- /**
1673
- * @description 预选中元素
1674
- */
1675
- preSelectedItem?: string;
1676
- /**
1677
- * @description 执行中元素
1678
- */
1679
- loadingItems?: string[];
1680
- };
1681
- type SDKBackgroundType = 'color' | 'image' | 'chess-board' | 'dot-board';
1682
- /**
1683
- * @description 图层创建信息
1684
- */
1685
- type SpriteCreateInfo = {
1686
- type: SDKItemType.SPRITE;
1687
- /**
1688
- * @description 图层名称
1689
- */
1690
- name?: string;
1691
- /**
1692
- * @description 元素id
1693
- */
1694
- id?: string;
1695
- /**
1696
- * @description 父节点id
1697
- */
1698
- parentId?: string;
1699
- /**
1700
- * @description 扩展属性
1701
- */
1702
- extension?: Record<string, any>;
1703
- /**
1704
- * @description 元素属性
1705
- */
1706
- property: {
1707
- /**
1708
- * @description 图片资源地址 | 数据
1709
- */
1710
- image?: string;
1711
- /**
1712
- * @description 图层像素宽度
1713
- */
1714
- width: number;
1715
- /**
1716
- * @description 图层像素高度
1717
- */
1718
- height: number;
1719
- /**
1720
- * @description 元素位置
1721
- */
1722
- position: [number, number];
1723
- /**
1724
- * @description 元素旋转 z | [x, y, z]
1725
- */
1726
- rotation?: number | [number, number, number];
1727
- /**
1728
- * @description 元素缩放
1729
- */
1730
- scale?: [number, number];
1731
- };
1732
- };
1733
- /**
1734
- * @description 空节点创建信息
1735
- */
1736
- type GroupCreateInfo = {
1737
- type: SDKItemType.GROUP;
1738
- /**
1739
- * @description 元素id
1740
- */
1741
- id?: string;
1742
- /**
1743
- * @description 父节点id
1744
- */
1745
- parentId?: string;
1746
- /**
1747
- * @description 元素名称
1748
- */
1749
- name?: string;
1750
- /**
1751
- * @description 扩展属性
1752
- */
1753
- extension?: Record<string, any>;
1754
- /**
1755
- * @description 元素属性
1756
- */
1757
- property: {
1758
- /**
1759
- * @description 元素位置
1760
- */
1761
- position?: [number, number];
1762
- /**
1763
- * @description 元素旋转 z | [x, y, z]
1764
- */
1765
- rotation?: number | [number, number, number];
1766
- /**
1767
- * @description 元素缩放
1768
- */
1769
- scale?: [number, number];
1770
- /**
1771
- * @description 子元素id
1772
- */
1773
- children: string[];
1774
- };
1775
- };
1776
- /**
1777
- * @description 文本创建信息
1778
- */
1779
- type TextCreateInfo = {
1780
- type: SDKItemType.TEXT;
1781
- /**
1782
- * @description 元素id
1783
- */
1784
- id?: string;
1785
- /**
1786
- * @description 父节点id
1787
- */
1788
- parentId?: string;
1789
- /**
1790
- * @description 元素名称
1791
- */
1792
- name?: string;
1793
- /**
1794
- * @description 扩展属性
1795
- */
1796
- extension?: Record<string, any>;
1797
- /**
1798
- * @description 元素属性
1799
- */
1800
- property: {
1801
- /**
1802
- * @description 文本宽度
1803
- */
1804
- width: number;
1805
- /**
1806
- * @description 文本高度
1807
- */
1808
- height?: number;
1809
- /**
1810
- * @description 元素位置
1811
- */
1812
- position: [number, number];
1813
- /**
1814
- * @description 元素旋转 z | [x, y, z]
1815
- */
1816
- rotation?: number | [number, number, number];
1817
- /**
1818
- * @description 元素缩放
1819
- */
1820
- scale?: [number, number];
1821
- /**
1822
- * @description 单行高度
1823
- */
1824
- lineHeight: number;
1825
- /**
1826
- * @description 字体名称
1827
- */
1828
- fontFamily: string;
1829
- /**
1830
- * @description 文字大小
1831
- */
1832
- fontSize: number;
1833
- /**
1834
- * @description 字重
1835
- */
1836
- fontWeight?: spec.TextWeight;
1837
- /**
1838
- * @description 字体格式
1839
- */
1840
- fontStyle?: spec.FontStyle;
1841
- /**
1842
- * @description 对齐方式
1843
- */
1844
- textAlign?: spec.TextAlignment;
1845
- /**
1846
- * @description 文本信息
1847
- */
1848
- text: string;
1849
- /**
1850
- * @description 填充色
1851
- */
1852
- color: spec.vec4;
1853
- /**
1854
- * @description 描边色
1855
- */
1856
- outlineColor?: spec.vec4;
1857
- /**
1858
- * @description 描边宽度
1859
- */
1860
- outlineWidth?: number;
1861
- /**
1862
- * @description 描边开关
1863
- */
1864
- outlineEnabled?: boolean;
1865
- /**
1866
- * @description 字体文件地址
1867
- */
1868
- fontUrl?: string;
1869
- };
1870
- };
1871
- /**
1872
- * @description 视频创建信息
1873
- */
1874
- type VideoCreateInfo = {
1875
- type: SDKItemType.VIDEO;
1876
- /**
1877
- * @description 视频名称
1878
- */
1879
- name?: string;
1880
- /**
1881
- * @description 元素id
1882
- */
1883
- id?: string;
1884
- /**
1885
- * @description 父节点id
1886
- */
1887
- parentId?: string;
1888
- /**
1889
- * @description 扩展属性
1890
- */
1891
- extension?: Record<string, any>;
1892
- /**
1893
- * @description 元素属性
1894
- */
1895
- property: {
1896
- /**
1897
- * @description 视频资源地址 | 数据
1898
- */
1899
- video?: string;
1900
- /**
1901
- * @description 视频元素像素宽度
1902
- */
1903
- width: number;
1904
- /**
1905
- * @description 视频元素像素高度
1906
- */
1907
- height: number;
1908
- /**
1909
- * @description 视频元素位置
1910
- */
1911
- position: [number, number];
1912
- /**
1913
- * @description 视频元素旋转 z | [x, y, z]
1914
- */
1915
- rotation?: number | [number, number, number];
1916
- /**
1917
- * @description 视频元素缩放
1918
- */
1919
- scale?: [number, number];
1920
- /**
1921
- * @description 是否静音
1922
- */
1923
- muted?: boolean;
1924
- /**
1925
- * @description 是否为透明视频
1926
- */
1927
- transparent?: boolean;
1928
- /**
1929
- * @description 播放速率
1930
- */
1931
- playbackRate?: number;
1932
- /**
1933
- * @description 音量
1934
- */
1935
- volume?: number;
1936
- };
1937
- };
1938
- /**
1939
- * @description 生成器类型
1940
- */
1941
- type GeneratorType = 'image' | 'video';
1942
- /**
1943
- * @description 生成器创建信息
1944
- */
1945
- type GeneratorCreateInfo = {
1946
- /**
1947
- * @description 元素类型 - 生成器
1948
- */
1949
- type: SDKItemType.GENERATOR;
1950
- /**
1951
- * @description 元素名称
1952
- */
1953
- name?: string;
1954
- /**
1955
- * @description 元素id
1956
- */
1957
- id?: string;
1958
- /**
1959
- * @description 父元素id
1960
- */
1961
- parentId?: string;
1962
- /**
1963
- * @description 扩展属性
1964
- */
1965
- extension?: Record<string, any>;
1966
- /**
1967
- * @description 元素属性
1968
- */
1969
- property: {
1970
- /**
1971
- * @description 生成器类型
1972
- */
1973
- generatorType: GeneratorType;
1974
- /**
1975
- * @description 生成器元素像素宽度
1976
- */
1977
- width: number;
1978
- /**
1979
- * @description 生成器元素像素高度
1980
- */
1981
- height: number;
1982
- /**
1983
- * @description 生成器元素位置
1984
- */
1985
- position: [number, number];
1986
- /**
1987
- * @description 生成器元素旋转 z | [x, y, z]
1988
- */
1989
- rotation?: number | [number, number, number];
1990
- /**
1991
- * @description 生成器元素缩放
1992
- */
1993
- scale?: [number, number];
1994
- };
1995
- };
1996
- /**
1997
- * @description 图片生成器资源信息
1998
- */
1999
- type SpriteGeneratorResource = {
2000
- /**
2001
- * @description 资源地址
2002
- */
2003
- url: string;
2004
- /**
2005
- * @description 资源尺寸
2006
- */
2007
- size?: spec.vec2;
2008
- /**
2009
- * @description 目标生成器元素 ID(必填)
2010
- */
2011
- itemId: string;
2012
- /**
2013
- * @description 扩展属性
2014
- */
2015
- extension?: Record<string, any>;
2016
- };
2017
- /**
2018
- * @description 视频生成器资源信息
2019
- */
2020
- type VideoGeneratorResource = {
2021
- /**
2022
- * @description 资源地址
2023
- */
2024
- url: string;
2025
- /**
2026
- * @description 资源尺寸
2027
- */
2028
- size?: spec.vec2;
2029
- /**
2030
- * @description 是否静音(仅用于视频)
2031
- */
2032
- muted?: boolean;
2033
- /**
2034
- * @description 是否为透明视频(仅用于视频)
2035
- */
2036
- transparent?: boolean;
2037
- /**
2038
- * @description 播放速率(仅用于视频)
2039
- */
2040
- playbackRate?: number;
2041
- /**
2042
- * @description 音量(仅用于视频)
2043
- */
2044
- volume?: number;
2045
- /**
2046
- * @description 目标生成器元素 ID(必填)
2047
- */
2048
- itemId: string;
2049
- /**
2050
- * @description 扩展属性
2051
- */
2052
- extension?: Record<string, any>;
2053
- };
2054
- type GeneratorResource = SpriteGeneratorResource | VideoGeneratorResource;
2055
- type EffectsCreateInfo = {
2056
- /**
2057
- * @description 元素类型 - 特效
2058
- */
2059
- type: SDKItemType.EFFECTS;
2060
- /**
2061
- * @description 元素名称
2062
- */
2063
- name?: string;
2064
- /**
2065
- * @description 元素id
2066
- */
2067
- id?: string;
2068
- /**
2069
- * @description 父元素id
2070
- */
2071
- parentId?: string;
2072
- property: {
2073
- /**
2074
- * @description 动效像素宽度
2075
- */
2076
- width?: number;
2077
- /**
2078
- * @description 动效像素高度
2079
- */
2080
- height?: number;
2081
- /**
2082
- * @description 生成器位置
2083
- */
2084
- position: spec.vec2;
2085
- /**
2086
- * @description 旋转角度
2087
- */
2088
- rotation?: number | [number, number, number];
2089
- /**
2090
- * @description 缩放
2091
- */
2092
- scale?: spec.vec2;
2093
- /**
2094
- * @description 动效资源地址
2095
- */
2096
- effects: string;
2097
- };
2098
- /**
2099
- * @description 扩展属性
2100
- */
2101
- extension?: Record<string, any>;
2102
- };
2103
- /**
2104
- * @description Frame 画板元素创建信息
2105
- */
2106
- type FrameCreateInfo = {
2107
- /**
2108
- * @description 元素类型 - 画板
2109
- */
2110
- type: SDKItemType.FRAME;
2111
- /**
2112
- * @description 元素名称
2113
- */
2114
- name?: string;
2115
- /**
2116
- * @description 元素id
2117
- */
2118
- id?: string;
2119
- /**
2120
- * @description 父元素id
2121
- */
2122
- parentId?: string;
2123
- /**
2124
- * @description 元素属性
2125
- */
2126
- property: {
2127
- /**
2128
- * @description 画板像素宽度
2129
- */
2130
- width: number;
2131
- /**
2132
- * @description 画板像素高度
2133
- */
2134
- height: number;
2135
- /**
2136
- * @description 画板位置
2137
- */
2138
- position: [number, number];
2139
- /**
2140
- * @description 画板旋转 z | [x, y, z]
2141
- */
2142
- rotation?: number | [number, number, number];
2143
- /**
2144
- * @description 画板缩放
2145
- */
2146
- scale?: [number, number];
2147
- /**
2148
- * @description 布局模式: 'auto' | 'free'
2149
- */
2150
- layoutMode?: FrameLayoutMode;
2151
- /**
2152
- * @description 子元素序号
2153
- */
2154
- children: string[];
2155
- };
2156
- /**
2157
- * @description 扩展属性
2158
- */
2159
- extension?: Record<string, any>;
2160
- };
2161
- type ItemCreateInfo = GroupCreateInfo | SpriteCreateInfo | TextCreateInfo | VideoCreateInfo | GeneratorCreateInfo | EffectsCreateInfo | FrameCreateInfo;
2162
- /**
2163
- * @description 场景创建信息
2164
- */
2165
- type SceneCreaetInfo = {
2166
- /**
2167
- * @description 场景名称
2168
- */
2169
- name: string;
2170
- /**
2171
- * @description 场景大小
2172
- */
2173
- size: spec.vec2;
2174
- };
2175
- declare enum ItemOrderAction {
2176
- BringToFront = 0,
2177
- SendToBack = 1,
2178
- BringForward = 2,
2179
- SendBackward = 3
2180
- }
2181
- /**
2182
- * @description 视图自适应偏移参数
2183
- */
2184
- type ViewportFitShiftParam = {
2185
- /**
2186
- * @description 左偏移
2187
- */
2188
- left?: number;
2189
- /**
2190
- * @description 右偏移
2191
- */
2192
- right?: number;
2193
- /**
2194
- * @description 上偏移
2195
- */
2196
- top?: number;
2197
- /**
2198
- * @description 下偏移
2199
- */
2200
- bottom?: number;
2201
- };
2202
-
2203
- type CreateOperation = {
2204
- type: 'create';
2205
- newData: ItemCreateInfo[];
2206
- };
2207
- type DeleteOperation = {
2208
- type: 'delete';
2209
- oldData: ItemCreateInfo[];
2210
- };
2211
- type UpdateOperation = {
2212
- type: 'update';
2213
- newData: ItemCreateInfo[];
2214
- oldData: ItemCreateInfo[];
2215
- };
2216
- type Operation = CreateOperation | UpdateOperation | DeleteOperation;
2217
- declare class UndoRedo {
2218
- private index;
2219
- private operations;
2220
- get canUndo(): boolean;
2221
- get canRedo(): boolean;
2222
- oldData?: ItemCreateInfo[];
2223
- push(operation: Operation): void;
2224
- undo(): Operation | undefined;
2225
- redo(): Operation | undefined;
2226
- clear(): void;
2227
- }
2228
-
2229
- type SDKMode = 'editor' | 'template';
2230
- /**
2231
- * @description SDK功能配置
2232
- */
2233
- type SDKConfig = {
2234
- /**
2235
- * @description SDK编辑模式 - 模板编辑模式 | 编辑器模式
2236
- */
2237
- mode: SDKMode;
2238
- /**
2239
- * @description 页面功能配置
2240
- */
2241
- pageConfig: PageConfig;
2242
- /**
2243
- * @description 异步加载功能配置
2244
- */
2245
- asyncLoadConfig: AsyncLoadConfig;
2246
- /**
2247
- * @description 截图功能配置
2248
- */
2249
- screenShotConfig: ScreenShotConfig;
2250
- /**
2251
- * @description 导出视频功能配置
2252
- */
2253
- exportConfig: ExportConfig;
2254
- /**
2255
- * @description 尺寸自适应功能开关
2256
- */
2257
- sizeAdaptConfig: SizeAdaptConfig;
2258
- /**
2259
- * @description 辅助面板功能配置
2260
- */
2261
- gestureHandlerConfig: {
2262
- enabled: boolean;
2263
- adsorptionGizmoEnabled: boolean;
2264
- adsorptionGizmoConfig: AdsorptionGizmoConfig;
2265
- controlGizmoEnabled: boolean;
2266
- controlGizmoConfig: ControlGizmoConfig;
2267
- preferenceGizmoEnabled: boolean;
2268
- preferenceGizmoConfig: PreferenceGizmoConfig;
2269
- selectorGizmoEnabled: boolean;
2270
- selectorGizmoConfig: SelectorGizmoConfig;
2271
- transformGizmoEnabled: boolean;
2272
- transformGizmoConfig: TransformGizmoConfig;
2273
- pictureCutGizmoEnabled: boolean;
2274
- pictureCutGizmoConfig: PictureCutGizmoConfig;
2275
- pictureExpandGizmoEnabled: boolean;
2276
- pictureExpandGizmoConfig: PictureExpandGizmoConfig;
2277
- textGizmoEnbaled: boolean;
2278
- textGizmoConfig: TextGizmoConfig;
2279
- maskGizmoEnabled: boolean;
2280
- maskGizmoConfig: MaskGizmoConfig;
2281
- spriteTextEditGizmoEnabled: boolean;
2282
- spriteTextEditGizmoConfig: SpriteTextEditGizmoConfig;
2283
- videoPlayGizmoEnabled: boolean;
2284
- videoPlayGizmoConfig: VideoPlayGizmoConfig;
2285
- itemCreateGizmoEnabled: boolean;
2286
- itemCreateGizmoConfig: ItemCreateGizmoConfig;
2287
- };
2288
- };
2289
- /**
2290
- * @description 页面功能配置
2291
- */
2292
- type PageConfig = {
2293
- /**
2294
- * @description 同步修改功能开关
2295
- */
2296
- asncMode: boolean;
2297
- /**
2298
- * @description 静态预览【视图只提供播放预览功能】功能开关
2299
- */
2300
- staticPreview: boolean;
2301
- /**
2302
- * @description 静态预览视图名称
2303
- */
2304
- staticPreviewName: string;
2305
- /**
2306
- * @description 需过滤的元素名称
2307
- */
2308
- filterItemNames: string[];
2309
- /**
2310
- * @description 成组操作元素显隐
2311
- */
2312
- groupVisible: boolean;
2313
- /**
2314
- * @description 缩放最大值
2315
- */
2316
- maxZoom: number;
2317
- /**
2318
- * @description 缩放最小值
2319
- */
2320
- minZoom: number;
2321
- };
2322
- /**
2323
- * @description 异步加载配置
2324
- */
2325
- type AsyncLoadConfig = {
2326
- enabled: boolean;
2327
- loadingTextureUrl: string;
2328
- };
2329
- /**
2330
- * @description 视频导出功能配置
2331
- */
2332
- type ExportConfig = {
2333
- enabled: boolean;
2334
- } & ExportMediaInitOptions;
2335
- /**
2336
- * @description 截图功能配置
2337
- */
2338
- type ScreenShotConfig = {
2339
- enabled: boolean;
2340
- defaultBackgroundColor: [number, number, number, number];
2341
- };
2342
- /**
2343
- * @description 尺寸自适应功能配置
2344
- */
2345
- type SizeAdaptConfig = {
2346
- enabled: boolean;
2347
- };
2348
- /**
2349
- * @description 对齐吸附功能参数
2350
- */
2351
- type AdsorptionGizmoConfig = {
2352
- /**
2353
- * @description 对齐吸附线宽
2354
- */
2355
- lineWidth: number;
2356
- /**
2357
- * @description 对齐线颜色
2358
- */
2359
- lineColor: number;
2360
- /**
2361
- * @description 对齐吸附距离
2362
- */
2363
- distance: number;
2364
- };
2365
- /**
2366
- * @description 视图控制功能参数
2367
- */
2368
- type ControlGizmoConfig = {
2369
- /**
2370
- * @description 缩放步长
2371
- */
2372
- zoomStep: number;
2373
- };
2374
- /**
2375
- * @description 视口展示功能参数
2376
- */
2377
- type PreferenceGizmoConfig = {
2378
- /**
2379
- * @description 视口窗包围盒颜色
2380
- */
2381
- boxColor: number;
2382
- /**
2383
- * @description 视口窗包围盒宽度
2384
- */
2385
- boxWidth: number;
2386
- /**
2387
- * @description 视口区域外遮罩颜色
2388
- */
2389
- markColor: number;
2390
- /**
2391
- * @description 视口区域外遮罩透明度
2392
- */
2393
- markAlpha: number;
2394
- /**
2395
- * @description 出血区预览开关
2396
- */
2397
- safeAreaEnabled: boolean;
2398
- /**
2399
- * @description 出血区颜色
2400
- */
2401
- safeAreaBoxColor: number;
2402
- /**
2403
- * @description 出血区透明度
2404
- */
2405
- safeAreaBoxAlpha: number;
2406
- };
2407
- /**
2408
- * @description 选择功能参数
2409
- */
2410
- type SelectorGizmoConfig = {
2411
- /**
2412
- * @description 视频预选中时
2413
- */
2414
- videoPreSelectedPlay: boolean;
2415
- /**
2416
- * @description 预选框线宽
2417
- */
2418
- preSelectedWidth: number;
2419
- /**
2420
- * @description 预选框颜色
2421
- */
2422
- preSelectedColor: number;
2423
- /**
2424
- * @description 框选区域颜色
2425
- */
2426
- regionBoxColor: number;
2427
- /**
2428
- * @description 框选区域透明度
2429
- */
2430
- regionBoxAlpha: number;
2431
- /**
2432
- * @description 框选区域包围框颜色
2433
- */
2434
- regionWireframeColor: number;
2435
- /**
2436
- * @description 框选区域包围框透明度
2437
- */
2438
- regionWireframeAlpha: number;
2439
- /**
2440
- * @description 框选区域包围框宽度
2441
- */
2442
- regionWireframeWidth: number;
2443
- };
2444
- /**
2445
- * @description 变换功能参数
2446
- */
2447
- type TransformGizmoConfig = {
2448
- /**
2449
- * @description 变换交互框颜色
2450
- */
2451
- wireframeColor: number;
2452
- /**
2453
- * @description 变换交互框透明度
2454
- */
2455
- wireframeAlpha: number;
2456
- /**
2457
- * @description 变换交互框宽度
2458
- */
2459
- wireframeWidth: number;
2460
- /**
2461
- * @description 变换交互框角点填充色
2462
- */
2463
- cornerFillColor: number;
2464
- /**
2465
- * @description 变换交互框角点线框色
2466
- */
2467
- cornerLineColor: number;
2468
- /**
2469
- * @description 变换交互框角点线框宽度
2470
- */
2471
- cornerLineWidth: number;
2472
- /**
2473
- * @description 变换交互框角点线框透明度
2474
- */
2475
- cornerLineAlpha: number;
2476
- /**
2477
- * @description 交互框缩放圆半径
2478
- */
2479
- scaleCircleSize: number;
2480
- /**
2481
- * @description 交互框旋转圆半径
2482
- */
2483
- rotationCircleSize: number;
2484
- /**
2485
- * @description 图片Logo地址
2486
- */
2487
- pictureLogoUrl: string;
2488
- /**
2489
- * @description 空节点Logo地址
2490
- */
2491
- groupLogoUrl: string;
2492
- /**
2493
- * @description 文本Logo地址
2494
- */
2495
- textLogoUrl: string;
2496
- /**
2497
- * @description 视频Logo地址
2498
- */
2499
- videoLogoUrl: string;
2500
- /**
2501
- * @description 大小文字颜色
2502
- */
2503
- sizeTextColor: number;
2504
- /**
2505
- * @description 名称文字颜色
2506
- */
2507
- nameTextColor: number;
2508
- /**
2509
- * @description 选中信息展示
2510
- */
2511
- infoShowEnabled: boolean;
2512
- };
2513
- /**
2514
- * @description 图片裁切参数
2515
- */
2516
- type PictureCutGizmoConfig = {
2517
- /**
2518
- * @description 蒙版颜色
2519
- */
2520
- maskColor: number;
2521
- /**
2522
- * @description 蒙版透明度
2523
- */
2524
- maskAlpha: number;
2525
- /**
2526
- * @description 裁切包围盒线框宽度
2527
- */
2528
- cutBoxLineWidth: number;
2529
- /**
2530
- * @description 裁切包围盒线框颜色
2531
- */
2532
- cutBoxLineColor: number;
2533
- /**
2534
- * @description 裁切包围盒线框透明度
2535
- */
2536
- cutBoxLineAlpha: number;
2537
- /**
2538
- * @description 元素包围盒线框宽度
2539
- */
2540
- itemBoxLineWidth: number;
2541
- /**
2542
- * @description 元素包围盒线框颜色
2543
- */
2544
- itemBoxLineColor: number;
2545
- /**
2546
- * @description 元素包围盒线框透明度
2547
- */
2548
- itemBoxLineAlpha: number;
2549
- /**
2550
- * @description 裁切包围盒角度半径
2551
- */
2552
- cutBoxCornerRadius: number;
2553
- /**
2554
- * @description 裁切包围盒角点宽度
2555
- */
2556
- cutBoxCornerLineWidth: number;
2557
- /**
2558
- * @description 裁切包围盒角点颜色
2559
- */
2560
- cutBoxCornerLineColor: number;
2561
- /**
2562
- * @description 裁切包围盒角点透明度
2563
- */
2564
- cutBoxCornerLineAlpha: number;
2565
- /**
2566
- * @description 裁切包围盒角点填充色
2567
- */
2568
- cutBoxCornerFillColor: number;
2569
- /**
2570
- * @description 缩放判断距离
2571
- */
2572
- scaleInteractionDistance: number;
2573
- /**
2574
- * @description 单向缩放判断距离
2575
- */
2576
- directionScaleInteractionDistance: number;
2577
- /**
2578
- * @description 网格线数量
2579
- */
2580
- gridCount: number;
2581
- /**
2582
- * @description 网格线颜色
2583
- */
2584
- gridLineColor: number;
2585
- /**
2586
- * @description 网格线宽度
2587
- */
2588
- gridLineWidth: number;
2589
- /**
2590
- * @description 网格线透明度
2591
- */
2592
- gridLineAlpha: number;
2593
- };
2594
- /**
2595
- * @description 图片扩边参数
2596
- */
2597
- type PictureExpandGizmoConfig = {
2598
- /**
2599
- * @description 蒙版颜色
2600
- */
2601
- maskColor: number;
2602
- /**
2603
- * @description 蒙版透明度
2604
- */
2605
- maskAlpha: number;
2606
- /**
2607
- * @description 扩边包围盒线框宽度
2608
- */
2609
- expandBoxLineWidth: number;
2610
- /**
2611
- * @description 扩边包围盒线框颜色
2612
- */
2613
- expandBoxLineColor: number;
2614
- /**
2615
- * @description 扩边包围盒线框透明度
2616
- */
2617
- expandBoxLineAlpha: number;
2618
- /**
2619
- * @description 扩边包围盒角度半径
2620
- */
2621
- expandBoxCornerRadius: number;
2622
- /**
2623
- * @description 扩边包围盒角点宽度
2624
- */
2625
- expandBoxCornerLineWidth: number;
2626
- /**
2627
- * @description 扩边包围盒角点颜色
2628
- */
2629
- expandBoxCornerLineColor: number;
2630
- /**
2631
- * @description 扩边包围盒角点透明度
2632
- */
2633
- expandBoxCornerLineAlpha: number;
2634
- /**
2635
- * @description 扩边包围盒角点填充色
2636
- */
2637
- expandBoxCornerFillColor: number;
2638
- /**
2639
- * @description 缩放判断距离
2640
- */
2641
- scaleInteractionDistance: number;
2642
- /**
2643
- * @description 单向缩放判断距离
2644
- */
2645
- directionScaleInteractionDistance: number;
2646
- /**
2647
- * @description 网格线数量
2648
- */
2649
- gridCount: number;
2650
- /**
2651
- * @description 网格线颜色
2652
- */
2653
- gridLineColor: number;
2654
- /**
2655
- * @description 网格线宽度
2656
- */
2657
- gridLineWidth: number;
2658
- /**
2659
- * @description 网格线透明度
2660
- */
2661
- gridLineAlpha: number;
2662
- };
2663
- /**
2664
- * @description 文本交互控制器旋转交互模式
2665
- * 'corner': 角点旋转
2666
- * 'top-center': 顶部中心旋转
2667
- */
2668
- type TextGizmoRotateInteractMode = 'corner' | 'top-center';
2669
- /**
2670
- * @description 文本交互控制器参数
2671
- */
2672
- type TextGizmoConfig = {
2673
- /**
2674
- * @description 旋转交互模式
2675
- */
2676
- rotateInteractMode: TextGizmoRotateInteractMode;
2677
- /**
2678
- * @description 包围盒线宽
2679
- */
2680
- boxLineWidth: number;
2681
- /**
2682
- * @description 包围盒线色
2683
- */
2684
- boxLineColor: number;
2685
- /**
2686
- * @description 旋转交互点边长 - 用于 top-center 交互模式
2687
- */
2688
- rotationCornerWidth: number;
2689
- /**
2690
- * @description 旋转交互贴图地址
2691
- */
2692
- rotationCornerTexture: string;
2693
- /**
2694
- * @description 旋转交互点半径
2695
- */
2696
- rotationCornerRadius: number;
2697
- /**
2698
- * @description top-center 模式旋转交互距离
2699
- */
2700
- rotationTopCenterInteractionDistance: number;
2701
- /**
2702
- * @description 旋转交互点填充色
2703
- */
2704
- rotationCornerFillColor: number;
2705
- /**
2706
- * @description 旋转交互点描边宽度
2707
- */
2708
- rotationCornerStrokeWidth: number;
2709
- /**
2710
- * @description 旋转交互点描边颜色
2711
- */
2712
- rotationCornerStrokeColor: number;
2713
- /**
2714
- * @description Corner 模式旋转交互距离
2715
- */
2716
- rotationCornerInteractionDistance: number;
2717
- /**
2718
- * @description 缩放交互点半径
2719
- */
2720
- scaleCornerRadius: number;
2721
- /**
2722
- * @description 缩放交互点填充色
2723
- */
2724
- scaleCornerFillColor: number;
2725
- /**
2726
- * @description 缩放交互点描边宽度
2727
- */
2728
- scaleCornerStrokeWidth: number;
2729
- /**
2730
- * @description 缩放交互点描边颜色
2731
- */
2732
- scaleCornerStrokeColor: number;
2733
- /**
2734
- * @description 触发缩放交互的距离
2735
- */
2736
- scaleInteractionDistance: number;
2737
- /**
2738
- * @description 触发边缩放交互的距离
2739
- */
2740
- widthScaleInteractionDistance: number;
2741
- };
2742
- /**
2743
- * @description 蒙版参数
2744
- */
2745
- type MaskGizmoConfig = {
2746
- /**
2747
- * @description 画笔大小
2748
- */
2749
- brushSize: number;
2750
- /**
2751
- * @description 笔刷颜色
2752
- */
2753
- brushColor: number;
2754
- /**
2755
- * @description 笔刷透明度
2756
- */
2757
- brushAlpha: number;
2758
- /**
2759
- * @description 蒙版颜色
2760
- */
2761
- maskColor: number;
2762
- /**
2763
- * @description 蒙版透明度
2764
- */
2765
- maskAlpha: number;
2766
- /**
2767
- * @description 蒙版图片
2768
- */
2769
- maskImage?: string;
2770
- /**
2771
- * @description 元素包围盒线框宽度
2772
- */
2773
- boxLineWidth: number;
2774
- /**
2775
- * @description 元素包围盒线框颜色
2776
- */
2777
- boxLineColor: number;
2778
- /**
2779
- * @description 元素包围盒线框透明度
2780
- */
2781
- boxLineAlpha: number;
2782
- };
2783
- /**
2784
- * @description 精准改字编辑参数
2785
- */
2786
- type SpriteTextEditGizmoConfig = {
2787
- /**
2788
- * @description 文案颜色
2789
- */
2790
- textColor: number;
2791
- /**
2792
- * @description 包围盒线框宽度
2793
- */
2794
- boxLineWidth: number;
2795
- /**
2796
- * @description 包围盒间隔线长度
2797
- */
2798
- dashLineDash: number;
2799
- /**
2800
- * @description 包围盒间隔线间隔
2801
- */
2802
- dashLineGap: number;
2803
- /**
2804
- * @description 预选中文案颜色
2805
- */
2806
- preSelectedTextColor: number;
2807
- /**
2808
- * @description 标记包围盒颜色
2809
- */
2810
- editBoxColor: number;
2811
- /**
2812
- * @description 编辑包围盒透明度
2813
- */
2814
- editBoxAlpha: number;
2815
- /**
2816
- * @description 编辑包围盒线框颜色
2817
- */
2818
- editBoxLineColor: number;
2819
- /**
2820
- * @description 编辑包围盒线框透明度
2821
- */
2822
- editBoxLineAlpha: number;
2823
- /**
2824
- * @description 已更改编辑包围盒颜色
2825
- */
2826
- hasChangedEditBoxColor: number;
2827
- /**
2828
- * @description 已更改编辑包围盒透明度
2829
- */
2830
- hasChangedEditBoxAlpha: number;
2831
- /**
2832
- * @description 已更改编辑包围盒线框颜色
2833
- */
2834
- hasChangedEditBoxLineColor: number;
2835
- /**
2836
- * @description 已更改编辑包围盒线框透明度
2837
- */
2838
- hasChangedEditBoxLineAlpha: number;
2839
- /**
2840
- * @description 编辑包围盒预选颜色
2841
- */
2842
- editBoxPreSelectedColor: number;
2843
- /**
2844
- * @description 编辑包围盒预选透明度
2845
- */
2846
- editBoxPreSelectedAlpha: number;
2847
- /**
2848
- * @description 编辑包围盒预选线框颜色
2849
- */
2850
- editBoxLinePreSelectedColor: number;
2851
- /**
2852
- * @description 编辑包围盒预选线框透明度
2853
- */
2854
- editBoxLinePreSelectedAlpha: number;
2855
- /**
2856
- * @description 已更改编辑包围盒预选颜色
2857
- */
2858
- hasChangedEditBoxPreSelectedColor: number;
2859
- /**
2860
- * @description 已更改编辑包围盒预选透明度
2861
- */
2862
- hasChangedEditBoxPreSelectedAlpha: number;
2863
- /**
2864
- * @description 已更改编辑包围盒线框颜色
2865
- */
2866
- hasChangedEditBoxLinePreSelectedColor: number;
2867
- /**
2868
- * @description 已更改编辑包围盒线框透明度
2869
- */
2870
- hasChangedEditBoxLinePreSelectedAlpha: number;
2871
- /**
2872
- * @description 选中状态标记包围盒颜色
2873
- */
2874
- editBoxSelectedColor: number;
2875
- /**
2876
- * @description 选中状态标记包围盒颜色
2877
- */
2878
- editBoxSelectedAlpha: number;
2879
- };
2880
- type VideoPlayGizmoConfig = {
2881
- /**
2882
- * @description 自动展示
2883
- */
2884
- autoShow: boolean;
2885
- /**
2886
- * @description 图标地址
2887
- */
2888
- logoUrl: string;
2889
- /**
2890
- * @description 距离右下角偏移值
2891
- */
2892
- logoShift: [number, number];
2893
- /**
2894
- * @description 宽
2895
- */
2896
- width: number;
2897
- /**
2898
- * @description 高
2899
- */
2900
- height: number;
2901
- };
2902
- type ItemCreateGizmoConfig = {
2903
- /**
2904
- * @description 边框颜色
2905
- */
2906
- frameBorderColor: number;
2907
- /**
2908
- * @description 边框宽度
2909
- */
2910
- frameBorderWidth: number;
2911
- /**
2912
- * @description 边框透明度
2913
- */
2914
- frameBorderAlpha: number;
2915
- /**
2916
- * @description 填充颜色
2917
- */
2918
- frameFillColor: number;
2919
- /**
2920
- * @description 填充透明度
2921
- */
2922
- frameFillAlpha: number;
2923
- };
2924
-
2925
- /**
2926
- * @description 精准改字功能初始化信息
2927
- */
2928
- type SpriteTextInitParam = {
2929
- /**
2930
- * @description 元素ID
2931
- */
2932
- id: string;
2933
- /**
2934
- * @description 改字信息
2935
- */
2936
- info: SpriteTextInitInfo[];
2937
- };
2938
- type SpriteTextInitInfo = {
2939
- /**
2940
- * @description 是否被修改过
2941
- */
2942
- hasChanged: boolean;
2943
- /**
2944
- * @description 文字内容
2945
- */
2946
- text: string;
2947
- /**
2948
- * @description 包围盒信息
2949
- */
2950
- box: [spec.vec2, spec.vec2, spec.vec2, spec.vec2];
2951
- };
2952
- type ItemCreateType = 'none' | 'text' | 'video-generator' | 'sprite-generator' | 'frame';
2953
- type GizmoType = 'null' | 'selector' | 'transform' | 'control' | 'adsorption' | 'preference' | 'picture-cut' | 'text' | 'mask' | 'loading' | 'picture-expand' | 'sprite-text-edit' | 'video-play' | 'item-create';
2954
- type GestureHandlerInteractType = 'select' | 'hand';
2955
-
2956
- type AlignType = 'left' | 'right' | 'horizontal-center' | 'top' | 'bottom' | 'vertical-center';
2957
- type DistributeType = 'vertical-spacing' | 'horizontal-spacing';
2958
-
2959
- declare module '@pixi/graphics' {
2960
- interface Graphics {
2961
- fillBox(box: Box2): void;
2962
- drawBox(box: Box2): void;
2963
- drawLine(line: Line2 | Point[]): void;
2964
- drawDashLine(toX: number, toY: number, dash: number, gap: number): void;
2965
- }
2966
- }
2967
-
2968
- type LoadingGizmoTip = {
2969
- text: string;
2970
- fontSize?: number;
2971
- fontFamily?: string;
2972
- color?: number;
2973
- };
2974
- type LoadingGizmoItemOptions = {
2975
- /** Loading 提示文案 */
2976
- tip?: LoadingGizmoTip;
2977
- /** 指定 Loading 区域 */
2978
- loadingBox?: Box2;
2979
- /** 清理选中 */
2980
- clearSelected?: boolean;
2981
- };
2982
-
2983
- type SDKEvents = {
2984
- 'loadingItemChange': [id: string[]];
2985
- 'selectedItemChange': [id: string[]];
2986
- 'preSelectedItemChange': [id: string | undefined];
2987
- 'selectedViewChange': [id: number];
2988
- 'pageDataChange': [pageData: PageData];
2989
- 'zoomChange': [zoom: number];
2990
- 'progress': [{
2991
- duration: number;
2992
- time: number;
2993
- end: boolean;
2994
- paused: boolean;
2995
- }];
2996
- 'itemPropertyChange': [{
2997
- id: string;
2998
- property: string;
2999
- }];
3000
- 'exportProgress': [progress?: number];
3001
- 'exportDone': [item: ExportItemParams | undefined, success: boolean, buffer?: FileBuffer];
3002
- 'exportComplete': [success: boolean, taskInfos: ExportParams, buffers: Buffers, extras: Extras];
3003
- 'sdkConfigChange': [preSDKConfig: SDKConfig, curSDKConfig: SDKConfig];
3004
- 'cutBoxChange': [box: Box2];
3005
- 'expandBoxChange': [box: Box2];
3006
- 'textInput': [{
3007
- itemId: string;
3008
- text: string;
3009
- fontFamily: string;
3010
- }];
3011
- 'undoRedoChange': [Operation];
3012
- 'viewportTransform': [{
3013
- zoom: number;
3014
- translation: [number, number];
3015
- }];
3016
- 'itemOnDragStart': [type: GizmoType];
3017
- 'itemOnDrag': [type: GizmoType];
3018
- 'itemOnDragEnd': [type: GizmoType];
3019
- 'spriteTextClick': [{
3020
- id: string;
3021
- index: number;
3022
- text: string;
3023
- } | undefined];
3024
- 'videoPlay': [{
3025
- id: string;
3026
- time: number;
3027
- }];
3028
- 'itemCreate': [{
3029
- type: ItemCreateType;
3030
- position: spec.vec2;
3031
- id: string;
3032
- }];
3033
- 'viewLost': [];
3034
- 'viewRebuildFinish': [];
3035
- };
3036
- declare class SDK {
3037
- static config: SDKConfig;
3038
- private _eventEmitter;
3039
- private _pageData;
3040
- private _screenShot;
3041
- private _exporter?;
3042
- private _pageDataUtils;
3043
- private _sizeAdapt;
3044
- private _gestureHandler;
3045
- private disposables;
3046
- private _isSwitchScene;
3047
- private _undoRedo;
3048
- player: Player;
3049
- _container: HTMLElement;
3050
- private _playerContainer;
3051
- constructor(container: HTMLElement, mode?: SDKMode);
3052
- get container(): HTMLElement;
3053
- get pageData(): PageData | undefined;
3054
- private get initExporterEnabled();
3055
- get exportStatus(): string | undefined;
3056
- get undoRedo(): UndoRedo;
3057
- private get exportOptions();
3058
- dispose(): void;
3059
- on: <E extends "progress" | "loadingItemChange" | "selectedItemChange" | "preSelectedItemChange" | "selectedViewChange" | "pageDataChange" | "zoomChange" | "itemPropertyChange" | "exportProgress" | "exportDone" | "exportComplete" | "sdkConfigChange" | "cutBoxChange" | "expandBoxChange" | "textInput" | "undoRedoChange" | "viewportTransform" | "itemOnDragStart" | "itemOnDrag" | "itemOnDragEnd" | "spriteTextClick" | "videoPlay" | "itemCreate" | "viewLost" | "viewRebuildFinish">(eventName: E, listener: _galacean_effects.EventEmitterListener<SDKEvents[E]>, options?: _galacean_effects.EventEmitterOptions) => () => void;
3060
- initPlayer(mode: SDKMode): void;
3061
- setSDKMode(mode: SDKMode): void;
3062
- private getInitParam;
3063
- private initExporter;
3064
- private initSDK;
3065
- run(param: SDKInputParam): Promise<void>;
3066
- getActiveItems(): string[];
3067
- setPreSelectedItem(id: string): void;
3068
- getPreSelectedItem(): string;
3069
- setSelectedItems(itemIds: string[]): void;
3070
- /**
3071
- * @description 设置元素属性(支持单个元素的单/多属性设置)
3072
- * @param param 设置参数,支持两种场景:
3073
- * 1. 单个元素单个属性: { itemId, type, propertyName, propertyValue }
3074
- * 2. 单个元素多个属性: { itemId, type, property }
3075
- */
3076
- setItemProperty<T extends SDKItemType>(param: SetItemPropertyParam<T>): Promise<void>;
3077
- generateScreenShot(id: number, size?: [number, number], tick?: number, backgroundColor?: spec.vec4): Promise<string | undefined>;
3078
- /**
3079
- * @description 切换场景
3080
- * @param index 场景索引
3081
- */
3082
- switchScene(index: number): Promise<void>;
3083
- /**
3084
- * @description 获取页面的 safeAreaPreview、zoom、adsorption、translation 值
3085
- * @returns 页面的 safeAreaPreview、zoom、adsorption、translation 值
3086
- */
3087
- getPageConfig(): PageConfig$1;
3088
- /**
3089
- * 设置页面的 safeAreaPreview、zoom、adsorption 值
3090
- * @param pageProperty 设置
3091
- */
3092
- setPageConfig(pageConfig: PageConfig$1): void;
3093
- /**
3094
- * @description 设置播放进度
3095
- * @param progress 播放进度 0-100
3096
- */
3097
- setPlayProgress(progress: number): Promise<void>;
3098
- /**
3099
- * @description 获取元素
3100
- * @param id 元素ID
3101
- * @returns 元素
3102
- * */
3103
- getSDKItem(id: string): SDKItem | undefined;
3104
- /**
3105
- * @description 获取元素数组
3106
- * @param id 元素ID数组
3107
- * @returns 元素数组
3108
- * */
3109
- getSDKItems(ids?: string[]): SDKItem[];
3110
- setPlayState(playState: 'play' | 'pause'): Promise<void>;
3111
- /**
3112
- * @description 获取场景预览图
3113
- * @returns 视图预览图
3114
- */
3115
- getViewThumbnail(): Promise<{
3116
- id: number;
3117
- thumbnail: string | undefined;
3118
- }>[];
3119
- /**
3120
- * @description 获取视图JSON产物
3121
- * @returns 当前所有视图JSON产物
3122
- */
3123
- getViewScene(): {
3124
- id: number;
3125
- thumbnail: spec.JSONScene;
3126
- }[];
3127
- private destroyCompositions;
3128
- /**
3129
- * @description 以媒体格式 buffer 下载
3130
- */
3131
- downloadByMediaBuffersOfExporter(params: ExportMediaItemDownloadInfo[], buffers: Buffers, extras: Extras): void;
3132
- /**
3133
- * @description 导出
3134
- * 支持导出媒体或其他,如MP4,未来支持 JSON 等;
3135
- */
3136
- onExport(): void;
3137
- /**
3138
- * @description 取消导出
3139
- */
3140
- cancelExport(): void;
3141
- loadPageData(data: PageData): Promise<void>;
3142
- runByPageData(data: PageData): Promise<void>;
3143
- reloadPageDataByScene(scene: string | spec.JSONScene): Promise<void>;
3144
- /**
3145
- * @description 新增视图数据
3146
- * @param viewParams 视图参数
3147
- * @param scene 场景数据 - 无输入时为默认场景数据
3148
- */
3149
- addViewParams(viewParams: ViewParam[], scene?: spec.JSONScene): Promise<void>;
3150
- deleteViewParams(ids: number[]): Promise<void>;
3151
- setExportParam(exportParam: Partial<ExportParam>, id?: number): void;
3152
- /**
3153
- * @description 设置视图缩放
3154
- * @param zoom 缩放值
3155
- * @param center 缩放中心
3156
- * @param ignoreClamp 是否忽视约束
3157
- */
3158
- setPageZoom(zoom: number, center?: Vector2, ignoreClamp?: boolean): void;
3159
- /**
3160
- * @description 设置元素移动
3161
- * @param targetTranslation 目标移动值
3162
- */
3163
- setPageMove(targetTranslation: Vector2): void;
3164
- /**
3165
- * @description 设置静态预览功能开关
3166
- * @param enabled 功能开关
3167
- */
3168
- setStaticPreviewEnabled(enabled: boolean): void;
3169
- /**
3170
- * @description 设置静态预览视图名称
3171
- * @param name 视图名称
3172
- */
3173
- setStaticPreviewName(name: string): void;
3174
- /**
3175
- * @description 设置同步修改功能开关
3176
- * @param enabled 功能开关
3177
- */
3178
- setAsyncEnabled(enabled: boolean): void;
3179
- /**
3180
- * @description 设置 成组显影 开关
3181
- */
3182
- setGroupVisibleEnabled(enabled: boolean): void;
3183
- /**
3184
- * @description 新增过滤元素名称
3185
- * @param itemNames 过滤元素名称
3186
- */
3187
- addFilterItemNames(itemNames: string[] | string): void;
3188
- /**
3189
- * @description 设置预览辅助层颜色
3190
- * @param color 色值
3191
- */
3192
- setPreferenceBackgroundColor(color: [number, number, number, number]): void;
3193
- /**
3194
- * @description 设置出血区颜色
3195
- * @param color 色值
3196
- */
3197
- setSafeAreaColor(color: [number, number, number, number]): void;
3198
- /**
3199
- * @description 设置 尺寸自适应拓展 功能开关
3200
- * @param enabled 功能开关
3201
- */
3202
- setSizeAdaptEnabled(enabled: boolean): void;
3203
- /**
3204
- * @description 设置 截图 功能开关
3205
- * @param enabled 功能开关
3206
- */
3207
- setScreenShotEnabled(enabled: boolean): void;
3208
- /**
3209
- * @description 设置导出功能初始化配置
3210
- * @param exportConfig
3211
- */
3212
- setExportConfig(exportConfig: Partial<ExportConfig>): void;
3213
- /**
3214
- * @description 设置预选框参数
3215
- * @param preSelectedColor 预选框颜色
3216
- * @param preSelectedWidth 预选框线框宽度
3217
- */
3218
- setSelectorGizmoPreSelectConfig(preSelectedColor?: number, preSelectedWidth?: number): void;
3219
- /**
3220
- * @description 设置 变换控制器 交互框参数
3221
- * @param config 参数
3222
- */
3223
- setTranformGizmoWireframeConfig(config: {
3224
- wireframeColor?: number;
3225
- wireframeAlpha?: number;
3226
- wireframeWidth?: number;
3227
- }): void;
3228
- /**
3229
- * @description 获取 SDK 配置参数
3230
- * @returns SDK 配置参数
3231
- */
3232
- getSDKConfig(): SDKConfig;
3233
- /**
3234
- * @description 设置 SDK 配置参数
3235
- * @param config SDK 配置参数
3236
- */
3237
- setSDKConfig(config: SDKConfig): void;
3238
- /**
3239
- * @description 设置SDK背景
3240
- * @param type 背景类型
3241
- * @param value 值
3242
- */
3243
- setSDKBackground(type: SDKBackgroundType, value?: string): void;
3244
- /**
3245
- * @description 创建图层元素
3246
- * @param spriteInfo 图层元素信息
3247
- */
3248
- addSpriteItem(spriteInfo: SpriteCreateInfo, scene?: spec.JSONScene): Promise<string>;
3249
- addVideoItem(videoInfo: VideoCreateInfo, scene?: spec.JSONScene): Promise<string>;
3250
- openPictureCutGizmo(): void;
3251
- closePictureCutGizmo(): void;
3252
- getCutInfo(): {
3253
- cutBox: Box2;
3254
- itemBox: Box2;
3255
- } | undefined;
3256
- setCutBox(min: Vector2, max: Vector2): Box2 | undefined;
3257
- openPictureExpandGizmo(): void;
3258
- closePictureExpandGizmo(): void;
3259
- getExpandInfo(): {
3260
- expandBox: Box2;
3261
- itemBox: Box2;
3262
- } | undefined;
3263
- setExpandBox(min: Vector2, max: Vector2): Box2 | undefined;
3264
- openMaskGizmo(brushSize: number): void;
3265
- clearMaskGizmo(): void;
3266
- closeMaskGizmo(): void;
3267
- getMask(): Promise<string | null | undefined>;
3268
- setMaskGizmoConfig(config: Partial<MaskGizmoConfig>): void;
3269
- /**
3270
- * @description 设置蒙版工具模式
3271
- * @param mode 模式类型:'paint' 表示涂抹,'erase' 表示擦除
3272
- */
3273
- setMaskGizmoMode(mode: 'paint' | 'erase'): void;
3274
- /**
3275
- * 撤销蒙版操作
3276
- * @returns 是否成功撤销
3277
- */
3278
- undoMaskGizmo(): boolean;
3279
- /**
3280
- * 重做蒙版操作
3281
- * @returns 是否成功重做
3282
- */
3283
- redoMaskGizmo(): boolean;
3284
- /**
3285
- * 检查蒙版是否可以撤销
3286
- */
3287
- get canUndoMaskGizmo(): boolean;
3288
- /**
3289
- * 检查蒙版是否可以重做
3290
- */
3291
- get canRedoMaskGizmo(): boolean;
3292
- /**
3293
- * 清空蒙版 undoRedo 历史
3294
- */
3295
- clearMaskGizmoUndoRedo(): void;
3296
- /**
3297
- * 撤销图片裁切操作
3298
- * @returns 是否成功撤销
3299
- */
3300
- undoPictureCutGizmo(): boolean;
3301
- /**
3302
- * 重做图片裁切操作
3303
- * @returns 是否成功重做
3304
- */
3305
- redoPictureCutGizmo(): boolean;
3306
- /**
3307
- * 检查图片裁切是否可以撤销
3308
- */
3309
- get canUndoPictureCutGizmo(): boolean;
3310
- /**
3311
- * 检查图片裁切是否可以重做
3312
- */
3313
- get canRedoPictureCutGizmo(): boolean;
3314
- /**
3315
- * 清空图片裁切 undoRedo 历史
3316
- */
3317
- clearPictureCutGizmoUndoRedo(): void;
3318
- openLoadingGizmo(id: string, options?: LoadingGizmoItemOptions): void;
3319
- updateLoadingGizmo(id: string, options: {
3320
- tip?: LoadingGizmoTip;
3321
- }): void;
3322
- closeLoadingGizmo(id: string): void;
3323
- /**
3324
- * @description 元素打组
3325
- * @param children 子元素ID
3326
- */
3327
- groupItems(groupInfo: GroupCreateInfo, scene?: spec.JSONScene): string | undefined;
3328
- setItemParent(id: string, parentId: string): void;
3329
- deleteItemParent(id: string, parentId: string): void;
3330
- addTextItem(textInfo: TextCreateInfo, scene?: spec.JSONScene): Promise<string | undefined>;
3331
- addItemByCreateInfos(createInfos: ItemCreateInfo[], asyncMode?: boolean): Promise<string[]>;
3332
- deleteItems(idInfo: string | string[]): void;
3333
- getItemCreateInfo(id: string): ItemCreateInfo | undefined;
3334
- getItemCreateInfos(ids?: string[]): ItemCreateInfo[];
3335
- createScreenShotSceneByIds(idInfo: string | string[], time?: number): Promise<string | undefined>;
3336
- getChildrenIds(id: string): string[];
3337
- /**
3338
- * @description 更新元素在图层中的顺序
3339
- * @param id 元素ID
3340
- * @param action 排序操作:BringToFront(置于顶层)、SendToBack(置于底层)、BringForward(上移一层)、SendBackward(下移一层)
3341
- */
3342
- updateItemOrder(id: string, action: ItemOrderAction): void;
3343
- /**
3344
- * @description 导出JSON
3345
- * @param idInfo 视图序号信息
3346
- * @returns JSON数组
3347
- */
3348
- exportJSON(idInfo?: number | number[]): spec.JSONScene[];
3349
- getViewBoxById(id: string): Box2;
3350
- /**
3351
- * @description 批量设置元素扩展属性
3352
- * @param id 元素ID
3353
- * @param extensions 扩展属性对象(支持同时设置多个)
3354
- * @returns 是否设置成功
3355
- */
3356
- setItemExtension(id: string, extension: Record<string, any>): boolean;
3357
- /**
3358
- * @description 批量获取元素扩展属性
3359
- * @param id 元素ID
3360
- * @param keys 扩展属性名称列表(不传则返回所有扩展属性)
3361
- * @returns 扩展属性对象
3362
- */
3363
- getItemExtension(id: string, keys?: string[]): Record<string, any> | undefined;
3364
- /**
3365
- * @description 删除元素扩展属性(支持批量删除)
3366
- * @param id 元素ID
3367
- * @param keys 扩展属性名称列表
3368
- * @returns 是否删除成功
3369
- */
3370
- deleteItemExtensions(id: string, keys: string[]): boolean;
3371
- /**
3372
- * @description 检查元素是否有指定扩展属性
3373
- * @param id 元素ID
3374
- * @param key 扩展属性名称
3375
- * @returns 是否存在
3376
- */
3377
- hasItemExtension(id: string, key: string): boolean;
3378
- /**
3379
- * @description 获取元素所有扩展属性的键名列表
3380
- * @param id 元素ID
3381
- * @returns 键名数组
3382
- */
3383
- getItemExtensionKeys(id: string): string[] | undefined;
3384
- getViewProperty(id: number): ViewProperty | undefined;
3385
- pageMove(shift: [number, number]): void;
3386
- pageZoom(shift: number, center?: [number, number]): void;
3387
- /**
3388
- * @description 设置视图缩放工具锁定缩放比例开关
3389
- * @param state 缩放比例开关
3390
- */
3391
- setPictureCutGizmoLockScale(state: boolean): void;
3392
- /**
3393
- * @description 设置视图扩展工具锁定缩放比例开关
3394
- * @param state 缩放比例开关
3395
- */
3396
- setPictureExpandGizmoLockScale(state: boolean): void;
3397
- /**
3398
- * @description 视图缩放函数
3399
- * @param shiftParam 视图偏移值
3400
- */
3401
- viewportFit(shiftParam?: ViewportFitShiftParam, box?: Box2): void;
3402
- /**
3403
- * @description 获取元素包围盒
3404
- * @param idInfo 元素Id
3405
- * @returns 元素包围盒
3406
- */
3407
- getItemBoxById(idInfo: string): Box2;
3408
- /**
3409
- * @description 设置元素字体
3410
- * @param id 元素Id
3411
- * @param fontFamilyName 字体名称
3412
- * @param url 字体地址
3413
- */
3414
- setItemFontFamily(id: string, fontFamilyName: string, url: string): Promise<void>;
3415
- createSceneByCreateInfos(createInfos: ItemCreateInfo[], sceneInfo: SceneCreaetInfo): spec.JSONScene;
3416
- setSpriteSize(id: string, size: spec.vec2): void;
3417
- setItemPropertyByCreateInfo(createInfo: ItemCreateInfo | ItemCreateInfo[]): void;
3418
- setTransformGizmoLockScale(state: boolean): void;
3419
- getViewBoxByBox(box: Box2): Box2;
3420
- openSpriteTextEditGizmo(initParam: SpriteTextInitParam[]): void;
3421
- closeSpriteTextEditGizmo(): void;
3422
- setSpriteTextSelectedIndex(id: string, index: number): void;
3423
- setSpriteTextSelectedText(id: string, index: number, text: string): void;
3424
- getBoundingBoxByItemCreateInfo(createInfo: ItemCreateInfo): Box2;
3425
- getBoundingBoxByItemCreateInfos(createInfos: ItemCreateInfo[]): Box2;
3426
- setSpriteTextChangedState(id: string, index: number, hasChanged: boolean): void;
3427
- setSpriteTextEditState(id: string, index: number, isEditing: boolean): void;
3428
- getVideoItemPlayTime(id: string): number;
3429
- setVideoItemPlayTime(id: string, time: number): void;
3430
- getEffectsItemPlayTime(id: string): number | undefined;
3431
- setEffectsItemPlayTime(id: string, time: number): void;
3432
- setEffectsResource(id: string, effects: string): void;
3433
- getPixelPositionByViewPosition(viewPosition: Vector2): Vector2;
3434
- hitTest(x: number, y: number): string[] | undefined;
3435
- setInteractType(type: GestureHandlerInteractType): void;
3436
- makeItemAlign(type: AlignType, ids?: string[]): void;
3437
- makeItemDistribute(type: DistributeType, ids?: string[]): void;
3438
- /**
3439
- * @description 创建生成器元素
3440
- * @param createInfo 生成器创建信息
3441
- * @returns 生成器元素ID
3442
- */
3443
- addGeneratorItem(createInfo: GeneratorCreateInfo): string;
3444
- /**
3445
- * @description 创建动效元素
3446
- * @param effectsInfo 动效创建信息
3447
- */
3448
- addEffectsItem(effectsInfo: EffectsCreateInfo): Promise<string | undefined>;
3449
- /**
3450
- * @description 创建画板元素
3451
- * @param createInfo 画板创建信息
3452
- * @returns 画板元素ID
3453
- */
3454
- addFrameItem(createInfo: FrameCreateInfo): Promise<string>;
3455
- /**
3456
- * @description 设置生成器资源,将生成器转换为对应的元素
3457
- * @param id 生成器元素ID
3458
- * @param resourceUrl 资源地址
3459
- * @returns 新的元素ID
3460
- */
3461
- setGeneratorResource(id: string, resourceUrl: string): Promise<string>;
3462
- /**
3463
- * @description 设置生成器资源(使用 GeneratorResource 对象)
3464
- * @param resource 生成器资源信息
3465
- */
3466
- setGeneratorResourceFromObject(resource: GeneratorResource): void;
3467
- /**
3468
- * @description 设置视频生成器资源
3469
- * @param resource 视频生成器资源信息
3470
- */
3471
- setVideoGeneratorResource(resource: VideoGeneratorResource): Promise<string>;
3472
- /**
3473
- * @description 设置图层生成器资源
3474
- * @param resource 图层生成器资源信息
3475
- */
3476
- setSpriteGeneratorResource(resource: SpriteGeneratorResource): Promise<string>;
3477
- setItemLockState(id: string, state: boolean): void;
3478
- getItemLockState(id: string): void;
3479
- openItemCreateGizmo(type: ItemCreateType): void;
3480
- closeItemCreateGizmo(): void;
3481
- setItemName(id: string, name: string): void;
3482
- setSafeAreaPreviewVisible(id: number, type: 'url' | 'color', visible: boolean): void;
3483
- }
3484
-
3485
- export { type ActiveData, BaseItem, type BaseItemProperty, type BaseItemPropertyKey, type BaseItemPropertyValueMap, Box2, type CreateOperation, type DeleteOperation, type EffectsCreateInfo, EffectsItem, type EffectsItemOptions, type FrameCreateInfo, FrameItem, type FrameItemOptions, type FrameItemProperty, FrameLayoutMode, type GeneratorCreateInfo, GeneratorItem, type GeneratorItemOptions, type GeneratorItemProperty, type GizmoType, type GroupCreateInfo, GroupItem, type GroupItemOptions, type ItemCreateInfo, ItemOrderAction, type ItemPropertyMap, type Operation, type PageData, type PageProperty, SDK, type SDKEvents, type SDKInputParam, type SDKItem, type SDKItemOptions, SDKItemType, type SDKOptions, type SetItemPropertyParam, type SetSingleItemMultiplePropertiesParam, type SetSingleItemSinglePropertyParam, type SpriteCreateInfo, SpriteItem, type SpriteItemOptions, type SpriteItemProperty, type TextCreateInfo, TextItem, type TextItemOptions, type TextItemProperty, type UpdateOperation, Vector2, type VideoCreateInfo, VideoItem, type VideoItemOptions, type VideoItemProperty, type ViewParam, type ViewProperty, createSDKItem, isBaseItem, isEffectsItem, isFrameItem, isGeneratorItem, isGroupItem, isSpriteItem, isTextItem, isVideoItem };