ugcinc 5.3.2 → 5.5.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.
Files changed (34) hide show
  1. package/README.md +70 -58
  2. package/dist/content-skills.js +4 -4
  3. package/dist/index.d.ts +1 -1
  4. package/dist/media-analysis.d.ts +460 -180
  5. package/dist/media-analysis.js +16 -9
  6. package/dist/render/components/TextElement.js +1 -1
  7. package/dist/render/compositions/IMessageDmComposition/convertPropsToElements.d.ts +27 -0
  8. package/dist/render/compositions/IMessageDmComposition/convertPropsToElements.js +629 -0
  9. package/dist/render/compositions/IMessageDmComposition/index.d.ts +21 -0
  10. package/dist/render/compositions/IMessageDmComposition/index.js +504 -0
  11. package/dist/render/compositions/IMessageDmComposition/types.d.ts +767 -0
  12. package/dist/render/compositions/IMessageDmComposition/types.js +228 -0
  13. package/dist/render/compositions/ImageEditorComposition.js +15 -2
  14. package/dist/render/compositions/VideoEditorComposition.js +7 -0
  15. package/dist/render/hooks/index.d.ts +10 -0
  16. package/dist/render/hooks/index.js +50 -0
  17. package/dist/render/types/base.d.ts +2 -0
  18. package/dist/render/types/element.d.ts +5 -0
  19. package/dist/render/types/native-text.d.ts +106 -1
  20. package/dist/render/types/native-text.js +17 -2
  21. package/dist/render/utils/fonts.d.ts +45 -3
  22. package/dist/render/utils/fonts.js +84 -3
  23. package/dist/render/utils/index.d.ts +1 -1
  24. package/dist/render/utils/index.js +9 -1
  25. package/dist/render/utils/positionResolver.js +2 -1
  26. package/dist/render.d.ts +1 -1
  27. package/dist/render.js +1 -1
  28. package/dist/skills.js +2 -2
  29. package/dist/stats.d.ts +24 -0
  30. package/dist/stats.js +11 -0
  31. package/package.json +1 -1
  32. package/skills/content-automation/SKILL.md +4 -2
  33. package/skills/media/SKILL.md +32 -11
  34. package/skills/media/references/tools.md +25 -20
@@ -0,0 +1,228 @@
1
+ "use strict";
2
+ /**
3
+ * iMessage DM Composition Types
4
+ *
5
+ * Types for the iMessage DM conversation composition.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.iMessageDmPropsSchema = void 0;
9
+ const zod_1 = require("zod");
10
+ /**
11
+ * Zod schema for iMessage DM composition props (for Remotion)
12
+ */
13
+ exports.iMessageDmPropsSchema = zod_1.z.object({
14
+ // Canvas
15
+ width: zod_1.z.number().optional(),
16
+ height: zod_1.z.number().optional(),
17
+ durationInFrames: zod_1.z.number().optional(),
18
+ fps: zod_1.z.number().optional(),
19
+ // Debug
20
+ showDebugOverlay: zod_1.z.boolean().optional(),
21
+ referenceImageUrl: zod_1.z.string().optional(),
22
+ showReferenceImage: zod_1.z.boolean().optional(),
23
+ referenceOpacity: zod_1.z.number().optional(),
24
+ // Light mode
25
+ lightMode: zod_1.z.boolean().optional(),
26
+ // iMessage header
27
+ headerTop: zod_1.z.number().optional(),
28
+ headerBottom: zod_1.z.number().optional(),
29
+ headerBackgroundColor: zod_1.z.string().optional(),
30
+ // Header profile section
31
+ profilePicUrl: zod_1.z.string().optional(),
32
+ profilePicTop: zod_1.z.number().optional(),
33
+ profilePicBottom: zod_1.z.number().optional(),
34
+ profilePicLeft: zod_1.z.number().optional(),
35
+ profilePicRight: zod_1.z.number().optional(),
36
+ username: zod_1.z.string().optional(),
37
+ usernameTop: zod_1.z.number().optional(),
38
+ usernameBottom: zod_1.z.number().optional(),
39
+ usernameLeft: zod_1.z.number().optional(),
40
+ usernameRight: zod_1.z.number().optional(),
41
+ usernameFontSize: zod_1.z.number().optional(),
42
+ usernameLetterSpacing: zod_1.z.number().optional(),
43
+ usernameColor: zod_1.z.string().optional(),
44
+ usernameArrowOffsetX: zod_1.z.number().optional(),
45
+ usernameArrowOffsetY: zod_1.z.number().optional(),
46
+ usernameArrowWidth: zod_1.z.number().optional(),
47
+ usernameArrowHeight: zod_1.z.number().optional(),
48
+ // Back arrow
49
+ backArrowTop: zod_1.z.number().optional(),
50
+ backArrowBottom: zod_1.z.number().optional(),
51
+ backArrowLeft: zod_1.z.number().optional(),
52
+ backArrowRight: zod_1.z.number().optional(),
53
+ // Unread badge
54
+ unreadBadgeText: zod_1.z.string().optional(),
55
+ unreadBadgeTop: zod_1.z.number().optional(),
56
+ unreadBadgeBottom: zod_1.z.number().optional(),
57
+ unreadBadgeLeft: zod_1.z.number().optional(),
58
+ unreadBadgeFontSize: zod_1.z.number().optional(),
59
+ unreadBadgeLetterSpacing: zod_1.z.number().optional(),
60
+ unreadBadgeTextColor: zod_1.z.string().optional(),
61
+ unreadBadgeBorderRadius: zod_1.z.number().optional(),
62
+ unreadBadgePaddingLeft: zod_1.z.number().optional(),
63
+ unreadBadgePaddingRight: zod_1.z.number().optional(),
64
+ // Camera icon
65
+ cameraIconTop: zod_1.z.number().optional(),
66
+ cameraIconBottom: zod_1.z.number().optional(),
67
+ cameraIconLeft: zod_1.z.number().optional(),
68
+ cameraIconRight: zod_1.z.number().optional(),
69
+ dividerLineY: zod_1.z.number().optional(),
70
+ dividerLineColor: zod_1.z.string().optional(),
71
+ backgroundColor: zod_1.z.string().optional(),
72
+ // Status bar - Time
73
+ time: zod_1.z.string().optional(),
74
+ timeRight: zod_1.z.number().optional(),
75
+ timeBottom: zod_1.z.number().optional(),
76
+ timeFontSize: zod_1.z.number().optional(),
77
+ timeLetterSpacing: zod_1.z.number().optional(),
78
+ timeColor: zod_1.z.string().optional(),
79
+ // Status bar - No notifications
80
+ noNotisTop: zod_1.z.number().optional(),
81
+ noNotisBottom: zod_1.z.number().optional(),
82
+ noNotisLeft: zod_1.z.number().optional(),
83
+ noNotisRight: zod_1.z.number().optional(),
84
+ // Status bar - Cell signal
85
+ cellLevel: zod_1.z.number().min(0).max(4).optional(),
86
+ cell1Top: zod_1.z.number().optional(),
87
+ cell1Bottom: zod_1.z.number().optional(),
88
+ cell1Left: zod_1.z.number().optional(),
89
+ cell1Right: zod_1.z.number().optional(),
90
+ cell2Top: zod_1.z.number().optional(),
91
+ cell2Bottom: zod_1.z.number().optional(),
92
+ cell2Left: zod_1.z.number().optional(),
93
+ cell2Right: zod_1.z.number().optional(),
94
+ cell3Top: zod_1.z.number().optional(),
95
+ cell3Bottom: zod_1.z.number().optional(),
96
+ cell3Left: zod_1.z.number().optional(),
97
+ cell3Right: zod_1.z.number().optional(),
98
+ cell4Top: zod_1.z.number().optional(),
99
+ cell4Bottom: zod_1.z.number().optional(),
100
+ cell4Left: zod_1.z.number().optional(),
101
+ cell4Right: zod_1.z.number().optional(),
102
+ // Status bar - WiFi
103
+ wifiTop: zod_1.z.number().optional(),
104
+ wifiBottom: zod_1.z.number().optional(),
105
+ wifiLeft: zod_1.z.number().optional(),
106
+ wifiRight: zod_1.z.number().optional(),
107
+ // Status bar - Battery
108
+ batteryTop: zod_1.z.number().optional(),
109
+ batteryBottom: zod_1.z.number().optional(),
110
+ batteryLeft: zod_1.z.number().optional(),
111
+ batteryRight: zod_1.z.number().optional(),
112
+ // Home indicator
113
+ homeIndicatorTop: zod_1.z.number().optional(),
114
+ homeIndicatorBottom: zod_1.z.number().optional(),
115
+ homeIndicatorLeft: zod_1.z.number().optional(),
116
+ homeIndicatorRight: zod_1.z.number().optional(),
117
+ homeIndicatorColor: zod_1.z.string().optional(),
118
+ // iMessage footer
119
+ plusButtonTop: zod_1.z.number().optional(),
120
+ plusButtonBottom: zod_1.z.number().optional(),
121
+ plusButtonLeft: zod_1.z.number().optional(),
122
+ plusButtonRight: zod_1.z.number().optional(),
123
+ footerTop: zod_1.z.number().optional(),
124
+ footerBottom: zod_1.z.number().optional(),
125
+ footerLeft: zod_1.z.number().optional(),
126
+ footerRight: zod_1.z.number().optional(),
127
+ footerBgColor: zod_1.z.string().optional(),
128
+ footerBorderRadius: zod_1.z.number().optional(),
129
+ footerBorderColor: zod_1.z.string().optional(),
130
+ footerBorderWidth: zod_1.z.number().optional(),
131
+ messageTextTop: zod_1.z.number().optional(),
132
+ messageTextBottom: zod_1.z.number().optional(),
133
+ messageTextLeft: zod_1.z.number().optional(),
134
+ messageTextRight: zod_1.z.number().optional(),
135
+ messageTextFontSize: zod_1.z.number().optional(),
136
+ messageTextLetterSpacing: zod_1.z.number().optional(),
137
+ messageTextColor: zod_1.z.string().optional(),
138
+ messageText: zod_1.z.string().optional(),
139
+ // Message area bounds
140
+ messageAreaTop: zod_1.z.number().optional(),
141
+ messageAreaBottom: zod_1.z.number().optional(),
142
+ // Message colors
143
+ senderBubbleColor: zod_1.z.string().optional(),
144
+ recipientBubbleColor: zod_1.z.string().optional(),
145
+ bubbleTextColor: zod_1.z.string().optional(),
146
+ recipientTextColor: zod_1.z.string().optional(),
147
+ // Message typography
148
+ messageFontSize: zod_1.z.number().optional(),
149
+ messageLineHeight: zod_1.z.number().optional(),
150
+ messageLetterSpacing: zod_1.z.number().optional(),
151
+ // Message padding (inside bubble)
152
+ messagePaddingTop: zod_1.z.number().optional(),
153
+ messagePaddingBottom: zod_1.z.number().optional(),
154
+ senderPaddingLeft: zod_1.z.number().optional(),
155
+ senderPaddingRight: zod_1.z.number().optional(),
156
+ multiLineSenderPaddingLeft: zod_1.z.number().optional(),
157
+ recipientPaddingLeft: zod_1.z.number().optional(),
158
+ recipientPaddingRight: zod_1.z.number().optional(),
159
+ multiLineRecipientPaddingRight: zod_1.z.number().optional(),
160
+ // Bubble corner radii
161
+ bubbleRadiusNormal: zod_1.z.number().optional(),
162
+ bubbleRadiusGrouped: zod_1.z.number().optional(),
163
+ // Message spacing
164
+ messageGapInGroup: zod_1.z.number().optional(),
165
+ messageGapSameUser: zod_1.z.number().optional(),
166
+ messageGapDifferentUser: zod_1.z.number().optional(),
167
+ // Bubble positioning
168
+ recipientBubbleLeft: zod_1.z.number().optional(),
169
+ senderBubbleRight: zod_1.z.number().optional(),
170
+ bubbleMaxWidth: zod_1.z.number().optional(),
171
+ // Sender image attachment
172
+ senderImageLeft: zod_1.z.number().optional(),
173
+ senderImageHeight: zod_1.z.number().optional(),
174
+ senderImageGapToText: zod_1.z.number().optional(),
175
+ senderImageBorderRadius: zod_1.z.number().optional(),
176
+ // Message area header text
177
+ messageHeaderImessageText: zod_1.z.string().optional(),
178
+ messageHeaderTimestampText: zod_1.z.string().optional(),
179
+ messageHeaderTimestampGap: zod_1.z.number().optional(),
180
+ messageHeaderImessageGap: zod_1.z.number().optional(),
181
+ messageHeaderTextColor: zod_1.z.string().optional(),
182
+ messageHeaderFontSize: zod_1.z.number().optional(),
183
+ messageHeaderLetterSpacing: zod_1.z.number().optional(),
184
+ messageHeaderLeft: zod_1.z.number().optional(),
185
+ messageHeaderRight: zod_1.z.number().optional(),
186
+ // Message tails (SVG-based)
187
+ showMessageTails: zod_1.z.boolean().optional(),
188
+ // Recipient tail anchor points
189
+ recipientTailSideY: zod_1.z.number().optional(),
190
+ recipientTailCurveStartY: zod_1.z.number().optional(),
191
+ recipientTailTipX: zod_1.z.number().optional(),
192
+ recipientTailTipY: zod_1.z.number().optional(),
193
+ recipientTailBottomX: zod_1.z.number().optional(),
194
+ recipientTailBottomY: zod_1.z.number().optional(),
195
+ // Recipient tail curve bend
196
+ recipientTailTopBend: zod_1.z.number().optional(),
197
+ recipientTailBottomBend: zod_1.z.number().optional(),
198
+ // Sender tail anchor points
199
+ senderTailSideY: zod_1.z.number().optional(),
200
+ senderTailCurveStartY: zod_1.z.number().optional(),
201
+ senderTailTipX: zod_1.z.number().optional(),
202
+ senderTailTipY: zod_1.z.number().optional(),
203
+ senderTailBottomX: zod_1.z.number().optional(),
204
+ senderTailBottomY: zod_1.z.number().optional(),
205
+ // Sender tail curve bend
206
+ senderTailTopBend: zod_1.z.number().optional(),
207
+ senderTailBottomBend: zod_1.z.number().optional(),
208
+ // Read receipt
209
+ showReadReceipt: zod_1.z.boolean().optional(),
210
+ readReceiptText: zod_1.z.string().optional(),
211
+ readReceiptGap: zod_1.z.number().optional(),
212
+ readReceiptFontSize: zod_1.z.number().optional(),
213
+ readReceiptLetterSpacing: zod_1.z.number().optional(),
214
+ readReceiptColor: zod_1.z.string().optional(),
215
+ readReceiptLeft: zod_1.z.number().optional(),
216
+ readReceiptRight: zod_1.z.number().optional(),
217
+ // Messages
218
+ messages: zod_1.z.array(zod_1.z.object({
219
+ id: zod_1.z.string(),
220
+ sender: zod_1.z.enum(['user', 'recipient']),
221
+ text: zod_1.z.string(),
222
+ imageUrl: zod_1.z.string().optional(),
223
+ groupWithPrevious: zod_1.z.boolean().optional(),
224
+ })).optional(),
225
+ // Dynamic crop - crop output to element bounds
226
+ dynamicCrop: zod_1.z.record(zod_1.z.any()).optional(),
227
+ cropVerticalCenter: zod_1.z.boolean().optional(),
228
+ });
@@ -18,6 +18,7 @@ const TextElement_1 = require("../components/TextElement");
18
18
  const ImageElement_1 = require("../components/ImageElement");
19
19
  const positionResolver_1 = require("../utils/positionResolver");
20
20
  const cropBounds_1 = require("../utils/cropBounds");
21
+ const hooks_1 = require("../hooks");
21
22
  /**
22
23
  * Get all segments from all channels, sorted by zIndex
23
24
  */
@@ -52,6 +53,7 @@ function elementToTextSegment(elem) {
52
53
  opacity: elem.opacity,
53
54
  text: elem.text ?? '',
54
55
  fontType: elem.font ?? 'tiktok',
56
+ fontFamily: elem.fontFamily,
55
57
  fontSize: elem.fontSize ?? 40,
56
58
  fontWeight: elem.fontWeight ?? 'normal',
57
59
  color: elem.color ?? '#FFFFFF',
@@ -207,6 +209,16 @@ elements, width, height, backgroundType = 'image', backgroundColor, backgroundFi
207
209
  }
208
210
  };
209
211
  }, []);
212
+ // Font-library faces used by text (fontFamily) must be loaded before
213
+ // positions are measured and text is drawn.
214
+ const libraryFontItems = (0, react_1.useMemo)(() => {
215
+ if (elements)
216
+ return elements.filter((e) => e.type === 'text');
217
+ if (!config)
218
+ return [];
219
+ return getSortedSegments(config).filter((s) => s.type === 'text');
220
+ }, [elements, config]);
221
+ const libraryFontsReady = (0, hooks_1.useLibraryFonts)(libraryFontItems);
210
222
  // Get dimensions (from new props or legacy config)
211
223
  const canvasWidth = width ?? config?.width ?? 1080;
212
224
  const canvasHeight = height ?? config?.height ?? 1920;
@@ -219,7 +231,8 @@ elements, width, height, backgroundType = 'image', backgroundColor, backgroundFi
219
231
  console.warn('Position resolution errors:', result.errors);
220
232
  }
221
233
  return result.elements;
222
- }, [elements, textValues]);
234
+ // libraryFontsReady: re-measure auto-width text once library faces are loaded.
235
+ }, [elements, textValues, libraryFontsReady]);
223
236
  // Calculate crop bounds when dynamic crop is enabled
224
237
  const cropBounds = (0, react_1.useMemo)(() => {
225
238
  if (!(0, cropBounds_1.isDynamicCropEnabled)(dynamicCrop) || !resolvedElements)
@@ -280,7 +293,7 @@ elements, width, height, backgroundType = 'image', backgroundColor, backgroundFi
280
293
  ? backgroundColor
281
294
  : '#000000';
282
295
  // Don't render content until fonts are loaded (prevents incorrect measurements)
283
- if (!fontsLoaded) {
296
+ if (!fontsLoaded || !libraryFontsReady) {
284
297
  return ((0, jsx_runtime_1.jsx)(remotion_1.AbsoluteFill, { style: { backgroundColor: containerBgColor } }));
285
298
  }
286
299
  return ((0, jsx_runtime_1.jsx)(remotion_1.AbsoluteFill, { style: { backgroundColor: containerBgColor }, children: (0, jsx_runtime_1.jsxs)("div", { style: {
@@ -14,6 +14,7 @@ const remotion_1 = require("remotion");
14
14
  const TextElement_1 = require("../components/TextElement");
15
15
  const ImageElement_1 = require("../components/ImageElement");
16
16
  const VideoElement_1 = require("../components/VideoElement");
17
+ const hooks_1 = require("../hooks");
17
18
  /**
18
19
  * Calculate timing for all segments
19
20
  */
@@ -152,6 +153,9 @@ function VideoEditorComposition({ config, sources = {}, textContent = {}, }) {
152
153
  return aZ - bZ;
153
154
  });
154
155
  }, [segmentTimings]);
156
+ // Hold the render until font-library faces used by text segments are loaded.
157
+ const libraryFontItems = (0, react_1.useMemo)(() => segmentTimings.map(({ segment }) => segment).filter((s) => s.type === 'text'), [segmentTimings]);
158
+ const libraryFontsReady = (0, hooks_1.useLibraryFonts)(libraryFontItems);
155
159
  // Premount window for video sequences: in the Player, upcoming videos
156
160
  // mount invisibly this many frames early so they buffer and pre-seek
157
161
  // before becoming visible. No effect on server rendering.
@@ -171,6 +175,9 @@ function VideoEditorComposition({ config, sources = {}, textContent = {}, }) {
171
175
  const audioTimings = (0, react_1.useMemo)(() => {
172
176
  return segmentTimings.filter(({ segment }) => segment.type === 'audio');
173
177
  }, [segmentTimings]);
178
+ if (!libraryFontsReady) {
179
+ return (0, jsx_runtime_1.jsx)(remotion_1.AbsoluteFill, { style: { backgroundColor: '#000000' } });
180
+ }
174
181
  return ((0, jsx_runtime_1.jsxs)(remotion_1.AbsoluteFill, { style: { backgroundColor: '#000000' }, children: [visualTimings.map(({ segment, startFrame, durationInFrames }) => {
175
182
  if (segment.type === 'text') {
176
183
  const textSegment = segment;
@@ -4,6 +4,7 @@
4
4
  * Hooks for common operations like font loading, media preloading,
5
5
  * and position resolution.
6
6
  */
7
+ import type { FontWeight } from '../types';
7
8
  import { type PositionResolutionResult, type PositionResolutionError } from '../utils/positionResolver';
8
9
  import type { ImageEditorElement } from '../types/element';
9
10
  /**
@@ -11,6 +12,15 @@ import type { ImageEditorElement } from '../types/element';
11
12
  * Returns true when fonts are ready
12
13
  */
13
14
  export declare function useFontsLoaded(): boolean;
15
+ /**
16
+ * Hold the render until every font-library face used by the given text items
17
+ * is loaded (no-op when none uses `fontFamily`). Returns true once ready, so
18
+ * text is never measured or drawn with a fallback font.
19
+ */
20
+ export declare function useLibraryFonts(items: {
21
+ fontFamily?: string;
22
+ fontWeight?: FontWeight;
23
+ }[]): boolean;
14
24
  /**
15
25
  * Hook to load an image and return it when ready
16
26
  */
@@ -7,10 +7,12 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.useFontsLoaded = useFontsLoaded;
10
+ exports.useLibraryFonts = useLibraryFonts;
10
11
  exports.useImageLoader = useImageLoader;
11
12
  exports.useImagePreloader = useImagePreloader;
12
13
  exports.useResolvedPositions = useResolvedPositions;
13
14
  const react_1 = require("react");
15
+ const remotion_1 = require("remotion");
14
16
  const fonts_1 = require("../utils/fonts");
15
17
  const positionResolver_1 = require("../utils/positionResolver");
16
18
  /**
@@ -28,6 +30,54 @@ function useFontsLoaded() {
28
30
  }, [loaded]);
29
31
  return loaded;
30
32
  }
33
+ /**
34
+ * Hold the render until every font-library face used by the given text items
35
+ * is loaded (no-op when none uses `fontFamily`). Returns true once ready, so
36
+ * text is never measured or drawn with a fallback font.
37
+ */
38
+ function useLibraryFonts(items) {
39
+ const key = (0, react_1.useMemo)(() => {
40
+ const pairs = new Set();
41
+ for (const item of items) {
42
+ if (item.fontFamily)
43
+ pairs.add(JSON.stringify([item.fontFamily, item.fontWeight ?? 'normal']));
44
+ }
45
+ return JSON.stringify([...pairs].sort());
46
+ }, [items]);
47
+ const [readyKey, setReadyKey] = (0, react_1.useState)(key === '[]' ? key : null);
48
+ (0, react_1.useEffect)(() => {
49
+ if (key === '[]') {
50
+ setReadyKey(key);
51
+ return;
52
+ }
53
+ const requests = JSON.parse(key).map((pair) => {
54
+ const [family, weight] = JSON.parse(pair);
55
+ return { family, weight };
56
+ });
57
+ const handle = (0, remotion_1.delayRender)(`Loading library fonts ${key}`);
58
+ let active = true;
59
+ (0, fonts_1.loadLibraryFonts)(requests)
60
+ .then((failed) => {
61
+ if (!failed.length)
62
+ return;
63
+ const message = `Font library faces failed to load: ${JSON.stringify(failed)}`;
64
+ // A final render must never fall back silently to another font; previews log and continue.
65
+ if ((0, remotion_1.getRemotionEnvironment)().isRendering)
66
+ (0, remotion_1.cancelRender)(new Error(message));
67
+ else
68
+ console.error(`[ugcinc-render/fonts] ${message}`);
69
+ })
70
+ .finally(() => {
71
+ if (active)
72
+ setReadyKey(key);
73
+ (0, remotion_1.continueRender)(handle);
74
+ });
75
+ return () => {
76
+ active = false;
77
+ };
78
+ }, [key]);
79
+ return readyKey === key;
80
+ }
31
81
  /**
32
82
  * Hook to load an image and return it when ready
33
83
  */
@@ -109,6 +109,8 @@ export interface TextStyleProperties {
109
109
  multiLineExtraPaddingLeft?: number;
110
110
  /** Font family (default: 'arial') */
111
111
  fontType?: FontType;
112
+ /** Font-library family; takes precedence over fontType when set */
113
+ fontFamily?: string;
112
114
  /** Font size in pixels (default: 40) */
113
115
  fontSize?: number;
114
116
  /** Font weight (default: 'normal') */
@@ -78,6 +78,11 @@ export interface ImageEditorElement {
78
78
  strokeColor?: string;
79
79
  /** Font family */
80
80
  font?: FontType;
81
+ /**
82
+ * Font-library family (Google Fonts catalogue mirrored by UGC, e.g. "Google Sans").
83
+ * When set it takes precedence over `font`; `fontWeight` picks the nearest available weight.
84
+ */
85
+ fontFamily?: string;
81
86
  /** Font size in pixels */
82
87
  fontSize?: number;
83
88
  /** Font weight */
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  /** Native points, rendered at 3 pixels per point. No coordinate rounding. */
3
- export declare const nativeTextStickerSchema: z.ZodObject<{
3
+ export declare const tiktokNativeTextStickerSchema: z.ZodObject<{
4
4
  profile: z.ZodDefault<z.ZodLiteral<"tiktok-classic-ios-47">>;
5
5
  text: z.ZodEffects<z.ZodString, string, string>;
6
6
  fontSizePt: z.ZodDefault<z.ZodNumber>;
@@ -33,4 +33,109 @@ export declare const nativeTextStickerSchema: z.ZodObject<{
33
33
  originPt?: [number, number] | undefined;
34
34
  viewFontSizePt?: number | undefined;
35
35
  }>;
36
+ /** Source-derived Snapchat Classic bar; height is measured automatically. */
37
+ export declare const snapchatNativeTextStickerSchema: z.ZodEffects<z.ZodObject<{
38
+ profile: z.ZodLiteral<"snapchat-classic-ios-18">;
39
+ text: z.ZodEffects<z.ZodString, string, string>;
40
+ fontSizePt: z.ZodDefault<z.ZodNumber>;
41
+ canvasWidthPt: z.ZodDefault<z.ZodNumber>;
42
+ referenceScale: z.ZodDefault<z.ZodNumber>;
43
+ background: z.ZodDefault<z.ZodBoolean>;
44
+ }, "strict", z.ZodTypeAny, {
45
+ text: string;
46
+ profile: "snapchat-classic-ios-18";
47
+ fontSizePt: number;
48
+ canvasWidthPt: number;
49
+ referenceScale: number;
50
+ background: boolean;
51
+ }, {
52
+ text: string;
53
+ profile: "snapchat-classic-ios-18";
54
+ fontSizePt?: number | undefined;
55
+ canvasWidthPt?: number | undefined;
56
+ referenceScale?: number | undefined;
57
+ background?: boolean | undefined;
58
+ }>, {
59
+ text: string;
60
+ profile: "snapchat-classic-ios-18";
61
+ fontSizePt: number;
62
+ canvasWidthPt: number;
63
+ referenceScale: number;
64
+ background: boolean;
65
+ }, {
66
+ text: string;
67
+ profile: "snapchat-classic-ios-18";
68
+ fontSizePt?: number | undefined;
69
+ canvasWidthPt?: number | undefined;
70
+ referenceScale?: number | undefined;
71
+ background?: boolean | undefined;
72
+ }>;
73
+ export declare const nativeTextStickerSchema: z.ZodUnion<[z.ZodObject<{
74
+ profile: z.ZodDefault<z.ZodLiteral<"tiktok-classic-ios-47">>;
75
+ text: z.ZodEffects<z.ZodString, string, string>;
76
+ fontSizePt: z.ZodDefault<z.ZodNumber>;
77
+ canvasWidthPt: z.ZodDefault<z.ZodNumber>;
78
+ canvasHeightPt: z.ZodDefault<z.ZodNumber>;
79
+ containerWidthPt: z.ZodDefault<z.ZodNumber>;
80
+ /** Omit for unlimited lines clipped by the canvas; zero has the same meaning. */
81
+ containerHeightPt: z.ZodOptional<z.ZodNumber>;
82
+ originPt: z.ZodDefault<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
83
+ /** Normally omitted. Reproduces an editor whose view font differs from the text run font. */
84
+ viewFontSizePt: z.ZodOptional<z.ZodNumber>;
85
+ }, "strict", z.ZodTypeAny, {
86
+ text: string;
87
+ profile: "tiktok-classic-ios-47";
88
+ fontSizePt: number;
89
+ canvasWidthPt: number;
90
+ canvasHeightPt: number;
91
+ containerWidthPt: number;
92
+ originPt: [number, number];
93
+ containerHeightPt?: number | undefined;
94
+ viewFontSizePt?: number | undefined;
95
+ }, {
96
+ text: string;
97
+ profile?: "tiktok-classic-ios-47" | undefined;
98
+ fontSizePt?: number | undefined;
99
+ canvasWidthPt?: number | undefined;
100
+ canvasHeightPt?: number | undefined;
101
+ containerWidthPt?: number | undefined;
102
+ containerHeightPt?: number | undefined;
103
+ originPt?: [number, number] | undefined;
104
+ viewFontSizePt?: number | undefined;
105
+ }>, z.ZodEffects<z.ZodObject<{
106
+ profile: z.ZodLiteral<"snapchat-classic-ios-18">;
107
+ text: z.ZodEffects<z.ZodString, string, string>;
108
+ fontSizePt: z.ZodDefault<z.ZodNumber>;
109
+ canvasWidthPt: z.ZodDefault<z.ZodNumber>;
110
+ referenceScale: z.ZodDefault<z.ZodNumber>;
111
+ background: z.ZodDefault<z.ZodBoolean>;
112
+ }, "strict", z.ZodTypeAny, {
113
+ text: string;
114
+ profile: "snapchat-classic-ios-18";
115
+ fontSizePt: number;
116
+ canvasWidthPt: number;
117
+ referenceScale: number;
118
+ background: boolean;
119
+ }, {
120
+ text: string;
121
+ profile: "snapchat-classic-ios-18";
122
+ fontSizePt?: number | undefined;
123
+ canvasWidthPt?: number | undefined;
124
+ referenceScale?: number | undefined;
125
+ background?: boolean | undefined;
126
+ }>, {
127
+ text: string;
128
+ profile: "snapchat-classic-ios-18";
129
+ fontSizePt: number;
130
+ canvasWidthPt: number;
131
+ referenceScale: number;
132
+ background: boolean;
133
+ }, {
134
+ text: string;
135
+ profile: "snapchat-classic-ios-18";
136
+ fontSizePt?: number | undefined;
137
+ canvasWidthPt?: number | undefined;
138
+ referenceScale?: number | undefined;
139
+ background?: boolean | undefined;
140
+ }>]>;
36
141
  export type NativeTextStickerInput = z.input<typeof nativeTextStickerSchema>;
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.nativeTextStickerSchema = void 0;
3
+ exports.nativeTextStickerSchema = exports.snapchatNativeTextStickerSchema = exports.tiktokNativeTextStickerSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const dimension = zod_1.z.number().finite().min(1).max(1365);
6
6
  const fontSize = zod_1.z.number().finite().min(11).max(72);
7
7
  /** Native points, rendered at 3 pixels per point. No coordinate rounding. */
8
- exports.nativeTextStickerSchema = zod_1.z.object({
8
+ exports.tiktokNativeTextStickerSchema = zod_1.z.object({
9
9
  profile: zod_1.z.literal('tiktok-classic-ios-47').default('tiktok-classic-ios-47'),
10
10
  text: zod_1.z.string().min(1).max(2048).refine(text => text.split('\n').every(line => line.replace(/ /g, '').length > 0)
11
11
  && !/[\u0000-\u0009\u000b-\u001f\u007f-\u009f\u2028\u2029\u202a-\u202e\u2066-\u2069]/u.test(text)
@@ -20,3 +20,18 @@ exports.nativeTextStickerSchema = zod_1.z.object({
20
20
  /** Normally omitted. Reproduces an editor whose view font differs from the text run font. */
21
21
  viewFontSizePt: fontSize.optional(),
22
22
  }).strict();
23
+ /** Source-derived Snapchat Classic bar; height is measured automatically. */
24
+ exports.snapchatNativeTextStickerSchema = zod_1.z.object({
25
+ profile: zod_1.z.literal('snapchat-classic-ios-18'),
26
+ text: exports.tiktokNativeTextStickerSchema.shape.text,
27
+ fontSizePt: zod_1.z.number().finite().min(7).max(72).default(17),
28
+ canvasWidthPt: zod_1.z.number().finite().min(16).max(1365).default(414),
29
+ referenceScale: zod_1.z.number().finite().min(0.25).max(4).default(1),
30
+ background: zod_1.z.boolean().default(true),
31
+ }).strict().superRefine((value, ctx) => {
32
+ if (value.fontSizePt * value.referenceScale > 72 || value.canvasWidthPt <= 16 * value.referenceScale
33
+ || !Number.isInteger(value.canvasWidthPt * 3)) {
34
+ ctx.addIssue({ code: 'custom', message: 'Unsupported Snapchat Classic geometry' });
35
+ }
36
+ });
37
+ exports.nativeTextStickerSchema = zod_1.z.union([exports.tiktokNativeTextStickerSchema, exports.snapchatNativeTextStickerSchema]);
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Font utilities for the rendering system
3
3
  */
4
- import type { FontType } from '../types';
4
+ import type { FontType, FontWeight } from '../types';
5
5
  /**
6
6
  * Apple Color Emoji font name - used as fallback for emoji characters
7
7
  */
@@ -13,9 +13,51 @@ export declare const APPLE_EMOJI_FONT = "\"Apple Color Emoji\"";
13
13
  */
14
14
  export declare const FONT_FAMILIES: Record<FontType, string>;
15
15
  /**
16
- * Get the CSS font family string for a font type
16
+ * Get the CSS font family string for a font type, or for a font-library family
17
+ * when `fontFamily` is set (it takes precedence over `fontType`).
17
18
  */
18
- export declare function getFontFamily(fontType: FontType): string;
19
+ export declare function getFontFamily(fontType: FontType, fontFamily?: string): string;
20
+ /**
21
+ * Font library: the Google Fonts catalogue mirrored by UGC (open licences).
22
+ * `catalogue.json` lists every family with its available upright weights;
23
+ * files live at `<base>/files/<slug>/<weight>.ttf` (Latin subset).
24
+ */
25
+ export declare const FONT_LIBRARY_BASE_URL = "https://media.ugc.inc/owned-uploads/render/fonts/google";
26
+ export interface FontLibraryCatalogue {
27
+ version: number;
28
+ source: 'google-fonts';
29
+ refreshedAt: number;
30
+ baseUrl: string;
31
+ families: Record<string, {
32
+ category: string;
33
+ slug: string;
34
+ weights: number[];
35
+ }>;
36
+ }
37
+ /** CSS family name a library font is registered under (namespaced so it never collides with bundled fonts). */
38
+ export declare function libraryFontFace(family: string): string;
39
+ /** URL-safe family slug used in library file paths. */
40
+ export declare function libraryFontSlug(family: string): string;
41
+ /** Numeric CSS weight for a FontWeight value. */
42
+ export declare function numericFontWeight(weight: FontWeight | undefined): number;
43
+ /** Nearest available weight (ties go to the heavier weight, as CSS matching does above 500). */
44
+ export declare function nearestLibraryWeight(available: number[], wanted: number): number;
45
+ /** Fetch (once per page) the font library catalogue. Resolves null when unreachable. */
46
+ export declare function fetchFontLibraryCatalogue(): Promise<FontLibraryCatalogue | null>;
47
+ /**
48
+ * Load library font faces for the given (family, weight) pairs into
49
+ * `document.fonts`. Each requested weight is snapped to the nearest weight the
50
+ * library has for that family and registered under the requested weight too,
51
+ * so CSS matching picks the same file in every renderer. Resolves to the list
52
+ * of pairs that failed to load (empty on success).
53
+ */
54
+ export declare function loadLibraryFonts(requests: {
55
+ family: string;
56
+ weight: FontWeight | undefined;
57
+ }[]): Promise<{
58
+ family: string;
59
+ weight: number;
60
+ }[]>;
19
61
  /**
20
62
  * Build a CSS font string
21
63
  */