@vvfx/sdk 0.1.13 → 0.1.14-alpha.2

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,8 +1,709 @@
1
1
  import * as _galacean_effects from '@galacean/effects';
2
- import { spec, math, Player } from '@galacean/effects';
2
+ import { spec, VFXItem, math, Player } from '@galacean/effects';
3
3
  export { generateGUID, spec } from '@galacean/effects';
4
4
  import { Point } from '@pixi/constants';
5
5
 
6
+ /**
7
+ * @description SDKItem 基础选项接口
8
+ * @description 支持扩展属性,允许添加任意额外属性
9
+ */
10
+ type SDKItemOptions = {
11
+ /**
12
+ * @description 元素ID
13
+ */
14
+ id: string;
15
+ /**
16
+ * @description 元素名称
17
+ */
18
+ name: string;
19
+ /**
20
+ * @description 父节点ID
21
+ */
22
+ parentId?: string;
23
+ /**
24
+ * @description 子元素ID列表
25
+ */
26
+ children?: string[];
27
+ /**
28
+ * @description 元素生命周期
29
+ */
30
+ duration?: number;
31
+ /**
32
+ * @description 元素生命周期延时
33
+ */
34
+ delay?: number;
35
+ /**
36
+ * @description 元素结束行为
37
+ */
38
+ endBehavior?: spec.EndBehavior;
39
+ /**
40
+ * @description 是否处于锁定状态
41
+ */
42
+ isLocked?: boolean;
43
+ /**
44
+ * @description 扩展属性存储(属性名 -> 属性值)
45
+ */
46
+ extensions?: Record<string, any>;
47
+ /**
48
+ * @description 允许任意额外属性(用于兼容旧代码)
49
+ */
50
+ [extraProp: string]: any;
51
+ };
52
+ /**
53
+ * @description Sprite SDKItem 选项
54
+ */
55
+ type SpriteItemOptions = SDKItemOptions & {
56
+ /**
57
+ * @description 元素属性
58
+ */
59
+ property?: Partial<SpriteFormProperty>;
60
+ };
61
+ /**
62
+ * @description Text SDKItem 选项
63
+ */
64
+ type TextItemOptions = SDKItemOptions & {
65
+ /**
66
+ * @description 元素属性
67
+ */
68
+ property?: Partial<TextFormProperty>;
69
+ };
70
+ /**
71
+ * @description Video SDKItem 选项
72
+ */
73
+ type VideoItemOptions = SDKItemOptions & {
74
+ /**
75
+ * @description 元素属性
76
+ */
77
+ property?: Partial<VideoFormProperty>;
78
+ };
79
+ /**
80
+ * @description Null SDKItem 选项(空节点/组)
81
+ */
82
+ type NullItemOptions = SDKItemOptions & {
83
+ /**
84
+ * @description 元素属性
85
+ */
86
+ property?: Partial<BaseFormProperty>;
87
+ };
88
+ /**
89
+ * @description Generator SDKItem 选项(资源生成器)
90
+ * @description 支持 image 和 video 两种生成器类型
91
+ * @description 复用 SpriteFormProperty 作为底层渲染
92
+ */
93
+ type GeneratorItemOptions = SDKItemOptions & {
94
+ /**
95
+ * @description 生成器类型
96
+ */
97
+ generatorType: GeneratorType;
98
+ /**
99
+ * @description 元素属性
100
+ */
101
+ property?: Partial<SpriteFormProperty>;
102
+ };
103
+ type EffectsItemOptions = SDKItemOptions & {
104
+ property?: Partial<EffectsFormProperty>;
105
+ };
106
+ /**
107
+ * @description SDKItem 类型(独立于 spec.ItemType)
108
+ * @description 包含所有 SDK 层级的元素类型,包括虚拟类型如 generator
109
+ */
110
+ type SDKItemType = 'sprite' | 'text' | 'video' | 'null' | 'generator' | 'effects' | 'frame';
111
+
112
+ /**
113
+ * @description SDKItem 抽象基类
114
+ * @description 支持属性扩展,允许添加任意自定义属性
115
+ */
116
+ declare abstract class BaseItem {
117
+ /**
118
+ * @description 元素ID
119
+ */
120
+ id: string;
121
+ /**
122
+ * @description 元素名称
123
+ */
124
+ name: string;
125
+ /**
126
+ * @description 父节点ID
127
+ */
128
+ parentId?: string;
129
+ /**
130
+ * @description 子元素ID列表
131
+ */
132
+ children: string[];
133
+ /**
134
+ * @description 元素生命周期
135
+ */
136
+ duration: number;
137
+ /**
138
+ * @description 元素生命周期延时
139
+ */
140
+ delay: number;
141
+ /**
142
+ * @description 元素结束行为
143
+ */
144
+ endBehavior: spec.EndBehavior;
145
+ /**
146
+ * @description 是否处于锁定状态
147
+ */
148
+ isLocked: boolean;
149
+ /**
150
+ * @description 扩展属性存储(私有)
151
+ */
152
+ private _extensions;
153
+ /**
154
+ * @description 元素类型(由子类实现)
155
+ * @description 支持 spec.ItemType 或扩展的 SDKItemType(如 'video-generator')
156
+ */
157
+ abstract readonly type: spec.ItemType | SDKItemType;
158
+ /**
159
+ * @description 元素属性(由子类实现)
160
+ */
161
+ abstract readonly property: BaseFormProperty;
162
+ constructor(options: SDKItemOptions);
163
+ /**
164
+ * @description 设置扩展属性
165
+ * @param key 属性名
166
+ * @param value 属性值
167
+ */
168
+ setExtension(key: string, value: any): void;
169
+ /**
170
+ * @description 获取扩展属性
171
+ * @param key 属性名
172
+ * @returns 属性值
173
+ */
174
+ getExtension(key: string): any;
175
+ /**
176
+ * @description 检查是否存在指定扩展属性
177
+ * @param key 属性名
178
+ * @returns 是否存在
179
+ */
180
+ hasExtension(key: string): boolean;
181
+ /**
182
+ * @description 删除扩展属性
183
+ * @param key 属性名
184
+ * @returns 是否删除成功
185
+ */
186
+ deleteExtension(key: string): boolean;
187
+ /**
188
+ * @description 获取所有扩展属性的键名列表
189
+ * @returns 键名数组
190
+ */
191
+ getExtensionKeys(): string[];
192
+ /**
193
+ * @description 获取所有扩展属性
194
+ * @returns 扩展属性对象
195
+ */
196
+ getAllExtensions(): Record<string, any>;
197
+ /**
198
+ * @description 批量设置扩展属性
199
+ * @param extensions 扩展属性对象
200
+ */
201
+ setExtensions(extensions: Record<string, any>): void;
202
+ /**
203
+ * @description 清空所有扩展属性
204
+ */
205
+ clearExtensions(): void;
206
+ /**
207
+ * @description 转换为 CreateInfo(用于元素复制/导出)
208
+ * @param withParent 是否包含父节点ID
209
+ * @returns CreateInfo 对象
210
+ */
211
+ abstract toCreateInfo(withParent?: boolean): ItemCreateInfo;
212
+ /**
213
+ * @description 克隆 SDKItem
214
+ * @returns 新的 SDKItem 实例
215
+ */
216
+ abstract clone(): BaseItem;
217
+ /**
218
+ * @description 获取基础属性的 JSON 对象,转换为普通对象(用于序列化)
219
+ * @returns 普通对象
220
+ */
221
+ toJSON(): Record<string, any>;
222
+ }
223
+ /**
224
+ * @description 类型守卫函数:检查对象是否是 BaseItem
225
+ * @param obj 要检查的对象
226
+ * @returns 是否是 BaseItem 实例
227
+ */
228
+ declare function isBaseItem(obj: any): obj is BaseItem;
229
+
230
+ /**
231
+ * @description 图片元素 SDKItem 类
232
+ * @description 支持属性扩展
233
+ */
234
+ declare class SpriteItem extends BaseItem {
235
+ /**
236
+ * @description 元素类型
237
+ */
238
+ readonly type = spec.ItemType.sprite;
239
+ /**
240
+ * @description 元素属性
241
+ */
242
+ property: SpriteFormProperty;
243
+ constructor(options: SpriteItemOptions);
244
+ /**
245
+ * @description 图片地址
246
+ */
247
+ get image(): string;
248
+ set image(value: string);
249
+ /**
250
+ * @description 位置
251
+ */
252
+ get position(): [number, number];
253
+ set position(value: [number, number]);
254
+ /**
255
+ * @description 大小
256
+ */
257
+ get size(): [number, number];
258
+ set size(value: [number, number]);
259
+ /**
260
+ * @description 旋转(二维旋转角度)
261
+ */
262
+ get rotation(): number;
263
+ set rotation(value: number);
264
+ /**
265
+ * @description 完整旋转(包含 x, y, z)
266
+ */
267
+ get fullRotation(): [number, number, number];
268
+ set fullRotation(value: [number, number, number]);
269
+ /**
270
+ * @description 可见性
271
+ */
272
+ get visible(): boolean;
273
+ set visible(value: boolean);
274
+ /**
275
+ * @description 是否正在编辑关键属性
276
+ */
277
+ get keyPropertyEditing(): boolean;
278
+ set keyPropertyEditing(value: boolean);
279
+ /**
280
+ * @description 转换为 CreateInfo
281
+ * @param withParent 是否包含父节点ID
282
+ */
283
+ toCreateInfo(withParent?: boolean): SpriteCreateInfo;
284
+ /**
285
+ * @description 克隆 SDKItem
286
+ */
287
+ clone(): SpriteItem;
288
+ /**
289
+ * @description 创建包含扩展属性的 CreateInfo
290
+ * @param withParent 是否包含父节点ID
291
+ * @param extraProps 额外的属性
292
+ */
293
+ toCreateInfoWithExtensions(withParent?: boolean, extraProps?: Record<string, any>): SpriteCreateInfo;
294
+ }
295
+ /**
296
+ * @description 类型守卫:检查是否是 SpriteItem
297
+ */
298
+ declare function isSpriteItem(obj: any): obj is SpriteItem;
299
+
300
+ /**
301
+ * @description 文本元素 SDKItem 类
302
+ * @description 支持属性扩展
303
+ */
304
+ declare class TextItem extends BaseItem {
305
+ /**
306
+ * @description 元素类型
307
+ */
308
+ readonly type = spec.ItemType.text;
309
+ /**
310
+ * @description 元素属性
311
+ */
312
+ property: TextFormProperty;
313
+ constructor(options: TextItemOptions);
314
+ /**
315
+ * @description 文本内容
316
+ */
317
+ get text(): string;
318
+ set text(value: string);
319
+ /**
320
+ * @description 字体名称
321
+ */
322
+ get fontFamily(): string;
323
+ set fontFamily(value: string);
324
+ /**
325
+ * @description 字号
326
+ */
327
+ get fontSize(): number;
328
+ set fontSize(value: number);
329
+ /**
330
+ * @description 字重
331
+ */
332
+ get fontWeight(): spec.TextWeight;
333
+ set fontWeight(value: spec.TextWeight);
334
+ /**
335
+ * @description 字体样式
336
+ */
337
+ get fontStyle(): spec.FontStyle;
338
+ set fontStyle(value: spec.FontStyle);
339
+ /**
340
+ * @description 文本对齐方式
341
+ */
342
+ get textAlign(): spec.TextAlignment;
343
+ set textAlign(value: spec.TextAlignment);
344
+ /**
345
+ * @description 文本颜色 [r, g, b, a]
346
+ */
347
+ get textColor(): [number, number, number, number];
348
+ set textColor(value: [number, number, number, number]);
349
+ /**
350
+ * @description 文本宽度
351
+ */
352
+ get textWidth(): number;
353
+ set textWidth(value: number);
354
+ /**
355
+ * @description 行高
356
+ */
357
+ get lineHeight(): number;
358
+ set lineHeight(value: number);
359
+ /**
360
+ * @description 文本高度
361
+ */
362
+ get textHeight(): number;
363
+ set textHeight(value: number);
364
+ /**
365
+ * @description 描边颜色
366
+ */
367
+ get outlineColor(): spec.vec4 | undefined;
368
+ set outlineColor(value: spec.vec4 | undefined);
369
+ /**
370
+ * @description 描边宽度
371
+ */
372
+ get outlineWidth(): number | undefined;
373
+ set outlineWidth(value: number | undefined);
374
+ /**
375
+ * @description 描边开关
376
+ */
377
+ get outlineEnabled(): boolean;
378
+ set outlineEnabled(value: boolean);
379
+ /**
380
+ * @description 位置
381
+ */
382
+ get position(): [number, number];
383
+ set position(value: [number, number]);
384
+ /**
385
+ * @description 旋转(二维旋转角度)
386
+ */
387
+ get rotation(): number;
388
+ set rotation(value: number);
389
+ /**
390
+ * @description 可见性
391
+ */
392
+ get visible(): boolean;
393
+ set visible(value: boolean);
394
+ /**
395
+ * @description 转换为 CreateInfo
396
+ * @param withParent 是否包含父节点ID
397
+ */
398
+ toCreateInfo(withParent?: boolean): TextCreateInfo;
399
+ /**
400
+ * @description 克隆 SDKItem
401
+ */
402
+ clone(): TextItem;
403
+ }
404
+ /**
405
+ * @description 类型守卫:检查是否是 TextItem
406
+ */
407
+ declare function isTextItem(obj: any): obj is TextItem;
408
+
409
+ /**
410
+ * @description 视频元素 SDKItem 类
411
+ * @description 支持属性扩展
412
+ */
413
+ declare class VideoItem extends BaseItem {
414
+ /**
415
+ * @description 元素类型
416
+ */
417
+ readonly type = spec.ItemType.video;
418
+ /**
419
+ * @description 元素属性
420
+ */
421
+ property: VideoFormProperty;
422
+ constructor(options: VideoItemOptions);
423
+ /**
424
+ * @description 视频地址
425
+ */
426
+ get video(): string;
427
+ set video(value: string);
428
+ /**
429
+ * @description 位置
430
+ */
431
+ get position(): [number, number];
432
+ set position(value: [number, number]);
433
+ /**
434
+ * @description 大小
435
+ */
436
+ get size(): [number, number];
437
+ set size(value: [number, number]);
438
+ /**
439
+ * @description 旋转(二维旋转角度)
440
+ */
441
+ get rotation(): number;
442
+ set rotation(value: number);
443
+ /**
444
+ * @description 完整旋转(包含 x, y, z)
445
+ */
446
+ get fullRotation(): [number, number, number];
447
+ set fullRotation(value: [number, number, number]);
448
+ /**
449
+ * @description 可见性
450
+ */
451
+ get visible(): boolean;
452
+ set visible(value: boolean);
453
+ /**
454
+ * @description 是否正在编辑关键属性
455
+ */
456
+ get keyPropertyEditing(): boolean;
457
+ set keyPropertyEditing(value: boolean);
458
+ /**
459
+ * @description 转换为 CreateInfo
460
+ * @param withParent 是否包含父节点ID
461
+ */
462
+ toCreateInfo(withParent?: boolean): VideoCreateInfo;
463
+ /**
464
+ * @description 克隆 SDKItem
465
+ */
466
+ clone(): VideoItem;
467
+ }
468
+ /**
469
+ * @description 类型守卫:检查是否是 VideoItem
470
+ */
471
+ declare function isVideoItem(obj: any): obj is VideoItem;
472
+
473
+ /**
474
+ * @description 空节点/组 SDKItem 类
475
+ * @description 支持属性扩展
476
+ */
477
+ declare class NullItem extends BaseItem {
478
+ /**
479
+ * @description 元素类型
480
+ */
481
+ readonly type = spec.ItemType.null;
482
+ /**
483
+ * @description 元素属性
484
+ */
485
+ property: BaseFormProperty;
486
+ constructor(options: NullItemOptions);
487
+ /**
488
+ * @description 位置
489
+ */
490
+ get position(): [number, number];
491
+ set position(value: [number, number]);
492
+ /**
493
+ * @description 大小
494
+ */
495
+ get size(): [number, number];
496
+ set size(value: [number, number]);
497
+ /**
498
+ * @description 旋转(二维旋转角度)
499
+ */
500
+ get rotation(): number;
501
+ set rotation(value: number);
502
+ /**
503
+ * @description 完整旋转(包含 x, y, z)
504
+ */
505
+ get fullRotation(): [number, number, number];
506
+ set fullRotation(value: [number, number, number]);
507
+ /**
508
+ * @description 可见性
509
+ */
510
+ get visible(): boolean;
511
+ set visible(value: boolean);
512
+ /**
513
+ * @description 是否正在编辑关键属性
514
+ */
515
+ get keyPropertyEditing(): boolean;
516
+ set keyPropertyEditing(value: boolean);
517
+ /**
518
+ * @description 计算缩放(基于子元素)
519
+ */
520
+ get scaleForCreateInfo(): [number, number];
521
+ /**
522
+ * @description 设置缩放(存储在扩展属性中)
523
+ */
524
+ set scaleForCreateInfo(value: [number, number]);
525
+ /**
526
+ * @description 转换为 CreateInfo
527
+ * @param withParent 是否包含父节点ID
528
+ */
529
+ toCreateInfo(withParent?: boolean): NullCreateInfo;
530
+ /**
531
+ * @description 克隆 SDKItem
532
+ */
533
+ clone(): NullItem;
534
+ }
535
+ /**
536
+ * @description 类型守卫:检查是否是 NullItem
537
+ */
538
+ declare function isNullItem(obj: any): obj is NullItem;
539
+
540
+ /**
541
+ * @description 资源生成器元素 SDKItem 类
542
+ * @description 支持 image 和 video 两种生成器类型
543
+ * @description 在 Player 中以透明 SpriteItem 形式渲染
544
+ * @description 支持属性扩展,可转换为 SpriteItem 或 VideoItem
545
+ */
546
+ declare class GeneratorItem extends BaseItem {
547
+ /**
548
+ * @description 元素类型(独立类型,不属于 spec.ItemType)
549
+ */
550
+ readonly type: SDKItemType;
551
+ /**
552
+ * @description 生成器类型
553
+ */
554
+ generatorType: GeneratorType;
555
+ /**
556
+ * @description 元素属性
557
+ */
558
+ property: SpriteFormProperty;
559
+ constructor(options: GeneratorItemOptions);
560
+ /**
561
+ * @description 图片地址(生成器返回空)
562
+ */
563
+ get image(): string;
564
+ set image(_value: string);
565
+ /**
566
+ * @description 位置
567
+ */
568
+ get position(): [number, number];
569
+ set position(value: [number, number]);
570
+ /**
571
+ * @description 大小
572
+ */
573
+ get size(): [number, number];
574
+ set size(value: [number, number]);
575
+ /**
576
+ * @description 旋转(二维旋转角度)
577
+ */
578
+ get rotation(): number;
579
+ set rotation(value: number);
580
+ /**
581
+ * @description 完整旋转(包含 x, y, z)
582
+ */
583
+ get fullRotation(): [number, number, number];
584
+ set fullRotation(value: [number, number, number]);
585
+ /**
586
+ * @description 可见性
587
+ */
588
+ get visible(): boolean;
589
+ set visible(value: boolean);
590
+ /**
591
+ * @description 是否正在编辑关键属性
592
+ */
593
+ get keyPropertyEditing(): boolean;
594
+ set keyPropertyEditing(value: boolean);
595
+ /**
596
+ * @description 转换为 GeneratorCreateInfo
597
+ * @param withParent 是否包含父节点ID
598
+ */
599
+ toCreateInfo(withParent?: boolean): GeneratorCreateInfo;
600
+ /**
601
+ * @description 转换为 VideoCreateInfo(用于转换为视频元素)
602
+ * @param videoUrl 视频资源地址
603
+ * @param withParent 是否包含父节点ID
604
+ */
605
+ toVideoCreateInfo(videoUrl: string, withParent?: boolean): VideoCreateInfo;
606
+ /**
607
+ * @description 转换为 SpriteCreateInfo(用于转换为图片元素)
608
+ * @param imageUrl 图片资源地址
609
+ * @param withParent 是否包含父节点ID
610
+ */
611
+ toSpriteCreateInfo(imageUrl: string, withParent?: boolean): SpriteCreateInfo;
612
+ /**
613
+ * @description 克隆 SDKItem
614
+ */
615
+ clone(): GeneratorItem;
616
+ }
617
+ /**
618
+ * @description 类型守卫:检查是否是 GeneratorItem
619
+ */
620
+ declare function isGeneratorItem(obj: any): obj is GeneratorItem;
621
+
622
+ /**
623
+ * @description 特效产物 元素 SDKItem 类
624
+ */
625
+ declare class EffectsItem extends BaseItem {
626
+ /**
627
+ * @description 元素类型(独立类型,不属于 spec.ItemType)
628
+ */
629
+ readonly type: SDKItemType;
630
+ /**
631
+ * @description 元素属性
632
+ */
633
+ property: EffectsFormProperty;
634
+ constructor(options: EffectsItemOptions);
635
+ /**
636
+ * @description 特效资源地址
637
+ */
638
+ get effects(): string;
639
+ set effects(value: string);
640
+ /**
641
+ * @description 位置
642
+ */
643
+ get position(): [number, number];
644
+ set position(value: [number, number]);
645
+ /**
646
+ * @description 大小
647
+ */
648
+ get size(): [number, number];
649
+ set size(value: [number, number]);
650
+ /**
651
+ * @description 旋转(二维旋转角度)
652
+ */
653
+ get rotation(): number;
654
+ set rotation(value: number);
655
+ /**
656
+ * @description 完整旋转(包含 x, y, z)
657
+ */
658
+ get fullRotation(): [number, number, number];
659
+ set fullRotation(value: [number, number, number]);
660
+ /**
661
+ * @description 可见性
662
+ */
663
+ get visible(): boolean;
664
+ set visible(value: boolean);
665
+ /**
666
+ * @description 是否正在编辑关键属性
667
+ */
668
+ get keyPropertyEditing(): boolean;
669
+ set keyPropertyEditing(value: boolean);
670
+ /**
671
+ * @description 转换为 EffectsCreateInfo
672
+ * @param withParent 是否包含父节点ID
673
+ */
674
+ toCreateInfo(withParent?: boolean): EffectsCreateInfo;
675
+ /**
676
+ * @description 克隆 SDKItem
677
+ */
678
+ clone(): EffectsItem;
679
+ }
680
+ /**
681
+ * @description 类型守卫:检查是否是 EffectsItem
682
+ */
683
+ declare function isEffectsItem(obj: any): obj is EffectsItem;
684
+
685
+ /**
686
+ * @description 根据 item type 创建对应的 SDKItem 实例
687
+ * @param type 元素类型
688
+ * @param options SDKItem 选项
689
+ * @returns SDKItem 实例
690
+ */
691
+ declare function createSDKItem(type: spec.ItemType, options: SDKItemOptions): BaseItem;
692
+ /**
693
+ * @description 从 Player Item 创建 SDKItem
694
+ * @param playerItem VFXItem
695
+ * @param parentId 父节点ID
696
+ * @param property 属性对象
697
+ * @param generatorType 生成器类型(如果是生成器元素)
698
+ * @returns SDKItem 实例
699
+ */
700
+ declare function createSDKItemFromPlayerItem(playerItem: VFXItem, parentId: string | undefined, property: Record<string, any>, generatorType?: GeneratorType): BaseItem;
701
+ /**
702
+ * @description SDKItem 类型联合
703
+ * @description 用于替换原来的 SDKItem type
704
+ */
705
+ type SDKItem$1 = SpriteItem | TextItem | VideoItem | NullItem | GeneratorItem;
706
+
6
707
  type ViewItemTypedProperty = {
7
708
  [K in keyof PageFormTypeAndPropertyReference]: {
8
709
  /**
@@ -1342,7 +2043,6 @@ declare class SDK {
1342
2043
  private initExporter;
1343
2044
  private initSDK;
1344
2045
  run(param: SDKInputParam): Promise<void>;
1345
- getPageData(): PageData;
1346
2046
  getActiveItems(): string[];
1347
2047
  setPreSelectedItem(id: string): void;
1348
2048
  getPreSelectedItem(): string;
@@ -1381,7 +2081,7 @@ declare class SDK {
1381
2081
  * @param progress 播放进度 0-100
1382
2082
  */
1383
2083
  setPlayProgress(progress: number): Promise<void>;
1384
- getViewItems(): ViewItem[];
2084
+ getSDKItems(): SDKItem$1[];
1385
2085
  setPlayState(playState: 'play' | 'pause'): Promise<void>;
1386
2086
  /**
1387
2087
  * @description 获取场景预览图
@@ -1567,7 +2267,48 @@ declare class SDK {
1567
2267
  */
1568
2268
  exportJSON(idInfo?: number | number[]): spec.JSONScene[];
1569
2269
  getViewBoxById(id: string): Box2;
1570
- getViewItemById(id: string): ViewItem | undefined;
2270
+ getSDKItemById(id: string): SDKItem$1 | undefined;
2271
+ /**
2272
+ * @description 批量设置元素扩展属性
2273
+ * @param id 元素ID
2274
+ * @param extensions 扩展属性对象(支持同时设置多个)
2275
+ * @returns 是否设置成功
2276
+ */
2277
+ setItemExtensions(id: string, extensions: Record<string, any>): boolean;
2278
+ /**
2279
+ * @description 批量获取元素扩展属性
2280
+ * @param id 元素ID
2281
+ * @param keys 扩展属性名称列表(不传则返回所有扩展属性)
2282
+ * @returns 扩展属性对象
2283
+ */
2284
+ getItemExtensions(id: string, keys?: string[]): Record<string, any> | undefined;
2285
+ /**
2286
+ * @description 获取单个元素扩展属性
2287
+ * @param id 元素ID
2288
+ * @param key 扩展属性名称
2289
+ * @returns 扩展属性值
2290
+ */
2291
+ getItemExtension(id: string, key: string): any;
2292
+ /**
2293
+ * @description 删除元素扩展属性(支持批量删除)
2294
+ * @param id 元素ID
2295
+ * @param keys 扩展属性名称列表
2296
+ * @returns 是否删除成功
2297
+ */
2298
+ deleteItemExtensions(id: string, keys: string[]): boolean;
2299
+ /**
2300
+ * @description 检查元素是否有指定扩展属性
2301
+ * @param id 元素ID
2302
+ * @param key 扩展属性名称
2303
+ * @returns 是否存在
2304
+ */
2305
+ hasItemExtension(id: string, key: string): boolean;
2306
+ /**
2307
+ * @description 获取元素所有扩展属性的键名列表
2308
+ * @param id 元素ID
2309
+ * @returns 键名数组
2310
+ */
2311
+ getItemExtensionKeys(id: string): string[] | undefined;
1571
2312
  getViewProperty(id: number): ViewProperty | undefined;
1572
2313
  pageMove(shift: [number, number]): void;
1573
2314
  pageZoom(shift: number, center?: [number, number]): void;
@@ -1619,10 +2360,39 @@ declare class SDK {
1619
2360
  setInteractType(type: GestureHandlerInteractType): void;
1620
2361
  makeItemAlign(type: AlignType, ids?: string[]): void;
1621
2362
  makeItemDistribute(type: DistributeType, ids?: string[]): void;
1622
- createVideoGenerator(createInfo: VideoGeneratorCreateInfo): void;
1623
- setVideoGeneratorResource(resource: VideoGeneratorResource): void;
1624
- createSpriteGenerator(createInfo: SpriteGeneratorCreateInfo): void;
1625
- setSpriteGeneratorResource(resource: SpriteGeneratorResource): void;
2363
+ /**
2364
+ * @description 创建生成器元素
2365
+ * @param createInfo 生成器创建信息
2366
+ * @returns 生成器元素ID
2367
+ */
2368
+ addGeneratorItem(createInfo: GeneratorCreateInfo): string;
2369
+ /**
2370
+ * @description 创建动效元素(仅限调试使用)
2371
+ * @param effectsInfo 动效创建信息
2372
+ */
2373
+ addEffectsItem(effectsInfo: EffectsCreateInfo): void;
2374
+ /**
2375
+ * @description 设置生成器资源,将生成器转换为对应的元素
2376
+ * @param id 生成器元素ID
2377
+ * @param resourceUrl 资源地址
2378
+ * @returns 新的元素ID
2379
+ */
2380
+ setGeneratorResource(id: string, resourceUrl: string): Promise<string>;
2381
+ /**
2382
+ * @description 设置生成器资源(使用 GeneratorResource 对象)
2383
+ * @param resource 生成器资源信息
2384
+ */
2385
+ setGeneratorResourceFromObject(resource: GeneratorResource): void;
2386
+ /**
2387
+ * @description 设置视频生成器资源
2388
+ * @param resource 视频生成器资源信息
2389
+ */
2390
+ setVideoGeneratorResource(resource: VideoGeneratorResource): Promise<string>;
2391
+ /**
2392
+ * @description 设置图层生成器资源
2393
+ * @param resource 图层生成器资源信息
2394
+ */
2395
+ setSpriteGeneratorResource(resource: SpriteGeneratorResource): Promise<string>;
1626
2396
  setItemLockState(id: string, state: boolean): void;
1627
2397
  getItemLockState(id: string): void;
1628
2398
  openItemCreateGizmo(type: ItemCreateType): void;
@@ -1635,7 +2405,9 @@ type BaseFormProperty = {
1635
2405
  position: [number, number];
1636
2406
  rotation: [number, number, number];
1637
2407
  size: [number, number];
2408
+ scale: [number, number];
1638
2409
  visible: boolean;
2410
+ isLocked?: boolean;
1639
2411
  keyPropertyEditing: boolean;
1640
2412
  };
1641
2413
  type SpriteFormProperty = BaseFormProperty & {
@@ -1662,6 +2434,9 @@ type TextFormProperty = BaseFormProperty & {
1662
2434
  type VideoFormProperty = BaseFormProperty & {
1663
2435
  video: string;
1664
2436
  };
2437
+ type EffectsFormProperty = BaseFormProperty & {
2438
+ effects: string;
2439
+ };
1665
2440
  /**
1666
2441
  * @description 页面表单类型和属性引用
1667
2442
  */
@@ -1765,7 +2540,7 @@ type PageData = {
1765
2540
  /**
1766
2541
  * @description 元素数据
1767
2542
  */
1768
- items: ViewItem[];
2543
+ items: SDKItem[];
1769
2544
  /**
1770
2545
  * @description 视图当前时间
1771
2546
  */
@@ -1936,42 +2711,12 @@ type ActiveData = {
1936
2711
  };
1937
2712
  /**
1938
2713
  * @description 视图元素
2714
+ * @description 注意:SDKItem 现在已从类实现中导入,见 view-item/index.ts
2715
+ * @description SDKItem 现在是类实例而非普通对象,支持属性扩展
2716
+ * @description 保持类型兼容性:新 SDKItem 类拥有与旧类型相同的属性
1939
2717
  */
1940
- type ViewItem = {
1941
- /**
1942
- * @description 元素ID
1943
- */
1944
- id: string;
1945
- /**
1946
- * @description 元素名称
1947
- */
1948
- name: string;
1949
- /**
1950
- * @description 元素父节点ID
1951
- */
1952
- parentId?: string;
1953
- /**
1954
- * @description 子元素
1955
- */
1956
- children: string[];
1957
- /**
1958
- * @description 元素生命周期
1959
- */
1960
- duration: number;
1961
- /**
1962
- * @description 元素生命周期延时
1963
- */
1964
- delay: number;
1965
- /**
1966
- * @description 元素结束行为
1967
- */
1968
- endBehavior: spec.EndBehavior;
1969
- /**
1970
- * @description 是否处于锁定状态
1971
- */
1972
- isLocked?: boolean;
1973
- } & ViewItemTypedProperty;
1974
- type SDKBackgroundType = 'color' | 'image' | 'chess-board';
2718
+ type SDKItem = SDKItem$1;
2719
+ type SDKBackgroundType = 'color' | 'image' | 'chess-board' | 'dot-board';
1975
2720
  /**
1976
2721
  * @description 图层创建信息
1977
2722
  */
@@ -2009,6 +2754,10 @@ type SpriteCreateInfo = {
2009
2754
  * @description 图层元素二维位置
2010
2755
  */
2011
2756
  position: spec.vec2;
2757
+ /**
2758
+ * @description 扩展属性
2759
+ */
2760
+ extensions?: Record<string, any>;
2012
2761
  };
2013
2762
  /**
2014
2763
  * @description 空节点创建信息
@@ -2043,6 +2792,10 @@ type NullCreateInfo = {
2043
2792
  * @description 空节点位移
2044
2793
  */
2045
2794
  position?: spec.vec2;
2795
+ /**
2796
+ * @description 扩展属性
2797
+ */
2798
+ extensions?: Record<string, any>;
2046
2799
  };
2047
2800
  /**
2048
2801
  * @description 文本创建信息
@@ -2125,6 +2878,10 @@ type TextCreateInfo = {
2125
2878
  * @description 字体文件地址
2126
2879
  */
2127
2880
  url?: string;
2881
+ /**
2882
+ * @description 扩展属性
2883
+ */
2884
+ extensions?: Record<string, any>;
2128
2885
  };
2129
2886
  /**
2130
2887
  * @description 视频创建信息
@@ -2179,100 +2936,159 @@ type VideoCreateInfo = {
2179
2936
  * @description 音量
2180
2937
  */
2181
2938
  volume?: number;
2939
+ /**
2940
+ * @description 扩展属性
2941
+ */
2942
+ extensions?: Record<string, any>;
2182
2943
  };
2183
2944
  /**
2184
- * @description 视频生成器创建信息
2945
+ * @description 生成器类型
2946
+ */
2947
+ type GeneratorType = 'image' | 'video';
2948
+ /**
2949
+ * @description 生成器创建信息
2185
2950
  */
2186
- type VideoGeneratorCreateInfo = {
2951
+ type GeneratorCreateInfo = {
2187
2952
  /**
2188
- * @description 类型 - 视频生成器
2953
+ * @description 元素类型 - 生成器
2189
2954
  */
2190
- type: 'video-generator';
2955
+ type: 'generator';
2191
2956
  /**
2192
- * @description 视频名称
2193
- */
2957
+ * @description 生成器类型
2958
+ */
2959
+ generatorType: GeneratorType;
2960
+ /**
2961
+ * @description 元素名称
2962
+ */
2194
2963
  name?: string;
2195
2964
  /**
2196
2965
  * @description 元素id
2197
2966
  */
2198
2967
  id?: string;
2199
2968
  /**
2200
- * @description 视频生成器大小
2969
+ * @description 父元素id
2970
+ */
2971
+ parentId?: string;
2972
+ /**
2973
+ * @description 生成器大小
2201
2974
  */
2202
2975
  size: spec.vec2;
2203
2976
  /**
2204
- * @description 视频生成器位置
2977
+ * @description 生成器位置
2205
2978
  */
2206
2979
  position: spec.vec2;
2980
+ /**
2981
+ * @description 旋转角度
2982
+ */
2983
+ rotation?: number;
2984
+ /**
2985
+ * @description 缩放
2986
+ */
2987
+ scale?: spec.vec2;
2988
+ /**
2989
+ * @description 扩展属性
2990
+ */
2991
+ extensions?: Record<string, any>;
2207
2992
  };
2208
2993
  /**
2209
- * @description 视频生成器资源信息
2994
+ * @description 生成器资源信息
2210
2995
  */
2211
- type VideoGeneratorResource = {
2996
+ type SpriteGeneratorResource = {
2212
2997
  /**
2213
2998
  * @description 资源地址
2214
2999
  */
2215
3000
  url: string;
2216
3001
  /**
2217
- * @description 视频尺寸
3002
+ * @description 资源尺寸
2218
3003
  */
2219
3004
  size?: spec.vec2;
2220
3005
  /**
2221
- * @description 是否静音
3006
+ * @description 目标生成器元素 ID(必填)
3007
+ */
3008
+ itemId: string;
3009
+ /**
3010
+ * @description 扩展属性
3011
+ */
3012
+ extensions?: Record<string, any>;
3013
+ };
3014
+ type VideoGeneratorResource = {
3015
+ /**
3016
+ * @description 资源地址
3017
+ */
3018
+ url: string;
3019
+ /**
3020
+ * @description 资源尺寸
3021
+ */
3022
+ size?: spec.vec2;
3023
+ /**
3024
+ * @description 是否静音(仅用于视频)
2222
3025
  */
2223
3026
  muted?: boolean;
2224
3027
  /**
2225
- * @description 是否为透明视频
3028
+ * @description 是否为透明视频(仅用于视频)
2226
3029
  */
2227
3030
  transparent?: boolean;
2228
3031
  /**
2229
- * @description 播放速率
3032
+ * @description 播放速率(仅用于视频)
2230
3033
  */
2231
3034
  playbackRate?: number;
2232
3035
  /**
2233
- * @description 音量
3036
+ * @description 音量(仅用于视频)
2234
3037
  */
2235
3038
  volume?: number;
3039
+ /**
3040
+ * @description 目标生成器元素 ID(必填)
3041
+ */
3042
+ itemId: string;
3043
+ /**
3044
+ * @description 扩展属性
3045
+ */
3046
+ extensions?: Record<string, any>;
2236
3047
  };
2237
- /**
2238
- * @description 图层生成器创建信息
2239
- */
2240
- type SpriteGeneratorCreateInfo = {
3048
+ type GeneratorResource = SpriteGeneratorResource | VideoGeneratorResource;
3049
+ type EffectsCreateInfo = {
2241
3050
  /**
2242
- * @description 类型 - 图层生成器
3051
+ * @description 元素类型 - 特效
2243
3052
  */
2244
- type: 'sprite-generator';
3053
+ type: 'effects';
2245
3054
  /**
2246
- * @description 图层名称
2247
- */
3055
+ * @description 元素名称
3056
+ */
2248
3057
  name?: string;
2249
3058
  /**
2250
3059
  * @description 元素id
2251
3060
  */
2252
3061
  id?: string;
2253
3062
  /**
2254
- * @description 图层生成器大小
3063
+ * @description 父元素id
2255
3064
  */
2256
- size: spec.vec2;
3065
+ parentId?: string;
2257
3066
  /**
2258
- * @description 图层生成器位置
3067
+ * @description 生成器大小
3068
+ */
3069
+ size?: spec.vec2;
3070
+ /**
3071
+ * @description 生成器位置
2259
3072
  */
2260
3073
  position: spec.vec2;
2261
- };
2262
- /**
2263
- * @description 图层生成器资源信息
2264
- */
2265
- type SpriteGeneratorResource = {
2266
3074
  /**
2267
- * @description 资源地址
3075
+ * @description 旋转角度
3076
+ */
3077
+ rotation?: number;
3078
+ /**
3079
+ * @description 缩放
3080
+ */
3081
+ scale?: spec.vec2;
3082
+ /**
3083
+ * @description 动效资源地址
2268
3084
  */
2269
3085
  url: string;
2270
3086
  /**
2271
- * @description 图层尺寸
3087
+ * @description 扩展属性
2272
3088
  */
2273
- size?: spec.vec2;
3089
+ extensions?: Record<string, any>;
2274
3090
  };
2275
- type ItemCreateInfo = NullCreateInfo | SpriteCreateInfo | TextCreateInfo | VideoCreateInfo | SpriteGeneratorCreateInfo | VideoGeneratorCreateInfo;
3091
+ type ItemCreateInfo = NullCreateInfo | SpriteCreateInfo | TextCreateInfo | VideoCreateInfo | GeneratorCreateInfo | EffectsCreateInfo;
2276
3092
  /**
2277
3093
  * @description 场景创建信息
2278
3094
  */
@@ -2314,4 +3130,4 @@ type ViewportFitShiftParam = {
2314
3130
  bottom?: number;
2315
3131
  };
2316
3132
 
2317
- export { type ActiveData, type BaseFormProperty, Box2, type CreateOperation, type DeleteOperation, type GizmoType, type ItemCreateInfo, ItemOrderAction, type NullCreateInfo, type Operation, type PageData, type PageFormTypedProperty, type PageProperty, SDK, type SDKEvents, type SDKInputParam, type SDKOptions, type SetItemPropertyValueParam, type SpecificPageFormProps, type SpriteCreateInfo, type SpriteFormProperty, type TextCreateInfo, type TextFormProperty, type UpdateOperation, Vector2, type VideoCreateInfo, type VideoFormProperty, type ViewItem, type ViewItemTypedProperty, type ViewParam, type ViewProperty };
3133
+ export { type ActiveData, type BaseFormProperty, BaseItem, Box2, type CreateOperation, type DeleteOperation, type EffectsCreateInfo, EffectsItem, type EffectsItemOptions, type GeneratorCreateInfo, GeneratorItem, type GeneratorItemOptions, type GizmoType, type ItemCreateInfo, ItemOrderAction, type NullCreateInfo, NullItem, type NullItemOptions, type Operation, type PageData, type PageFormTypedProperty, type PageProperty, SDK, type SDKEvents, type SDKInputParam, type SDKItem$1 as SDKItem, type SDKItemOptions, type SDKOptions, type SetItemPropertyValueParam, type SpecificPageFormProps, type SpriteCreateInfo, type SpriteFormProperty, SpriteItem, type SpriteItemOptions, type TextCreateInfo, type TextFormProperty, TextItem, type TextItemOptions, type UpdateOperation, Vector2, type VideoCreateInfo, type VideoFormProperty, VideoItem, type VideoItemOptions, type ViewItemTypedProperty, type ViewParam, type ViewProperty, createSDKItem, createSDKItemFromPlayerItem, isBaseItem, isEffectsItem, isGeneratorItem, isNullItem, isSpriteItem, isTextItem, isVideoItem };