ugcinc-render 1.5.19 → 1.5.20

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.js CHANGED
@@ -1312,6 +1312,43 @@ function ImageEditorComposition({
1312
1312
  textValues = {},
1313
1313
  dynamicCrop
1314
1314
  }) {
1315
+ const [fontsLoaded, setFontsLoaded] = (0, import_react3.useState)(false);
1316
+ (0, import_react3.useEffect)(() => {
1317
+ const handle = (0, import_remotion2.delayRender)("Loading fonts...");
1318
+ const loadFonts = async () => {
1319
+ try {
1320
+ if (typeof document !== "undefined" && document.fonts) {
1321
+ console.log("[Composition] Waiting for fonts to load...");
1322
+ await document.fonts.ready;
1323
+ const fontChecks = await Promise.all([
1324
+ document.fonts.load('normal 48px "SF Pro"').catch(() => []),
1325
+ document.fonts.load('bold 48px "SF Pro"').catch(() => []),
1326
+ document.fonts.load('normal 48px "TikTok Sans"').catch(() => []),
1327
+ document.fonts.load('bold 48px "TikTok Sans"').catch(() => [])
1328
+ ]);
1329
+ console.log("[Composition] Fonts loaded:", {
1330
+ sfProNormal: document.fonts.check('normal 48px "SF Pro"'),
1331
+ sfProBold: document.fonts.check('bold 48px "SF Pro"'),
1332
+ tiktokNormal: document.fonts.check('normal 48px "TikTok Sans"'),
1333
+ tiktokBold: document.fonts.check('bold 48px "TikTok Sans"')
1334
+ });
1335
+ }
1336
+ setFontsLoaded(true);
1337
+ (0, import_remotion2.continueRender)(handle);
1338
+ } catch (err) {
1339
+ console.error("[Composition] Font loading error:", err);
1340
+ setFontsLoaded(true);
1341
+ (0, import_remotion2.continueRender)(handle);
1342
+ }
1343
+ };
1344
+ loadFonts();
1345
+ return () => {
1346
+ try {
1347
+ (0, import_remotion2.continueRender)(handle);
1348
+ } catch {
1349
+ }
1350
+ };
1351
+ }, []);
1315
1352
  const canvasWidth = width ?? config?.width ?? 1080;
1316
1353
  const canvasHeight = height ?? config?.height ?? 1920;
1317
1354
  const resolvedElements = (0, import_react3.useMemo)(() => {
@@ -1366,6 +1403,9 @@ function ImageEditorComposition({
1366
1403
  return void 0;
1367
1404
  };
1368
1405
  const containerBgColor = backgroundType === "color" && backgroundColor ? backgroundColor : "#000000";
1406
+ if (!fontsLoaded) {
1407
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_remotion2.AbsoluteFill, { style: { backgroundColor: containerBgColor } });
1408
+ }
1369
1409
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_remotion2.AbsoluteFill, { style: { backgroundColor: containerBgColor }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
1370
1410
  "div",
1371
1411
  {
package/dist/index.mjs CHANGED
@@ -8,8 +8,8 @@ var DIMENSION_PRESETS = {
8
8
  };
9
9
 
10
10
  // src/compositions/ImageEditorComposition.tsx
11
- import { useMemo as useMemo3 } from "react";
12
- import { AbsoluteFill, Img as Img2 } from "remotion";
11
+ import { useMemo as useMemo3, useState, useEffect } from "react";
12
+ import { AbsoluteFill, Img as Img2, delayRender, continueRender } from "remotion";
13
13
 
14
14
  // src/components/TextElement.tsx
15
15
  import React, { useMemo } from "react";
@@ -1226,6 +1226,43 @@ function ImageEditorComposition({
1226
1226
  textValues = {},
1227
1227
  dynamicCrop
1228
1228
  }) {
1229
+ const [fontsLoaded, setFontsLoaded] = useState(false);
1230
+ useEffect(() => {
1231
+ const handle = delayRender("Loading fonts...");
1232
+ const loadFonts = async () => {
1233
+ try {
1234
+ if (typeof document !== "undefined" && document.fonts) {
1235
+ console.log("[Composition] Waiting for fonts to load...");
1236
+ await document.fonts.ready;
1237
+ const fontChecks = await Promise.all([
1238
+ document.fonts.load('normal 48px "SF Pro"').catch(() => []),
1239
+ document.fonts.load('bold 48px "SF Pro"').catch(() => []),
1240
+ document.fonts.load('normal 48px "TikTok Sans"').catch(() => []),
1241
+ document.fonts.load('bold 48px "TikTok Sans"').catch(() => [])
1242
+ ]);
1243
+ console.log("[Composition] Fonts loaded:", {
1244
+ sfProNormal: document.fonts.check('normal 48px "SF Pro"'),
1245
+ sfProBold: document.fonts.check('bold 48px "SF Pro"'),
1246
+ tiktokNormal: document.fonts.check('normal 48px "TikTok Sans"'),
1247
+ tiktokBold: document.fonts.check('bold 48px "TikTok Sans"')
1248
+ });
1249
+ }
1250
+ setFontsLoaded(true);
1251
+ continueRender(handle);
1252
+ } catch (err) {
1253
+ console.error("[Composition] Font loading error:", err);
1254
+ setFontsLoaded(true);
1255
+ continueRender(handle);
1256
+ }
1257
+ };
1258
+ loadFonts();
1259
+ return () => {
1260
+ try {
1261
+ continueRender(handle);
1262
+ } catch {
1263
+ }
1264
+ };
1265
+ }, []);
1229
1266
  const canvasWidth = width ?? config?.width ?? 1080;
1230
1267
  const canvasHeight = height ?? config?.height ?? 1920;
1231
1268
  const resolvedElements = useMemo3(() => {
@@ -1280,6 +1317,9 @@ function ImageEditorComposition({
1280
1317
  return void 0;
1281
1318
  };
1282
1319
  const containerBgColor = backgroundType === "color" && backgroundColor ? backgroundColor : "#000000";
1320
+ if (!fontsLoaded) {
1321
+ return /* @__PURE__ */ jsx3(AbsoluteFill, { style: { backgroundColor: containerBgColor } });
1322
+ }
1283
1323
  return /* @__PURE__ */ jsx3(AbsoluteFill, { style: { backgroundColor: containerBgColor }, children: /* @__PURE__ */ jsxs2(
1284
1324
  "div",
1285
1325
  {
@@ -1792,10 +1832,10 @@ function generateOverlayId() {
1792
1832
  }
1793
1833
 
1794
1834
  // src/hooks/index.ts
1795
- import { useEffect, useState, useMemo as useMemo6 } from "react";
1835
+ import { useEffect as useEffect2, useState as useState2, useMemo as useMemo6 } from "react";
1796
1836
  function useFontsLoaded() {
1797
- const [loaded, setLoaded] = useState(areFontsLoaded());
1798
- useEffect(() => {
1837
+ const [loaded, setLoaded] = useState2(areFontsLoaded());
1838
+ useEffect2(() => {
1799
1839
  if (!loaded) {
1800
1840
  preloadFonts().then(() => setLoaded(true)).catch(console.error);
1801
1841
  }
@@ -1803,8 +1843,8 @@ function useFontsLoaded() {
1803
1843
  return loaded;
1804
1844
  }
1805
1845
  function useImageLoader(src) {
1806
- const [image, setImage] = useState(null);
1807
- useEffect(() => {
1846
+ const [image, setImage] = useState2(null);
1847
+ useEffect2(() => {
1808
1848
  if (!src) {
1809
1849
  setImage(null);
1810
1850
  return;
@@ -1824,9 +1864,9 @@ function useImageLoader(src) {
1824
1864
  return image;
1825
1865
  }
1826
1866
  function useImagePreloader(sources) {
1827
- const [images, setImages] = useState({});
1828
- const [loaded, setLoaded] = useState(false);
1829
- useEffect(() => {
1867
+ const [images, setImages] = useState2({});
1868
+ const [loaded, setLoaded] = useState2(false);
1869
+ useEffect2(() => {
1830
1870
  const entries = Object.entries(sources);
1831
1871
  if (entries.length === 0) {
1832
1872
  setLoaded(true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ugcinc-render",
3
- "version": "1.5.19",
3
+ "version": "1.5.20",
4
4
  "description": "Unified rendering package for UGC Inc - shared types, components, and compositions for pixel-perfect client/server rendering",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",