ugcinc 2.4.4 → 2.5.1
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 +1 -1
- package/dist/render.d.ts +9 -7
- package/dist/render.js +34 -9
- package/dist/types.d.ts +117 -24
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -11,4 +11,4 @@ export { StatsClient } from './stats';
|
|
|
11
11
|
export { OrganizationClient } from './org';
|
|
12
12
|
export { RenderClient } from './render';
|
|
13
13
|
export type { ClientConfig, } from './base';
|
|
14
|
-
export type { SuccessResponse, ErrorResponse, ApiResponse, Account, AccountStat, AccountTask, EditProfileInfo, Task, TaskType, Post, PostType, PostStat, ApiKey, EditorConfig, VideoEditorConfig, ImageEditorConfig, EditorChannel, EditorSegment, VideoSegment, AudioSegment, ImageSegment, TextSegment, StaticSegment, RenderJobSubmit, RenderVideoRequest, RenderImageRequest, RenderJobResponse, RenderJobStatus, GetAccountsParams, GetAccountStatsParams, GetAccountStatusParams, UpdateAccountInfoParams, UpdateAccountSocialParams, GetTasksParams, GetPostsParams, CreateSlideshowParams, GetPostStatsParams, GetPostStatusParams, CreateVideoParams, RefreshStatsParams, RefreshStatsResponse, RefreshStatsError, } from './types';
|
|
14
|
+
export type { SuccessResponse, ErrorResponse, ApiResponse, Account, AccountStat, AccountTask, EditProfileInfo, Task, TaskType, Post, PostType, PostStat, ApiKey, EditorConfig, VideoEditorConfig, ImageEditorConfig, EditorChannel, TimeValue, BaseSegmentProps, VisualSegmentProps, EditorSegment, VideoSegment, AudioSegment, ImageSegment, TextSegment, StaticSegment, RenderJobSubmit, RenderVideoRequest, RenderImageRequest, RenderJobResponse, RenderJobStatus, GetAccountsParams, GetAccountStatsParams, GetAccountStatusParams, UpdateAccountInfoParams, UpdateAccountSocialParams, GetTasksParams, GetPostsParams, CreateSlideshowParams, GetPostStatsParams, GetPostStatusParams, CreateVideoParams, RefreshStatsParams, RefreshStatsResponse, RefreshStatsError, } from './types';
|
package/dist/render.d.ts
CHANGED
|
@@ -56,21 +56,23 @@ export declare class RenderClient extends BaseClient {
|
|
|
56
56
|
* if (status.data.status === 'completed') {
|
|
57
57
|
* console.log('Output type:', status.data.output_type); // 'video' or 'image'
|
|
58
58
|
* console.log('Download URL:', status.data.download_url);
|
|
59
|
-
* // Use the download_url to get the file (video or image)
|
|
60
59
|
* }
|
|
61
60
|
* ```
|
|
62
61
|
*/
|
|
63
62
|
getStatus(jobId: string): Promise<ApiResponse<RenderJobStatus>>;
|
|
64
63
|
/**
|
|
65
|
-
*
|
|
64
|
+
* Download the rendered file (video or image)
|
|
66
65
|
* @param jobId - The job ID
|
|
67
|
-
* @returns
|
|
66
|
+
* @returns The rendered file as a blob
|
|
68
67
|
* @example
|
|
69
68
|
* ```typescript
|
|
70
|
-
* const
|
|
71
|
-
*
|
|
72
|
-
*
|
|
69
|
+
* const file = await client.render.download(jobId);
|
|
70
|
+
* if (file.ok) {
|
|
71
|
+
* // Create download link
|
|
72
|
+
* const url = URL.createObjectURL(file.data);
|
|
73
|
+
* window.location.href = url;
|
|
74
|
+
* }
|
|
73
75
|
* ```
|
|
74
76
|
*/
|
|
75
|
-
|
|
77
|
+
download(jobId: string): Promise<ApiResponse<Blob>>;
|
|
76
78
|
}
|
package/dist/render.js
CHANGED
|
@@ -64,26 +64,51 @@ class RenderClient extends base_1.BaseClient {
|
|
|
64
64
|
* if (status.data.status === 'completed') {
|
|
65
65
|
* console.log('Output type:', status.data.output_type); // 'video' or 'image'
|
|
66
66
|
* console.log('Download URL:', status.data.download_url);
|
|
67
|
-
* // Use the download_url to get the file (video or image)
|
|
68
67
|
* }
|
|
69
68
|
* ```
|
|
70
69
|
*/
|
|
71
70
|
async getStatus(jobId) {
|
|
72
|
-
return this.
|
|
71
|
+
return this.post('/render/status', { job_id: jobId });
|
|
73
72
|
}
|
|
74
73
|
/**
|
|
75
|
-
*
|
|
74
|
+
* Download the rendered file (video or image)
|
|
76
75
|
* @param jobId - The job ID
|
|
77
|
-
* @returns
|
|
76
|
+
* @returns The rendered file as a blob
|
|
78
77
|
* @example
|
|
79
78
|
* ```typescript
|
|
80
|
-
* const
|
|
81
|
-
*
|
|
82
|
-
*
|
|
79
|
+
* const file = await client.render.download(jobId);
|
|
80
|
+
* if (file.ok) {
|
|
81
|
+
* // Create download link
|
|
82
|
+
* const url = URL.createObjectURL(file.data);
|
|
83
|
+
* window.location.href = url;
|
|
84
|
+
* }
|
|
83
85
|
* ```
|
|
84
86
|
*/
|
|
85
|
-
|
|
86
|
-
|
|
87
|
+
async download(jobId) {
|
|
88
|
+
const response = await fetch(`${this['baseUrl']}/render/download`, {
|
|
89
|
+
method: 'POST',
|
|
90
|
+
headers: {
|
|
91
|
+
'Authorization': this.orgId ? '' : `Bearer ${this.apiKey}`,
|
|
92
|
+
'x-api-key': this.orgId ? this.apiKey : '',
|
|
93
|
+
'Content-Type': 'application/json',
|
|
94
|
+
},
|
|
95
|
+
body: JSON.stringify({ job_id: jobId })
|
|
96
|
+
});
|
|
97
|
+
if (!response.ok) {
|
|
98
|
+
const errorData = await response.json().catch(() => ({ message: 'Download failed' }));
|
|
99
|
+
return {
|
|
100
|
+
ok: false,
|
|
101
|
+
code: response.status,
|
|
102
|
+
message: errorData.message || 'Failed to download file'
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
const blob = await response.blob();
|
|
106
|
+
return {
|
|
107
|
+
ok: true,
|
|
108
|
+
code: 200,
|
|
109
|
+
message: 'Success',
|
|
110
|
+
data: blob
|
|
111
|
+
};
|
|
87
112
|
}
|
|
88
113
|
}
|
|
89
114
|
exports.RenderClient = RenderClient;
|
package/dist/types.d.ts
CHANGED
|
@@ -265,65 +265,158 @@ export interface EditorChannel {
|
|
|
265
265
|
id: string;
|
|
266
266
|
segments: EditorSegment[];
|
|
267
267
|
}
|
|
268
|
-
|
|
268
|
+
/**
|
|
269
|
+
* Time value - can be absolute (milliseconds) or relative (0-1 percentage)
|
|
270
|
+
*
|
|
271
|
+
* @example
|
|
272
|
+
* // Absolute: 500 milliseconds
|
|
273
|
+
* { type: 'absolute', value: 500 }
|
|
274
|
+
*
|
|
275
|
+
* @example
|
|
276
|
+
* // Relative: 50% of total duration
|
|
277
|
+
* { type: 'relative', value: 0.5 }
|
|
278
|
+
*/
|
|
279
|
+
export interface TimeValue {
|
|
280
|
+
type: 'absolute' | 'relative';
|
|
281
|
+
value: number;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Base properties for all segments
|
|
285
|
+
*/
|
|
286
|
+
export interface BaseSegmentProps {
|
|
287
|
+
/** Unique segment identifier */
|
|
269
288
|
id: string;
|
|
289
|
+
/** Public URL to media file */
|
|
270
290
|
source: string;
|
|
291
|
+
/** Sequence order within channel (0-based) */
|
|
271
292
|
order: number;
|
|
272
|
-
offset
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
};
|
|
293
|
+
/** Time offset after previous segment starts */
|
|
294
|
+
offset: TimeValue;
|
|
295
|
+
/** Trim from start in milliseconds (default: 0) */
|
|
276
296
|
startTrim?: number;
|
|
297
|
+
/** Trim from end in milliseconds (default: 0) */
|
|
277
298
|
endTrim?: number;
|
|
278
|
-
duration
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
299
|
+
/** Override segment duration (auto-calculated if omitted) */
|
|
300
|
+
duration?: TimeValue;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Visual segment properties (video, image, text, editor)
|
|
304
|
+
*/
|
|
305
|
+
export interface VisualSegmentProps extends BaseSegmentProps {
|
|
306
|
+
/** Horizontal position from left edge in pixels */
|
|
307
|
+
xOffset: number;
|
|
308
|
+
/** Vertical position from top edge in pixels */
|
|
309
|
+
yOffset: number;
|
|
310
|
+
/** Width in pixels */
|
|
311
|
+
width: number;
|
|
312
|
+
/** Height in pixels */
|
|
313
|
+
height: number;
|
|
314
|
+
/** Layer order - higher values appear on top (default: 0) */
|
|
286
315
|
zIndex?: number;
|
|
316
|
+
/** Scale multiplier (1.0 = 100%, 2.0 = 200%) (default: 1) */
|
|
287
317
|
scale?: number;
|
|
318
|
+
/** Rotation in degrees clockwise (default: 0) */
|
|
288
319
|
rotation?: number;
|
|
320
|
+
/** Opacity percentage 0-100 (default: 100) */
|
|
289
321
|
opacity?: number;
|
|
290
322
|
}
|
|
291
|
-
|
|
323
|
+
/**
|
|
324
|
+
* Video segment - displays video content with optional audio
|
|
325
|
+
* Only available for video output type
|
|
326
|
+
*/
|
|
327
|
+
export interface VideoSegment extends VisualSegmentProps {
|
|
292
328
|
type: 'video';
|
|
329
|
+
/** How video fits in bounds: cover (fill+crop), contain (fit+letterbox), fill (stretch) (default: 'cover') */
|
|
293
330
|
fit?: 'cover' | 'contain' | 'fill';
|
|
331
|
+
/** Playback speed multiplier (0.5 = half speed, 2.0 = double speed) (default: 1) */
|
|
294
332
|
speed?: number;
|
|
333
|
+
/** Audio volume percentage 0-100 (0 = muted, 100 = full) (default: 100) */
|
|
295
334
|
volume?: number;
|
|
296
335
|
}
|
|
297
|
-
|
|
336
|
+
/**
|
|
337
|
+
* Audio segment - background audio or music
|
|
338
|
+
* Only available for video output type
|
|
339
|
+
*/
|
|
340
|
+
export interface AudioSegment extends BaseSegmentProps {
|
|
298
341
|
type: 'audio';
|
|
342
|
+
/** Audio volume percentage 0-100 (default: 100) */
|
|
299
343
|
volume?: number;
|
|
300
344
|
}
|
|
301
|
-
|
|
345
|
+
/**
|
|
346
|
+
* Image segment - static images or animated GIFs
|
|
347
|
+
* Available for both video and image output types
|
|
348
|
+
*/
|
|
349
|
+
export interface ImageSegment extends VisualSegmentProps {
|
|
302
350
|
type: 'image';
|
|
351
|
+
/** How image fits in bounds (default: 'contain') */
|
|
303
352
|
fit?: 'cover' | 'contain' | 'fill';
|
|
353
|
+
/** Loop animated GIFs (default: false) */
|
|
304
354
|
loop?: boolean;
|
|
305
355
|
}
|
|
306
|
-
|
|
356
|
+
/**
|
|
357
|
+
* Text segment - rich text overlays with full typography control
|
|
358
|
+
* Available for both video and image output types
|
|
359
|
+
*/
|
|
360
|
+
export interface TextSegment extends VisualSegmentProps {
|
|
307
361
|
type: 'text';
|
|
308
362
|
source: '';
|
|
309
|
-
text
|
|
310
|
-
|
|
363
|
+
/** The text content (supports emojis) */
|
|
364
|
+
text: string;
|
|
365
|
+
/** Horizontal alignment (default: 'left') */
|
|
366
|
+
alignment?: 'left' | 'center' | 'right' | 'justify';
|
|
367
|
+
/** Vertical alignment within bounds (default: 'top') */
|
|
311
368
|
verticalAlign?: 'top' | 'middle' | 'bottom';
|
|
369
|
+
/** Text direction (default: 'ltr') */
|
|
312
370
|
direction?: 'ltr' | 'rtl';
|
|
371
|
+
/** Inner padding in pixels (default: 0) */
|
|
313
372
|
padding?: number;
|
|
314
|
-
|
|
373
|
+
/** Font family (default: 'tiktok') */
|
|
374
|
+
fontType?: 'tiktok' | 'apple' | 'arial';
|
|
375
|
+
/** Font size in pixels (default: 40) */
|
|
315
376
|
fontSize?: number;
|
|
316
|
-
|
|
377
|
+
/** Font weight (default: 'normal') */
|
|
378
|
+
fontWeight?: 'normal' | 'bold';
|
|
379
|
+
/** Line height multiplier (default: 1.2) */
|
|
317
380
|
lineHeight?: number;
|
|
381
|
+
/** Letter spacing in pixels (default: 0) */
|
|
318
382
|
letterSpacing?: number;
|
|
319
|
-
|
|
320
|
-
|
|
383
|
+
/** How text wraps to new lines (default: 'word') */
|
|
384
|
+
textWrap?: 'word' | 'char' | 'none';
|
|
385
|
+
/** How words break across lines (default: 'normal') */
|
|
386
|
+
wordBreak?: 'normal' | 'break-all' | 'break-word';
|
|
387
|
+
/** Automatic hyphenation (default: 'none') */
|
|
388
|
+
hyphenation?: 'none' | 'auto';
|
|
389
|
+
/** Maximum lines (0 = unlimited) (default: 0) */
|
|
390
|
+
maxLines?: number;
|
|
391
|
+
/** How overflow is handled (default: 'clip') */
|
|
392
|
+
textOverflow?: 'clip' | 'ellipsis';
|
|
393
|
+
/** Ellipsis string for overflow (default: '...') */
|
|
394
|
+
ellipsis?: string;
|
|
395
|
+
/** Text color (default: '#FFFFFF') */
|
|
321
396
|
color?: string;
|
|
397
|
+
/** Background color with optional alpha (default: transparent) */
|
|
322
398
|
backgroundColor?: string;
|
|
399
|
+
/** Text outline color (default: none) */
|
|
323
400
|
strokeColor?: string;
|
|
401
|
+
/** Outline width in pixels (default: 0) */
|
|
324
402
|
strokeWidth?: number;
|
|
325
403
|
}
|
|
326
|
-
|
|
404
|
+
/**
|
|
405
|
+
* Editor segment - nested composition (editor within editor)
|
|
406
|
+
* Only available for video output type
|
|
407
|
+
*/
|
|
408
|
+
export interface EditorSegment_Nested extends VisualSegmentProps {
|
|
409
|
+
type: 'editor';
|
|
410
|
+
/** Nested editor configuration */
|
|
411
|
+
editor: EditorConfig;
|
|
412
|
+
/** How rendered video fits in bounds (default: 'contain') */
|
|
413
|
+
fit?: 'cover' | 'contain' | 'fill';
|
|
414
|
+
/** Playback speed of nested composition (default: 1) */
|
|
415
|
+
speed?: number;
|
|
416
|
+
/** Audio volume of nested composition 0-100 (default: 100) */
|
|
417
|
+
volume?: number;
|
|
418
|
+
}
|
|
419
|
+
export type EditorSegment = VideoSegment | AudioSegment | ImageSegment | TextSegment | EditorSegment_Nested;
|
|
327
420
|
export type StaticSegment = ImageSegment | TextSegment;
|
|
328
421
|
export interface RenderVideoRequest {
|
|
329
422
|
editor?: VideoEditorConfig;
|