ugcinc 4.23.0 → 4.25.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.
- package/README.md +51 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +8 -1
- package/dist/media-analysis.d.ts +4458 -1638
- package/dist/media-analysis.js +31 -2
- package/dist/media.d.ts +5 -2
- package/dist/media.js +10 -1
- package/dist/render/compositions/IMessageDmComposition/types.d.ts +2 -2
- package/dist/tools/media.js +3 -0
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
package/dist/media-analysis.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mediaAnalysisResultSchema = 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);
|
|
@@ -87,4 +87,33 @@ exports.audioTranscriptResultSchema = zod_1.z.object({ version: zod_1.z.literal(
|
|
|
87
87
|
segments: zod_1.z.array(zod_1.z.object({ index: zod_1.z.number().int(), text: zod_1.z.string(), startMs: zod_1.z.number().finite(), endMs: zod_1.z.number().finite(), timing: zod_1.z.literal('estimated'), avgLogProbability: zod_1.z.number(), noSpeechProbability: zod_1.z.number(), words: zod_1.z.array(estimatedWord) })),
|
|
88
88
|
language: zod_1.z.string().nullable(), languageProbability: zod_1.z.number().nullable(), segmentTiming: zod_1.z.enum(['estimated', 'unavailable']), wordTiming: zod_1.z.enum(['estimated', 'unavailable']), speakerLabels: zod_1.z.literal('unavailable'),
|
|
89
89
|
channelPolicy: zod_1.z.string(), warnings: zod_1.z.array(zod_1.z.string()), audioPreviewUrl: zod_1.z.string().url().optional(), manifestUrl: zod_1.z.string().url() });
|
|
90
|
-
|
|
90
|
+
const imageBox = zod_1.z.object({ x: zod_1.z.number().finite().min(0).max(4096), y: zod_1.z.number().finite().min(0).max(4096), width: zod_1.z.number().finite().positive().max(4096), height: zod_1.z.number().finite().positive().max(4096) }).strict().refine(b => b.x + b.width <= 4096 && b.y + b.height <= 4096, 'Box exceeds image limit');
|
|
91
|
+
exports.binaryMaskSchema = zod_1.z.object({ width: zod_1.z.number().int().min(1).max(4096), height: zod_1.z.number().int().min(1).max(4096), counts: zod_1.z.array(zod_1.z.number().int().min(0).max(16777216)).min(1).max(100000) }).strict().refine(m => m.counts.reduce((s, n) => s + n, 0) === m.width * m.height && m.counts.every((n, i) => i === 0 || n > 0), 'Row-major runs must sum to width*height and alternate background/foreground; only first may be zero');
|
|
92
|
+
exports.sampleColorsSchema = zod_1.z.object({ url: videoUrl,
|
|
93
|
+
point: zod_1.z.object({ x: zod_1.z.number().int().min(0).max(4095), y: zod_1.z.number().int().min(0).max(4095) }).strict().optional(),
|
|
94
|
+
box: imageBox.optional(), mask: exports.binaryMaskSchema.optional(), maxColors: zod_1.z.number().int().min(1).max(32).default(8),
|
|
95
|
+
}).strict().refine(v => [v.point, v.box, v.mask].filter(x => x !== undefined).length <= 1, 'Provide at most one point, box or mask');
|
|
96
|
+
const layoutElement = zod_1.z.object({ id: zod_1.z.string().min(1).max(80), box: imageBox.optional(), mask: exports.binaryMaskSchema.optional() }).strict().refine(v => Boolean(v.box) !== Boolean(v.mask), 'Provide box or mask exclusively');
|
|
97
|
+
exports.measureLayoutSchema = zod_1.z.object({ url: videoUrl, elements: zod_1.z.array(layoutElement).min(1).max(32) }).strict().refine(v => new Set(v.elements.map(e => e.id)).size === v.elements.length && v.elements.reduce((s, e) => s + (e.mask?.counts.length ?? 0), 0) <= 100000, 'IDs must be unique; total mask runs at most 100000');
|
|
98
|
+
const visualSource = zod_1.z.object({ encodedWidth: zod_1.z.number(), encodedHeight: zod_1.z.number(), displayWidth: zod_1.z.number(), displayHeight: zod_1.z.number(), exifOrientation: zod_1.z.number(), colorSpace: zod_1.z.literal('sRGB'), colorPolicy: zod_1.z.enum(['embedded-ICC-to-sRGB-relative-colorimetric', 'untagged-assumed-sRGB']), alphaPolicy: zod_1.z.literal('straight-alpha-no-background-composite'), sha256: zod_1.z.string(), bytes: zod_1.z.number() });
|
|
99
|
+
const finiteNumber = zod_1.z.number().finite();
|
|
100
|
+
const edges = zod_1.z.object({ left: finiteNumber, top: finiteNumber, right: finiteNumber, bottom: finiteNumber });
|
|
101
|
+
exports.sampleColorsResultSchema = zod_1.z.object({ version: zod_1.z.literal(1), operation: zod_1.z.literal('sample_colors'), source: visualSource,
|
|
102
|
+
point: zod_1.z.object({ x: finiteNumber, y: finiteNumber, rgba: zod_1.z.array(zod_1.z.number().int().min(0).max(255)).length(4) }).nullable(), selectionBox: boxSchema.nullable(),
|
|
103
|
+
selectedPixelCount: time, visiblePixelCount: time, alphaWeight: time, palette: zod_1.z.array(zod_1.z.object({ rgb: zod_1.z.array(zod_1.z.number().int().min(0).max(255)).length(3), hex: zod_1.z.string(), proportion: zod_1.z.number().min(0).max(1) })), otherProportion: zod_1.z.number().min(0).max(1),
|
|
104
|
+
method: zod_1.z.enum(['exact-observed-colors', '5-bit-sRGB-bins-alpha-weighted-mean']), warnings: zod_1.z.array(zod_1.z.string()), previewUrl: zod_1.z.string().url(), manifestUrl: zod_1.z.string().url() });
|
|
105
|
+
exports.measureLayoutResultSchema = zod_1.z.object({ version: zod_1.z.literal(1), operation: zod_1.z.literal('measure_layout'), source: visualSource, coordinates: zod_1.z.literal('display-oriented-source-pixels'),
|
|
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
|
+
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
|
+
warnings: zod_1.z.array(zod_1.z.string()), previewUrl: zod_1.z.string().url(), manifestUrl: zod_1.z.string().url() });
|
|
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 { 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,10 @@ export interface OwnedUploadResponse {
|
|
|
200
200
|
* Client for managing media files
|
|
201
201
|
*/
|
|
202
202
|
export declare class MediaClient extends BaseClient {
|
|
203
|
-
/**
|
|
203
|
+
/** Fit supported image-editor text settings using local render-and-compare. */
|
|
204
|
+
matchTextStyle(params: MatchTextStyleParams): Promise<ApiResponse<MediaAnalysisJob>>;
|
|
205
|
+
sampleColors(params: SampleColorsParams): Promise<ApiResponse<MediaAnalysisJob>>;
|
|
206
|
+
measureLayout(params: MeasureLayoutParams): Promise<ApiResponse<MediaAnalysisJob>>;
|
|
204
207
|
transcribeAudio(params: TranscribeAudioParams): Promise<ApiResponse<MediaAnalysisJob>>;
|
|
205
208
|
/** Measure native-channel loudness, RMS/peaks, silence and potential clipping. */
|
|
206
209
|
measureAudioLevels(params: MeasureAudioLevelsParams): Promise<ApiResponse<MediaAnalysisJob>>;
|
package/dist/media.js
CHANGED
|
@@ -6,7 +6,16 @@ const base_1 = require("./base");
|
|
|
6
6
|
* Client for managing media files
|
|
7
7
|
*/
|
|
8
8
|
class MediaClient extends base_1.BaseClient {
|
|
9
|
-
/**
|
|
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
|
+
}
|
|
13
|
+
async sampleColors(params) {
|
|
14
|
+
return this.waitForAnalysis(await this.post('/media/analysis/sample-colors', params));
|
|
15
|
+
}
|
|
16
|
+
async measureLayout(params) {
|
|
17
|
+
return this.waitForAnalysis(await this.post('/media/analysis/measure-layout', params));
|
|
18
|
+
}
|
|
10
19
|
async transcribeAudio(params) {
|
|
11
20
|
return this.waitForAnalysis(await this.post('/media/analysis/transcribe-audio', params));
|
|
12
21
|
}
|
|
@@ -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;
|
package/dist/tools/media.js
CHANGED
|
@@ -4,6 +4,9 @@ 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) },
|
|
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) },
|
|
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) },
|
|
7
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) },
|
|
8
11
|
{ name: 'measure_audio_levels', description: 'Measure audio/video native-channel RMS and sample peaks, integrated/momentary/short-term loudness, estimated true peaks, window-based silence and possible clipping. Distinguishes missing audio from silence and sample peaks from intersample overshoot. Optional range <=120 seconds; default windows 100ms. If pending, use get_media_analysis.', schema: media_analysis_1.measureAudioLevelsSchema, execute: async (client, params) => client.media.measureAudioLevels(params) },
|
|
9
12
|
{ name: 'read_image_text', description: 'Read English image text with raw recognition, polygons in display-oriented source pixels, inferred lines/order and confidence. Includes annotated preview. Empty output does not prove no text. If pending, use get_media_analysis.', schema: media_analysis_1.readImageTextSchema, execute: async (client, params) => client.media.readImageText(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 { 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";
|