@vvfx/sdk 0.0.0-alpha.5 → 0.0.0-alpha.51

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,6 +1,6 @@
1
- import { spec, Player } from '@galacean/effects';
2
- export { spec } from '@galacean/effects';
3
- import * as _galacean_effects_weapp from '@galacean/effects/weapp';
1
+ import * as _galacean_effects from '@galacean/effects';
2
+ import { spec, math, Player } from '@galacean/effects';
3
+ export { generateGUID, spec } from '@galacean/effects';
4
4
 
5
5
  type ViewItemTypedProperty = {
6
6
  [K in keyof PageFormTypeAndPropertyReference]: {
@@ -44,23 +44,1231 @@ type SetItemPropertyValueParam = {
44
44
  propertyValue: PageFormTypeAndPropertyReference[T][N];
45
45
  };
46
46
  }[keyof PageFormTypeAndPropertyReference[T]];
47
- }[keyof PageFormTypeAndPropertyReference];
47
+ }[keyof PageFormTypeAndPropertyReference] | {
48
+ itemId: string;
49
+ type: spec.ItemType;
50
+ propertyName: 'position' | 'size';
51
+ propertyValue: spec.vec2 | spec.vec3;
52
+ };
53
+
54
+ /**
55
+ * @class 二维线段
56
+ */
57
+ declare class Line2 {
58
+ start: Vector2;
59
+ end: Vector2;
60
+ constructor(start?: Vector2, end?: Vector2);
61
+ /**
62
+ * 设置二维线段
63
+ * @param {Vector2} start 线段起点
64
+ * @param {Vector2} end 线段终点
65
+ * @returns {Line2} 二维线段
66
+ */
67
+ set(start: Vector2, end: Vector2): this;
68
+ /**
69
+ * 复制二维线段
70
+ * @param {Line2} line 复制对象
71
+ * @returns {Line2} 复制结果
72
+ */
73
+ copyFrom(line: Line2): this;
74
+ /**
75
+ * 二维线段求方向
76
+ * @returns {Vector2} 二维线段方向
77
+ */
78
+ direction(): Vector2;
79
+ /**
80
+ * 二维线段求中点
81
+ * @param {Vector2} [target=new Vector2()] 目标保存对象
82
+ * @returns {Vector2} 二维线段中点
83
+ */
84
+ getCenter(target?: Vector2): Vector2;
85
+ /**
86
+ * 二维线段向量值
87
+ * @param {Vector2} [target=new Vector2()] 目标保存对象
88
+ * @returns {Vector2} 二维线段向量值
89
+ */
90
+ delta(target?: Vector2): Vector2;
91
+ /**
92
+ * 二维线段欧式距离平方(应用于计算)
93
+ * @returns {number} 计算结果
94
+ */
95
+ distanceSq(): number;
96
+ /**
97
+ * 二维线段欧式距离
98
+ * @returns {number} 计算结果
99
+ */
100
+ distance(): number;
101
+ /**
102
+ * 求二维线段比例点
103
+ * @param {number} t 比例值
104
+ * @param {Vector2} target 目标保存对象
105
+ * @returns {Vector2} 比例点结果
106
+ */
107
+ at(t: number, target?: Vector2): Vector2;
108
+ /**
109
+ * 求点与线段的最短距离
110
+ * @param {Vector2} point 二维空间点
111
+ * @param {boolean} clampToLine 是否限制于线段内
112
+ * @returns {number} 距离结果
113
+ */
114
+ closestPointToPointParameter(point: Vector2, clampToLine: boolean): number;
115
+ /**
116
+ * 求点与线段的最近交点
117
+ * @param {Vector2} point 二维空间点
118
+ * @param {boolean} clampToLine 是否限制于线段内
119
+ * @param {Vector2} target 目标保存对象
120
+ * @returns {Vector2} 最近交点
121
+ */
122
+ closestPointToPoint(point: Vector2, clampToLine: boolean, target?: Vector2): Vector2;
123
+ /**
124
+ * 二维线段判等
125
+ * @param {Line2} line 二维线段
126
+ * @returns {boolean} 判等结果
127
+ */
128
+ equals(line: Line2): boolean;
129
+ /**
130
+ * 克隆二维线段
131
+ * @returns {Line2} 克隆结果
132
+ */
133
+ clone(): Line2;
134
+ /**
135
+ * 二维线段求长度
136
+ * @returns {number} 长度
137
+ */
138
+ length(): number;
139
+ /**
140
+ * 二维线段判断相交
141
+ * @param {Line2} other 二维线段
142
+ * @returns {boolean} 相交判断结果
143
+ */
144
+ crossWithLine(other: Line2): boolean;
145
+ }
146
+
147
+ declare class Vector2 extends math.Vector2 {
148
+ subtract(other: Vector2): this;
149
+ toViewCoordinate(width: number, height: number): this;
150
+ clone(): Vector2;
151
+ distanceTo(other: Vector2): number;
152
+ scaleByCenter(scalar: Vector2, anchor?: Vector2): this;
153
+ round(precision?: number): this;
154
+ /**
155
+ * 点到直线的最短距离
156
+ * @returns {{d: number, t: number}} d表示距离,t表示最近点在直线的比例
157
+ */
158
+ distanceToLine(line: Line2): {
159
+ d: number;
160
+ t: number;
161
+ };
162
+ /**
163
+ * 二维向量与x轴夹角
164
+ * @returns {number} 弧度值
165
+ */
166
+ angle(): number;
167
+ /**
168
+ * 二维点绕点旋转
169
+ * @param {Vec2} center 旋转中心
170
+ * @param {number} angle 旋转角度
171
+ * @returns {Vec2} 旋转结果
172
+ */
173
+ rotateAround(center: Vector2, angle: number): this;
174
+ }
175
+
176
+ /**
177
+ * @class 二维包围盒
178
+ */
179
+ declare class Box2 {
180
+ /**
181
+ * @member {Vector2[]} corners 二维包围盒角点
182
+ */
183
+ corners: Vector2[];
184
+ min: Vector2;
185
+ max: Vector2;
186
+ /**
187
+ * 构造函数,传入值为空时表示空包围盒
188
+ * @param {Vector2} [min=new Vector2(Infinity, Infinity)] 最小点
189
+ * @param {Vector2} [max=new Vector2(-Infinity, -Infinity)] 最大点
190
+ */
191
+ constructor(min?: Vector2, max?: Vector2);
192
+ /**
193
+ * 通过最大最小点设置二维包围盒
194
+ * @param {Vector2} min 最小点
195
+ * @param {Vector2} max 最大点
196
+ * @returns {Box2} 二维包围盒
197
+ */
198
+ set(min: Vector2, max: Vector2): this;
199
+ /**
200
+ * 通过角点设置二维包围盒
201
+ * @param {Vector2[]} vecArray 二维空间点数组
202
+ * @returns {Box2} 二维包围盒
203
+ */
204
+ setFromVec2Array(vecArray: Vector2[]): this;
205
+ /**
206
+ * 通过屏幕坐标点设置二维包围盒 - 点为屏幕坐标点,x正方向为右,y正方向为向上
207
+ * @param vecArray 屏幕坐标点
208
+ */
209
+ setFromVec2ArrayWithOutCorners(vecArray: Vector2[]): this;
210
+ /**
211
+ * 通过中心与大小设置二维包围盒
212
+ * @param {Vector2} center 二维中心点
213
+ * @param {Vector2} size 二维大小
214
+ * @returns {Box2} 二维包围盒
215
+ */
216
+ setFromCenterAndSize(center: Vector2, size: Vector2): this;
217
+ /**
218
+ * 克隆二维包围盒
219
+ * @returns {Box2} 克隆结果
220
+ */
221
+ clone(): Box2;
222
+ /**
223
+ * 复制二维包围盒
224
+ * @param {Box2} box 二维包围盒
225
+ * @returns {Box2} 复制结果
226
+ */
227
+ copyFrom(box: Box2): this;
228
+ /**
229
+ * 二维包围盒置空
230
+ * @returns {Box2} 置空结果
231
+ */
232
+ makeEmpty(): this;
233
+ /**
234
+ * 二维包围盒判空
235
+ * @returns {boolean} 判空结果
236
+ */
237
+ isEmpty(): boolean;
238
+ /**
239
+ * 获取二维包围盒角点
240
+ * @returns {Vector2[]} 二维包围盒角点
241
+ */
242
+ getCorners(): Vector2[];
243
+ /**
244
+ * 获取二维包围盒中心点
245
+ * @param {Vector2} [target=new Vector2()] 目标点(用以存放二维包围盒中心点)
246
+ * @returns {Vector2} 二维包围盒中心点
247
+ */
248
+ getCenter(target?: Vector2): Vector2;
249
+ /**
250
+ * 获取二维包围盒大小
251
+ * @param {Vector2} [target=new Vector2()] 目标向量(用以存放二维包围盒大小)
252
+ * @returns {Vector2} 二维包围盒大小
253
+ */
254
+ getSize(target?: Vector2): Vector2;
255
+ /**
256
+ * 通过二维空间点扩展二维包围盒
257
+ * @param {Vector2} point 二维空间点
258
+ * @returns {Box2} 扩展包围盒
259
+ */
260
+ expandByPoint(point: Vector2): this;
261
+ /**
262
+ * 通过向量扩展二维包围盒
263
+ * @param {Vector2} vector 二维向量
264
+ * @returns {Box2} 扩展结果
265
+ */
266
+ expandByVector(vector: Vector2): this;
267
+ /**
268
+ * 通过大小扩展二维包围盒
269
+ * @param {number} scalar 扩展大小
270
+ * @returns {Box2} 扩展结果
271
+ */
272
+ expandByScalar(scalar: number): this;
273
+ /**
274
+ * 判断二维包围盒是否包含二维空间点
275
+ * @param {Vector2} point 二维空间点
276
+ * @param {boolean} [isOrthogonal=true] 包围盒正交判断(默认为true)
277
+ * @returns {boolean} 点包含判断结果
278
+ */
279
+ containsPoint(point: Vector2, isOrthogonal?: boolean): boolean;
280
+ /**
281
+ * 判断二维包围盒包含关系(if this contains other)
282
+ * @param {Box2} box 其它包围盒
283
+ * @returns {boolean} 二维包围盒包含判断结果
284
+ */
285
+ containsBox(box: Box2): boolean;
286
+ /**
287
+ * 获取点以包围盒左上角顶点为原点的相对位置
288
+ * @param {Vector2} point 指定二维空间点
289
+ * @param {Vector2} [target=new Vector2()] 目标空间点
290
+ * @returns {Vector2} 计算结果空间点
291
+ */
292
+ getParameter(point: Vector2, target?: Vector2): Vector2;
293
+ /**
294
+ * 求点与二维包围盒的最近点
295
+ * @param {Vector2} point 二维空间点
296
+ * @param {Vector2} [target=new Vector2()] 结果点
297
+ * @returns {Vector2} 二维空间点
298
+ */
299
+ clampPoint(point: Vector2, target?: Vector2): Vector2;
300
+ /**
301
+ * 求点到二维包围盒的距离
302
+ * @param {Vector2} point 二维空间点
303
+ * @returns {number} 距离
304
+ */
305
+ distanceToPoint(point: Vector2): number;
306
+ /**
307
+ * 二维包围盒求交集
308
+ * @param {Box2} box 二维包围盒
309
+ * @returns {Box2} 求交结果
310
+ */
311
+ intersect(box: Box2): this;
312
+ /**
313
+ * 二维包围盒求并集
314
+ * @param {Box2} box 二维包围盒
315
+ * @returns {Box2} 求并结果
316
+ */
317
+ union(box: Box2): this;
318
+ /**
319
+ * 二维包围盒位移
320
+ * @param {Vector2} offset 位移向量
321
+ * @returns {Box2} 位移结果
322
+ */
323
+ translate(offset: Vector2): this;
324
+ scaleByCenter(scalar: number | Vector2, anchor?: Vector2): this;
325
+ scale(scalar: number, center?: Vector2): this;
326
+ /**
327
+ * 二维包围盒判等
328
+ * @param {Box2} box 二维包围盒
329
+ * @returns {boolean} 判等结果
330
+ */
331
+ equals(box: Box2): boolean;
332
+ /**
333
+ * 判断二维包围盒相交关系(if this intersect other)
334
+ * @param {Box2} box 二维包围盒
335
+ * @param {boolean} [isOrthogonal=true] 正交判断(当前包围盒)
336
+ * @returns {boolean} 相交判断结果
337
+ */
338
+ intersectsBox(box: Box2, isOrthogonal?: boolean): boolean;
339
+ rotate(angle: number, center?: Vector2): this;
340
+ }
341
+
342
+ type CreateOperation = {
343
+ type: 'create';
344
+ newData: ItemCreateInfo;
345
+ };
346
+ type DeleteOperation = {
347
+ type: 'delete';
348
+ oldData: ItemCreateInfo;
349
+ };
350
+ type UpdateOperation = {
351
+ type: 'update';
352
+ newData: ItemCreateInfo;
353
+ oldData: ItemCreateInfo;
354
+ };
355
+ type Operation = CreateOperation | UpdateOperation | DeleteOperation;
356
+ declare class UndoRedo {
357
+ private index;
358
+ private operations;
359
+ get canUndo(): boolean;
360
+ get canRedo(): boolean;
361
+ push(operation: Operation): void;
362
+ undo(): Operation | undefined;
363
+ redo(): Operation | undefined;
364
+ clear(): void;
365
+ }
366
+
367
+ declare const MEDIA_TYPE: {
368
+ readonly APNG: "APNG";
369
+ readonly MP4: "MP4";
370
+ readonly WebM: "WebM";
371
+ readonly Images: "Images";
372
+ readonly WebP: "WebP";
373
+ readonly GIF: "GIF";
374
+ readonly AlphaMaskVideo: "AlphaMaskVideo";
375
+ };
376
+ /**
377
+ * GIF 压缩参数
378
+ * 核心通过参数 flags + palettegen + paletteuse 实现
379
+ * highest: lanczos + max_colors=256 + dither=bayer
380
+ * high: bicubic + max_colors=200 + dither=bayer
381
+ * medium: bilinear + max_colors=64 + dither=bayer
382
+ * low: neighbor + max_colors=32 + dither=none
383
+ */
384
+ declare const GIF_QUALITY_TO_FFMPEG_ARGS: {
385
+ highest: string;
386
+ high: string;
387
+ medium: string;
388
+ low: string;
389
+ };
390
+
391
+ declare global {
392
+ interface Window {
393
+ /**
394
+ * @description 创建 WebP Core 实例
395
+ */
396
+ createWebPCore: (config: any) => Promise<Img2WebPCore>;
397
+ }
398
+ }
399
+ type FileBuffer = ArrayBuffer | Uint8Array;
400
+ type MediaType = typeof MEDIA_TYPE[keyof typeof MEDIA_TYPE];
401
+ type FS = {
402
+ writeFile: (path: string, data: Uint8Array | string) => void;
403
+ readFile(path: string, opts: {
404
+ encoding: 'binary';
405
+ flags?: string | undefined;
406
+ }): Uint8Array;
407
+ readFile(path: string, opts: {
408
+ encoding: 'utf8';
409
+ flags?: string | undefined;
410
+ }): string;
411
+ readFile(path: string, opts?: {
412
+ flags?: string | undefined;
413
+ }): Uint8Array;
414
+ unlink: (path: string) => void;
415
+ quit: () => void;
416
+ };
417
+ type Pointer = number;
418
+ type Img2WebPCore = {
419
+ FS: FS;
420
+ run: (...args: string[]) => number;
421
+ cwrap: (ident: string, returnType: string, argTypes: string[]) => ((argc: number, argv: Pointer) => number);
422
+ _malloc: (size: number) => Pointer;
423
+ writeAsciiToMemory: (str: string, buffer: number, dontAddNull?: boolean) => void;
424
+ setValue: (ptr: number, value: any, type: string, noSafe?: boolean) => void;
425
+ };
426
+ type ExportMediaInitOptions = {
427
+ /**
428
+ * 导出类型
429
+ */
430
+ mediaType: MediaType;
431
+ /**
432
+ * 额外画布,导出透明视频时使用
433
+ */
434
+ extraCanvas?: HTMLCanvasElement | null;
435
+ /**
436
+ * 是否打印转码过程中的日志,仅在导出 MP4/AlphaMaskVideo 时有效, 默认 false
437
+ * 供开发调试使用
438
+ */
439
+ loggerInTranscoding?: boolean;
440
+ /**
441
+ * ffmpeg 转码是否开启多线程,默认 false,确保环境支持 SharedArrayBuffer
442
+ */
443
+ multiThreading?: boolean;
444
+ /**
445
+ * 是否输出 buffer,默认 false
446
+ */
447
+ isOutputBuffer?: boolean;
448
+ };
449
+ type GifConfig = {
450
+ /**
451
+ * @description GIF 导出时的帧率
452
+ */
453
+ fps?: number;
454
+ /**
455
+ * @description GIF 导出时的缩放比例
456
+ * 默认 '-1:-1', 表示不缩放
457
+ * 例如 '100:-1', 表示宽度 100,高度自动
458
+ * 例如 '-1:100', 表示宽度自动,高度 100
459
+ */
460
+ scale?: string;
461
+ /**
462
+ * @description GIF 导出时的质量
463
+ * 默认 'highest'
464
+ * 可选 'highest', 'high', 'medium', 'low'
465
+ */
466
+ quality?: keyof typeof GIF_QUALITY_TO_FFMPEG_ARGS;
467
+ };
468
+ type ApngConfig = {
469
+ /**
470
+ * @description APNG 导出时的帧率
471
+ */
472
+ fps?: number;
473
+ /**
474
+ * @description APNG 导出时的缩放比例
475
+ * 默认 '-1:-1', 表示不缩放
476
+ * 例如 '100:-1', 表示宽度 100,高度自动
477
+ * 例如 '-1:100', 表示宽度自动,高度 100
478
+ */
479
+ scale?: string;
480
+ /**
481
+ * @description APNG 导出时的质量
482
+ * 默认 'highest'
483
+ * 可选 'highest', 'high', 'medium', 'low'
484
+ */
485
+ quality?: keyof typeof GIF_QUALITY_TO_FFMPEG_ARGS;
486
+ };
487
+ type ExportMediaItemOptions = {
488
+ /**
489
+ * 尺寸
490
+ */
491
+ size: [number, number];
492
+ /**
493
+ * 动效资源
494
+ */
495
+ scene: spec.JSONScene;
496
+ /**
497
+ * 视频时长,目前仅在导出 MP4 / AlphaMaskVideo 时有效,默认取动效资源时长
498
+ */
499
+ time?: number;
500
+ /**
501
+ * 是否生成音轨,默认 false,仅在导出 MP4 时有效
502
+ */
503
+ audioEnable?: boolean;
504
+ /**
505
+ * 帧率, 默认 30
506
+ */
507
+ fps?: number;
508
+ /**
509
+ * 是否循环,默认 true
510
+ */
511
+ loop?: boolean;
512
+ /**
513
+ * 视频背景颜色,默认 #000000
514
+ */
515
+ backgroundColor?: string;
516
+ /**
517
+ * 导出 GIF 时,设置的导出配置
518
+ */
519
+ gifConfig?: GifConfig;
520
+ apngConfig?: ApngConfig;
521
+ };
522
+
523
+ type SDKMode = 'editor' | 'template';
524
+ /**
525
+ * @description SDK功能配置
526
+ */
527
+ type SDKConfig = {
528
+ /**
529
+ * @description SDK编辑模式 - 模板编辑 | 产物编辑
530
+ */
531
+ mode: SDKMode;
532
+ /**
533
+ * @description 页面功能配置
534
+ */
535
+ pageConfig: PageConfig$1;
536
+ /**
537
+ * @description 截图功能配置
538
+ */
539
+ screenShotConfig: ScreenShotConfig;
540
+ /**
541
+ * @description 导出视频功能配置
542
+ */
543
+ exportConfig: ExportConfig;
544
+ /**
545
+ * @description 尺寸自适应功能开关
546
+ */
547
+ sizeAdaptConfig: SizeAdaptConfig;
548
+ /**
549
+ * @description 辅助面板功能配置
550
+ */
551
+ gestureHandlerConfig: {
552
+ enabled: boolean;
553
+ adsorptionGizmoEnabled: boolean;
554
+ adsorptionGizmoConfig: AdsorptionGizmoConfig;
555
+ controlGizmoEnabled: boolean;
556
+ controlGizmoConfig: ControlGizmoConfig;
557
+ preferenceGizmoEnabled: boolean;
558
+ preferenceGizmoConfig: PreferenceGizmoConfig;
559
+ selectorGizmoEnabled: boolean;
560
+ selectorGizmoConfig: SelectorGizmoConfig;
561
+ transformGizmoEnabled: boolean;
562
+ transformGizmoConfig: TransformGizmoConfig;
563
+ pictureCutGizmoEnabled: boolean;
564
+ pictureCutGizmoConfig: PictureCutGizmoConfig;
565
+ pictureExpandGizmoEnabled: boolean;
566
+ pictureExpandGizmoConfig: PictureExpandGizmoConfig;
567
+ textGizmoEnbaled: boolean;
568
+ textGizmoConfig: TextGizmoConfig;
569
+ maskGizmoEnabled: boolean;
570
+ maskGizmoConfig: MaskGizmoConfig;
571
+ };
572
+ };
573
+ /**
574
+ * @description 页面功能配置
575
+ */
576
+ type PageConfig$1 = {
577
+ /**
578
+ * @description 同步修改功能开关
579
+ */
580
+ asncMode: boolean;
581
+ /**
582
+ * @description 静态预览【视图只提供播放预览功能】功能开关
583
+ */
584
+ staticPreview: boolean;
585
+ /**
586
+ * @description 静态预览视图名称
587
+ */
588
+ staticPreviewName: string;
589
+ /**
590
+ * @description 需过滤的元素名称
591
+ */
592
+ filterItemNames: string[];
593
+ /**
594
+ * @description 成组操作元素显隐
595
+ */
596
+ groupVisible: boolean;
597
+ /**
598
+ * @description 缩放最大值
599
+ */
600
+ maxZoom: number;
601
+ /**
602
+ * @description 缩放最小值
603
+ */
604
+ minZoom: number;
605
+ };
606
+ /**
607
+ * @description 视频导出功能配置
608
+ */
609
+ type ExportConfig = {
610
+ enabled: boolean;
611
+ } & ExportMediaInitOptions;
612
+ /**
613
+ * @description 截图功能配置
614
+ */
615
+ type ScreenShotConfig = {
616
+ enabled: boolean;
617
+ };
618
+ /**
619
+ * @description 尺寸自适应功能配置
620
+ */
621
+ type SizeAdaptConfig = {
622
+ enabled: boolean;
623
+ };
624
+ /**
625
+ * @description 对齐吸附功能参数
626
+ */
627
+ type AdsorptionGizmoConfig = {
628
+ /**
629
+ * @description 对齐吸附线宽
630
+ */
631
+ lineWidth: number;
632
+ /**
633
+ * @description 对齐线颜色
634
+ */
635
+ lineColor: number;
636
+ /**
637
+ * @description 对齐吸附距离
638
+ */
639
+ distance: number;
640
+ };
641
+ /**
642
+ * @description 视图控制功能参数
643
+ */
644
+ type ControlGizmoConfig = {
645
+ /**
646
+ * @description 缩放步长
647
+ */
648
+ zoomStep: number;
649
+ };
650
+ /**
651
+ * @description 视口展示功能参数
652
+ */
653
+ type PreferenceGizmoConfig = {
654
+ /**
655
+ * @description 视口窗包围盒颜色
656
+ */
657
+ boxColor: number;
658
+ /**
659
+ * @description 视口窗包围盒宽度
660
+ */
661
+ boxWidth: number;
662
+ /**
663
+ * @description 视口区域外遮罩颜色
664
+ */
665
+ markColor: number;
666
+ /**
667
+ * @description 视口区域外遮罩透明度
668
+ */
669
+ markAlpha: number;
670
+ /**
671
+ * @description 出血区预览开关
672
+ */
673
+ safeAreaEnabled: boolean;
674
+ /**
675
+ * @description 出血区颜色
676
+ */
677
+ safeAreaBoxColor: number;
678
+ /**
679
+ * @description 出血区透明度
680
+ */
681
+ safeAreaBoxAlpha: number;
682
+ };
683
+ /**
684
+ * @description 选择功能参数
685
+ */
686
+ type SelectorGizmoConfig = {
687
+ /**
688
+ * @description 预选框线宽
689
+ */
690
+ preSelectedWidth: number;
691
+ /**
692
+ * @description 预选框颜色
693
+ */
694
+ preSelectedColor: number;
695
+ /**
696
+ * @description 框选区域颜色
697
+ */
698
+ regionBoxColor: number;
699
+ /**
700
+ * @description 框选区域透明度
701
+ */
702
+ regionBoxAlpha: number;
703
+ /**
704
+ * @description 框选区域包围框颜色
705
+ */
706
+ regionWireframeColor: number;
707
+ /**
708
+ * @description 框选区域包围框透明度
709
+ */
710
+ regionWireframeAlpha: number;
711
+ /**
712
+ * @description 框选区域包围框宽度
713
+ */
714
+ regionWireframeWidth: number;
715
+ };
716
+ /**
717
+ * @description 变换功能参数
718
+ */
719
+ type TransformGizmoConfig = {
720
+ /**
721
+ * @description 变换交互框颜色
722
+ */
723
+ wireframeColor: number;
724
+ /**
725
+ * @description 变换交互框透明度
726
+ */
727
+ wireframeAlpha: number;
728
+ /**
729
+ * @description 变换交互框宽度
730
+ */
731
+ wireframeWidth: number;
732
+ /**
733
+ * @description 变换交互框角点填充色
734
+ */
735
+ cornerFillColor: number;
736
+ /**
737
+ * @description 变换交互框角点线框色
738
+ */
739
+ cornerLineColor: number;
740
+ /**
741
+ * @description 变换交互框角点线框宽度
742
+ */
743
+ cornerLineWidth: number;
744
+ /**
745
+ * @description 变换交互框角点线框透明度
746
+ */
747
+ cornerLineAlpha: number;
748
+ /**
749
+ * @description 交互框缩放圆半径
750
+ */
751
+ scaleCircleSize: number;
752
+ /**
753
+ * @description 交互框旋转圆半径
754
+ */
755
+ rotationCircleSize: number;
756
+ /**
757
+ * @description 图片Logo地址
758
+ */
759
+ pictureLogoUrl: string;
760
+ /**
761
+ * @description
762
+ */
763
+ nullLogoUrl: string;
764
+ /**
765
+ * @description 大小文字颜色
766
+ */
767
+ sizeTextColor: number;
768
+ /**
769
+ * @description 名称文字颜色
770
+ */
771
+ nameTextColor: number;
772
+ };
773
+ /**
774
+ * @description 图片裁切参数
775
+ */
776
+ type PictureCutGizmoConfig = {
777
+ /**
778
+ * @description 蒙版颜色
779
+ */
780
+ maskColor: number;
781
+ /**
782
+ * @description 蒙版透明度
783
+ */
784
+ maskAlpha: number;
785
+ /**
786
+ * @description 裁切包围盒线框宽度
787
+ */
788
+ cutBoxLineWidth: number;
789
+ /**
790
+ * @description 裁切包围盒线框颜色
791
+ */
792
+ cutBoxLineColor: number;
793
+ /**
794
+ * @description 裁切包围盒线框透明度
795
+ */
796
+ cutBoxLineAlpha: number;
797
+ /**
798
+ * @description 元素包围盒线框宽度
799
+ */
800
+ itemBoxLineWidth: number;
801
+ /**
802
+ * @description 元素包围盒线框颜色
803
+ */
804
+ itemBoxLineColor: number;
805
+ /**
806
+ * @description 元素包围盒线框透明度
807
+ */
808
+ itemBoxLineAlpha: number;
809
+ /**
810
+ * @description 裁切包围盒角度半径
811
+ */
812
+ cutBoxCornerRadius: number;
813
+ /**
814
+ * @description 裁切包围盒角点宽度
815
+ */
816
+ cutBoxCornerLineWidth: number;
817
+ /**
818
+ * @description 裁切包围盒角点颜色
819
+ */
820
+ cutBoxCornerLineColor: number;
821
+ /**
822
+ * @description 裁切包围盒角点透明度
823
+ */
824
+ cutBoxCornerLineAlpha: number;
825
+ /**
826
+ * @description 裁切包围盒角点填充色
827
+ */
828
+ cutBoxCornerFillColor: number;
829
+ /**
830
+ * @description 缩放判断距离
831
+ */
832
+ scaleInteractionDistance: number;
833
+ /**
834
+ * @description 单向缩放判断距离
835
+ */
836
+ directionScaleInteractionDistance: number;
837
+ };
838
+ /**
839
+ * @description 图片扩边参数
840
+ */
841
+ type PictureExpandGizmoConfig = {
842
+ /**
843
+ * @description 蒙版颜色
844
+ */
845
+ maskColor: number;
846
+ /**
847
+ * @description 蒙版透明度
848
+ */
849
+ maskAlpha: number;
850
+ /**
851
+ * @description 扩边包围盒线框宽度
852
+ */
853
+ expandBoxLineWidth: number;
854
+ /**
855
+ * @description 扩边包围盒线框颜色
856
+ */
857
+ expandBoxLineColor: number;
858
+ /**
859
+ * @description 扩边包围盒线框透明度
860
+ */
861
+ expandBoxLineAlpha: number;
862
+ /**
863
+ * @description 扩边包围盒角度半径
864
+ */
865
+ expandBoxCornerRadius: number;
866
+ /**
867
+ * @description 扩边包围盒角点宽度
868
+ */
869
+ expandBoxCornerLineWidth: number;
870
+ /**
871
+ * @description 扩边包围盒角点颜色
872
+ */
873
+ expandBoxCornerLineColor: number;
874
+ /**
875
+ * @description 扩边包围盒角点透明度
876
+ */
877
+ expandBoxCornerLineAlpha: number;
878
+ /**
879
+ * @description 扩边包围盒角点填充色
880
+ */
881
+ expandBoxCornerFillColor: number;
882
+ /**
883
+ * @description 缩放判断距离
884
+ */
885
+ scaleInteractionDistance: number;
886
+ /**
887
+ * @description 单向缩放判断距离
888
+ */
889
+ directionScaleInteractionDistance: number;
890
+ };
891
+ /**
892
+ * @description 文本交互控制器参数
893
+ */
894
+ type TextGizmoConfig = {
895
+ /**
896
+ * @description 包围盒线宽
897
+ */
898
+ boxLineWidth: number;
899
+ /**
900
+ * @description 包围盒线色
901
+ */
902
+ boxLineColor: number;
903
+ /**
904
+ * @description 缩放交互点半径
905
+ */
906
+ scaleCornerRadius: number;
907
+ /**
908
+ * @description 旋转交互点边长
909
+ */
910
+ rotationCornerWidth: number;
911
+ /**
912
+ * @description 旋转交互贴图地址
913
+ */
914
+ rotationCornerTexture: string;
915
+ /**
916
+ * @description 缩放交互点填充色
917
+ */
918
+ scaleCornerFillColor: number;
919
+ /**
920
+ * @description 缩放交互点描边宽度
921
+ */
922
+ scaleCornerStrokeWidth: number;
923
+ /**
924
+ * @description 缩放交互点描边颜色
925
+ */
926
+ scaleCornerStrokeColor: number;
927
+ };
928
+ /**
929
+ * @description 蒙版参数
930
+ */
931
+ type MaskGizmoConfig = {
932
+ /**
933
+ * @description 画笔大小
934
+ */
935
+ brushSize: number;
936
+ /**
937
+ * @description 笔刷颜色
938
+ */
939
+ brushColor: number;
940
+ /**
941
+ * @description 笔刷透明度
942
+ */
943
+ brushAlpha: number;
944
+ /**
945
+ * @description 蒙版颜色
946
+ */
947
+ maskColor: number;
948
+ /**
949
+ * @description 蒙版透明度
950
+ */
951
+ maskAlpha: number;
952
+ /**
953
+ * @description 元素包围盒线框宽度
954
+ */
955
+ boxLineWidth: number;
956
+ /**
957
+ * @description 元素包围盒线框颜色
958
+ */
959
+ boxLineColor: number;
960
+ /**
961
+ * @description 元素包围盒线框透明度
962
+ */
963
+ boxLineAlpha: number;
964
+ };
965
+
966
+ type SDKEvents = {
967
+ 'loadingItemChange': [id: string[]];
968
+ 'selectedItemChange': [id: string[]];
969
+ 'preSelectedItemChange': [id: string | undefined];
970
+ 'selectedViewChange': [id: number];
971
+ 'pageDataChange': [pageData: PageData];
972
+ 'zoomChange': [zoom: number];
973
+ 'progress': [{
974
+ duration: number;
975
+ time: number;
976
+ end: boolean;
977
+ paused: boolean;
978
+ }];
979
+ 'itemPropertyChange': [{
980
+ id: string;
981
+ property: string;
982
+ }];
983
+ 'exportProgress': [progress?: number];
984
+ 'exportDone': [item: ExportMediaItemOptions | undefined, success: boolean, buffer?: FileBuffer];
985
+ 'exportComplete': [success: boolean, taskInfos: ExportMediaItemOptions[], buffers?: FileBuffer[]];
986
+ 'sdkConfigChange': [preSDKConfig: SDKConfig, curSDKConfig: SDKConfig];
987
+ 'cutBoxChange': [box: Box2];
988
+ 'expandBoxChange': [box: Box2];
989
+ 'textInput': [{
990
+ text: string;
991
+ fontFamily: string;
992
+ }];
993
+ 'canvasChange': [Operation];
994
+ 'viewportTransform': [{
995
+ zoom: number;
996
+ translatoion: [number, number];
997
+ }];
998
+ };
999
+ declare class SDK {
1000
+ static config: SDKConfig;
1001
+ private _eventEmitter;
1002
+ private _pageData;
1003
+ private _screenShot;
1004
+ private _exporter?;
1005
+ private _pageDataUtils;
1006
+ private _sizeAdapt;
1007
+ private _gestureHandler;
1008
+ private disposables;
1009
+ private _isSwitchScene;
1010
+ private _canvasUndoRedo;
1011
+ player: Player;
1012
+ _container: HTMLElement;
1013
+ private _playerContainer;
1014
+ constructor(container: HTMLElement, mode?: SDKMode);
1015
+ get container(): HTMLElement;
1016
+ get pageData(): PageData | undefined;
1017
+ get exportStatus(): string | undefined;
1018
+ get canvasUndoRedo(): UndoRedo;
1019
+ private get exportOptions();
1020
+ dispose(): void;
1021
+ on: <E extends "progress" | "loadingItemChange" | "selectedItemChange" | "preSelectedItemChange" | "selectedViewChange" | "pageDataChange" | "zoomChange" | "itemPropertyChange" | "exportProgress" | "exportDone" | "exportComplete" | "sdkConfigChange" | "cutBoxChange" | "expandBoxChange" | "textInput" | "canvasChange" | "viewportTransform">(eventName: E, listener: _galacean_effects.EventEmitterListener<SDKEvents[E]>, options?: _galacean_effects.EventEmitterOptions) => () => void;
1022
+ setSDKMode(mode: SDKMode): void;
1023
+ private getInitParam;
1024
+ /**
1025
+ * 检测导出是否需要重新初始化
1026
+ * @param preExportVideoConfig
1027
+ * @param curExportVideoConfig
1028
+ */
1029
+ private checkExporter;
1030
+ private initExporter;
1031
+ private initSDK;
1032
+ run(param: SDKInputParam): Promise<void>;
1033
+ getPageData(): PageData;
1034
+ getActiveItems(): string[];
1035
+ setPreSelectedItem(id: string): void;
1036
+ getPreSelectedItem(): string;
1037
+ setSelectedItems(itemIds: string[]): void;
1038
+ /**
1039
+ * @description 获取目标元素的所有属性
1040
+ * @param param 元素ID、类型
1041
+ * @returns 元素属性
1042
+ */
1043
+ getItemProperty<T extends keyof PageFormTypeAndPropertyReference>(param: GetItemPropertyParam<T>): GetItemPropertyResult<T> | undefined;
1044
+ /**
1045
+ * @description 获取目标元素的指定属性
1046
+ * @param param 元素ID、类型、属性名
1047
+ * @returns 元素属性值
1048
+ */
1049
+ getItemPropertyValue<T extends keyof PageFormTypeAndPropertyReference, N extends keyof PageFormTypeAndPropertyReference[T]>(param: GetItemPropertyValueParam<T, N>): GetItemPropertyValueResult<T, N> | undefined;
1050
+ setItemPropertyValue(param: SetItemPropertyValueParam): Promise<void>;
1051
+ generateScreenShot(id: number, size?: [number, number], tick?: number, backgroundColor?: spec.vec4): Promise<string | undefined>;
1052
+ /**
1053
+ * @description 切换场景
1054
+ * @param index 场景索引
1055
+ */
1056
+ switchScene(index: number): Promise<void>;
1057
+ /**
1058
+ * @description 获取页面的 safeAreaPreview、zoom、adsorption 值
1059
+ * @returns 页面的 safeAreaPreview、zoom、adsorption 值
1060
+ */
1061
+ getPageConfig(): PageConfig;
1062
+ /**
1063
+ * 设置页面的 safeAreaPreview、zoom、adsorption 值
1064
+ * @param pageProperty 设置
1065
+ */
1066
+ setPageConfig(pageConfig: PageConfig): void;
1067
+ /**
1068
+ * @description 设置播放进度
1069
+ * @param progress 播放进度 0-100
1070
+ */
1071
+ setPlayProgress(progress: number): Promise<void>;
1072
+ getViewItems(): ViewItem[];
1073
+ setPlayState(playState: 'play' | 'pause'): Promise<void>;
1074
+ /**
1075
+ * @description 获取场景预览图
1076
+ * @returns 视图预览图
1077
+ */
1078
+ getViewThumbnail(): Promise<{
1079
+ id: number;
1080
+ thumbnail: string | undefined;
1081
+ }>[];
1082
+ /**
1083
+ * @description 获取视图JSON产物
1084
+ * @returns 当前所有视图JSON产物
1085
+ */
1086
+ getViewScene(): {
1087
+ id: number;
1088
+ thumbnail: spec.JSONScene;
1089
+ }[];
1090
+ private destroyCompositions;
1091
+ /**
1092
+ * @description 导出,支持导出媒体或其他,如MP4,未来支持 JSON 等;
1093
+ */
1094
+ onExport(): void;
1095
+ /**
1096
+ * @description 取消导出
1097
+ */
1098
+ cancelExport(): void;
1099
+ loadPageData(data: PageData): Promise<void>;
1100
+ runByPageData(data: PageData): Promise<void>;
1101
+ reloadPageDataByScene(scene: string | spec.JSONScene): Promise<void>;
1102
+ addViewParams(viewParams: ViewParam[]): Promise<void>;
1103
+ deleteViewParams(ids: number[]): Promise<void>;
1104
+ setExportParam(exportParam: Partial<ExportParam>, id?: number): void;
1105
+ /**
1106
+ * @description 设置视图缩放
1107
+ * @param zoom 缩放值
1108
+ */
1109
+ setPageZoom(zoom: number): void;
1110
+ /**
1111
+ * @description 设置静态预览功能开关
1112
+ * @param enabled 功能开关
1113
+ */
1114
+ setStaticPreviewEnabled(enabled: boolean): void;
1115
+ /**
1116
+ * @description 设置静态预览视图名称
1117
+ * @param name 视图名称
1118
+ */
1119
+ setStaticPreviewName(name: string): void;
1120
+ /**
1121
+ * @description 设置同步修改功能开关
1122
+ * @param enabled 功能开关
1123
+ */
1124
+ setAsyncEnabled(enabled: boolean): void;
1125
+ /**
1126
+ * @description 设置 成组显影 开关
1127
+ */
1128
+ setGroupVisibleEnabled(enabled: boolean): void;
1129
+ /**
1130
+ * @description 新增过滤元素名称
1131
+ * @param itemNames 过滤元素名称
1132
+ */
1133
+ addFilterItemNames(itemNames: string[] | string): void;
1134
+ /**
1135
+ * @description 设置预览辅助层颜色
1136
+ * @param color 色值
1137
+ */
1138
+ setPreferenceBackgroundColor(color: [number, number, number, number]): void;
1139
+ /**
1140
+ * @description 设置出血区颜色
1141
+ * @param color 色值
1142
+ */
1143
+ setSafeAreaColor(color: [number, number, number, number]): void;
1144
+ /**
1145
+ * @description 设置 尺寸自适应拓展 功能开关
1146
+ * @param enabled 功能开关
1147
+ */
1148
+ setSizeAdaptEnabled(enabled: boolean): void;
1149
+ /**
1150
+ * @description 设置 截图 功能开关
1151
+ * @param enabled 功能开关
1152
+ */
1153
+ setScreenShotEnabled(enabled: boolean): void;
1154
+ /**
1155
+ * @description 设置导出功能初始化配置
1156
+ * @param exportConfig
1157
+ */
1158
+ setExportConfig(exportConfig: Partial<ExportConfig>): void;
1159
+ /**
1160
+ * @description 设置预选框参数
1161
+ * @param preSelectedColor 预选框颜色
1162
+ * @param preSelectedWidth 预选框线框宽度
1163
+ */
1164
+ setSelectorGizmoPreSelectConfig(preSelectedColor?: number, preSelectedWidth?: number): void;
1165
+ /**
1166
+ * @description 设置 变换控制器 交互框参数
1167
+ * @param config 参数
1168
+ */
1169
+ setTranformGizmoWireframeConfig(config: {
1170
+ wireframeColor?: number;
1171
+ wireframeAlpha?: number;
1172
+ wireframeWidth?: number;
1173
+ }): void;
1174
+ /**
1175
+ * @description 获取 SDK 配置参数
1176
+ * @returns SDK 配置参数
1177
+ */
1178
+ getSDKConfig(): SDKConfig;
1179
+ /**
1180
+ * @description 设置 SDK 配置参数
1181
+ * @param config SDK 配置参数
1182
+ */
1183
+ setSDKConfig(config: SDKConfig): void;
1184
+ /**
1185
+ * @description 设置SDK背景
1186
+ * @param type 背景类型
1187
+ * @param value 值
1188
+ */
1189
+ setSDKBackground(type: SDKBackgroundType, value?: string): void;
1190
+ /**
1191
+ * @description 创建图层元素
1192
+ * @param spriteInfo 图层元素信息
1193
+ */
1194
+ addSpriteItem(spriteInfo: SpriteCreateInfo): Promise<string | undefined>;
1195
+ openPictureCutGizmo(): void;
1196
+ closePictureCutGizmo(): void;
1197
+ getCutInfo(): {
1198
+ cutBox: Box2;
1199
+ itemBox: Box2;
1200
+ } | undefined;
1201
+ setCutBox(min: Vector2, max: Vector2): Box2 | undefined;
1202
+ openPictureExpandGizmo(): void;
1203
+ closePictureExpandGizmo(): void;
1204
+ getExpandInfo(): {
1205
+ expandBox: Box2;
1206
+ itemBox: Box2;
1207
+ } | undefined;
1208
+ setExpandBox(min: Vector2, max: Vector2): Box2 | undefined;
1209
+ openMaskGizmo(brushSize: number): void;
1210
+ clearMaskGizmo(): void;
1211
+ closeMaskGizmo(): void;
1212
+ getMask(): string | null | undefined;
1213
+ setMaskGizmoConfig(config: Partial<MaskGizmoConfig>): void;
1214
+ openLoadingGizmo(id: string): void;
1215
+ closeLoadingGizmo(id: string): void;
1216
+ /**
1217
+ * @description 元素打组
1218
+ * @param children 子元素ID
1219
+ */
1220
+ groupItems(nullInfo: NullCreateInfo): string | undefined;
1221
+ addTextItem(textInfo: TextCreateInfo): Promise<void>;
1222
+ deleteItems(idInfo: string | string[]): void;
1223
+ getItemCreateInfo(idInfo: string | string[]): ItemCreateInfo[];
1224
+ createScreenShotSceneByIds(idInfo: string | string[], time?: number): Promise<string | undefined>;
1225
+ getChildrenIds(id: string): string[];
1226
+ /**
1227
+ * @description 更新元素在图层中的顺序
1228
+ * @param id 元素ID
1229
+ * @param action 排序操作:BringToFront(置于顶层)、SendToBack(置于底层)、BringForward(上移一层)、SendBackward(下移一层)
1230
+ */
1231
+ updateItemOrder(id: string, action: ItemOrderAction): void;
1232
+ /**
1233
+ * @description 导出JSON
1234
+ * @param idInfo 视图序号信息
1235
+ * @returns JSON数组
1236
+ */
1237
+ exportJSON(idInfo?: number | number[]): spec.JSONScene[];
1238
+ getViewBoxById(id: string): Box2;
1239
+ getViewItemById(id: string): ViewItem | undefined;
1240
+ getViewProperty(id: number): ViewProperty | undefined;
1241
+ pageMove(shift: [number, number]): void;
1242
+ pageZoom(shift: number, center?: [number, number]): void;
1243
+ setPictureCutGizmoLockScale(state: boolean): void;
1244
+ setPictureExpandGizmoLockScale(state: boolean): void;
1245
+ viewportFit(): void;
1246
+ }
1247
+
1248
+ type SizeAdaptDirection = 'x' | 'y';
48
1249
 
49
1250
  type BaseFormProperty = {
50
- position: [number, number, number];
1251
+ position: [number, number];
51
1252
  rotation: [number, number, number];
52
- scale: [number, number, number];
1253
+ size: [number, number];
1254
+ visible: boolean;
53
1255
  keyPropertyEditing: boolean;
54
1256
  };
55
1257
  type SpriteFormProperty = BaseFormProperty & {
56
1258
  image: string;
57
1259
  };
58
1260
  type TextFormProperty = BaseFormProperty & {
59
- font: string;
60
- color: [number, number, number, number];
61
- weight: spec.TextWeight;
1261
+ fontFamily: string;
1262
+ textColor: [number, number, number, number];
1263
+ fontWeight: spec.TextWeight;
62
1264
  text: string;
63
- alignment: spec.TextAlignment;
1265
+ textAlign: spec.TextAlignment;
1266
+ fontSize: number;
1267
+ fontStyle: spec.FontStyle;
1268
+ textWidth: number;
1269
+ lineHeight: number;
1270
+ outlineColor?: spec.vec4;
1271
+ outlineWidth?: number;
64
1272
  };
65
1273
  /**
66
1274
  * @description 页面表单类型和属性引用
@@ -93,26 +1301,37 @@ type SpecificPageFormProps<T extends keyof PageFormTypeAndPropertyReference> = {
93
1301
  property: PageFormTypeAndPropertyReference[T];
94
1302
  onPropertyValueChange: <N extends keyof PageFormTypeAndPropertyReference[T]>(propertyName: N, propertyValue: PageFormTypeAndPropertyReference[T][N]) => void;
95
1303
  };
1304
+ type SDKOptions = {
1305
+ /** 导出视频时,是否开启转码日志 */
1306
+ loggerInExportVideoTranscoding?: boolean;
1307
+ };
1308
+ type SDKInputParam = SDKTemplateInputParam | SDKEditorInputParam;
96
1309
  /**
97
1310
  * @description SDK入参
98
1311
  */
99
- type SDKInputParam = {
1312
+ type SDKTemplateInputParam = {
100
1313
  /**
101
1314
  * @description JSON地址
102
1315
  */
103
- scene: string;
1316
+ scene: string | spec.JSONScene;
1317
+ /**
1318
+ * @description SDK模式 - 模板编辑模式
1319
+ */
1320
+ mode: 'template';
104
1321
  /**
105
1322
  * @description 视图参数
106
1323
  */
107
- viewParams: ViewParam[];
1324
+ viewParams?: ViewParam[];
108
1325
  /**
109
1326
  * @description 页面属性
110
1327
  */
111
1328
  options: PageOptions;
1329
+ };
1330
+ type SDKEditorInputParam = {
112
1331
  /**
113
- * @description 是否开启出血区强制变换
1332
+ * @description SDK模式 - 编辑器模式
114
1333
  */
115
- keepSafe: boolean;
1334
+ mode: 'editor';
116
1335
  };
117
1336
  /**
118
1337
  * @description 页面属性
@@ -135,6 +1354,10 @@ type PageOptions = {
135
1354
  * @description 页面数据
136
1355
  */
137
1356
  type PageData = {
1357
+ /**
1358
+ * @description 基础场景数据
1359
+ */
1360
+ scene: spec.JSONScene;
138
1361
  /**
139
1362
  * @description 页面属性
140
1363
  */
@@ -176,6 +1399,10 @@ type PageConfig = {
176
1399
  * @description 吸附开关
177
1400
  */
178
1401
  adsorption: boolean;
1402
+ /**
1403
+ * @description 同步开关
1404
+ */
1405
+ asyncMode: boolean;
179
1406
  };
180
1407
  /**
181
1408
  * @description 页面属性
@@ -200,7 +1427,7 @@ type PageProperty = {
200
1427
  /**
201
1428
  * @description 同步开关
202
1429
  */
203
- sync: boolean;
1430
+ asyncMode: boolean;
204
1431
  };
205
1432
  /**
206
1433
  * @description 视图创建参数
@@ -209,50 +1436,33 @@ type ViewParam = {
209
1436
  /**
210
1437
  * @description 页面尺寸
211
1438
  */
212
- size: [number, number];
1439
+ size?: [number, number];
213
1440
  /**
214
1441
  * @description 出血区参数
215
1442
  */
216
- safeArea: SafeAreaParam;
1443
+ safeArea?: [number, number, number, number];
217
1444
  /**
218
- * @description 导出参数
1445
+ * @description 自适应方向 - 默认根据视图宽高决定
219
1446
  */
220
- export: ExportParam;
221
- };
222
- /**
223
- * @description 安全区数据
224
- */
225
- type SafeAreaParam = {
1447
+ adaptionDirection?: SizeAdaptDirection;
226
1448
  /**
227
- * @description 出血区大小 - [上, 下, 左, 右]
1449
+ * @description 自定义出血区 - 用于展示
228
1450
  */
229
- size: [number, number, number, number];
1451
+ previewSafeAreas?: PreviewSafeAreaParam[];
230
1452
  /**
231
- * @description 元素名称关键字
1453
+ * @description 导出参数
232
1454
  */
233
- keyWords: string[];
1455
+ export: ExportParam;
234
1456
  };
235
1457
  /**
236
1458
  * @description 导出参数
237
1459
  */
238
1460
  type ExportParam = {
239
1461
  /**
240
- * @description 导出视频时长
241
- */
242
- time: number;
243
- /**
244
- * @description 导出大小上限 - 单位kb
245
- */
246
- fileSizeLimit: number;
247
- /**
248
- * @description 是否开启音轨
249
- */
250
- audioEnable: boolean;
251
- /**
252
- * @description 导出视频类型 - 预留参数
1462
+ * @description 视频名称
253
1463
  */
254
- type?: string;
255
- };
1464
+ name?: string;
1465
+ } & Omit<ExportMediaItemOptions, 'scene' | 'size'>;
256
1466
  /**
257
1467
  * @description 视图属性
258
1468
  */
@@ -268,19 +1478,36 @@ type ViewProperty = {
268
1478
  /**
269
1479
  * @description 出血区数据
270
1480
  */
271
- safeArea: SafeAreaParam;
1481
+ safeArea: [number, number, number, number];
272
1482
  /**
273
- * @description 视图场景数据
1483
+ * @description 自定义出血区数据
274
1484
  */
275
- scene: spec.JSONScene;
1485
+ previewSafeAreas: PreviewSafeAreaParam[];
276
1486
  /**
277
- * @description 预览图数据
1487
+ * @description 视图场景数据
278
1488
  */
279
- thumbnail: string;
1489
+ scene: spec.JSONScene;
280
1490
  /**
281
1491
  * @description 导出参数
282
1492
  */
283
1493
  export: ExportParam;
1494
+ /**
1495
+ * @description 忽略交互 - 仅供展示
1496
+ */
1497
+ ignoreInteraction: boolean;
1498
+ };
1499
+ /**
1500
+ * @description 自定义出血区数据
1501
+ */
1502
+ type PreviewSafeAreaParam = {
1503
+ /**
1504
+ * @description 出血区包围盒 [left top width height]
1505
+ */
1506
+ box: [number, number, number, number];
1507
+ /**
1508
+ * @description 出血区色块颜色 默认为 [255, 255, 255, 0.3]
1509
+ */
1510
+ color?: [number, number, number, number];
284
1511
  };
285
1512
  /**
286
1513
  * @description 页面活跃数据
@@ -298,6 +1525,10 @@ type ActiveData = {
298
1525
  * @description 预选中元素
299
1526
  */
300
1527
  preSelectedItem?: string;
1528
+ /**
1529
+ * @description 执行中元素
1530
+ */
1531
+ loadingItems?: string[];
301
1532
  };
302
1533
  /**
303
1534
  * @description 视图元素
@@ -332,112 +1563,163 @@ type ViewItem = {
332
1563
  */
333
1564
  endBehavior: spec.EndBehavior;
334
1565
  } & ViewItemTypedProperty;
335
-
336
- declare const ExportStatusMap: {
337
- readonly DEFAULT: "default";
338
- readonly EXPORTING: "exporting";
339
- readonly SUCCESS: "success";
340
- readonly ERROR: "error";
1566
+ type SDKBackgroundType = 'color' | 'image' | 'chess-board';
1567
+ /**
1568
+ * @description 图层创建信息
1569
+ */
1570
+ type SpriteCreateInfo = {
1571
+ type: 'sprite';
1572
+ /**
1573
+ * @description 图层名称
1574
+ */
1575
+ name?: string;
1576
+ /**
1577
+ * @description 元素id
1578
+ */
1579
+ id?: string;
1580
+ /**
1581
+ * @description 父节点id
1582
+ */
1583
+ parentId?: string;
1584
+ /**
1585
+ * @description 图片资源地址
1586
+ */
1587
+ url: string;
1588
+ /**
1589
+ * @description 图层元素像素大小
1590
+ */
1591
+ size: spec.vec2;
1592
+ /**
1593
+ * @description 图层元素缩放
1594
+ */
1595
+ scale?: spec.vec2;
1596
+ /**
1597
+ * @description 图层元素旋转
1598
+ */
1599
+ rotation?: number;
1600
+ /**
1601
+ * @description 图层元素二维位置
1602
+ */
1603
+ position: spec.vec2;
341
1604
  };
342
- type ExportStatus = typeof ExportStatusMap[keyof typeof ExportStatusMap];
343
- type SDKEvents = {
344
- 'selectedItemChange': [id: string[]];
345
- 'preSelectedItemChange': [id: string | undefined];
346
- 'pageDataChange': [pageData: PageData];
347
- 'zoomChange': [zoom: number];
348
- 'progress': [{
349
- duration: number;
350
- time: number;
351
- end: boolean;
352
- paused: boolean;
353
- }];
354
- 'itemPropertyChange': [{
355
- id: string;
356
- property: string;
357
- }];
358
- 'exportProgress': [progress?: number];
359
- 'exportComplete': [success: boolean];
1605
+ /**
1606
+ * @description 空节点创建信息
1607
+ */
1608
+ type NullCreateInfo = {
1609
+ type: 'null';
1610
+ /**
1611
+ * @description 元素id
1612
+ */
1613
+ id?: string;
1614
+ /**
1615
+ * @description 父节点id
1616
+ */
1617
+ parentId?: string;
1618
+ /**
1619
+ * @description 元素名称
1620
+ */
1621
+ name?: string;
1622
+ /**
1623
+ * @description 空节点缩放
1624
+ */
1625
+ scale?: spec.vec2;
1626
+ /**
1627
+ * @description 子元素id
1628
+ */
1629
+ children: string[];
1630
+ /**
1631
+ * @description 空节点旋转
1632
+ */
1633
+ rotation?: number;
1634
+ /**
1635
+ * @description 空节点位移
1636
+ */
1637
+ position?: spec.vec2;
360
1638
  };
361
- declare class SDK {
362
- private _eventEmitter;
363
- private _pageData;
364
- private _screenShotContainer;
365
- private _screenShotPlayer;
366
- private _SDKUtils;
367
- private _ExportVideo;
368
- private _gestureHandler;
369
- private _playerContainer;
370
- private _exportStatus;
371
- private disposables;
372
- player: Player;
373
- constructor(container: HTMLElement);
374
- get pageData(): PageData | undefined;
375
- get exportStatus(): ExportStatus;
376
- private get exportOptions();
377
- dispose(): void;
378
- on: <E extends "progress" | "selectedItemChange" | "preSelectedItemChange" | "pageDataChange" | "zoomChange" | "itemPropertyChange" | "exportProgress" | "exportComplete">(eventName: E, listener: _galacean_effects_weapp.EventEmitterListener<SDKEvents[E]>, options?: _galacean_effects_weapp.EventEmitterOptions) => () => void;
379
- private getInitParam;
380
- private initSDK;
381
- run(param: SDKInputParam): Promise<void>;
382
- getPageData(): PageData;
383
- getActiveItems(): string[];
384
- setPreSelectedItem(id: string): void;
385
- getPreSelectedItem(): string;
386
- setSelectedItems(itemIds: string[]): void;
1639
+ /**
1640
+ * @description 文本创建信息
1641
+ */
1642
+ type TextCreateInfo = {
1643
+ type: 'text';
387
1644
  /**
388
- * @description 获取目标元素的所有属性
389
- * @param param 元素ID、类型
390
- * @returns 元素属性
1645
+ * @description 元素id
391
1646
  */
392
- getItemProperty<T extends keyof PageFormTypeAndPropertyReference>(param: GetItemPropertyParam<T>): GetItemPropertyResult<T> | undefined;
1647
+ id?: string;
393
1648
  /**
394
- * @description 获取目标元素的指定属性
395
- * @param param 元素ID、类型、属性名
396
- * @returns 元素属性值
1649
+ * @description 父节点id
397
1650
  */
398
- getItemPropertyValue<T extends keyof PageFormTypeAndPropertyReference, N extends keyof PageFormTypeAndPropertyReference[T]>(param: GetItemPropertyValueParam<T, N>): GetItemPropertyValueResult<T, N> | undefined;
399
- setItemPropertyValue(param: SetItemPropertyValueParam): Promise<void>;
400
- generateScreenShot(id: number): Promise<string>;
1651
+ parentId?: string;
401
1652
  /**
402
- * @description 切换场景
403
- * @param index 场景索引
1653
+ * @description 元素名称
404
1654
  */
405
- switchScene(index: number): Promise<void>;
1655
+ name?: string;
406
1656
  /**
407
- * @description 获取页面的 safeAreaPreview、zoom、adsorption 值
408
- * @returns 页面的 safeAreaPreview、zoom、adsorption 值
1657
+ * @description 单行高度
409
1658
  */
410
- getConfig(): PageConfig;
1659
+ lineHeight: number;
411
1660
  /**
412
- * 设置页面的 safeAreaPreview、zoom、adsorption 值
413
- * @param pageProperty 设置
1661
+ * @description 文本高度
414
1662
  */
415
- setConfig(pageConfig: PageConfig): void;
1663
+ textHeight?: number;
416
1664
  /**
417
- * @description 设置播放进度
418
- * @param progress 播放进度 0-100
1665
+ * @description 宽度
419
1666
  */
420
- setPlayProgress(progress: number): Promise<void>;
421
- getViewItems(): ViewItem[];
422
- setPlayState(playState: 'play' | 'pause'): void;
1667
+ textWidth: number;
423
1668
  /**
424
- * @description 获取场景预览图
425
- * @returns 视图预览图
1669
+ * @description 字体名称
426
1670
  */
427
- getViewThumbnail(): {
428
- id: number;
429
- thumbnail: string;
430
- }[];
431
- private onExportProgress;
432
- private onExportFinish;
433
- private onExportError;
1671
+ fontFamily: string;
434
1672
  /**
435
- * @description 导出视频
1673
+ * @description 文本位置
436
1674
  */
437
- exportAllVideos(): void;
438
- cancelExportAllVideos(): void;
439
- loadPageData(data: PageData): Promise<void>;
440
- runByPageData(data: PageData): Promise<void>;
1675
+ position?: spec.vec2;
1676
+ /**
1677
+ * @description 文本旋转
1678
+ */
1679
+ rotation?: number;
1680
+ /**
1681
+ * @description 文字大小
1682
+ */
1683
+ fontSize: number;
1684
+ /**
1685
+ * @description 字重
1686
+ */
1687
+ fontWeight?: spec.TextWeight;
1688
+ /**
1689
+ * @description 字体格式
1690
+ */
1691
+ fontStyle?: spec.FontStyle;
1692
+ /**
1693
+ * @description 对齐方式
1694
+ */
1695
+ textAlign?: spec.TextAlignment;
1696
+ /**
1697
+ * @description 文本信息
1698
+ */
1699
+ text: string;
1700
+ /**
1701
+ * @description 填充色
1702
+ */
1703
+ textColor: spec.vec4;
1704
+ /**
1705
+ * @description 描边色
1706
+ */
1707
+ outlineColor?: spec.vec4;
1708
+ /**
1709
+ * @description 描边宽度
1710
+ */
1711
+ outlineWidth?: number;
1712
+ /**
1713
+ * @description 字体文件地址
1714
+ */
1715
+ url?: string;
1716
+ };
1717
+ type ItemCreateInfo = NullCreateInfo | SpriteCreateInfo | TextCreateInfo;
1718
+ declare enum ItemOrderAction {
1719
+ BringToFront = 0,
1720
+ SendToBack = 1,
1721
+ BringForward = 2,
1722
+ SendBackward = 3
441
1723
  }
442
1724
 
443
- export { type ActiveData, type BaseFormProperty, type ExportStatus, ExportStatusMap, type PageData, type PageFormTypedProperty, type PageProperty, SDK, type SDKEvents, type SDKInputParam, type SpecificPageFormProps, type SpriteFormProperty, type TextFormProperty, type ViewItem, type ViewParam, type ViewProperty };
1725
+ export { type ActiveData, type BaseFormProperty, Box2, type CreateOperation, type DeleteOperation, type ItemCreateInfo, ItemOrderAction, type NullCreateInfo, type Operation, type PageData, type PageFormTypedProperty, type PageProperty, SDK, type SDKEvents, type SDKInputParam, type SDKOptions, type SpecificPageFormProps, type SpriteCreateInfo, type SpriteFormProperty, type TextCreateInfo, type TextFormProperty, type UpdateOperation, Vector2, type ViewItem, type ViewItemTypedProperty, type ViewParam, type ViewProperty };