ugcinc 4.24.0 → 4.26.0

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.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mediaAnalysisResultSchema = exports.measureLayoutResultSchema = exports.sampleColorsResultSchema = exports.measureLayoutSchema = exports.sampleColorsSchema = exports.binaryMaskSchema = exports.audioTranscriptResultSchema = exports.audioLevelsResultSchema = exports.measureAudioLevelsSchema = exports.transcribeAudioSchema = exports.videoTextResultSchema = exports.imageTextResultSchema = exports.textLineSchema = exports.textRegionSchema = exports.readVideoTextSchema = exports.readImageTextSchema = exports.scenesResultSchema = exports.framesResultSchema = exports.analysisSourceSchema = exports.mediaAnalysisStatusSchema = exports.extractFramesSchema = exports.detectScenesSchema = void 0;
3
+ exports.mediaAnalysisResultSchema = exports.matchTextStyleResultSchema = exports.matchTextStyleSchema = exports.measureLayoutResultSchema = exports.sampleColorsResultSchema = exports.measureLayoutSchema = exports.sampleColorsSchema = exports.binaryMaskSchema = exports.audioTranscriptResultSchema = exports.audioLevelsResultSchema = exports.measureAudioLevelsSchema = exports.transcribeAudioSchema = exports.videoTextResultSchema = exports.imageTextResultSchema = exports.textLineSchema = exports.textRegionSchema = exports.readVideoTextSchema = exports.readImageTextSchema = exports.scenesResultSchema = exports.framesResultSchema = exports.analysisSourceSchema = exports.mediaAnalysisStatusSchema = exports.extractFramesSchema = exports.detectScenesSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const videoUrl = zod_1.z.string().url().max(8192).refine(value => {
6
6
  const url = new URL(value);
@@ -106,4 +106,14 @@ exports.measureLayoutResultSchema = zod_1.z.object({ version: zod_1.z.literal(1)
106
106
  elements: zod_1.z.array(zod_1.z.object({ id: zod_1.z.string(), geometry: zod_1.z.enum(['box', 'mask']), box: boxSchema.nullable(), normalizedBox: boxSchema.nullable(), boxArea: time, visibleArea: time.nullable(), visibleFractionOfCanvas: time.nullable(), boxCenter: pointSchema.nullable(), visibleCentroid: pointSchema.nullable(), margins: edges.nullable() })),
107
107
  pairs: zod_1.z.array(zod_1.z.object({ a: zod_1.z.string(), b: zod_1.z.string(), boxIntersectionArea: time, boxIoU: time.nullable(), visibleIntersectionArea: time.nullable(), visibleIoU: time.nullable(), axisGaps: zod_1.z.object({ x: finiteNumber, y: finiteNumber }).nullable(), alignmentDeltas: edges.extend({ centerX: finiteNumber, centerY: finiteNumber }).nullable() })),
108
108
  warnings: zod_1.z.array(zod_1.z.string()), previewUrl: zod_1.z.string().url(), manifestUrl: zod_1.z.string().url() });
109
- exports.mediaAnalysisResultSchema = zod_1.z.discriminatedUnion('operation', [exports.framesResultSchema, exports.scenesResultSchema, exports.imageTextResultSchema, exports.videoTextResultSchema, exports.audioTranscriptResultSchema, exports.audioLevelsResultSchema, exports.sampleColorsResultSchema, exports.measureLayoutResultSchema]);
109
+ exports.matchTextStyleSchema = zod_1.z.object({ url: videoUrl,
110
+ box: zod_1.z.object({ x: zod_1.z.number().int().min(0).max(4096), y: zod_1.z.number().int().min(0).max(4096), width: zod_1.z.number().int().min(16).max(1536), height: zod_1.z.number().int().min(16).max(512) }).strict().refine(b => b.x + b.width <= 4096 && b.y + b.height <= 4096, 'Region exceeds image limit'),
111
+ text: zod_1.z.string().min(1).max(160).refine(t => t.trim().length > 0 && t.split('\n').length <= 4 && /^[\x20-\x7e\n]+$/.test(t), 'Use printable Latin ASCII text, at most four lines').optional(),
112
+ }).strict();
113
+ const matchedTextElement = zod_1.z.object({ id: zod_1.z.string(), type: zod_1.z.literal('text'), x: finiteNumber, y: finiteNumber, width: finiteNumber, height: finiteNumber, zIndex: zod_1.z.number(), textIsVariable: zod_1.z.literal(false), text: zod_1.z.string(), font: zod_1.z.enum(['arial', 'tiktok', 'apple']), fontSize: finiteNumber,
114
+ fontWeight: zod_1.z.union([zod_1.z.literal(400), zod_1.z.literal(500), zod_1.z.literal(600), zod_1.z.literal(700), zod_1.z.literal(800), zod_1.z.literal(900)]), color: zod_1.z.string(), strokeColor: zod_1.z.string(), outlineWidth: finiteNumber, lineHeight: finiteNumber, letterSpacing: finiteNumber, textAlign: zod_1.z.enum(['left', 'center', 'right']), verticalAlign: zod_1.z.literal('top'), autoWidth: zod_1.z.literal(false), paddingTop: finiteNumber, paddingRight: finiteNumber, paddingBottom: finiteNumber, paddingLeft: finiteNumber });
115
+ exports.matchTextStyleResultSchema = zod_1.z.object({ version: zod_1.z.literal(1), operation: zod_1.z.literal('match_text_style'), source: visualSource, box: boxSchema, surface: zod_1.z.literal('image-editor-element'), status: zod_1.z.enum(['fitted', 'unavailable']), reason: zod_1.z.string().nullable(), text: zod_1.z.string().nullable(), textSource: zod_1.z.enum(['supplied', 'ocr']),
116
+ renderer: zod_1.z.object({ name: zod_1.z.literal('UGC-ImageEditorComposition'), ugcVersion: zod_1.z.string(), fonts: zod_1.z.array(zod_1.z.string()), fontHashes: zod_1.z.record(zod_1.z.string()), maxRenders: zod_1.z.number() }),
117
+ candidates: zod_1.z.array(zod_1.z.object({ element: matchedTextElement, previewConfig: zod_1.z.object({ width: zod_1.z.number(), height: zod_1.z.number(), aspectRatio: zod_1.z.string(), dimensionPreset: zod_1.z.literal('custom'), elements: zod_1.z.array(matchedTextElement), backgroundType: zod_1.z.literal('color'), backgroundColor: zod_1.z.string() }), maskIoU: zod_1.z.number().min(0).max(1), foregroundMae: zod_1.z.number().min(0).max(1), fontIdentity: zod_1.z.literal('unverified'), quality: zod_1.z.enum(['close', 'approximate']) })).max(3),
118
+ renders: zod_1.z.number().int().nonnegative(), backgroundColor: zod_1.z.string(), warnings: zod_1.z.array(zod_1.z.string()), previewUrl: zod_1.z.string().url(), manifestUrl: zod_1.z.string().url() });
119
+ exports.mediaAnalysisResultSchema = zod_1.z.discriminatedUnion('operation', [exports.framesResultSchema, exports.scenesResultSchema, exports.imageTextResultSchema, exports.videoTextResultSchema, exports.audioTranscriptResultSchema, exports.audioLevelsResultSchema, exports.sampleColorsResultSchema, exports.measureLayoutResultSchema, exports.matchTextStyleResultSchema]);
package/dist/media.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { BaseClient } from './base';
2
- import type { SampleColorsParams, MeasureLayoutParams, TranscribeAudioParams, MeasureAudioLevelsParams, ExtractFramesParams, DetectScenesParams, ReadImageTextParams, ReadVideoTextParams, MediaAnalysisJob } from './media-analysis';
2
+ import type { MatchTextStyleParams, SampleColorsParams, MeasureLayoutParams, TranscribeAudioParams, MeasureAudioLevelsParams, ExtractFramesParams, DetectScenesParams, ReadImageTextParams, ReadVideoTextParams, MediaAnalysisJob } from './media-analysis';
3
3
  import type { ListProfilePostsParams, ListProfilePostsResult, DownloadSocialPostParams, DownloadSocialPostResult } from './social-acquisition';
4
4
  import type { ApiResponse } from './types';
5
5
  export interface UserMedia {
@@ -200,7 +200,8 @@ export interface OwnedUploadResponse {
200
200
  * Client for managing media files
201
201
  */
202
202
  export declare class MediaClient extends BaseClient {
203
- /** Transcribe locally with explicit estimated segment/word timing. */
203
+ /** Fit supported image-editor text settings using local render-and-compare. */
204
+ matchTextStyle(params: MatchTextStyleParams): Promise<ApiResponse<MediaAnalysisJob>>;
204
205
  sampleColors(params: SampleColorsParams): Promise<ApiResponse<MediaAnalysisJob>>;
205
206
  measureLayout(params: MeasureLayoutParams): Promise<ApiResponse<MediaAnalysisJob>>;
206
207
  transcribeAudio(params: TranscribeAudioParams): Promise<ApiResponse<MediaAnalysisJob>>;
package/dist/media.js CHANGED
@@ -6,7 +6,10 @@ const base_1 = require("./base");
6
6
  * Client for managing media files
7
7
  */
8
8
  class MediaClient extends base_1.BaseClient {
9
- /** Transcribe locally with explicit estimated segment/word timing. */
9
+ /** Fit supported image-editor text settings using local render-and-compare. */
10
+ async matchTextStyle(params) {
11
+ return this.waitForAnalysis(await this.post('/media/analysis/match-text-style', params));
12
+ }
10
13
  async sampleColors(params) {
11
14
  return this.waitForAnalysis(await this.post('/media/analysis/sample-colors', params));
12
15
  }
@@ -401,8 +401,8 @@ export declare const iMessageDmPropsSchema: z.ZodObject<{
401
401
  }, "strip", z.ZodTypeAny, {
402
402
  width?: number | undefined;
403
403
  height?: number | undefined;
404
- time?: string | undefined;
405
404
  backgroundColor?: string | undefined;
405
+ time?: string | undefined;
406
406
  lightMode?: boolean | undefined;
407
407
  username?: string | undefined;
408
408
  profilePicUrl?: string | undefined;
@@ -584,8 +584,8 @@ export declare const iMessageDmPropsSchema: z.ZodObject<{
584
584
  }, {
585
585
  width?: number | undefined;
586
586
  height?: number | undefined;
587
- time?: string | undefined;
588
587
  backgroundColor?: string | undefined;
588
+ time?: string | undefined;
589
589
  lightMode?: boolean | undefined;
590
590
  username?: string | undefined;
591
591
  profilePicUrl?: string | undefined;
@@ -0,0 +1,36 @@
1
+ import { z } from 'zod';
2
+ /** Native points, rendered at 3 pixels per point. No coordinate rounding. */
3
+ export declare const nativeTextStickerSchema: z.ZodObject<{
4
+ profile: z.ZodDefault<z.ZodLiteral<"tiktok-classic-ios-47">>;
5
+ text: z.ZodEffects<z.ZodString, string, string>;
6
+ fontSizePt: z.ZodDefault<z.ZodNumber>;
7
+ canvasWidthPt: z.ZodDefault<z.ZodNumber>;
8
+ canvasHeightPt: z.ZodDefault<z.ZodNumber>;
9
+ containerWidthPt: z.ZodDefault<z.ZodNumber>;
10
+ /** Omit for unlimited lines clipped by the canvas; zero has the same meaning. */
11
+ containerHeightPt: z.ZodOptional<z.ZodNumber>;
12
+ originPt: z.ZodDefault<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
13
+ /** Normally omitted. Reproduces an editor whose view font differs from the text run font. */
14
+ viewFontSizePt: z.ZodOptional<z.ZodNumber>;
15
+ }, "strict", z.ZodTypeAny, {
16
+ text: string;
17
+ profile: "tiktok-classic-ios-47";
18
+ fontSizePt: number;
19
+ canvasWidthPt: number;
20
+ canvasHeightPt: number;
21
+ containerWidthPt: number;
22
+ originPt: [number, number];
23
+ containerHeightPt?: number | undefined;
24
+ viewFontSizePt?: number | undefined;
25
+ }, {
26
+ text: string;
27
+ profile?: "tiktok-classic-ios-47" | undefined;
28
+ fontSizePt?: number | undefined;
29
+ canvasWidthPt?: number | undefined;
30
+ canvasHeightPt?: number | undefined;
31
+ containerWidthPt?: number | undefined;
32
+ containerHeightPt?: number | undefined;
33
+ originPt?: [number, number] | undefined;
34
+ viewFontSizePt?: number | undefined;
35
+ }>;
36
+ export type NativeTextStickerInput = z.input<typeof nativeTextStickerSchema>;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.nativeTextStickerSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const dimension = zod_1.z.number().finite().min(1).max(1365);
6
+ const fontSize = zod_1.z.number().finite().min(11).max(72);
7
+ /** Native points, rendered at 3 pixels per point. No coordinate rounding. */
8
+ exports.nativeTextStickerSchema = zod_1.z.object({
9
+ profile: zod_1.z.literal('tiktok-classic-ios-47').default('tiktok-classic-ios-47'),
10
+ text: zod_1.z.string().min(1).max(2048).refine(text => text.split('\n').every(line => line.replace(/ /g, '').length > 0)
11
+ && !/[\u0000-\u0009\u000b-\u001f\u007f-\u009f\u2028\u2029\u202a-\u202e\u2066-\u2069]/u.test(text)
12
+ && !/[\uD800-\uDFFF]/u.test(text), 'Empty paragraphs, control characters and unpaired surrogates are not supported'),
13
+ fontSizePt: fontSize.default(28),
14
+ canvasWidthPt: dimension.default(600),
15
+ canvasHeightPt: dimension.default(180),
16
+ containerWidthPt: dimension.default(560),
17
+ /** Omit for unlimited lines clipped by the canvas; zero has the same meaning. */
18
+ containerHeightPt: zod_1.z.number().finite().min(0).max(1365).optional(),
19
+ originPt: zod_1.z.tuple([zod_1.z.number().finite().min(0).max(1365), zod_1.z.number().finite().min(0).max(1365)]).default([20, 18]),
20
+ /** Normally omitted. Reproduces an editor whose view font differs from the text run font. */
21
+ viewFontSizePt: fontSize.optional(),
22
+ }).strict();
package/dist/render.d.ts CHANGED
@@ -13,6 +13,25 @@ import type { CaptionWord, CaptionStyle } from './render/types/caption';
13
13
  import type { ImageEditorNodeConfig } from './automations/nodes/image-composer';
14
14
  import type { CreateDmMessage } from './automations/nodes/create-dm';
15
15
  import { type RemotionCompositionInput } from './render/types/remotion-composition';
16
+ import { type NativeTextStickerInput } from './render/types/native-text';
17
+ export { nativeTextStickerSchema, type NativeTextStickerInput } from './render/types/native-text';
18
+ /** Render a native text/emoji sticker directly to a transparent PNG. */
19
+ export declare function submitNativeTextStickerRenderJob(params: NativeTextStickerInput): Promise<{
20
+ ok: boolean;
21
+ code: number;
22
+ message: string;
23
+ data?: undefined;
24
+ } | {
25
+ ok: boolean;
26
+ code: number;
27
+ message: string;
28
+ data: {
29
+ message: string;
30
+ status: string;
31
+ job_id: string;
32
+ output_type: string;
33
+ };
34
+ }>;
16
35
  /** Submit TSX source and props; UGC owns registration and bundling. */
17
36
  export declare function submitRemotionCompositionRenderJob(params: RemotionCompositionInput & {
18
37
  outputType?: 'video' | 'image';
@@ -208,4 +227,3 @@ export declare function submitInstagramDmRenderJob(params: SubmitInstagramDmRend
208
227
  * Renders a fake iMessage conversation image.
209
228
  */
210
229
  export declare function submitIMessageDmRenderJob(params: SubmitIMessageDmRenderJobParams): Promise<ApiResponse<RenderJobResponse>>;
211
- export {};
package/dist/render.js CHANGED
@@ -9,6 +9,8 @@
9
9
  * variable set fails fast.
10
10
  */
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.nativeTextStickerSchema = void 0;
13
+ exports.submitNativeTextStickerRenderJob = submitNativeTextStickerRenderJob;
12
14
  exports.submitRemotionCompositionRenderJob = submitRemotionCompositionRenderJob;
13
15
  exports.submitImageRenderJob = submitImageRenderJob;
14
16
  exports.submitVideoRenderJob = submitVideoRenderJob;
@@ -21,6 +23,9 @@ exports.submitInstagramDmRenderJob = submitInstagramDmRenderJob;
21
23
  exports.submitIMessageDmRenderJob = submitIMessageDmRenderJob;
22
24
  const zod_1 = require("zod");
23
25
  const remotion_composition_1 = require("./render/types/remotion-composition");
26
+ const native_text_1 = require("./render/types/native-text");
27
+ var native_text_2 = require("./render/types/native-text");
28
+ Object.defineProperty(exports, "nativeTextStickerSchema", { enumerable: true, get: function () { return native_text_2.nativeTextStickerSchema; } });
24
29
  function renderBaseUrl() {
25
30
  const url = process.env.UGC_RENDER_URL?.trim();
26
31
  if (!url) {
@@ -29,6 +34,25 @@ function renderBaseUrl() {
29
34
  return url.replace(/\/+$/, '');
30
35
  }
31
36
  const MAX_RETRIES = 3;
37
+ /** Render a native text/emoji sticker directly to a transparent PNG. */
38
+ async function submitNativeTextStickerRenderJob(params) {
39
+ const parsed = native_text_1.nativeTextStickerSchema.safeParse(params);
40
+ if (!parsed.success)
41
+ return { ok: false, code: 400, message: parsed.error.message };
42
+ const response = await renderFetch('/submit-job', {
43
+ method: 'POST', headers: { 'Content-Type': 'application/json' },
44
+ body: JSON.stringify({ config: { _compositionType: 'native-text', ...parsed.data },
45
+ output_type: 'image', image_format: 'png' }),
46
+ });
47
+ const data = await response.json();
48
+ const result = zod_1.z.object({ job_id: zod_1.z.string(), status: zod_1.z.string(), output_type: zod_1.z.string(), message: zod_1.z.string() }).safeParse(data);
49
+ if (!response.ok || !result.success || result.data.status === 'error') {
50
+ const error = zod_1.z.object({ error: zod_1.z.string() }).safeParse(data);
51
+ return { ok: false, code: response.ok ? 400 : response.status,
52
+ message: error.success ? error.data.error : 'Failed to submit native text sticker' };
53
+ }
54
+ return { ok: true, code: 200, message: 'Native text sticker submitted', data: result.data };
55
+ }
32
56
  /** Submit TSX source and props; UGC owns registration and bundling. */
33
57
  async function submitRemotionCompositionRenderJob(params) {
34
58
  const { outputType = 'video', ...composition } = params;
@@ -4,6 +4,7 @@ exports.mediaTools = void 0;
4
4
  const media_analysis_1 = require("../media-analysis");
5
5
  const zod_1 = require("zod");
6
6
  exports.mediaTools = [
7
+ { name: 'match_text_style', description: 'Fit a reference text crop to actual UGC image-editor text settings using local render-and-compare. Provide HTTPS image URL and integer display-pixel box with a small plain-background margin; optionally exact text with line breaks (otherwise local English OCR). Up to 160 printable ASCII characters/four lines; crop 16–1536 by 16–512. Returns three supported candidates, renderable preview configs, foreground residuals and a comparison image. Fonts are approximations, not identified originals. No shadow/gradient/perspective/mixed-style support; unsuitable references explicitly unavailable. Use get_media_analysis if pending.', schema: media_analysis_1.matchTextStyleSchema, execute: async (client, params) => client.media.matchTextStyle(params) },
7
8
  { name: 'sample_colors', description: 'Sample observed sRGB colors from an image URL: optional integer point, half-open source-pixel box, or full-size row-major binary RLE mask. Counts alternate background/foreground starting with background (not COCO order). Default whole image, maxColors 8 (1–32). Returns RGBA point and alpha-weighted palette, method, omitted proportion, source hash and preview. Does not recover original authoring colors. Use get_media_analysis if pending.', schema: media_analysis_1.sampleColorsSchema, execute: async (client, params) => client.media.sampleColors(params) },
8
9
  { name: 'measure_layout', description: 'Measure supplied element boxes or binary masks against an image URL. Returns margins, centers, spacing, alignment deltas and overlap. Coordinates are display-oriented source pixels. Masks match source dimensions, row-major counts alternate background/foreground starting with background (not COCO). Up to 32 uniquely identified elements. Visible area/intersection requires masks; boxes do not imply visible ink. Does not detect elements. Use get_media_analysis if pending.', schema: media_analysis_1.measureLayoutSchema, execute: async (client, params) => client.media.measureLayout(params) },
9
10
  { name: 'transcribe_audio', description: 'Transcribe audio/video using an owned local speech model. Returns text, source-relative milliseconds, estimated segment/word timings, model details and an audio preview. No forced alignment or speaker separation. Optional range <=120 seconds and channel 0/1; default averages channels. If pending, use get_media_analysis.', schema: media_analysis_1.transcribeAudioSchema, execute: async (client, params) => client.media.transcribeAudio(params) },
package/dist/types.d.ts CHANGED
@@ -20,4 +20,4 @@ export interface ErrorResponse {
20
20
  export type ApiResponse<T> = SuccessResponse<T> | ErrorResponse;
21
21
  export type { PublicPostFailureCode, PublicPostRecovery, PublicPostNextAction, PublicPostFailure } from './post-failure';
22
22
  export type { ListProfilePostsParams, ListProfilePostsResult, DownloadSocialPostParams, DownloadSocialPostResult, SocialReferencePost, SocialReferenceAsset } from './social-acquisition';
23
- export type { SampleColorsParams, MeasureLayoutParams, SampleColorsResult, MeasureLayoutResult, TranscribeAudioParams, MeasureAudioLevelsParams, AudioTranscriptResult, AudioLevelsResult, ReadImageTextParams, ReadVideoTextParams, ImageTextResult, VideoTextResult, ExtractFramesParams, DetectScenesParams, FramesResult, ScenesResult, MediaAnalysisResult, MediaAnalysisJob } from "./media-analysis";
23
+ export type { MatchTextStyleParams, MatchTextStyleResult, SampleColorsParams, MeasureLayoutParams, SampleColorsResult, MeasureLayoutResult, TranscribeAudioParams, MeasureAudioLevelsParams, AudioTranscriptResult, AudioLevelsResult, ReadImageTextParams, ReadVideoTextParams, ImageTextResult, VideoTextResult, ExtractFramesParams, DetectScenesParams, FramesResult, ScenesResult, MediaAnalysisResult, MediaAnalysisJob } from "./media-analysis";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ugcinc",
3
- "version": "4.24.0",
3
+ "version": "4.26.0",
4
4
  "description": "TypeScript/JavaScript client for the UGC Inc API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",