ugcinc 1.1.1 → 1.1.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/README.md CHANGED
@@ -25,6 +25,128 @@ if (response.ok) {
25
25
  }
26
26
  ```
27
27
 
28
+ ## Video Rendering
29
+
30
+ The UGC Inc API now includes powerful video rendering capabilities. You can create custom videos by composing multiple layers of video, images, text, and audio.
31
+
32
+ ### Basic Video Rendering Example
33
+
34
+ ```typescript
35
+ import { UGCClient } from 'ugcinc';
36
+
37
+ const client = new UGCClient({
38
+ apiKey: 'your-api-key-here'
39
+ });
40
+
41
+ const result = await client.video.render({
42
+ editor: {
43
+ width: 1080,
44
+ height: 1920,
45
+ fps: 30,
46
+ duration: 5000, // 5 seconds in milliseconds
47
+ channels: [
48
+ {
49
+ id: "background",
50
+ segments: [
51
+ {
52
+ id: "bg-video",
53
+ type: "video",
54
+ source: "https://example.com/background.mp4",
55
+ order: 0,
56
+ offset: { type: "absolute", value: 0 },
57
+ startTrim: 0,
58
+ endTrim: 0,
59
+ xOffset: 0,
60
+ yOffset: 0,
61
+ width: 1080,
62
+ height: 1920,
63
+ zIndex: 0,
64
+ scale: 1,
65
+ rotation: 0,
66
+ fit: "cover",
67
+ speed: 1,
68
+ opacity: 100,
69
+ volume: 50
70
+ }
71
+ ]
72
+ },
73
+ {
74
+ id: "text-layer",
75
+ segments: [
76
+ {
77
+ id: "title",
78
+ type: "text",
79
+ source: "",
80
+ order: 0,
81
+ offset: { type: "absolute", value: 500 },
82
+ startTrim: 0,
83
+ endTrim: 0,
84
+ duration: { type: "absolute", value: 4000 },
85
+ xOffset: 90,
86
+ yOffset: 800,
87
+ width: 900,
88
+ height: 320,
89
+ zIndex: 10,
90
+ scale: 1,
91
+ rotation: 0,
92
+ text: "Hello World! 🎉",
93
+ alignment: "center",
94
+ verticalAlign: "middle",
95
+ direction: "ltr",
96
+ padding: 20,
97
+ fontType: "tiktok",
98
+ fontSize: 80,
99
+ fontWeight: "bold",
100
+ lineHeight: 1.2,
101
+ letterSpacing: 0,
102
+ textWrap: "word",
103
+ wordBreak: "break-word",
104
+ hyphenation: "none",
105
+ maxLines: 0,
106
+ textOverflow: "clip",
107
+ ellipsis: "...",
108
+ color: "#FFFFFF",
109
+ backgroundColor: "#00000080",
110
+ strokeColor: "#000000",
111
+ strokeWidth: 4
112
+ }
113
+ ]
114
+ }
115
+ ]
116
+ }
117
+ });
118
+
119
+ if (result.ok) {
120
+ console.log('Video URL:', result.data.video_url);
121
+ }
122
+ ```
123
+
124
+ ### Segment Types
125
+
126
+ The video renderer supports multiple segment types:
127
+
128
+ - **video**: Video clips with playback control
129
+ - **image**: Static or animated images (including GIFs)
130
+ - **text**: Customizable text overlays with fonts, colors, and effects
131
+ - **audio**: Audio tracks that can be mixed together
132
+ - **editor**: Nested editors for complex compositions
133
+
134
+ ### Time Values
135
+
136
+ Time values can be specified as absolute (milliseconds) or relative (0-1 percentage):
137
+
138
+ ```typescript
139
+ // Absolute time (500ms)
140
+ offset: { type: "absolute", value: 500 }
141
+
142
+ // Relative time (50% of video duration)
143
+ offset: { type: "relative", value: 0.5 }
144
+ ```
145
+
146
+ ### Layering with Channels
147
+
148
+ Organize your composition into channels, where each channel can contain multiple segments. Segments are ordered by their `order` property and layered by their `zIndex`.
149
+
28
150
  ## Get Your API Key
29
151
 
30
152
  To get your API key:
@@ -46,7 +168,16 @@ For complete API documentation, including all endpoints, parameters, and example
46
168
  This package is written in TypeScript and provides full type definitions:
47
169
 
48
170
  ```typescript
49
- import type { Account, Post, Task, ApiResponse } from 'ugcinc';
171
+ import type {
172
+ Account,
173
+ Post,
174
+ Task,
175
+ ApiResponse,
176
+ Editor,
177
+ VideoSegment,
178
+ TextSegment,
179
+ Channel
180
+ } from 'ugcinc';
50
181
  ```
51
182
 
52
183
  ## License
package/dist/client.d.ts CHANGED
@@ -2,6 +2,7 @@ import { AccountsClient } from './accounts';
2
2
  import { TasksClient } from './tasks';
3
3
  import { PostsClient } from './posts';
4
4
  import { StatsClient } from './stats';
5
+ import { VideoClient } from './video';
5
6
  import type { ClientConfig } from './base';
6
7
  /**
7
8
  * Main UGC Inc API Client
@@ -26,6 +27,16 @@ import type { ClientConfig } from './base';
26
27
  * videoUrl: 'https://example.com/video.mp4',
27
28
  * caption: 'My awesome video!',
28
29
  * });
30
+ *
31
+ * // Render a video
32
+ * const renderResponse = await client.video.render({
33
+ * editor: {
34
+ * width: 1080,
35
+ * height: 1920,
36
+ * fps: 30,
37
+ * channels: [...]
38
+ * }
39
+ * });
29
40
  * ```
30
41
  */
31
42
  export declare class UGCClient {
@@ -45,5 +56,9 @@ export declare class UGCClient {
45
56
  * Client for statistics operations
46
57
  */
47
58
  stats: StatsClient;
59
+ /**
60
+ * Client for video rendering operations
61
+ */
62
+ video: VideoClient;
48
63
  constructor(config: ClientConfig);
49
64
  }
package/dist/client.js CHANGED
@@ -5,6 +5,7 @@ const accounts_1 = require("./accounts");
5
5
  const tasks_1 = require("./tasks");
6
6
  const posts_1 = require("./posts");
7
7
  const stats_1 = require("./stats");
8
+ const video_1 = require("./video");
8
9
  /**
9
10
  * Main UGC Inc API Client
10
11
  *
@@ -28,6 +29,16 @@ const stats_1 = require("./stats");
28
29
  * videoUrl: 'https://example.com/video.mp4',
29
30
  * caption: 'My awesome video!',
30
31
  * });
32
+ *
33
+ * // Render a video
34
+ * const renderResponse = await client.video.render({
35
+ * editor: {
36
+ * width: 1080,
37
+ * height: 1920,
38
+ * fps: 30,
39
+ * channels: [...]
40
+ * }
41
+ * });
31
42
  * ```
32
43
  */
33
44
  class UGCClient {
@@ -36,6 +47,7 @@ class UGCClient {
36
47
  this.tasks = new tasks_1.TasksClient(config);
37
48
  this.posts = new posts_1.PostsClient(config);
38
49
  this.stats = new stats_1.StatsClient(config);
50
+ this.video = new video_1.VideoClient(config);
39
51
  }
40
52
  }
41
53
  exports.UGCClient = UGCClient;
package/dist/index.d.ts CHANGED
@@ -8,5 +8,6 @@ export { AccountsClient } from './accounts';
8
8
  export { TasksClient } from './tasks';
9
9
  export { PostsClient } from './posts';
10
10
  export { StatsClient } from './stats';
11
+ export { VideoClient } from './video';
11
12
  export type { ClientConfig, } from './base';
12
- export type { SuccessResponse, ErrorResponse, ApiResponse, Account, AccountStat, AccountTask, EditProfileInfo, Task, TaskType, Post, PostType, PostStat, GetAccountsParams, GetAccountStatsParams, GetAccountStatusParams, UpdateAccountInfoParams, UpdateAccountSocialParams, GetTasksParams, GetPostsParams, CreateSlideshowParams, GetPostStatsParams, GetPostStatusParams, CreateVideoParams, RefreshStatsParams, RefreshStatsResponse, RefreshStatsError, } from './types';
13
+ export type { SuccessResponse, ErrorResponse, ApiResponse, Account, AccountStat, AccountTask, EditProfileInfo, Task, TaskType, Post, PostType, PostStat, GetAccountsParams, GetAccountStatsParams, GetAccountStatusParams, UpdateAccountInfoParams, UpdateAccountSocialParams, GetTasksParams, GetPostsParams, CreateSlideshowParams, GetPostStatsParams, GetPostStatusParams, CreateVideoParams, RefreshStatsParams, RefreshStatsResponse, RefreshStatsError, RenderVideoParams, RenderVideoResponse, SegmentType, TimeValue, BaseSegment, VisualSegment, PictureSegment, VideoSegment, ImageSegment, AudioSegment, TextSegment, EditorSegment, Channel, Editor, } from './types';
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@
5
5
  * Official TypeScript/JavaScript client for the UGC Inc API
6
6
  */
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.StatsClient = exports.PostsClient = exports.TasksClient = exports.AccountsClient = exports.UGCClient = void 0;
8
+ exports.VideoClient = exports.StatsClient = exports.PostsClient = exports.TasksClient = exports.AccountsClient = exports.UGCClient = void 0;
9
9
  var client_1 = require("./client");
10
10
  Object.defineProperty(exports, "UGCClient", { enumerable: true, get: function () { return client_1.UGCClient; } });
11
11
  var accounts_1 = require("./accounts");
@@ -16,3 +16,5 @@ var posts_1 = require("./posts");
16
16
  Object.defineProperty(exports, "PostsClient", { enumerable: true, get: function () { return posts_1.PostsClient; } });
17
17
  var stats_1 = require("./stats");
18
18
  Object.defineProperty(exports, "StatsClient", { enumerable: true, get: function () { return stats_1.StatsClient; } });
19
+ var video_1 = require("./video");
20
+ Object.defineProperty(exports, "VideoClient", { enumerable: true, get: function () { return video_1.VideoClient; } });
package/dist/types.d.ts CHANGED
@@ -173,3 +173,16 @@ export interface RefreshStatsResponse {
173
173
  post_stats_count: number;
174
174
  errors?: RefreshStatsError[];
175
175
  }
176
+ /**
177
+ * Video rendering types - imported from video-render module
178
+ * These are copied during the build process from ../../src/video-render/types/
179
+ */
180
+ import type { SegmentType, TimeValue, BaseSegment, VisualSegment, PictureSegment, VideoSegment, ImageSegment, AudioSegment, TextSegment, EditorSegment } from './video-render-types/segment';
181
+ import type { Channel, Editor } from './video-render-types/video';
182
+ export type { SegmentType, TimeValue, BaseSegment, VisualSegment, PictureSegment, VideoSegment, ImageSegment, AudioSegment, TextSegment, EditorSegment, Channel, Editor, };
183
+ export interface RenderVideoParams {
184
+ editor: Editor;
185
+ }
186
+ export interface RenderVideoResponse {
187
+ video_url: string;
188
+ }
@@ -0,0 +1,78 @@
1
+ export type SegmentType = 'video' | 'image' | 'text' | 'audio' | 'editor';
2
+ export type TimeValue = {
3
+ type: 'absolute';
4
+ value: number;
5
+ } | {
6
+ type: 'relative';
7
+ value: number;
8
+ };
9
+ export interface BaseSegment {
10
+ id: string;
11
+ type: SegmentType;
12
+ source: string;
13
+ order: number;
14
+ offset: TimeValue;
15
+ startTrim: number;
16
+ endTrim: number;
17
+ duration?: TimeValue;
18
+ }
19
+ export interface VisualSegment extends BaseSegment {
20
+ type: 'video' | 'image' | 'text';
21
+ xOffset: number;
22
+ yOffset: number;
23
+ width: number;
24
+ height: number;
25
+ zIndex: number;
26
+ scale: number;
27
+ rotation: number;
28
+ }
29
+ export interface PictureSegment extends VisualSegment {
30
+ type: 'video' | 'image';
31
+ fit: 'cover' | 'contain' | 'fill';
32
+ speed: number;
33
+ opacity: number;
34
+ }
35
+ export interface VideoSegment extends PictureSegment {
36
+ type: 'video';
37
+ volume: number;
38
+ }
39
+ export interface ImageSegment extends PictureSegment {
40
+ type: 'image';
41
+ loop: boolean;
42
+ }
43
+ export interface AudioSegment extends BaseSegment {
44
+ type: 'audio';
45
+ }
46
+ export interface TextSegment extends VisualSegment {
47
+ type: 'text';
48
+ text: string;
49
+ alignment: 'left' | 'center' | 'right' | 'justify';
50
+ verticalAlign: 'top' | 'middle' | 'bottom';
51
+ direction: 'ltr' | 'rtl' | 'auto';
52
+ padding: number;
53
+ fontType: 'arial' | 'tiktok' | 'apple';
54
+ fontSize: number;
55
+ fontWeight: 'normal' | 'bold';
56
+ lineHeight: number;
57
+ letterSpacing: number;
58
+ textWrap: 'word' | 'char' | 'none';
59
+ wordBreak: 'normal' | 'break-word' | 'break-all';
60
+ hyphenation: 'none' | 'auto';
61
+ maxLines: number;
62
+ textOverflow: 'clip' | 'ellipsis';
63
+ ellipsis: string;
64
+ color: string;
65
+ backgroundColor: string;
66
+ strokeColor?: string;
67
+ strokeWidth?: number;
68
+ }
69
+ import type { Editor } from './video';
70
+ export interface EditorSegment extends Omit<VisualSegment, 'type' | 'source'> {
71
+ type: 'editor';
72
+ source: '';
73
+ editor: Editor;
74
+ fit?: 'cover' | 'contain' | 'fill';
75
+ opacity?: number;
76
+ speed?: number;
77
+ volume?: number;
78
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,12 @@
1
+ import type { BaseSegment, EditorSegment } from "./segment";
2
+ export interface Channel {
3
+ id: string;
4
+ segments: Array<BaseSegment | EditorSegment>;
5
+ }
6
+ export interface Editor {
7
+ width: number;
8
+ height: number;
9
+ duration?: number;
10
+ fps: number;
11
+ channels: Channel[];
12
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,50 @@
1
+ import { BaseClient } from './base';
2
+ import type { RenderVideoParams, RenderVideoResponse, ApiResponse } from './types';
3
+ /**
4
+ * Client for video rendering operations
5
+ */
6
+ export declare class VideoClient extends BaseClient {
7
+ /**
8
+ * Render a video from an editor configuration
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * const result = await client.video.render({
13
+ * editor: {
14
+ * width: 1080,
15
+ * height: 1920,
16
+ * fps: 30,
17
+ * duration: 5000,
18
+ * channels: [
19
+ * {
20
+ * id: "background",
21
+ * segments: [
22
+ * {
23
+ * id: "bg-video",
24
+ * type: "video",
25
+ * source: "https://example.com/video.mp4",
26
+ * order: 0,
27
+ * offset: { type: "absolute", value: 0 },
28
+ * startTrim: 0,
29
+ * endTrim: 0,
30
+ * xOffset: 0,
31
+ * yOffset: 0,
32
+ * width: 1080,
33
+ * height: 1920,
34
+ * zIndex: 0,
35
+ * scale: 1,
36
+ * rotation: 0,
37
+ * fit: "cover",
38
+ * speed: 1,
39
+ * opacity: 100,
40
+ * volume: 50
41
+ * }
42
+ * ]
43
+ * }
44
+ * ]
45
+ * }
46
+ * });
47
+ * ```
48
+ */
49
+ render(params: RenderVideoParams): Promise<ApiResponse<RenderVideoResponse>>;
50
+ }
package/dist/video.js ADDED
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VideoClient = void 0;
4
+ const base_1 = require("./base");
5
+ /**
6
+ * Client for video rendering operations
7
+ */
8
+ class VideoClient extends base_1.BaseClient {
9
+ /**
10
+ * Render a video from an editor configuration
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * const result = await client.video.render({
15
+ * editor: {
16
+ * width: 1080,
17
+ * height: 1920,
18
+ * fps: 30,
19
+ * duration: 5000,
20
+ * channels: [
21
+ * {
22
+ * id: "background",
23
+ * segments: [
24
+ * {
25
+ * id: "bg-video",
26
+ * type: "video",
27
+ * source: "https://example.com/video.mp4",
28
+ * order: 0,
29
+ * offset: { type: "absolute", value: 0 },
30
+ * startTrim: 0,
31
+ * endTrim: 0,
32
+ * xOffset: 0,
33
+ * yOffset: 0,
34
+ * width: 1080,
35
+ * height: 1920,
36
+ * zIndex: 0,
37
+ * scale: 1,
38
+ * rotation: 0,
39
+ * fit: "cover",
40
+ * speed: 1,
41
+ * opacity: 100,
42
+ * volume: 50
43
+ * }
44
+ * ]
45
+ * }
46
+ * ]
47
+ * }
48
+ * });
49
+ * ```
50
+ */
51
+ async render(params) {
52
+ return this.post('/video/render', params);
53
+ }
54
+ }
55
+ exports.VideoClient = VideoClient;
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "ugcinc",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "TypeScript/JavaScript client for the UGC Inc API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "scripts": {
8
- "build": "tsc",
8
+ "prebuild": "node -e \"const fs = require('fs'); const path = require('path'); const srcDir = path.join(__dirname, '../../src/video-render/types'); const destDir = path.join(__dirname, 'src/video-render-types'); fs.mkdirSync(destDir, {recursive: true}); ['segment.ts', 'video.ts'].forEach(file => fs.copyFileSync(path.join(srcDir, file), path.join(destDir, file)));\"",
9
+ "build": "npm run prebuild && tsc",
9
10
  "prepublishOnly": "npm run build",
10
11
  "test": "echo \"No tests specified\" && exit 0"
11
12
  },