@vvfx/sdk 0.1.19-alpha.6 → 0.1.19-alpha.7

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.
package/dist/index.d.ts CHANGED
@@ -1,678 +1,752 @@
1
1
  import * as _galacean_effects from '@galacean/effects';
2
- import { spec, math, Player } from '@galacean/effects';
2
+ import { math, spec, Player } from '@galacean/effects';
3
3
  export { generateGUID, spec } from '@galacean/effects';
4
4
  import { Point } from '@pixi/constants';
5
5
 
6
6
  /**
7
- * @description SDKItem 基础选项接口
8
- * @description 支持扩展属性,允许添加任意额外属性
7
+ * @class 二维线段
9
8
  */
10
- type SDKItemOptions = {
11
- /**
12
- * @description 元素ID
13
- */
14
- id: string;
9
+ declare class Line2 {
10
+ start: Vector2;
11
+ end: Vector2;
12
+ constructor(start?: Vector2, end?: Vector2);
15
13
  /**
16
- * @description 元素名称
14
+ * 设置二维线段
15
+ * @param {Vector2} start 线段起点
16
+ * @param {Vector2} end 线段终点
17
+ * @returns {Line2} 二维线段
17
18
  */
18
- name: string;
19
+ set(start: Vector2, end: Vector2): this;
19
20
  /**
20
- * @description 父节点ID
21
+ * 复制二维线段
22
+ * @param {Line2} line 复制对象
23
+ * @returns {Line2} 复制结果
21
24
  */
22
- parentId?: string;
25
+ copyFrom(line: Line2): this;
23
26
  /**
24
- * @description 子元素ID列表
27
+ * 二维线段求方向
28
+ * @returns {Vector2} 二维线段方向
25
29
  */
26
- children?: string[];
30
+ direction(): Vector2;
27
31
  /**
28
- * @description 元素生命周期
32
+ * 二维线段求中点
33
+ * @param {Vector2} [target=new Vector2()] 目标保存对象
34
+ * @returns {Vector2} 二维线段中点
29
35
  */
30
- duration?: number;
36
+ getCenter(target?: Vector2): Vector2;
31
37
  /**
32
- * @description 元素生命周期延时
38
+ * 二维线段向量值
39
+ * @param {Vector2} [target=new Vector2()] 目标保存对象
40
+ * @returns {Vector2} 二维线段向量值
33
41
  */
34
- delay?: number;
42
+ delta(target?: Vector2): Vector2;
35
43
  /**
36
- * @description 可视状态
44
+ * 二维线段欧式距离平方(应用于计算)
45
+ * @returns {number} 计算结果
37
46
  */
38
- visible?: boolean;
47
+ distanceSq(): number;
39
48
  /**
40
- * @description 元素结束行为
49
+ * 二维线段欧式距离
50
+ * @returns {number} 计算结果
41
51
  */
42
- endBehavior?: spec.EndBehavior;
52
+ distance(): number;
43
53
  /**
44
- * @description 是否处于锁定状态
54
+ * 求二维线段比例点
55
+ * @param {number} t 比例值
56
+ * @param {Vector2} target 目标保存对象
57
+ * @returns {Vector2} 比例点结果
45
58
  */
46
- isLocked?: boolean;
59
+ at(t: number, target?: Vector2): Vector2;
47
60
  /**
48
- * @description 关键属性是否可编辑
61
+ * 求点与线段的最短距离
62
+ * @param {Vector2} point 二维空间点
63
+ * @param {boolean} clampToLine 是否限制于线段内
64
+ * @returns {number} 距离结果
49
65
  */
50
- isCoreEditable: boolean;
66
+ closestPointToPointParameter(point: Vector2, clampToLine: boolean): number;
51
67
  /**
52
- * @description 扩展属性存储(属性名 -> 属性值)
68
+ * 求点与线段的最近交点
69
+ * @param {Vector2} point 二维空间点
70
+ * @param {boolean} clampToLine 是否限制于线段内
71
+ * @param {Vector2} target 目标保存对象
72
+ * @returns {Vector2} 最近交点
53
73
  */
54
- extension?: Record<string, any>;
74
+ closestPointToPoint(point: Vector2, clampToLine: boolean, target?: Vector2): Vector2;
55
75
  /**
56
- * @description 允许任意额外属性(用于兼容旧代码)
76
+ * 二维线段判等
77
+ * @param {Line2} line 二维线段
78
+ * @returns {boolean} 判等结果
57
79
  */
58
- [extraProp: string]: any;
59
- };
60
- /**
61
- * @description Sprite SDKItem 选项
62
- */
63
- type SpriteItemOptions = SDKItemOptions & {
80
+ equals(line: Line2): boolean;
64
81
  /**
65
- * @description 元素属性
82
+ * 克隆二维线段
83
+ * @returns {Line2} 克隆结果
66
84
  */
67
- property?: Partial<SpriteItemProperty>;
68
- };
69
- /**
70
- * @description Text SDKItem 选项
71
- */
72
- type TextItemOptions = SDKItemOptions & {
85
+ clone(): Line2;
73
86
  /**
74
- * @description 元素属性
87
+ * 二维线段求长度
88
+ * @returns {number} 长度
75
89
  */
76
- property?: Partial<TextItemProperty>;
77
- };
78
- /**
79
- * @description Video SDKItem 选项
80
- */
81
- type VideoItemOptions = SDKItemOptions & {
90
+ length(): number;
82
91
  /**
83
- * @description 元素属性
92
+ * 二维线段判断相交
93
+ * @param {Line2} other 二维线段
94
+ * @returns {boolean} 相交判断结果
84
95
  */
85
- property?: Partial<VideoItemProperty>;
86
- };
87
- /**
88
- * @description Group SDKItem 选项(空节点/组)
89
- */
90
- type GroupItemOptions = SDKItemOptions & {
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;
91
106
  /**
92
- * @description 元素属性
107
+ * 点到直线的最短距离
108
+ * @returns {{d: number, t: number}} d表示距离,t表示最近点在直线的比例
93
109
  */
94
- property?: Partial<GroupItemProperty>;
95
- };
96
- /**
97
- * @description Generator SDKItem 选项(资源生成器)
98
- * @description 支持 image 和 video 两种生成器类型
99
- * @description 使用 GeneratorItemProperty 包含 generatorType
100
- */
101
- type GeneratorItemOptions = SDKItemOptions & {
110
+ distanceToLine(line: Line2): {
111
+ d: number;
112
+ t: number;
113
+ };
102
114
  /**
103
- * @description 元素属性(包含 generatorType)
115
+ * 二维向量与x轴夹角
116
+ * @returns {number} 弧度值
104
117
  */
105
- property?: Partial<GeneratorItemProperty>;
106
- };
107
- type EffectsItemOptions = SDKItemOptions & {
108
- property?: Partial<EffectsItemProperty>;
109
- };
110
- /**
111
- * @description Frame 画板元素 SDKItem 选项
112
- */
113
- type FrameItemOptions = SDKItemOptions & {
118
+ angle(): number;
114
119
  /**
115
- * @description 元素属性
120
+ * 二维点绕点旋转
121
+ * @param {Vec2} center 旋转中心
122
+ * @param {number} angle 旋转角度
123
+ * @returns {Vec2} 旋转结果
116
124
  */
117
- property?: Partial<FrameItemProperty>;
118
- };
119
- /**
120
- * @description SDKItem 类型(独立于 spec.ItemType)
121
- * @description 包含所有 SDK 层级的元素类型,包括虚拟类型如 generator
122
- */
123
- declare enum SDKItemType {
124
- SPRITE = "sprite",
125
- TEXT = "text",
126
- VIDEO = "video",
127
- GROUP = "group",
128
- GENERATOR = "generator",
129
- EFFECTS = "effects",
130
- FRAME = "frame"
125
+ rotateAround(center: Vector2, angle: number): this;
131
126
  }
132
127
 
133
128
  /**
134
- * @description SDKItem 抽象基类
135
- * @description 支持属性扩展,允许添加任意自定义属性
129
+ * @class 二维包围盒
136
130
  */
137
- declare abstract class BaseItem {
131
+ declare class Box2 {
138
132
  /**
139
- * @description 元素ID
133
+ * @member {Vector2[]} corners 二维包围盒角点
140
134
  */
141
- id: string;
135
+ corners: Vector2[];
136
+ min: Vector2;
137
+ max: Vector2;
142
138
  /**
143
- * @description 元素名称
139
+ * 构造函数,传入值为空时表示空包围盒
140
+ * @param {Vector2} [min=new Vector2(Infinity, Infinity)] 最小点
141
+ * @param {Vector2} [max=new Vector2(-Infinity, -Infinity)] 最大点
144
142
  */
145
- name: string;
143
+ constructor(min?: Vector2, max?: Vector2);
146
144
  /**
147
- * @description 父节点ID
145
+ * 通过最大最小点设置二维包围盒
146
+ * @param {Vector2} min 最小点
147
+ * @param {Vector2} max 最大点
148
+ * @returns {Box2} 二维包围盒
148
149
  */
149
- parentId?: string;
150
+ set(min: Vector2, max: Vector2): this;
150
151
  /**
151
- * @description 元素生命周期
152
+ * 通过角点设置二维包围盒
153
+ * @param {Vector2[]} vecArray 二维空间点数组
154
+ * @returns {Box2} 二维包围盒
152
155
  */
153
- duration: number;
156
+ setFromVec2Array(vecArray: Vector2[]): this;
154
157
  /**
155
- * @description 元素生命周期延时
158
+ * 通过屏幕坐标点设置二维包围盒 - 点为屏幕坐标点,x正方向为右,y正方向为向上
159
+ * @param vecArray 屏幕坐标点
156
160
  */
157
- delay: number;
161
+ setFromVec2ArrayWithOutCorners(vecArray: Vector2[]): this;
158
162
  /**
159
- * @description 元素结束行为
163
+ * 通过中心与大小设置二维包围盒
164
+ * @param {Vector2} center 二维中心点
165
+ * @param {Vector2} size 二维大小
166
+ * @returns {Box2} 二维包围盒
160
167
  */
161
- endBehavior: spec.EndBehavior;
168
+ setFromCenterAndSize(center: Vector2, size: Vector2): this;
162
169
  /**
163
- * @description 是否可见
170
+ * 克隆二维包围盒
171
+ * @returns {Box2} 克隆结果
164
172
  */
165
- visible: boolean;
173
+ clone(): Box2;
166
174
  /**
167
- * @description 是否处于锁定状态
175
+ * 复制二维包围盒
176
+ * @param {Box2} box 二维包围盒
177
+ * @returns {Box2} 复制结果
168
178
  */
169
- isLocked: boolean;
170
- isCoreEditable: boolean;
179
+ copyFrom(box: Box2): this;
171
180
  /**
172
- * @description 扩展属性存储(与 property 同级)
181
+ * 二维包围盒置空
182
+ * @returns {Box2} 置空结果
173
183
  */
174
- private _extension;
184
+ makeEmpty(): this;
175
185
  /**
176
- * @description 元素类型(由子类实现)
177
- * @description 支持 spec.ItemType 或扩展的 SDKItemType
186
+ * 二维包围盒判空
187
+ * @returns {boolean} 判空结果
178
188
  */
179
- abstract readonly type: SDKItemType;
189
+ isEmpty(): boolean;
180
190
  /**
181
- * @description 元素属性(由子类实现)
191
+ * 获取二维包围盒角点
192
+ * @returns {Vector2[]} 二维包围盒角点
182
193
  */
183
- abstract readonly property: BaseItemProperty;
184
- constructor(options: SDKItemOptions);
194
+ getCorners(): Vector2[];
185
195
  /**
186
- * @description 设置扩展属性
187
- * @param key 属性名
188
- * @param value 属性值
196
+ * 获取二维包围盒中心点
197
+ * @param {Vector2} [target=new Vector2()] 目标点(用以存放二维包围盒中心点)
198
+ * @returns {Vector2} 二维包围盒中心点
189
199
  */
190
- setExtension(key: string, value: any): void;
200
+ getCenter(target?: Vector2): Vector2;
191
201
  /**
192
- * @description 获取扩展属性
193
- * @param key 属性名
194
- * @returns 属性值
195
- */
196
- getExtension(key: string): any;
197
- /**
198
- * @description 检查是否存在指定扩展属性
199
- * @param key 属性名
200
- * @returns 是否存在
202
+ * 获取二维包围盒大小
203
+ * @param {Vector2} [target=new Vector2()] 目标向量(用以存放二维包围盒大小)
204
+ * @returns {Vector2} 二维包围盒大小
201
205
  */
202
- hasExtension(key: string): boolean;
206
+ getSize(target?: Vector2): Vector2;
203
207
  /**
204
- * @description 删除扩展属性
205
- * @param key 属性名
206
- * @returns 是否删除成功
208
+ * 通过二维空间点扩展二维包围盒
209
+ * @param {Vector2} point 二维空间点
210
+ * @returns {Box2} 扩展包围盒
207
211
  */
208
- deleteExtension(key: string): boolean;
212
+ expandByPoint(point: Vector2): this;
209
213
  /**
210
- * @description 获取所有扩展属性的键名列表
211
- * @returns 键名数组
214
+ * 通过向量扩展二维包围盒
215
+ * @param {Vector2} vector 二维向量
216
+ * @returns {Box2} 扩展结果
212
217
  */
213
- getExtensionKeys(): string[];
218
+ expandByVector(vector: Vector2): this;
214
219
  /**
215
- * @description 获取所有扩展属性
216
- * @returns 扩展属性对象
220
+ * 通过大小扩展二维包围盒
221
+ * @param {number} scalar 扩展大小
222
+ * @returns {Box2} 扩展结果
217
223
  */
218
- getAllExtension(): Record<string, any>;
224
+ expandByScalar(scalar: number): this;
219
225
  /**
220
- * @description 批量设置扩展属性
221
- * @param extensions 扩展属性对象
226
+ * 判断二维包围盒是否包含二维空间点
227
+ * @param {Vector2} point 二维空间点
228
+ * @param {boolean} [isOrthogonal=true] 包围盒正交判断(默认为true)
229
+ * @returns {boolean} 点包含判断结果
222
230
  */
223
- setExtensions(extensions: Record<string, any>): void;
231
+ containsPoint(point: Vector2, isOrthogonal?: boolean): boolean;
224
232
  /**
225
- * @description 清空所有扩展属性
233
+ * 判断二维包围盒包含关系(if this contains other)
234
+ * @param {Box2} box 其它包围盒
235
+ * @returns {boolean} 二维包围盒包含判断结果
226
236
  */
227
- clearExtension(): void;
237
+ containsBox(box: Box2): boolean;
228
238
  /**
229
- * @description 转换为 CreateInfo(用于元素复制/导出)
230
- * @param withParent 是否包含父节点ID
231
- * @returns CreateInfo 对象
239
+ * 获取点以包围盒左上角顶点为原点的相对位置
240
+ * @param {Vector2} point 指定二维空间点
241
+ * @param {Vector2} [target=new Vector2()] 目标空间点
242
+ * @returns {Vector2} 计算结果空间点
232
243
  */
233
- abstract toCreateInfo(withParent?: boolean): ItemCreateInfo;
244
+ getParameter(point: Vector2, target?: Vector2): Vector2;
234
245
  /**
235
- * @description 克隆 SDKItem
236
- * @returns 新的 SDKItem 实例
246
+ * 求点与二维包围盒的最近点
247
+ * @param {Vector2} point 二维空间点
248
+ * @param {Vector2} [target=new Vector2()] 结果点
249
+ * @returns {Vector2} 二维空间点
237
250
  */
238
- abstract clone(): BaseItem;
251
+ clampPoint(point: Vector2, target?: Vector2): Vector2;
239
252
  /**
240
- * @description 获取基础属性的 JSON 对象,转换为普通对象(用于序列化)
241
- * @returns 普通对象
253
+ * 求点到二维包围盒的距离
254
+ * @param {Vector2} point 二维空间点
255
+ * @returns {number} 距离
242
256
  */
243
- toJSON(): Record<string, any>;
244
- }
245
- /**
246
- * @description 类型守卫函数:检查对象是否是 BaseItem
247
- * @param obj 要检查的对象
248
- * @returns 是否是 BaseItem 实例
249
- */
250
- declare function isBaseItem(obj: any): obj is BaseItem;
251
-
252
- /**
253
- * @description 图片元素 SDKItem 类
254
- * @description 支持属性扩展
255
- */
256
- declare class SpriteItem extends BaseItem {
257
+ distanceToPoint(point: Vector2): number;
257
258
  /**
258
- * @description 元素类型
259
+ * 二维包围盒求交集
260
+ * @param {Box2} box 二维包围盒
261
+ * @returns {Box2} 求交结果
259
262
  */
260
- readonly type = SDKItemType.SPRITE;
263
+ intersect(box: Box2): this;
261
264
  /**
262
- * @description 元素属性
265
+ * 二维包围盒求并集
266
+ * @param {Box2} box 二维包围盒
267
+ * @returns {Box2} 求并结果
263
268
  */
264
- property: SpriteItemProperty;
265
- constructor(options: SpriteItemOptions);
269
+ union(target: Box2 | Vector2): this;
266
270
  /**
267
- * @description 图片地址
271
+ * 二维包围盒位移
272
+ * @param {Vector2} offset 位移向量
273
+ * @returns {Box2} 位移结果
268
274
  */
269
- get image(): string;
270
- set image(value: string);
275
+ translate(offset: Vector2): this;
276
+ scale(scalar: number | Vector2, anchor?: Vector2): this;
271
277
  /**
272
- * @description 位置
278
+ * 二维包围盒判等
279
+ * @param {Box2} box 二维包围盒
280
+ * @returns {boolean} 判等结果
273
281
  */
274
- get position(): [number, number];
275
- set position(value: [number, number]);
276
- get width(): number;
277
- set width(value: number);
278
- get height(): number;
279
- set height(value: number);
282
+ equals(box: Box2): boolean;
280
283
  /**
281
- * @description 旋转(二维旋转角度)
284
+ * 判断二维包围盒相交关系(if this intersect other)
285
+ * @param {Box2} box 二维包围盒
286
+ * @param {boolean} [isOrthogonal=true] 正交判断(当前包围盒)
287
+ * @returns {boolean} 相交判断结果
282
288
  */
283
- get rotation(): number;
284
- set rotation(value: number);
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 = {
285
355
  /**
286
- * @description 完整旋转(包含 x, y, z)
356
+ * 导出类型
287
357
  */
288
- get fullRotation(): [number, number, number];
289
- set fullRotation(value: [number, number, number]);
358
+ mediaType: MediaType;
290
359
  /**
291
- * @description 是否正在编辑关键属性
292
- * @deprecated 该属性即将废弃,使用 isCoreEditable 代替
360
+ * 额外画布,导出透明视频时使用
293
361
  */
294
- get keyPropertyEditing(): boolean;
295
- set keyPropertyEditing(value: boolean);
362
+ extraCanvas?: HTMLCanvasElement | null;
296
363
  /**
297
- * @description 转换为 CreateInfo
298
- * @param withParent 是否包含父节点ID
364
+ * 是否打印转码过程中的日志,仅在导出 MP4/AlphaMaskVideo 时有效, 默认 false
365
+ * 供开发调试使用
299
366
  */
300
- toCreateInfo(withParent?: boolean): SpriteCreateInfo;
367
+ loggerInTranscoding?: boolean;
301
368
  /**
302
- * @description 克隆 SDKItem
369
+ * ffmpeg 转码是否开启多线程,默认 false,确保环境支持 SharedArrayBuffer
303
370
  */
304
- clone(): SpriteItem;
371
+ multiThreading?: boolean;
305
372
  /**
306
- * @description 创建包含扩展属性的 CreateInfo
307
- * @param withParent 是否包含父节点ID
308
- * @param extraProps 额外的属性
373
+ * 是否输出 buffer,默认 false
309
374
  */
310
- toCreateInfoWithExtensions(withParent?: boolean, extraProps?: Record<string, any>): SpriteCreateInfo;
311
- }
312
- /**
313
- * @description 类型守卫:检查是否是 SpriteItem
314
- */
315
- declare function isSpriteItem(obj: any): obj is SpriteItem;
316
-
317
- /**
318
- * @description 文本元素 SDKItem 类
319
- * @description 支持属性扩展
320
- */
321
- declare class TextItem extends BaseItem {
375
+ isOutputBuffer?: boolean;
376
+ };
377
+ type MP4Config = {
322
378
  /**
323
- * @description 元素类型
379
+ * @description MP4 导出时是否需要导出最后一帧 PNG
324
380
  */
325
- readonly type = SDKItemType.TEXT;
381
+ isExportLastFrameJPEG?: boolean;
382
+ };
383
+ type GifConfig = {
326
384
  /**
327
- * @description 元素属性
385
+ * @description GIF 导出时的帧率
328
386
  */
329
- property: TextItemProperty;
330
- constructor(options: TextItemOptions);
387
+ fps?: number;
331
388
  /**
332
- * @description 文本内容
389
+ * @description GIF 导出时的缩放比例
390
+ * 默认 '-1:-1', 表示不缩放
391
+ * 例如 '100:-1', 表示宽度 100,高度自动
392
+ * 例如 '-1:100', 表示宽度自动,高度 100
333
393
  */
334
- get text(): string;
335
- set text(value: string);
394
+ scale?: string;
336
395
  /**
337
- * @description 字体名称
396
+ * @description GIF 导出时的质量
397
+ * 默认 'highest'
398
+ * 可选 'highest', 'high', 'medium', 'low'
338
399
  */
339
- get fontFamily(): string;
340
- set fontFamily(value: string);
400
+ quality?: keyof typeof GIF_QUALITY_TO_FFMPEG_ARGS;
401
+ };
402
+ type ApngConfig = {
341
403
  /**
342
- * @description 字号
404
+ * @description APNG 导出时的帧率
343
405
  */
344
- get fontSize(): number;
345
- set fontSize(value: number);
406
+ fps?: number;
346
407
  /**
347
- * @description 字重
408
+ * @description APNG 导出时的缩放比例
409
+ * 默认 '-1:-1', 表示不缩放
410
+ * 例如 '100:-1', 表示宽度 100,高度自动
411
+ * 例如 '-1:100', 表示宽度自动,高度 100
348
412
  */
349
- get fontWeight(): spec.TextWeight;
350
- set fontWeight(value: spec.TextWeight);
413
+ scale?: string;
351
414
  /**
352
- * @description 字体样式
415
+ * @description APNG 导出时的质量
416
+ * 默认 'highest'
417
+ * 可选 'highest', 'high', 'medium', 'low'
353
418
  */
354
- get fontStyle(): spec.FontStyle;
355
- set fontStyle(value: spec.FontStyle);
419
+ quality?: keyof typeof GIF_QUALITY_TO_FFMPEG_ARGS;
420
+ };
421
+ type ExportMediaItemOptions = {
356
422
  /**
357
- * @description 文本对齐方式
423
+ * 尺寸
358
424
  */
359
- get textAlign(): spec.TextAlignment;
360
- set textAlign(value: spec.TextAlignment);
425
+ size: [number, number];
361
426
  /**
362
- * @description 文本颜色 [r, g, b, a]
427
+ * 动效资源
363
428
  */
364
- get color(): [number, number, number, number];
365
- set color(value: [number, number, number, number]);
429
+ scene: spec.JSONScene;
366
430
  /**
367
- * @description 文本宽度
431
+ * 视频时长,目前仅在导出 MP4 / AlphaMaskVideo 时有效,默认取动效资源时长
368
432
  */
369
- get width(): number;
370
- set width(value: number);
433
+ time?: number;
371
434
  /**
372
- * @description 行高
435
+ * 是否生成音轨,默认 false,仅在导出 MP4 时有效
373
436
  */
374
- get lineHeight(): number;
375
- set lineHeight(value: number);
437
+ audioEnable?: boolean;
376
438
  /**
377
- * @description 文本高度
439
+ * 帧率, 默认 30
378
440
  */
379
- get height(): number;
380
- set height(value: number);
441
+ fps?: number;
381
442
  /**
382
- * @description 描边颜色
443
+ * 是否循环,默认 true
383
444
  */
384
- get outlineColor(): spec.vec4 | undefined;
385
- set outlineColor(value: spec.vec4 | undefined);
445
+ loop?: boolean;
386
446
  /**
387
- * @description 描边宽度
447
+ * 视频背景颜色,默认 #000000
388
448
  */
389
- get outlineWidth(): number | undefined;
390
- set outlineWidth(value: number | undefined);
449
+ backgroundColor?: string;
391
450
  /**
392
- * @description 描边开关
451
+ * 导出 MP4 时,设置的导出配置
393
452
  */
394
- get outlineEnabled(): boolean;
395
- set outlineEnabled(value: boolean);
453
+ mp4Config?: MP4Config;
396
454
  /**
397
- * @description 位置
455
+ * 导出 GIF 时,设置的导出配置
398
456
  */
399
- get position(): [number, number];
400
- set position(value: [number, number]);
457
+ gifConfig?: GifConfig;
401
458
  /**
402
- * @description 旋转(二维旋转角度)
459
+ * 导出 APNG 时,设置的导出配置
403
460
  */
404
- get rotation(): number;
405
- set rotation(value: number);
461
+ apngConfig?: ApngConfig;
462
+ };
463
+ type ExportMediaItemDownloadInfo = {
406
464
  /**
407
- * @description 转换为 CreateInfo
408
- * @param withParent 是否包含父节点ID
465
+ * @description 导出文件夹名称
409
466
  */
410
- toCreateInfo(withParent?: boolean): TextCreateInfo;
467
+ folderName: string;
411
468
  /**
412
- * @description 克隆 SDKItem
469
+ * @description 导出视频名称
413
470
  */
414
- clone(): TextItem;
415
- }
416
- /**
417
- * @description 类型守卫:检查是否是 TextItem
418
- */
419
- declare function isTextItem(obj: any): obj is TextItem;
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;
420
477
 
421
478
  /**
422
- * @description 视频元素 SDKItem
423
- * @description 支持属性扩展
479
+ * @description SDKItem 基础选项接口
480
+ * @description 支持扩展属性,允许添加任意额外属性
424
481
  */
425
- declare class VideoItem extends BaseItem {
482
+ type SDKItemOptions = {
426
483
  /**
427
- * @description 元素类型
484
+ * @description 元素ID
428
485
  */
429
- readonly type = SDKItemType.VIDEO;
486
+ id: string;
430
487
  /**
431
- * @description 元素属性
488
+ * @description 元素名称
432
489
  */
433
- property: VideoItemProperty;
434
- constructor(options: VideoItemOptions);
490
+ name: string;
435
491
  /**
436
- * @description 视频地址
492
+ * @description 父节点ID
437
493
  */
438
- get video(): string;
439
- set video(value: string);
494
+ parentId?: string;
440
495
  /**
441
- * @description 位置
496
+ * @description 子元素ID列表
442
497
  */
443
- get position(): [number, number];
444
- set position(value: [number, number]);
498
+ children?: string[];
445
499
  /**
446
- * @description 宽度
500
+ * @description 元素生命周期
447
501
  */
448
- get width(): number;
449
- set width(value: number);
502
+ duration?: number;
450
503
  /**
451
- * @description 高度
504
+ * @description 元素生命周期延时
452
505
  */
453
- get height(): number;
454
- set height(value: number);
506
+ delay?: number;
455
507
  /**
456
- * @description 旋转(二维旋转角度)
508
+ * @description 可视状态
457
509
  */
458
- get rotation(): number;
459
- set rotation(value: number);
510
+ visible?: boolean;
460
511
  /**
461
- * @description 完整旋转(包含 x, y, z)
512
+ * @description 元素结束行为
462
513
  */
463
- get fullRotation(): [number, number, number];
464
- set fullRotation(value: [number, number, number]);
514
+ endBehavior?: spec.EndBehavior;
465
515
  /**
466
- * @description 是否正在编辑关键属性
467
- * @deprecated 该属性即将废弃,使用 isCoreEditable 代替
516
+ * @description 是否处于锁定状态
468
517
  */
469
- get keyPropertyEditing(): boolean;
470
- set keyPropertyEditing(value: boolean);
518
+ isLocked?: boolean;
471
519
  /**
472
- * @description 是否静音
520
+ * @description 关键属性是否可编辑
473
521
  */
474
- get muted(): boolean;
475
- set muted(state: boolean);
522
+ isCoreEditable: boolean;
476
523
  /**
477
- * @description 是否为透明视频
524
+ * @description 扩展属性存储(属性名 -> 属性值)
478
525
  */
479
- get transparent(): boolean;
480
- set transparent(state: boolean);
526
+ extension?: Record<string, any>;
481
527
  /**
482
- * @description 播放音量
528
+ * @description 允许任意额外属性(用于兼容旧代码)
483
529
  */
484
- get volume(): number;
485
- set volume(value: number);
530
+ [extraProp: string]: any;
531
+ };
532
+ /**
533
+ * @description Sprite SDKItem 选项
534
+ */
535
+ type SpriteItemOptions = SDKItemOptions & {
486
536
  /**
487
- * @description 播放速率
537
+ * @description 元素属性
488
538
  */
489
- get playbackRate(): number;
490
- set playbackRate(value: number);
539
+ property?: Partial<SpriteItemProperty>;
540
+ };
541
+ /**
542
+ * @description Text SDKItem 选项
543
+ */
544
+ type TextItemOptions = SDKItemOptions & {
491
545
  /**
492
- * @description 转换为 CreateInfo
493
- * @param withParent 是否包含父节点ID
546
+ * @description 元素属性
494
547
  */
495
- toCreateInfo(withParent?: boolean): VideoCreateInfo;
548
+ property?: Partial<TextItemProperty>;
549
+ };
550
+ /**
551
+ * @description Video SDKItem 选项
552
+ */
553
+ type VideoItemOptions = SDKItemOptions & {
496
554
  /**
497
- * @description 克隆 SDKItem
555
+ * @description 元素属性
498
556
  */
499
- clone(): VideoItem;
500
- }
557
+ property?: Partial<VideoItemProperty>;
558
+ };
501
559
  /**
502
- * @description 类型守卫:检查是否是 VideoItem
560
+ * @description Group SDKItem 选项(空节点/组)
503
561
  */
504
- declare function isVideoItem(obj: any): obj is VideoItem;
505
-
562
+ type GroupItemOptions = SDKItemOptions & {
563
+ /**
564
+ * @description 元素属性
565
+ */
566
+ property?: Partial<GroupItemProperty>;
567
+ };
506
568
  /**
507
- * @description 空节点/组 SDKItem
508
- * @description 支持属性扩展
569
+ * @description Generator SDKItem 选项(资源生成器)
570
+ * @description 支持 image 和 video 两种生成器类型
571
+ * @description 使用 GeneratorItemProperty 包含 generatorType
509
572
  */
510
- declare class GroupItem extends BaseItem {
573
+ type GeneratorItemOptions = SDKItemOptions & {
511
574
  /**
512
- * @description 元素类型
575
+ * @description 元素属性(包含 generatorType)
513
576
  */
514
- readonly type = SDKItemType.GROUP;
577
+ property?: Partial<GeneratorItemProperty>;
578
+ };
579
+ type EffectsItemOptions = SDKItemOptions & {
580
+ property?: Partial<EffectsItemProperty>;
581
+ };
582
+ /**
583
+ * @description Frame 画板元素 SDKItem 选项
584
+ */
585
+ type FrameItemOptions = SDKItemOptions & {
515
586
  /**
516
587
  * @description 元素属性
517
588
  */
518
- property: GroupItemProperty;
519
- constructor(options: GroupItemOptions);
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 {
520
610
  /**
521
- * @description 位置
611
+ * @description 元素ID
522
612
  */
523
- get position(): [number, number];
524
- set position(value: [number, number]);
613
+ id: string;
525
614
  /**
526
- * @description 大小
615
+ * @description 元素名称
527
616
  */
528
- get scale(): [number, number];
529
- set scale(value: [number, number]);
617
+ name: string;
530
618
  /**
531
- * @description 旋转(二维旋转角度)
619
+ * @description 父节点ID
532
620
  */
533
- get rotation(): number;
534
- set rotation(value: number);
621
+ parentId?: string;
535
622
  /**
536
- * @description 完整旋转(包含 x, y, z)
623
+ * @description 元素生命周期
537
624
  */
538
- get fullRotation(): [number, number, number];
539
- set fullRotation(value: [number, number, number]);
625
+ duration: number;
540
626
  /**
541
- * @description 是否正在编辑关键属性
542
- * @deprecated 该属性即将废弃,使用 isCoreEditable 代替
627
+ * @description 元素生命周期延时
543
628
  */
544
- get keyPropertyEditing(): boolean;
545
- set keyPropertyEditing(value: boolean);
629
+ delay: number;
546
630
  /**
547
- * @description 转换为 CreateInfo
548
- * @param withParent 是否包含父节点ID
631
+ * @description 元素结束行为
549
632
  */
550
- toCreateInfo(withParent?: boolean): GroupCreateInfo;
633
+ endBehavior: spec.EndBehavior;
551
634
  /**
552
- * @description 克隆 SDKItem
635
+ * @description 是否可见
553
636
  */
554
- clone(): GroupItem;
555
- }
556
- /**
557
- * @description 类型守卫:检查是否是 GroupItem
558
- */
559
- declare function isGroupItem(obj: any): obj is GroupItem;
560
-
561
- /**
562
- * @description 资源生成器元素 SDKItem 类
563
- * @description 支持 image 和 video 两种生成器类型
564
- * @description 在 Player 中以透明 SpriteItem 形式渲染
565
- * @description 支持属性扩展,可转换为 SpriteItem 或 VideoItem
566
- */
567
- declare class GeneratorItem extends BaseItem {
637
+ visible: boolean;
568
638
  /**
569
- * @description 元素类型(独立类型,不属于 spec.ItemType)
639
+ * @description 是否处于锁定状态
570
640
  */
571
- readonly type = SDKItemType.GENERATOR;
641
+ isLocked: boolean;
642
+ isCoreEditable: boolean;
572
643
  /**
573
- * @description 元素属性(包含 generatorType)
644
+ * @description 扩展属性存储(与 property 同级)
574
645
  */
575
- property: GeneratorItemProperty;
576
- constructor(options: GeneratorItemOptions);
646
+ private _extension;
577
647
  /**
578
- * @description 生成器类型
648
+ * @description 元素类型(由子类实现)
649
+ * @description 支持 spec.ItemType 或扩展的 SDKItemType
579
650
  */
580
- get generatorType(): 'image' | 'video';
581
- set generatorType(value: 'image' | 'video');
651
+ abstract readonly type: SDKItemType;
582
652
  /**
583
- * @description 图片地址(生成器返回空)
653
+ * @description 元素属性(由子类实现)
584
654
  */
585
- get image(): string;
586
- set image(_value: string);
655
+ abstract readonly property: BaseItemProperty;
656
+ constructor(options: SDKItemOptions);
587
657
  /**
588
- * @description 位置
658
+ * @description 设置扩展属性
659
+ * @param key 属性名
660
+ * @param value 属性值
589
661
  */
590
- get position(): [number, number];
591
- set position(value: [number, number]);
662
+ setExtension(key: string, value: any): void;
592
663
  /**
593
- * @description 宽度
664
+ * @description 获取扩展属性
665
+ * @param key 属性名
666
+ * @returns 属性值
594
667
  */
595
- get width(): number;
596
- set width(value: number);
668
+ getExtension(key: string): any;
597
669
  /**
598
- * @description 高度
670
+ * @description 检查是否存在指定扩展属性
671
+ * @param key 属性名
672
+ * @returns 是否存在
599
673
  */
600
- get height(): number;
601
- set height(value: number);
674
+ hasExtension(key: string): boolean;
602
675
  /**
603
- * @description 旋转(二维旋转角度)
676
+ * @description 删除扩展属性
677
+ * @param key 属性名
678
+ * @returns 是否删除成功
604
679
  */
605
- get rotation(): number;
606
- set rotation(value: number);
680
+ deleteExtension(key: string): boolean;
607
681
  /**
608
- * @description 完整旋转(包含 x, y, z)
682
+ * @description 获取所有扩展属性的键名列表
683
+ * @returns 键名数组
609
684
  */
610
- get fullRotation(): [number, number, number];
611
- set fullRotation(value: [number, number, number]);
685
+ getExtensionKeys(): string[];
612
686
  /**
613
- * @description 是否正在编辑关键属性
614
- * @deprecated 该属性即将废弃,使用 isCoreEditable 代替
687
+ * @description 获取所有扩展属性
688
+ * @returns 扩展属性对象
615
689
  */
616
- get keyPropertyEditing(): boolean;
617
- set keyPropertyEditing(value: boolean);
690
+ getAllExtension(): Record<string, any>;
618
691
  /**
619
- * @description 转换为 GeneratorCreateInfo
620
- * @param withParent 是否包含父节点ID
692
+ * @description 批量设置扩展属性
693
+ * @param extensions 扩展属性对象
621
694
  */
622
- toCreateInfo(withParent?: boolean): GeneratorCreateInfo;
695
+ setExtensions(extensions: Record<string, any>): void;
623
696
  /**
624
- * @description 转换为 VideoCreateInfo(用于转换为视频元素)
625
- * @param videoUrl 视频资源地址
626
- * @param withParent 是否包含父节点ID
697
+ * @description 清空所有扩展属性
627
698
  */
628
- toVideoCreateInfo(videoUrl: string, withParent?: boolean): VideoCreateInfo;
699
+ clearExtension(): void;
629
700
  /**
630
- * @description 转换为 SpriteCreateInfo(用于转换为图片元素)
631
- * @param imageUrl 图片资源地址
701
+ * @description 转换为 CreateInfo(用于元素复制/导出)
632
702
  * @param withParent 是否包含父节点ID
703
+ * @returns CreateInfo 对象
633
704
  */
634
- toSpriteCreateInfo(imageUrl: string, withParent?: boolean): SpriteCreateInfo;
705
+ abstract toCreateInfo(withParent?: boolean): ItemCreateInfo;
635
706
  /**
636
707
  * @description 克隆 SDKItem
708
+ * @returns 新的 SDKItem 实例
637
709
  */
638
- clone(): GeneratorItem;
710
+ abstract clone(): BaseItem;
711
+ /**
712
+ * @description 获取基础属性的 JSON 对象,转换为普通对象(用于序列化)
713
+ * @returns 普通对象
714
+ */
715
+ toJSON(): Record<string, any>;
639
716
  }
640
717
  /**
641
- * @description 类型守卫:检查是否是 GeneratorItem
718
+ * @description 类型守卫函数:检查对象是否是 BaseItem
719
+ * @param obj 要检查的对象
720
+ * @returns 是否是 BaseItem 实例
642
721
  */
643
- declare function isGeneratorItem(obj: any): obj is GeneratorItem;
722
+ declare function isBaseItem(obj: any): obj is BaseItem;
644
723
 
645
724
  /**
646
- * @description 特效产物 元素 SDKItem 类
725
+ * @description 图片元素 SDKItem 类
726
+ * @description 支持属性扩展
647
727
  */
648
- declare class EffectsItem extends BaseItem {
728
+ declare class SpriteItem extends BaseItem {
649
729
  /**
650
- * @description 元素类型(独立类型,不属于 spec.ItemType)
730
+ * @description 元素类型
651
731
  */
652
- readonly type = SDKItemType.EFFECTS;
732
+ readonly type = SDKItemType.SPRITE;
653
733
  /**
654
734
  * @description 元素属性
655
735
  */
656
- property: EffectsItemProperty;
657
- constructor(options: EffectsItemOptions);
736
+ property: SpriteItemProperty;
737
+ constructor(options: SpriteItemOptions);
658
738
  /**
659
- * @description 特效资源地址
739
+ * @description 图片地址
660
740
  */
661
- get effects(): string;
662
- set effects(value: string);
741
+ get image(): string;
742
+ set image(value: string);
663
743
  /**
664
744
  * @description 位置
665
745
  */
666
746
  get position(): [number, number];
667
747
  set position(value: [number, number]);
668
- /**
669
- * @description 宽度
670
- */
671
748
  get width(): number;
672
749
  set width(value: number);
673
- /**
674
- * @description 高度
675
- */
676
750
  get height(): number;
677
751
  set height(value: number);
678
752
  /**
@@ -692,604 +766,530 @@ declare class EffectsItem extends BaseItem {
692
766
  get keyPropertyEditing(): boolean;
693
767
  set keyPropertyEditing(value: boolean);
694
768
  /**
695
- * @description 转换为 EffectsCreateInfo
769
+ * @description 转换为 CreateInfo
696
770
  * @param withParent 是否包含父节点ID
697
771
  */
698
- toCreateInfo(withParent?: boolean): EffectsCreateInfo;
772
+ toCreateInfo(withParent?: boolean): SpriteCreateInfo;
699
773
  /**
700
774
  * @description 克隆 SDKItem
701
775
  */
702
- clone(): EffectsItem;
776
+ clone(): SpriteItem;
777
+ /**
778
+ * @description 创建包含扩展属性的 CreateInfo
779
+ * @param withParent 是否包含父节点ID
780
+ * @param extraProps 额外的属性
781
+ */
782
+ toCreateInfoWithExtensions(withParent?: boolean, extraProps?: Record<string, any>): SpriteCreateInfo;
703
783
  }
704
784
  /**
705
- * @description 类型守卫:检查是否是 EffectsItem
785
+ * @description 类型守卫:检查是否是 SpriteItem
706
786
  */
707
- declare function isEffectsItem(obj: any): obj is EffectsItem;
787
+ declare function isSpriteItem(obj: any): obj is SpriteItem;
708
788
 
709
789
  /**
710
- * @description 画板/框架元素 SDKItem 类
711
- * @description 支持自动布局和自由布局两种模式
712
- * @description 底层以 composition 形式渲染
790
+ * @description 文本元素 SDKItem 类
791
+ * @description 支持属性扩展
713
792
  */
714
- declare class FrameItem extends BaseItem {
793
+ declare class TextItem extends BaseItem {
715
794
  /**
716
795
  * @description 元素类型
717
796
  */
718
- readonly type = SDKItemType.FRAME;
797
+ readonly type = SDKItemType.TEXT;
719
798
  /**
720
799
  * @description 元素属性
721
800
  */
722
- property: FrameItemProperty;
723
- constructor(options: FrameItemOptions);
801
+ property: TextItemProperty;
802
+ constructor(options: TextItemOptions);
724
803
  /**
725
- * @description 子元素ID列表(只读)
804
+ * @description 文本内容
726
805
  */
727
- get children(): readonly string[];
806
+ get text(): string;
807
+ set text(value: string);
728
808
  /**
729
- * @description 布局模式
809
+ * @description 字体名称
730
810
  */
731
- get layoutMode(): FrameLayoutMode;
732
- set layoutMode(value: FrameLayoutMode);
811
+ get fontFamily(): string;
812
+ set fontFamily(value: string);
733
813
  /**
734
- * @description 位置
814
+ * @description 字号
735
815
  */
736
- get position(): [number, number];
737
- set position(value: [number, number]);
816
+ get fontSize(): number;
817
+ set fontSize(value: number);
738
818
  /**
739
- * @description 宽度
819
+ * @description 字重
740
820
  */
741
- get width(): number;
742
- set width(value: number);
821
+ get fontWeight(): spec.TextWeight;
822
+ set fontWeight(value: spec.TextWeight);
743
823
  /**
744
- * @description 高度
824
+ * @description 字体样式
745
825
  */
746
- get height(): number;
747
- set height(value: number);
826
+ get fontStyle(): spec.FontStyle;
827
+ set fontStyle(value: spec.FontStyle);
748
828
  /**
749
- * @description 缩放
829
+ * @description 文本对齐方式
750
830
  */
751
- get scale(): [number, number];
752
- set scale(value: [number, number]);
831
+ get textAlign(): spec.TextAlignment;
832
+ set textAlign(value: spec.TextAlignment);
753
833
  /**
754
- * @description 旋转(二维旋转角度)
834
+ * @description 文本颜色 [r, g, b, a]
755
835
  */
756
- get rotation(): number;
757
- set rotation(value: number);
836
+ get color(): [number, number, number, number];
837
+ set color(value: [number, number, number, number]);
758
838
  /**
759
- * @description 完整旋转(包含 x, y, z)
839
+ * @description 文本宽度
760
840
  */
761
- get fullRotation(): [number, number, number];
762
- set fullRotation(value: [number, number, number]);
841
+ get width(): number;
842
+ set width(value: number);
763
843
  /**
764
- * @description 添加子元素
765
- * @param itemId 子元素ID
766
- * @returns 是否添加成功
844
+ * @description 行高
767
845
  */
768
- addChild(itemId: string): boolean;
846
+ get lineHeight(): number;
847
+ set lineHeight(value: number);
769
848
  /**
770
- * @description 批量添加子元素
771
- * @param itemIds 子元素ID列表
849
+ * @description 文本高度
772
850
  */
773
- addChildren(itemIds: string[]): void;
851
+ get height(): number;
852
+ set height(value: number);
774
853
  /**
775
- * @description 移除子元素
776
- * @param itemId 子元素ID
777
- * @returns 是否移除成功
854
+ * @description 描边颜色
778
855
  */
779
- removeChild(itemId: string): boolean;
856
+ get outlineColor(): spec.vec4 | undefined;
857
+ set outlineColor(value: spec.vec4 | undefined);
780
858
  /**
781
- * @description 批量移除子元素
782
- * @param itemIds 子元素ID列表
859
+ * @description 描边宽度
783
860
  */
784
- removeChildren(itemIds: string[]): void;
861
+ get outlineWidth(): number | undefined;
862
+ set outlineWidth(value: number | undefined);
785
863
  /**
786
- * @description 是否包含指定子元素
787
- * @param itemId 子元素ID
864
+ * @description 描边开关
788
865
  */
789
- hasChild(itemId: string): boolean;
866
+ get outlineEnabled(): boolean;
867
+ set outlineEnabled(value: boolean);
790
868
  /**
791
- * @description 清空所有子元素
869
+ * @description 位置
792
870
  */
793
- clearChildren(): void;
871
+ get position(): [number, number];
872
+ set position(value: [number, number]);
794
873
  /**
795
- * @description 转换为 FrameCreateInfo
874
+ * @description 旋转(二维旋转角度)
875
+ */
876
+ get rotation(): number;
877
+ set rotation(value: number);
878
+ /**
879
+ * @description 转换为 CreateInfo
796
880
  * @param withParent 是否包含父节点ID
797
881
  */
798
- toCreateInfo(withParent?: boolean): FrameCreateInfo;
882
+ toCreateInfo(withParent?: boolean): TextCreateInfo;
799
883
  /**
800
884
  * @description 克隆 SDKItem
801
885
  */
802
- clone(): FrameItem;
886
+ clone(): TextItem;
803
887
  }
804
888
  /**
805
- * @description 类型守卫:检查是否是 FrameItem
806
- */
807
- declare function isFrameItem(obj: any): obj is FrameItem;
808
-
809
- /**
810
- * @description 根据 item type 创建对应的 SDKItem 实例
811
- * @param type 元素类型
812
- * @param options SDKItem 选项
813
- * @returns SDKItem 实例
814
- */
815
- declare function createSDKItem(type: spec.ItemType, options: SDKItemOptions): BaseItem;
816
- /**
817
- * @description SDKItem 类型联合
818
- * @description 用于替换原来的 SDKItem type
889
+ * @description 类型守卫:检查是否是 TextItem
819
890
  */
820
- type SDKItem$1 = SpriteItem | TextItem | VideoItem | GroupItem | GeneratorItem | EffectsItem | FrameItem;
891
+ declare function isTextItem(obj: any): obj is TextItem;
821
892
 
822
893
  /**
823
- * @class 二维线段
894
+ * @description 视频元素 SDKItem 类
895
+ * @description 支持属性扩展
824
896
  */
825
- declare class Line2 {
826
- start: Vector2;
827
- end: Vector2;
828
- constructor(start?: Vector2, end?: Vector2);
829
- /**
830
- * 设置二维线段
831
- * @param {Vector2} start 线段起点
832
- * @param {Vector2} end 线段终点
833
- * @returns {Line2} 二维线段
834
- */
835
- set(start: Vector2, end: Vector2): this;
836
- /**
837
- * 复制二维线段
838
- * @param {Line2} line 复制对象
839
- * @returns {Line2} 复制结果
840
- */
841
- copyFrom(line: Line2): this;
897
+ declare class VideoItem extends BaseItem {
842
898
  /**
843
- * 二维线段求方向
844
- * @returns {Vector2} 二维线段方向
899
+ * @description 元素类型
845
900
  */
846
- direction(): Vector2;
901
+ readonly type = SDKItemType.VIDEO;
847
902
  /**
848
- * 二维线段求中点
849
- * @param {Vector2} [target=new Vector2()] 目标保存对象
850
- * @returns {Vector2} 二维线段中点
903
+ * @description 元素属性
851
904
  */
852
- getCenter(target?: Vector2): Vector2;
905
+ property: VideoItemProperty;
906
+ constructor(options: VideoItemOptions);
853
907
  /**
854
- * 二维线段向量值
855
- * @param {Vector2} [target=new Vector2()] 目标保存对象
856
- * @returns {Vector2} 二维线段向量值
908
+ * @description 视频地址
857
909
  */
858
- delta(target?: Vector2): Vector2;
910
+ get video(): string;
911
+ set video(value: string);
859
912
  /**
860
- * 二维线段欧式距离平方(应用于计算)
861
- * @returns {number} 计算结果
913
+ * @description 位置
862
914
  */
863
- distanceSq(): number;
915
+ get position(): [number, number];
916
+ set position(value: [number, number]);
864
917
  /**
865
- * 二维线段欧式距离
866
- * @returns {number} 计算结果
918
+ * @description 宽度
867
919
  */
868
- distance(): number;
920
+ get width(): number;
921
+ set width(value: number);
869
922
  /**
870
- * 求二维线段比例点
871
- * @param {number} t 比例值
872
- * @param {Vector2} target 目标保存对象
873
- * @returns {Vector2} 比例点结果
923
+ * @description 高度
874
924
  */
875
- at(t: number, target?: Vector2): Vector2;
925
+ get height(): number;
926
+ set height(value: number);
876
927
  /**
877
- * 求点与线段的最短距离
878
- * @param {Vector2} point 二维空间点
879
- * @param {boolean} clampToLine 是否限制于线段内
880
- * @returns {number} 距离结果
928
+ * @description 旋转(二维旋转角度)
881
929
  */
882
- closestPointToPointParameter(point: Vector2, clampToLine: boolean): number;
930
+ get rotation(): number;
931
+ set rotation(value: number);
883
932
  /**
884
- * 求点与线段的最近交点
885
- * @param {Vector2} point 二维空间点
886
- * @param {boolean} clampToLine 是否限制于线段内
887
- * @param {Vector2} target 目标保存对象
888
- * @returns {Vector2} 最近交点
933
+ * @description 完整旋转(包含 x, y, z)
889
934
  */
890
- closestPointToPoint(point: Vector2, clampToLine: boolean, target?: Vector2): Vector2;
935
+ get fullRotation(): [number, number, number];
936
+ set fullRotation(value: [number, number, number]);
891
937
  /**
892
- * 二维线段判等
893
- * @param {Line2} line 二维线段
894
- * @returns {boolean} 判等结果
938
+ * @description 是否正在编辑关键属性
939
+ * @deprecated 该属性即将废弃,使用 isCoreEditable 代替
895
940
  */
896
- equals(line: Line2): boolean;
941
+ get keyPropertyEditing(): boolean;
942
+ set keyPropertyEditing(value: boolean);
897
943
  /**
898
- * 克隆二维线段
899
- * @returns {Line2} 克隆结果
944
+ * @description 是否静音
900
945
  */
901
- clone(): Line2;
946
+ get muted(): boolean;
947
+ set muted(state: boolean);
902
948
  /**
903
- * 二维线段求长度
904
- * @returns {number} 长度
949
+ * @description 是否为透明视频
905
950
  */
906
- length(): number;
951
+ get transparent(): boolean;
952
+ set transparent(state: boolean);
907
953
  /**
908
- * 二维线段判断相交
909
- * @param {Line2} other 二维线段
910
- * @returns {boolean} 相交判断结果
954
+ * @description 播放音量
911
955
  */
912
- crossWithLine(other: Line2): boolean;
913
- }
914
-
915
- declare class Vector2 extends math.Vector2 {
916
- subtract(other: Vector2): this;
917
- toViewCoordinate(width: number, height: number): this;
918
- clone(): Vector2;
919
- distanceTo(other: Vector2): number;
920
- scaleByCenter(scalar: Vector2, anchor?: Vector2): this;
921
- round(precision?: number): this;
956
+ get volume(): number;
957
+ set volume(value: number);
922
958
  /**
923
- * 点到直线的最短距离
924
- * @returns {{d: number, t: number}} d表示距离,t表示最近点在直线的比例
959
+ * @description 播放速率
925
960
  */
926
- distanceToLine(line: Line2): {
927
- d: number;
928
- t: number;
929
- };
961
+ get playbackRate(): number;
962
+ set playbackRate(value: number);
930
963
  /**
931
- * 二维向量与x轴夹角
932
- * @returns {number} 弧度值
964
+ * @description 转换为 CreateInfo
965
+ * @param withParent 是否包含父节点ID
933
966
  */
934
- angle(): number;
967
+ toCreateInfo(withParent?: boolean): VideoCreateInfo;
935
968
  /**
936
- * 二维点绕点旋转
937
- * @param {Vec2} center 旋转中心
938
- * @param {number} angle 旋转角度
939
- * @returns {Vec2} 旋转结果
969
+ * @description 克隆 SDKItem
940
970
  */
941
- rotateAround(center: Vector2, angle: number): this;
971
+ clone(): VideoItem;
942
972
  }
973
+ /**
974
+ * @description 类型守卫:检查是否是 VideoItem
975
+ */
976
+ declare function isVideoItem(obj: any): obj is VideoItem;
943
977
 
944
978
  /**
945
- * @class 二维包围盒
979
+ * @description 空节点/组 SDKItem 类
980
+ * @description 支持属性扩展
946
981
  */
947
- declare class Box2 {
982
+ declare class GroupItem extends BaseItem {
948
983
  /**
949
- * @member {Vector2[]} corners 二维包围盒角点
984
+ * @description 元素类型
950
985
  */
951
- corners: Vector2[];
952
- min: Vector2;
953
- max: Vector2;
986
+ readonly type = SDKItemType.GROUP;
954
987
  /**
955
- * 构造函数,传入值为空时表示空包围盒
956
- * @param {Vector2} [min=new Vector2(Infinity, Infinity)] 最小点
957
- * @param {Vector2} [max=new Vector2(-Infinity, -Infinity)] 最大点
988
+ * @description 元素属性
958
989
  */
959
- constructor(min?: Vector2, max?: Vector2);
990
+ property: GroupItemProperty;
991
+ constructor(options: GroupItemOptions);
960
992
  /**
961
- * 通过最大最小点设置二维包围盒
962
- * @param {Vector2} min 最小点
963
- * @param {Vector2} max 最大点
964
- * @returns {Box2} 二维包围盒
993
+ * @description 位置
965
994
  */
966
- set(min: Vector2, max: Vector2): this;
995
+ get position(): [number, number];
996
+ set position(value: [number, number]);
967
997
  /**
968
- * 通过角点设置二维包围盒
969
- * @param {Vector2[]} vecArray 二维空间点数组
970
- * @returns {Box2} 二维包围盒
998
+ * @description 大小
971
999
  */
972
- setFromVec2Array(vecArray: Vector2[]): this;
1000
+ get scale(): [number, number];
1001
+ set scale(value: [number, number]);
973
1002
  /**
974
- * 通过屏幕坐标点设置二维包围盒 - 点为屏幕坐标点,x正方向为右,y正方向为向上
975
- * @param vecArray 屏幕坐标点
1003
+ * @description 旋转(二维旋转角度)
976
1004
  */
977
- setFromVec2ArrayWithOutCorners(vecArray: Vector2[]): this;
1005
+ get rotation(): number;
1006
+ set rotation(value: number);
978
1007
  /**
979
- * 通过中心与大小设置二维包围盒
980
- * @param {Vector2} center 二维中心点
981
- * @param {Vector2} size 二维大小
982
- * @returns {Box2} 二维包围盒
1008
+ * @description 完整旋转(包含 x, y, z)
983
1009
  */
984
- setFromCenterAndSize(center: Vector2, size: Vector2): this;
1010
+ get fullRotation(): [number, number, number];
1011
+ set fullRotation(value: [number, number, number]);
985
1012
  /**
986
- * 克隆二维包围盒
987
- * @returns {Box2} 克隆结果
1013
+ * @description 是否正在编辑关键属性
1014
+ * @deprecated 该属性即将废弃,使用 isCoreEditable 代替
988
1015
  */
989
- clone(): Box2;
1016
+ get keyPropertyEditing(): boolean;
1017
+ set keyPropertyEditing(value: boolean);
990
1018
  /**
991
- * 复制二维包围盒
992
- * @param {Box2} box 二维包围盒
993
- * @returns {Box2} 复制结果
1019
+ * @description 转换为 CreateInfo
1020
+ * @param withParent 是否包含父节点ID
994
1021
  */
995
- copyFrom(box: Box2): this;
1022
+ toCreateInfo(withParent?: boolean): GroupCreateInfo;
996
1023
  /**
997
- * 二维包围盒置空
998
- * @returns {Box2} 置空结果
1024
+ * @description 克隆 SDKItem
999
1025
  */
1000
- makeEmpty(): this;
1026
+ clone(): GroupItem;
1027
+ }
1028
+ /**
1029
+ * @description 类型守卫:检查是否是 GroupItem
1030
+ */
1031
+ declare function isGroupItem(obj: any): obj is GroupItem;
1032
+
1033
+ /**
1034
+ * @description 资源生成器元素 SDKItem 类
1035
+ * @description 支持 image 和 video 两种生成器类型
1036
+ * @description 在 Player 中以透明 SpriteItem 形式渲染
1037
+ * @description 支持属性扩展,可转换为 SpriteItem 或 VideoItem
1038
+ */
1039
+ declare class GeneratorItem extends BaseItem {
1001
1040
  /**
1002
- * 二维包围盒判空
1003
- * @returns {boolean} 判空结果
1041
+ * @description 元素类型(独立类型,不属于 spec.ItemType)
1004
1042
  */
1005
- isEmpty(): boolean;
1043
+ readonly type = SDKItemType.GENERATOR;
1006
1044
  /**
1007
- * 获取二维包围盒角点
1008
- * @returns {Vector2[]} 二维包围盒角点
1045
+ * @description 元素属性(包含 generatorType)
1009
1046
  */
1010
- getCorners(): Vector2[];
1047
+ property: GeneratorItemProperty;
1048
+ constructor(options: GeneratorItemOptions);
1011
1049
  /**
1012
- * 获取二维包围盒中心点
1013
- * @param {Vector2} [target=new Vector2()] 目标点(用以存放二维包围盒中心点)
1014
- * @returns {Vector2} 二维包围盒中心点
1050
+ * @description 生成器类型
1015
1051
  */
1016
- getCenter(target?: Vector2): Vector2;
1052
+ get generatorType(): 'image' | 'video';
1053
+ set generatorType(value: 'image' | 'video');
1017
1054
  /**
1018
- * 获取二维包围盒大小
1019
- * @param {Vector2} [target=new Vector2()] 目标向量(用以存放二维包围盒大小)
1020
- * @returns {Vector2} 二维包围盒大小
1055
+ * @description 图片地址(生成器返回空)
1021
1056
  */
1022
- getSize(target?: Vector2): Vector2;
1057
+ get image(): string;
1058
+ set image(_value: string);
1023
1059
  /**
1024
- * 通过二维空间点扩展二维包围盒
1025
- * @param {Vector2} point 二维空间点
1026
- * @returns {Box2} 扩展包围盒
1060
+ * @description 位置
1027
1061
  */
1028
- expandByPoint(point: Vector2): this;
1062
+ get position(): [number, number];
1063
+ set position(value: [number, number]);
1029
1064
  /**
1030
- * 通过向量扩展二维包围盒
1031
- * @param {Vector2} vector 二维向量
1032
- * @returns {Box2} 扩展结果
1065
+ * @description 宽度
1033
1066
  */
1034
- expandByVector(vector: Vector2): this;
1067
+ get width(): number;
1068
+ set width(value: number);
1035
1069
  /**
1036
- * 通过大小扩展二维包围盒
1037
- * @param {number} scalar 扩展大小
1038
- * @returns {Box2} 扩展结果
1070
+ * @description 高度
1039
1071
  */
1040
- expandByScalar(scalar: number): this;
1072
+ get height(): number;
1073
+ set height(value: number);
1041
1074
  /**
1042
- * 判断二维包围盒是否包含二维空间点
1043
- * @param {Vector2} point 二维空间点
1044
- * @param {boolean} [isOrthogonal=true] 包围盒正交判断(默认为true)
1045
- * @returns {boolean} 点包含判断结果
1075
+ * @description 旋转(二维旋转角度)
1046
1076
  */
1047
- containsPoint(point: Vector2, isOrthogonal?: boolean): boolean;
1077
+ get rotation(): number;
1078
+ set rotation(value: number);
1048
1079
  /**
1049
- * 判断二维包围盒包含关系(if this contains other)
1050
- * @param {Box2} box 其它包围盒
1051
- * @returns {boolean} 二维包围盒包含判断结果
1080
+ * @description 完整旋转(包含 x, y, z)
1052
1081
  */
1053
- containsBox(box: Box2): boolean;
1082
+ get fullRotation(): [number, number, number];
1083
+ set fullRotation(value: [number, number, number]);
1054
1084
  /**
1055
- * 获取点以包围盒左上角顶点为原点的相对位置
1056
- * @param {Vector2} point 指定二维空间点
1057
- * @param {Vector2} [target=new Vector2()] 目标空间点
1058
- * @returns {Vector2} 计算结果空间点
1085
+ * @description 是否正在编辑关键属性
1086
+ * @deprecated 该属性即将废弃,使用 isCoreEditable 代替
1059
1087
  */
1060
- getParameter(point: Vector2, target?: Vector2): Vector2;
1088
+ get keyPropertyEditing(): boolean;
1089
+ set keyPropertyEditing(value: boolean);
1061
1090
  /**
1062
- * 求点与二维包围盒的最近点
1063
- * @param {Vector2} point 二维空间点
1064
- * @param {Vector2} [target=new Vector2()] 结果点
1065
- * @returns {Vector2} 二维空间点
1091
+ * @description 转换为 GeneratorCreateInfo
1092
+ * @param withParent 是否包含父节点ID
1066
1093
  */
1067
- clampPoint(point: Vector2, target?: Vector2): Vector2;
1094
+ toCreateInfo(withParent?: boolean): GeneratorCreateInfo;
1068
1095
  /**
1069
- * 求点到二维包围盒的距离
1070
- * @param {Vector2} point 二维空间点
1071
- * @returns {number} 距离
1096
+ * @description 转换为 VideoCreateInfo(用于转换为视频元素)
1097
+ * @param videoUrl 视频资源地址
1098
+ * @param withParent 是否包含父节点ID
1072
1099
  */
1073
- distanceToPoint(point: Vector2): number;
1100
+ toVideoCreateInfo(videoUrl: string, withParent?: boolean): VideoCreateInfo;
1074
1101
  /**
1075
- * 二维包围盒求交集
1076
- * @param {Box2} box 二维包围盒
1077
- * @returns {Box2} 求交结果
1102
+ * @description 转换为 SpriteCreateInfo(用于转换为图片元素)
1103
+ * @param imageUrl 图片资源地址
1104
+ * @param withParent 是否包含父节点ID
1078
1105
  */
1079
- intersect(box: Box2): this;
1106
+ toSpriteCreateInfo(imageUrl: string, withParent?: boolean): SpriteCreateInfo;
1080
1107
  /**
1081
- * 二维包围盒求并集
1082
- * @param {Box2} box 二维包围盒
1083
- * @returns {Box2} 求并结果
1108
+ * @description 克隆 SDKItem
1084
1109
  */
1085
- union(target: Box2 | Vector2): this;
1110
+ clone(): GeneratorItem;
1111
+ }
1112
+ /**
1113
+ * @description 类型守卫:检查是否是 GeneratorItem
1114
+ */
1115
+ declare function isGeneratorItem(obj: any): obj is GeneratorItem;
1116
+
1117
+ /**
1118
+ * @description 特效产物 元素 SDKItem 类
1119
+ */
1120
+ declare class EffectsItem extends BaseItem {
1086
1121
  /**
1087
- * 二维包围盒位移
1088
- * @param {Vector2} offset 位移向量
1089
- * @returns {Box2} 位移结果
1122
+ * @description 元素类型(独立类型,不属于 spec.ItemType)
1090
1123
  */
1091
- translate(offset: Vector2): this;
1092
- scale(scalar: number | Vector2, anchor?: Vector2): this;
1124
+ readonly type = SDKItemType.EFFECTS;
1125
+ /**
1126
+ * @description 元素属性
1127
+ */
1128
+ property: EffectsItemProperty;
1129
+ constructor(options: EffectsItemOptions);
1130
+ /**
1131
+ * @description 特效资源地址
1132
+ */
1133
+ get effects(): string;
1134
+ set effects(value: string);
1093
1135
  /**
1094
- * 二维包围盒判等
1095
- * @param {Box2} box 二维包围盒
1096
- * @returns {boolean} 判等结果
1136
+ * @description 位置
1097
1137
  */
1098
- equals(box: Box2): boolean;
1138
+ get position(): [number, number];
1139
+ set position(value: [number, number]);
1099
1140
  /**
1100
- * 判断二维包围盒相交关系(if this intersect other)
1101
- * @param {Box2} box 二维包围盒
1102
- * @param {boolean} [isOrthogonal=true] 正交判断(当前包围盒)
1103
- * @returns {boolean} 相交判断结果
1141
+ * @description 宽度
1104
1142
  */
1105
- intersectsBox(box: Box2, isOrthogonal?: boolean): boolean;
1106
- rotate(angle: number, center?: Vector2): this;
1107
- }
1108
-
1109
- type SizeAdaptDirection = 'x' | 'y';
1110
-
1111
- declare const MEDIA_TYPE: {
1112
- readonly APNG: "APNG";
1113
- readonly MP4: "MP4";
1114
- readonly WebM: "WebM";
1115
- readonly Images: "Images";
1116
- readonly WebP: "WebP";
1117
- readonly GIF: "GIF";
1118
- readonly AlphaMaskVideo: "AlphaMaskVideo";
1119
- };
1120
- /**
1121
- * GIF 压缩参数
1122
- * 核心通过参数 flags + palettegen + paletteuse 实现
1123
- * highest: lanczos + max_colors=256 + dither=bayer
1124
- * high: bicubic + max_colors=200 + dither=bayer
1125
- * medium: bilinear + max_colors=64 + dither=bayer
1126
- * low: neighbor + max_colors=32 + dither=none
1127
- */
1128
- declare const GIF_QUALITY_TO_FFMPEG_ARGS: {
1129
- highest: string;
1130
- high: string;
1131
- medium: string;
1132
- low: string;
1133
- };
1134
-
1135
- declare global {
1136
- interface Window {
1137
- /**
1138
- * @description 创建 WebP Core 实例
1139
- */
1140
- createWebPCore: (config: any) => Promise<Img2WebPCore>;
1141
- }
1142
- }
1143
- type FileBuffer = ArrayBuffer | Uint8Array;
1144
- type MediaType = typeof MEDIA_TYPE[keyof typeof MEDIA_TYPE];
1145
- type FS = {
1146
- writeFile: (path: string, data: Uint8Array | string) => void;
1147
- readFile(path: string, opts: {
1148
- encoding: 'binary';
1149
- flags?: string | undefined;
1150
- }): Uint8Array;
1151
- readFile(path: string, opts: {
1152
- encoding: 'utf8';
1153
- flags?: string | undefined;
1154
- }): string;
1155
- readFile(path: string, opts?: {
1156
- flags?: string | undefined;
1157
- }): Uint8Array;
1158
- unlink: (path: string) => void;
1159
- quit: () => void;
1160
- };
1161
- type Pointer = number;
1162
- type Img2WebPCore = {
1163
- FS: FS;
1164
- run: (...args: string[]) => number;
1165
- cwrap: (ident: string, returnType: string, argTypes: string[]) => ((argc: number, argv: Pointer) => number);
1166
- _malloc: (size: number) => Pointer;
1167
- writeAsciiToMemory: (str: string, buffer: number, dontAddNull?: boolean) => void;
1168
- setValue: (ptr: number, value: any, type: string, noSafe?: boolean) => void;
1169
- };
1170
- type ExportMediaInitOptions = {
1143
+ get width(): number;
1144
+ set width(value: number);
1171
1145
  /**
1172
- * 导出类型
1146
+ * @description 高度
1173
1147
  */
1174
- mediaType: MediaType;
1148
+ get height(): number;
1149
+ set height(value: number);
1175
1150
  /**
1176
- * 额外画布,导出透明视频时使用
1151
+ * @description 旋转(二维旋转角度)
1177
1152
  */
1178
- extraCanvas?: HTMLCanvasElement | null;
1153
+ get rotation(): number;
1154
+ set rotation(value: number);
1179
1155
  /**
1180
- * 是否打印转码过程中的日志,仅在导出 MP4/AlphaMaskVideo 时有效, 默认 false
1181
- * 供开发调试使用
1156
+ * @description 完整旋转(包含 x, y, z)
1182
1157
  */
1183
- loggerInTranscoding?: boolean;
1158
+ get fullRotation(): [number, number, number];
1159
+ set fullRotation(value: [number, number, number]);
1184
1160
  /**
1185
- * ffmpeg 转码是否开启多线程,默认 false,确保环境支持 SharedArrayBuffer
1161
+ * @description 是否正在编辑关键属性
1162
+ * @deprecated 该属性即将废弃,使用 isCoreEditable 代替
1186
1163
  */
1187
- multiThreading?: boolean;
1164
+ get keyPropertyEditing(): boolean;
1165
+ set keyPropertyEditing(value: boolean);
1188
1166
  /**
1189
- * 是否输出 buffer,默认 false
1167
+ * @description 转换为 EffectsCreateInfo
1168
+ * @param withParent 是否包含父节点ID
1190
1169
  */
1191
- isOutputBuffer?: boolean;
1192
- };
1193
- type MP4Config = {
1170
+ toCreateInfo(withParent?: boolean): EffectsCreateInfo;
1194
1171
  /**
1195
- * @description MP4 导出时是否需要导出最后一帧 PNG
1172
+ * @description 克隆 SDKItem
1196
1173
  */
1197
- isExportLastFrameJPEG?: boolean;
1198
- };
1199
- type GifConfig = {
1174
+ clone(): EffectsItem;
1175
+ }
1176
+ /**
1177
+ * @description 类型守卫:检查是否是 EffectsItem
1178
+ */
1179
+ declare function isEffectsItem(obj: any): obj is EffectsItem;
1180
+
1181
+ /**
1182
+ * @description 画板/框架元素 SDKItem 类
1183
+ * @description 支持自动布局和自由布局两种模式
1184
+ * @description 底层以 composition 形式渲染
1185
+ */
1186
+ declare class FrameItem extends BaseItem {
1200
1187
  /**
1201
- * @description GIF 导出时的帧率
1188
+ * @description 元素类型
1202
1189
  */
1203
- fps?: number;
1190
+ readonly type = SDKItemType.FRAME;
1204
1191
  /**
1205
- * @description GIF 导出时的缩放比例
1206
- * 默认 '-1:-1', 表示不缩放
1207
- * 例如 '100:-1', 表示宽度 100,高度自动
1208
- * 例如 '-1:100', 表示宽度自动,高度 100
1192
+ * @description 元素属性
1209
1193
  */
1210
- scale?: string;
1194
+ property: FrameItemProperty;
1195
+ constructor(options: FrameItemOptions);
1211
1196
  /**
1212
- * @description GIF 导出时的质量
1213
- * 默认 'highest'
1214
- * 可选 'highest', 'high', 'medium', 'low'
1197
+ * @description 子元素ID列表(只读)
1215
1198
  */
1216
- quality?: keyof typeof GIF_QUALITY_TO_FFMPEG_ARGS;
1217
- };
1218
- type ApngConfig = {
1199
+ get children(): readonly string[];
1219
1200
  /**
1220
- * @description APNG 导出时的帧率
1201
+ * @description 布局模式
1221
1202
  */
1222
- fps?: number;
1203
+ get layoutMode(): FrameLayoutMode;
1204
+ set layoutMode(value: FrameLayoutMode);
1223
1205
  /**
1224
- * @description APNG 导出时的缩放比例
1225
- * 默认 '-1:-1', 表示不缩放
1226
- * 例如 '100:-1', 表示宽度 100,高度自动
1227
- * 例如 '-1:100', 表示宽度自动,高度 100
1206
+ * @description 位置
1228
1207
  */
1229
- scale?: string;
1208
+ get position(): [number, number];
1209
+ set position(value: [number, number]);
1230
1210
  /**
1231
- * @description APNG 导出时的质量
1232
- * 默认 'highest'
1233
- * 可选 'highest', 'high', 'medium', 'low'
1211
+ * @description 宽度
1234
1212
  */
1235
- quality?: keyof typeof GIF_QUALITY_TO_FFMPEG_ARGS;
1236
- };
1237
- type ExportMediaItemOptions = {
1213
+ get width(): number;
1214
+ set width(value: number);
1238
1215
  /**
1239
- * 尺寸
1216
+ * @description 高度
1240
1217
  */
1241
- size: [number, number];
1218
+ get height(): number;
1219
+ set height(value: number);
1242
1220
  /**
1243
- * 动效资源
1221
+ * @description 缩放
1244
1222
  */
1245
- scene: spec.JSONScene;
1223
+ get scale(): [number, number];
1224
+ set scale(value: [number, number]);
1246
1225
  /**
1247
- * 视频时长,目前仅在导出 MP4 / AlphaMaskVideo 时有效,默认取动效资源时长
1226
+ * @description 旋转(二维旋转角度)
1248
1227
  */
1249
- time?: number;
1228
+ get rotation(): number;
1229
+ set rotation(value: number);
1250
1230
  /**
1251
- * 是否生成音轨,默认 false,仅在导出 MP4 时有效
1231
+ * @description 完整旋转(包含 x, y, z)
1252
1232
  */
1253
- audioEnable?: boolean;
1233
+ get fullRotation(): [number, number, number];
1234
+ set fullRotation(value: [number, number, number]);
1254
1235
  /**
1255
- * 帧率, 默认 30
1236
+ * @description 添加子元素
1237
+ * @param itemId 子元素ID
1238
+ * @returns 是否添加成功
1256
1239
  */
1257
- fps?: number;
1240
+ addChild(itemId: string): boolean;
1258
1241
  /**
1259
- * 是否循环,默认 true
1242
+ * @description 批量添加子元素
1243
+ * @param itemIds 子元素ID列表
1260
1244
  */
1261
- loop?: boolean;
1245
+ addChildren(itemIds: string[]): void;
1262
1246
  /**
1263
- * 视频背景颜色,默认 #000000
1247
+ * @description 移除子元素
1248
+ * @param itemId 子元素ID
1249
+ * @returns 是否移除成功
1264
1250
  */
1265
- backgroundColor?: string;
1251
+ removeChild(itemId: string): boolean;
1266
1252
  /**
1267
- * 导出 MP4 时,设置的导出配置
1253
+ * @description 批量移除子元素
1254
+ * @param itemIds 子元素ID列表
1268
1255
  */
1269
- mp4Config?: MP4Config;
1256
+ removeChildren(itemIds: string[]): void;
1270
1257
  /**
1271
- * 导出 GIF 时,设置的导出配置
1258
+ * @description 是否包含指定子元素
1259
+ * @param itemId 子元素ID
1272
1260
  */
1273
- gifConfig?: GifConfig;
1261
+ hasChild(itemId: string): boolean;
1274
1262
  /**
1275
- * 导出 APNG 时,设置的导出配置
1263
+ * @description 清空所有子元素
1276
1264
  */
1277
- apngConfig?: ApngConfig;
1278
- };
1279
- type ExportMediaItemDownloadInfo = {
1265
+ clearChildren(): void;
1280
1266
  /**
1281
- * @description 导出文件夹名称
1267
+ * @description 转换为 FrameCreateInfo
1268
+ * @param withParent 是否包含父节点ID
1282
1269
  */
1283
- folderName: string;
1270
+ toCreateInfo(withParent?: boolean): FrameCreateInfo;
1284
1271
  /**
1285
- * @description 导出视频名称
1272
+ * @description 克隆 SDKItem
1286
1273
  */
1287
- name: string;
1288
- };
1289
- type ExportItemParams = ExportMediaItemOptions & ExportMediaItemDownloadInfo;
1290
- type ExportParams = ExportItemParams[];
1291
- type Buffers = FileBuffer[] | undefined;
1292
- type Extras = (FileBuffer | null)[] | null | undefined;
1274
+ clone(): FrameItem;
1275
+ }
1276
+ /**
1277
+ * @description 类型守卫:检查是否是 FrameItem
1278
+ */
1279
+ declare function isFrameItem(obj: any): obj is FrameItem;
1280
+
1281
+ /**
1282
+ * @description 根据 item type 创建对应的 SDKItem 实例
1283
+ * @param type 元素类型
1284
+ * @param options SDKItem 选项
1285
+ * @returns SDKItem 实例
1286
+ */
1287
+ declare function createSDKItem(type: spec.ItemType, options: SDKItemOptions): BaseItem;
1288
+ /**
1289
+ * @description SDKItem 类型联合
1290
+ * @description 用于替换原来的 SDKItem type
1291
+ */
1292
+ type SDKItem = SpriteItem | TextItem | VideoItem | GroupItem | GeneratorItem | EffectsItem | FrameItem;
1293
1293
 
1294
1294
  type BaseItemProperty = {
1295
1295
  position: [number, number];
@@ -1351,6 +1351,7 @@ type GeneratorItemProperty = BaseItemProperty & {
1351
1351
  };
1352
1352
  type EffectsItemProperty = BaseItemProperty & {
1353
1353
  effects: string;
1354
+ children?: string[];
1354
1355
  };
1355
1356
  /**
1356
1357
  * @description Frame 画板元素布局模式
@@ -1670,13 +1671,6 @@ type ActiveData = {
1670
1671
  */
1671
1672
  loadingItems?: string[];
1672
1673
  };
1673
- /**
1674
- * @description 视图元素
1675
- * @description 注意:SDKItem 现在已从类实现中导入,见 view-item/index.ts
1676
- * @description SDKItem 现在是类实例而非普通对象,支持属性扩展
1677
- * @description 保持类型兼容性:新 SDKItem 类拥有与旧类型相同的属性
1678
- */
1679
- type SDKItem = SDKItem$1;
1680
1674
  type SDKBackgroundType = 'color' | 'image' | 'chess-board' | 'dot-board';
1681
1675
  /**
1682
1676
  * @description 图层创建信息
@@ -3094,13 +3088,13 @@ declare class SDK {
3094
3088
  * @param id 元素ID
3095
3089
  * @returns 元素
3096
3090
  * */
3097
- getSDKItem(id: string): SDKItem$1 | undefined;
3091
+ getSDKItem(id: string): SDKItem | undefined;
3098
3092
  /**
3099
3093
  * @description 获取元素数组
3100
3094
  * @param id 元素ID数组
3101
3095
  * @returns 元素数组
3102
3096
  * */
3103
- getSDKItems(ids?: string[]): SDKItem$1[];
3097
+ getSDKItems(ids?: string[]): SDKItem[];
3104
3098
  setPlayState(playState: 'play' | 'pause'): Promise<void>;
3105
3099
  /**
3106
3100
  * @description 获取场景预览图
@@ -3421,6 +3415,9 @@ declare class SDK {
3421
3415
  setSpriteTextEditState(id: string, index: number, isEditing: boolean): void;
3422
3416
  getVideoItemPlayTime(id: string): number;
3423
3417
  setVideoItemPlayTime(id: string, time: number): void;
3418
+ getEffectsItemPlayTime(id: string): number | undefined;
3419
+ setEffectsItemPlayTime(id: string, time: number): void;
3420
+ setEffectsResource(id: string, effects: string): void;
3424
3421
  getPixelPositionByViewPosition(viewPosition: Vector2): Vector2;
3425
3422
  hitTest(x: number, y: number): string[] | undefined;
3426
3423
  setInteractType(type: GestureHandlerInteractType): void;
@@ -3433,7 +3430,7 @@ declare class SDK {
3433
3430
  */
3434
3431
  addGeneratorItem(createInfo: GeneratorCreateInfo): string;
3435
3432
  /**
3436
- * @description 创建动效元素(仅限调试使用)
3433
+ * @description 创建动效元素
3437
3434
  * @param effectsInfo 动效创建信息
3438
3435
  */
3439
3436
  addEffectsItem(effectsInfo: EffectsCreateInfo): Promise<string | undefined>;
@@ -3473,4 +3470,4 @@ declare class SDK {
3473
3470
  setSafeAreaPreviewVisible(id: number, type: 'url' | 'color', visible: boolean): void;
3474
3471
  }
3475
3472
 
3476
- 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$1 as 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 };
3473
+ 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 };