@vvfx/sdk 0.0.0-alpha.4
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/README.md +30 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +447 -0
- package/dist/index.d.ts +447 -0
- package/dist/index.global.js +286 -0
- package/dist/index.js +1 -0
- package/package.json +75 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
import { math, spec, Player } from '@galacean/effects';
|
|
2
|
+
export { spec } from '@galacean/effects';
|
|
3
|
+
import * as _galacean_effects_weapp from '@galacean/effects/weapp';
|
|
4
|
+
|
|
5
|
+
declare class Vector2 extends math.Vector2 {
|
|
6
|
+
subtract(other: Vector2): this;
|
|
7
|
+
toViewCoordinate(width: number, height: number): this;
|
|
8
|
+
clone(): Vector2;
|
|
9
|
+
distanceTo(other: Vector2): number;
|
|
10
|
+
scaleByCenter(scalar: Vector2, anchor?: Vector2): Vector2;
|
|
11
|
+
round(precision?: number): this;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type ViewItemTypedProperty = {
|
|
15
|
+
[K in keyof PageFormTypeAndPropertyReference]: {
|
|
16
|
+
/**
|
|
17
|
+
* @description 元素类型
|
|
18
|
+
*/
|
|
19
|
+
type: K;
|
|
20
|
+
/**
|
|
21
|
+
* @description 元素属性
|
|
22
|
+
*/
|
|
23
|
+
property: PageFormTypeAndPropertyReference[K];
|
|
24
|
+
};
|
|
25
|
+
}[keyof PageFormTypeAndPropertyReference];
|
|
26
|
+
type PageFormTypedProperty = {
|
|
27
|
+
[K in keyof PageFormTypeAndPropertyReference]: {
|
|
28
|
+
type: K;
|
|
29
|
+
property: PageFormTypeAndPropertyReference[K];
|
|
30
|
+
onPropertyValueChange: <N extends keyof PageFormTypeAndPropertyReference[K]>(propertyName: N, propertyValue: PageFormTypeAndPropertyReference[K][N]) => void;
|
|
31
|
+
};
|
|
32
|
+
}[keyof PageFormTypeAndPropertyReference];
|
|
33
|
+
type GetItemPropertyValueParam<T extends keyof PageFormTypeAndPropertyReference, N extends keyof PageFormTypeAndPropertyReference[T]> = {
|
|
34
|
+
itemId: string;
|
|
35
|
+
type: T;
|
|
36
|
+
propertyName: N;
|
|
37
|
+
};
|
|
38
|
+
type GetItemPropertyValueResult<T extends keyof PageFormTypeAndPropertyReference, N extends keyof PageFormTypeAndPropertyReference[T]> = PageFormTypeAndPropertyReference[T][N];
|
|
39
|
+
type GetItemPropertyParam<T extends keyof PageFormTypeAndPropertyReference> = {
|
|
40
|
+
itemId: string;
|
|
41
|
+
type: T;
|
|
42
|
+
};
|
|
43
|
+
type GetItemPropertyResult<T extends keyof PageFormTypeAndPropertyReference> = {
|
|
44
|
+
type: T;
|
|
45
|
+
property: PageFormTypeAndPropertyReference[T];
|
|
46
|
+
};
|
|
47
|
+
type SetItemPropertyValueParam = {
|
|
48
|
+
[T in keyof PageFormTypeAndPropertyReference]: {
|
|
49
|
+
[N in keyof PageFormTypeAndPropertyReference[T]]: {
|
|
50
|
+
itemId: string;
|
|
51
|
+
type: T;
|
|
52
|
+
propertyName: N;
|
|
53
|
+
propertyValue: PageFormTypeAndPropertyReference[T][N];
|
|
54
|
+
};
|
|
55
|
+
}[keyof PageFormTypeAndPropertyReference[T]];
|
|
56
|
+
}[keyof PageFormTypeAndPropertyReference];
|
|
57
|
+
|
|
58
|
+
type BaseFormProperty = {
|
|
59
|
+
position: [number, number, number];
|
|
60
|
+
rotation: [number, number, number];
|
|
61
|
+
scale: [number, number, number];
|
|
62
|
+
keyPropertyEditing: boolean;
|
|
63
|
+
};
|
|
64
|
+
type SpriteFormProperty = BaseFormProperty & {
|
|
65
|
+
image: string;
|
|
66
|
+
};
|
|
67
|
+
type TextFormProperty = BaseFormProperty & {
|
|
68
|
+
font: string;
|
|
69
|
+
color: [number, number, number, number];
|
|
70
|
+
weight: spec.TextWeight;
|
|
71
|
+
text: string;
|
|
72
|
+
alignment: spec.TextAlignment;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* @description 页面表单类型和属性引用
|
|
76
|
+
*/
|
|
77
|
+
type PageFormTypeAndPropertyReference = {
|
|
78
|
+
[spec.ItemType.base]: BaseFormProperty;
|
|
79
|
+
[spec.ItemType.sprite]: SpriteFormProperty;
|
|
80
|
+
[spec.ItemType.particle]: BaseFormProperty;
|
|
81
|
+
[spec.ItemType.null]: BaseFormProperty;
|
|
82
|
+
[spec.ItemType.interact]: BaseFormProperty;
|
|
83
|
+
[spec.ItemType.plugin]: BaseFormProperty;
|
|
84
|
+
[spec.ItemType.camera]: BaseFormProperty;
|
|
85
|
+
[spec.ItemType.composition]: BaseFormProperty;
|
|
86
|
+
[spec.ItemType.spine]: BaseFormProperty;
|
|
87
|
+
[spec.ItemType.mesh]: BaseFormProperty;
|
|
88
|
+
[spec.ItemType.tree]: BaseFormProperty;
|
|
89
|
+
[spec.ItemType.text]: TextFormProperty;
|
|
90
|
+
[spec.ItemType.light]: BaseFormProperty;
|
|
91
|
+
[spec.ItemType.skybox]: BaseFormProperty;
|
|
92
|
+
[spec.ItemType.effect]: BaseFormProperty;
|
|
93
|
+
[spec.ItemType.shape]: BaseFormProperty;
|
|
94
|
+
[spec.ItemType.postProcessVolume]: BaseFormProperty;
|
|
95
|
+
[spec.ItemType.node]: BaseFormProperty;
|
|
96
|
+
[spec.ItemType.video]: BaseFormProperty;
|
|
97
|
+
[spec.ItemType.audio]: BaseFormProperty;
|
|
98
|
+
[spec.ItemType.richtext]: TextFormProperty;
|
|
99
|
+
};
|
|
100
|
+
type SpecificPageFormProps<T extends keyof PageFormTypeAndPropertyReference> = {
|
|
101
|
+
type: T;
|
|
102
|
+
property: PageFormTypeAndPropertyReference[T];
|
|
103
|
+
onPropertyValueChange: <N extends keyof PageFormTypeAndPropertyReference[T]>(propertyName: N, propertyValue: PageFormTypeAndPropertyReference[T][N]) => void;
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* @description SDK入参
|
|
107
|
+
*/
|
|
108
|
+
type SDKInputParam = {
|
|
109
|
+
/**
|
|
110
|
+
* @description JSON地址
|
|
111
|
+
*/
|
|
112
|
+
scene: string;
|
|
113
|
+
/**
|
|
114
|
+
* @description 视图参数
|
|
115
|
+
*/
|
|
116
|
+
viewParams: ViewParam[];
|
|
117
|
+
/**
|
|
118
|
+
* @description 页面属性
|
|
119
|
+
*/
|
|
120
|
+
options: PageOptions;
|
|
121
|
+
/**
|
|
122
|
+
* @description 是否开启出血区强制变换
|
|
123
|
+
*/
|
|
124
|
+
keepSafe: boolean;
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* @description 页面属性
|
|
128
|
+
*/
|
|
129
|
+
type PageOptions = {
|
|
130
|
+
/**
|
|
131
|
+
* @description 同步模式开关
|
|
132
|
+
*/
|
|
133
|
+
asyncMode: boolean;
|
|
134
|
+
/**
|
|
135
|
+
* @description 安全区展示开关
|
|
136
|
+
*/
|
|
137
|
+
safeAreaPreview: boolean;
|
|
138
|
+
/**
|
|
139
|
+
* @description 吸附开关
|
|
140
|
+
*/
|
|
141
|
+
adsorption: boolean;
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* @description 页面数据
|
|
145
|
+
*/
|
|
146
|
+
type PageData = {
|
|
147
|
+
/**
|
|
148
|
+
* @description 页面属性
|
|
149
|
+
*/
|
|
150
|
+
property: PageProperty;
|
|
151
|
+
/**
|
|
152
|
+
* @description 视图属性
|
|
153
|
+
*/
|
|
154
|
+
viewProperties: ViewProperty[];
|
|
155
|
+
/**
|
|
156
|
+
* @description 活跃数据
|
|
157
|
+
*/
|
|
158
|
+
activeData: ActiveData;
|
|
159
|
+
/**
|
|
160
|
+
* @description 元素数据
|
|
161
|
+
*/
|
|
162
|
+
items: ViewItem[];
|
|
163
|
+
/**
|
|
164
|
+
* @description 视图当前时间
|
|
165
|
+
*/
|
|
166
|
+
time: number;
|
|
167
|
+
/**
|
|
168
|
+
* @description 是否处于播放态
|
|
169
|
+
*/
|
|
170
|
+
playing: boolean;
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* @description 页面配置
|
|
174
|
+
*/
|
|
175
|
+
type PageConfig = {
|
|
176
|
+
/**
|
|
177
|
+
* @description 出血区域展示开关
|
|
178
|
+
*/
|
|
179
|
+
safeAreaPreview: boolean;
|
|
180
|
+
/**
|
|
181
|
+
* @description 缩放值
|
|
182
|
+
*/
|
|
183
|
+
zoom: number;
|
|
184
|
+
/**
|
|
185
|
+
* @description 吸附开关
|
|
186
|
+
*/
|
|
187
|
+
adsorption: boolean;
|
|
188
|
+
};
|
|
189
|
+
/**
|
|
190
|
+
* @description 页面属性
|
|
191
|
+
*/
|
|
192
|
+
type PageProperty = {
|
|
193
|
+
/**
|
|
194
|
+
* @description 出血区域展示开关
|
|
195
|
+
*/
|
|
196
|
+
safeAreaPreview: boolean;
|
|
197
|
+
/**
|
|
198
|
+
* @description 缩放值
|
|
199
|
+
*/
|
|
200
|
+
zoom: number;
|
|
201
|
+
/**
|
|
202
|
+
* @description 偏移值
|
|
203
|
+
*/
|
|
204
|
+
translation: Vector2;
|
|
205
|
+
/**
|
|
206
|
+
* @description 吸附开关
|
|
207
|
+
*/
|
|
208
|
+
adsorption: boolean;
|
|
209
|
+
/**
|
|
210
|
+
* @description 同步开关
|
|
211
|
+
*/
|
|
212
|
+
sync: boolean;
|
|
213
|
+
};
|
|
214
|
+
/**
|
|
215
|
+
* @description 视图创建参数
|
|
216
|
+
*/
|
|
217
|
+
type ViewParam = {
|
|
218
|
+
/**
|
|
219
|
+
* @description 页面尺寸
|
|
220
|
+
*/
|
|
221
|
+
size: [number, number];
|
|
222
|
+
/**
|
|
223
|
+
* @description 出血区参数
|
|
224
|
+
*/
|
|
225
|
+
safeArea: SafeAreaParam;
|
|
226
|
+
/**
|
|
227
|
+
* @description 导出参数
|
|
228
|
+
*/
|
|
229
|
+
export: ExportParam;
|
|
230
|
+
};
|
|
231
|
+
/**
|
|
232
|
+
* @description 安全区数据
|
|
233
|
+
*/
|
|
234
|
+
type SafeAreaParam = {
|
|
235
|
+
/**
|
|
236
|
+
* @description 出血区大小 - [上, 下, 左, 右]
|
|
237
|
+
*/
|
|
238
|
+
size: [number, number, number, number];
|
|
239
|
+
/**
|
|
240
|
+
* @description 元素名称关键字
|
|
241
|
+
*/
|
|
242
|
+
keyWords: string[];
|
|
243
|
+
};
|
|
244
|
+
/**
|
|
245
|
+
* @description 导出参数
|
|
246
|
+
*/
|
|
247
|
+
type ExportParam = {
|
|
248
|
+
/**
|
|
249
|
+
* @description 导出视频时长
|
|
250
|
+
*/
|
|
251
|
+
time: number;
|
|
252
|
+
/**
|
|
253
|
+
* @description 导出大小上限 - 单位kb
|
|
254
|
+
*/
|
|
255
|
+
fileSizeLimit: number;
|
|
256
|
+
/**
|
|
257
|
+
* @description 是否开启音轨
|
|
258
|
+
*/
|
|
259
|
+
audioEnable: boolean;
|
|
260
|
+
/**
|
|
261
|
+
* @description 导出视频类型 - 预留参数
|
|
262
|
+
*/
|
|
263
|
+
type?: string;
|
|
264
|
+
};
|
|
265
|
+
/**
|
|
266
|
+
* @description 视图属性
|
|
267
|
+
*/
|
|
268
|
+
type ViewProperty = {
|
|
269
|
+
/**
|
|
270
|
+
* @description 视图ID
|
|
271
|
+
*/
|
|
272
|
+
id: number;
|
|
273
|
+
/**
|
|
274
|
+
* @description 视图宽高
|
|
275
|
+
*/
|
|
276
|
+
size: [number, number];
|
|
277
|
+
/**
|
|
278
|
+
* @description 出血区数据
|
|
279
|
+
*/
|
|
280
|
+
safeArea: SafeAreaParam;
|
|
281
|
+
/**
|
|
282
|
+
* @description 视图场景数据
|
|
283
|
+
*/
|
|
284
|
+
scene: spec.JSONScene;
|
|
285
|
+
/**
|
|
286
|
+
* @description 预览图数据
|
|
287
|
+
*/
|
|
288
|
+
thumbnail: string;
|
|
289
|
+
/**
|
|
290
|
+
* @description 导出参数
|
|
291
|
+
*/
|
|
292
|
+
export: ExportParam;
|
|
293
|
+
};
|
|
294
|
+
/**
|
|
295
|
+
* @description 页面活跃数据
|
|
296
|
+
*/
|
|
297
|
+
type ActiveData = {
|
|
298
|
+
/**
|
|
299
|
+
* @description 视图ID
|
|
300
|
+
*/
|
|
301
|
+
view?: number;
|
|
302
|
+
/**
|
|
303
|
+
* @description 选中元素
|
|
304
|
+
*/
|
|
305
|
+
selectedItems: string[];
|
|
306
|
+
/**
|
|
307
|
+
* @description 预选中元素
|
|
308
|
+
*/
|
|
309
|
+
preSelectedItem?: string;
|
|
310
|
+
};
|
|
311
|
+
/**
|
|
312
|
+
* @description 视图元素
|
|
313
|
+
*/
|
|
314
|
+
type ViewItem = {
|
|
315
|
+
/**
|
|
316
|
+
* @description 元素ID
|
|
317
|
+
*/
|
|
318
|
+
id: string;
|
|
319
|
+
/**
|
|
320
|
+
* @description 元素名称
|
|
321
|
+
*/
|
|
322
|
+
name: string;
|
|
323
|
+
/**
|
|
324
|
+
* @description 元素父节点ID
|
|
325
|
+
*/
|
|
326
|
+
parentId?: string;
|
|
327
|
+
/**
|
|
328
|
+
* @description 子元素
|
|
329
|
+
*/
|
|
330
|
+
children: string[];
|
|
331
|
+
/**
|
|
332
|
+
* @description 元素生命周期
|
|
333
|
+
*/
|
|
334
|
+
duration: number;
|
|
335
|
+
/**
|
|
336
|
+
* @description 元素生命周期延时
|
|
337
|
+
*/
|
|
338
|
+
delay: number;
|
|
339
|
+
/**
|
|
340
|
+
* @description 元素结束行为
|
|
341
|
+
*/
|
|
342
|
+
endBehavior: spec.EndBehavior;
|
|
343
|
+
} & ViewItemTypedProperty;
|
|
344
|
+
|
|
345
|
+
declare const ExportStatusMap: {
|
|
346
|
+
readonly DEFAULT: "default";
|
|
347
|
+
readonly EXPORTING: "exporting";
|
|
348
|
+
readonly SUCCESS: "success";
|
|
349
|
+
readonly ERROR: "error";
|
|
350
|
+
};
|
|
351
|
+
type ExportStatus = typeof ExportStatusMap[keyof typeof ExportStatusMap];
|
|
352
|
+
type SDKEvents = {
|
|
353
|
+
'selectedItemChange': [id: string[]];
|
|
354
|
+
'preSelectedItemChange': [id: string | undefined];
|
|
355
|
+
'pageDataChange': [pageData: PageData];
|
|
356
|
+
'zoomChange': [zoom: number];
|
|
357
|
+
'progress': [{
|
|
358
|
+
duration: number;
|
|
359
|
+
time: number;
|
|
360
|
+
end: boolean;
|
|
361
|
+
paused: boolean;
|
|
362
|
+
}];
|
|
363
|
+
'exportingChange': [status: ExportStatus, progress?: number];
|
|
364
|
+
'itemPropertyChange': [{
|
|
365
|
+
id: string;
|
|
366
|
+
property: string;
|
|
367
|
+
}];
|
|
368
|
+
};
|
|
369
|
+
declare class SDK {
|
|
370
|
+
private _eventEmitter;
|
|
371
|
+
private _pageData;
|
|
372
|
+
private _screenShotContainer;
|
|
373
|
+
private _screenShotPlayer;
|
|
374
|
+
private _SDKUtils;
|
|
375
|
+
private _ExportVideo;
|
|
376
|
+
private _gestureHandler;
|
|
377
|
+
private _playerContainer;
|
|
378
|
+
private _isExportReady;
|
|
379
|
+
private _exportStatus;
|
|
380
|
+
player: Player;
|
|
381
|
+
constructor(container: HTMLElement);
|
|
382
|
+
get pageData(): PageData | undefined;
|
|
383
|
+
get exportStatus(): ExportStatus;
|
|
384
|
+
private get exportVideoCanceled();
|
|
385
|
+
dispose(): void;
|
|
386
|
+
on: <E extends "progress" | "selectedItemChange" | "preSelectedItemChange" | "pageDataChange" | "zoomChange" | "exportingChange" | "itemPropertyChange">(eventName: E, listener: _galacean_effects_weapp.EventEmitterListener<SDKEvents[E]>, options?: _galacean_effects_weapp.EventEmitterOptions) => () => void;
|
|
387
|
+
private getInitParam;
|
|
388
|
+
private initSDK;
|
|
389
|
+
run(param: SDKInputParam): Promise<void>;
|
|
390
|
+
getPageData(): PageData;
|
|
391
|
+
getActiveItems(): string[];
|
|
392
|
+
setPreSelectedItem(id: string): void;
|
|
393
|
+
getPreSelectedItem(): string;
|
|
394
|
+
setSelectedItems(itemIds: string[]): void;
|
|
395
|
+
/**
|
|
396
|
+
* @description 获取目标元素的所有属性
|
|
397
|
+
* @param param 元素ID、类型
|
|
398
|
+
* @returns 元素属性
|
|
399
|
+
*/
|
|
400
|
+
getItemProperty<T extends keyof PageFormTypeAndPropertyReference>(param: GetItemPropertyParam<T>): GetItemPropertyResult<T> | undefined;
|
|
401
|
+
/**
|
|
402
|
+
* @description 获取目标元素的指定属性
|
|
403
|
+
* @param param 元素ID、类型、属性名
|
|
404
|
+
* @returns 元素属性值
|
|
405
|
+
*/
|
|
406
|
+
getItemPropertyValue<T extends keyof PageFormTypeAndPropertyReference, N extends keyof PageFormTypeAndPropertyReference[T]>(param: GetItemPropertyValueParam<T, N>): GetItemPropertyValueResult<T, N> | undefined;
|
|
407
|
+
setItemPropertyValue(param: SetItemPropertyValueParam): void;
|
|
408
|
+
generateScreenShot(id: number): Promise<string>;
|
|
409
|
+
/**
|
|
410
|
+
* @description 切换场景
|
|
411
|
+
* @param index 场景索引
|
|
412
|
+
*/
|
|
413
|
+
switchScene(index: number): Promise<void>;
|
|
414
|
+
/**
|
|
415
|
+
* @description 获取页面的 safeAreaPreview、zoom、adsorption 值
|
|
416
|
+
* @returns 页面的 safeAreaPreview、zoom、adsorption 值
|
|
417
|
+
*/
|
|
418
|
+
getConfig(): PageConfig;
|
|
419
|
+
/**
|
|
420
|
+
* 设置页面的 safeAreaPreview、zoom、adsorption 值
|
|
421
|
+
* @param pageProperty 设置
|
|
422
|
+
*/
|
|
423
|
+
setConfig(pageConfig: PageConfig): void;
|
|
424
|
+
/**
|
|
425
|
+
* @description 设置播放进度
|
|
426
|
+
* @param progress 播放进度 0-100
|
|
427
|
+
*/
|
|
428
|
+
setPlayProgress(progress: number): void;
|
|
429
|
+
getViewItems(): ViewItem[];
|
|
430
|
+
setPlayState(playState: 'play' | 'pause'): void;
|
|
431
|
+
/**
|
|
432
|
+
* @description 获取场景预览图
|
|
433
|
+
* @returns 视图预览图
|
|
434
|
+
*/
|
|
435
|
+
getViewThumbnail(): {
|
|
436
|
+
id: number;
|
|
437
|
+
thumbnail: string;
|
|
438
|
+
}[];
|
|
439
|
+
/**
|
|
440
|
+
* @description 导出所有视频
|
|
441
|
+
* @returns 导出视频的 ArrayBuffer 数组
|
|
442
|
+
*/
|
|
443
|
+
exportAllVideos(): Promise<void>;
|
|
444
|
+
cancelExportAllVideos(): void;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
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 };
|