ugcinc-render 1.5.19 → 1.5.21
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 +65 -0
- package/dist/index.mjs +75 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1312,6 +1312,68 @@ 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 fontsToLoad = [
|
|
1324
|
+
// SF Pro
|
|
1325
|
+
'normal 48px "SF Pro"',
|
|
1326
|
+
'bold 48px "SF Pro"',
|
|
1327
|
+
'100 48px "SF Pro"',
|
|
1328
|
+
'200 48px "SF Pro"',
|
|
1329
|
+
'300 48px "SF Pro"',
|
|
1330
|
+
'400 48px "SF Pro"',
|
|
1331
|
+
'500 48px "SF Pro"',
|
|
1332
|
+
'600 48px "SF Pro"',
|
|
1333
|
+
'700 48px "SF Pro"',
|
|
1334
|
+
'800 48px "SF Pro"',
|
|
1335
|
+
'900 48px "SF Pro"',
|
|
1336
|
+
// TikTok Sans
|
|
1337
|
+
'normal 48px "TikTok Sans"',
|
|
1338
|
+
'bold 48px "TikTok Sans"',
|
|
1339
|
+
'400 48px "TikTok Sans"',
|
|
1340
|
+
'500 48px "TikTok Sans"',
|
|
1341
|
+
'600 48px "TikTok Sans"',
|
|
1342
|
+
'700 48px "TikTok Sans"',
|
|
1343
|
+
'800 48px "TikTok Sans"',
|
|
1344
|
+
'900 48px "TikTok Sans"',
|
|
1345
|
+
// Apple Color Emoji
|
|
1346
|
+
'normal 48px "Apple Color Emoji"'
|
|
1347
|
+
];
|
|
1348
|
+
await Promise.all(
|
|
1349
|
+
fontsToLoad.map(
|
|
1350
|
+
(font) => document.fonts.load(font).catch(() => [])
|
|
1351
|
+
)
|
|
1352
|
+
);
|
|
1353
|
+
await document.fonts.ready;
|
|
1354
|
+
console.log("[Composition] Fonts loaded:", {
|
|
1355
|
+
sfPro: document.fonts.check('normal 48px "SF Pro"'),
|
|
1356
|
+
tiktok: document.fonts.check('normal 48px "TikTok Sans"'),
|
|
1357
|
+
emoji: document.fonts.check('normal 48px "Apple Color Emoji"'),
|
|
1358
|
+
totalFonts: document.fonts.size
|
|
1359
|
+
});
|
|
1360
|
+
}
|
|
1361
|
+
setFontsLoaded(true);
|
|
1362
|
+
(0, import_remotion2.continueRender)(handle);
|
|
1363
|
+
} catch (err) {
|
|
1364
|
+
console.error("[Composition] Font loading error:", err);
|
|
1365
|
+
setFontsLoaded(true);
|
|
1366
|
+
(0, import_remotion2.continueRender)(handle);
|
|
1367
|
+
}
|
|
1368
|
+
};
|
|
1369
|
+
loadFonts();
|
|
1370
|
+
return () => {
|
|
1371
|
+
try {
|
|
1372
|
+
(0, import_remotion2.continueRender)(handle);
|
|
1373
|
+
} catch {
|
|
1374
|
+
}
|
|
1375
|
+
};
|
|
1376
|
+
}, []);
|
|
1315
1377
|
const canvasWidth = width ?? config?.width ?? 1080;
|
|
1316
1378
|
const canvasHeight = height ?? config?.height ?? 1920;
|
|
1317
1379
|
const resolvedElements = (0, import_react3.useMemo)(() => {
|
|
@@ -1366,6 +1428,9 @@ function ImageEditorComposition({
|
|
|
1366
1428
|
return void 0;
|
|
1367
1429
|
};
|
|
1368
1430
|
const containerBgColor = backgroundType === "color" && backgroundColor ? backgroundColor : "#000000";
|
|
1431
|
+
if (!fontsLoaded) {
|
|
1432
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_remotion2.AbsoluteFill, { style: { backgroundColor: containerBgColor } });
|
|
1433
|
+
}
|
|
1369
1434
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_remotion2.AbsoluteFill, { style: { backgroundColor: containerBgColor }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
1370
1435
|
"div",
|
|
1371
1436
|
{
|
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,68 @@ 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 fontsToLoad = [
|
|
1238
|
+
// SF Pro
|
|
1239
|
+
'normal 48px "SF Pro"',
|
|
1240
|
+
'bold 48px "SF Pro"',
|
|
1241
|
+
'100 48px "SF Pro"',
|
|
1242
|
+
'200 48px "SF Pro"',
|
|
1243
|
+
'300 48px "SF Pro"',
|
|
1244
|
+
'400 48px "SF Pro"',
|
|
1245
|
+
'500 48px "SF Pro"',
|
|
1246
|
+
'600 48px "SF Pro"',
|
|
1247
|
+
'700 48px "SF Pro"',
|
|
1248
|
+
'800 48px "SF Pro"',
|
|
1249
|
+
'900 48px "SF Pro"',
|
|
1250
|
+
// TikTok Sans
|
|
1251
|
+
'normal 48px "TikTok Sans"',
|
|
1252
|
+
'bold 48px "TikTok Sans"',
|
|
1253
|
+
'400 48px "TikTok Sans"',
|
|
1254
|
+
'500 48px "TikTok Sans"',
|
|
1255
|
+
'600 48px "TikTok Sans"',
|
|
1256
|
+
'700 48px "TikTok Sans"',
|
|
1257
|
+
'800 48px "TikTok Sans"',
|
|
1258
|
+
'900 48px "TikTok Sans"',
|
|
1259
|
+
// Apple Color Emoji
|
|
1260
|
+
'normal 48px "Apple Color Emoji"'
|
|
1261
|
+
];
|
|
1262
|
+
await Promise.all(
|
|
1263
|
+
fontsToLoad.map(
|
|
1264
|
+
(font) => document.fonts.load(font).catch(() => [])
|
|
1265
|
+
)
|
|
1266
|
+
);
|
|
1267
|
+
await document.fonts.ready;
|
|
1268
|
+
console.log("[Composition] Fonts loaded:", {
|
|
1269
|
+
sfPro: document.fonts.check('normal 48px "SF Pro"'),
|
|
1270
|
+
tiktok: document.fonts.check('normal 48px "TikTok Sans"'),
|
|
1271
|
+
emoji: document.fonts.check('normal 48px "Apple Color Emoji"'),
|
|
1272
|
+
totalFonts: document.fonts.size
|
|
1273
|
+
});
|
|
1274
|
+
}
|
|
1275
|
+
setFontsLoaded(true);
|
|
1276
|
+
continueRender(handle);
|
|
1277
|
+
} catch (err) {
|
|
1278
|
+
console.error("[Composition] Font loading error:", err);
|
|
1279
|
+
setFontsLoaded(true);
|
|
1280
|
+
continueRender(handle);
|
|
1281
|
+
}
|
|
1282
|
+
};
|
|
1283
|
+
loadFonts();
|
|
1284
|
+
return () => {
|
|
1285
|
+
try {
|
|
1286
|
+
continueRender(handle);
|
|
1287
|
+
} catch {
|
|
1288
|
+
}
|
|
1289
|
+
};
|
|
1290
|
+
}, []);
|
|
1229
1291
|
const canvasWidth = width ?? config?.width ?? 1080;
|
|
1230
1292
|
const canvasHeight = height ?? config?.height ?? 1920;
|
|
1231
1293
|
const resolvedElements = useMemo3(() => {
|
|
@@ -1280,6 +1342,9 @@ function ImageEditorComposition({
|
|
|
1280
1342
|
return void 0;
|
|
1281
1343
|
};
|
|
1282
1344
|
const containerBgColor = backgroundType === "color" && backgroundColor ? backgroundColor : "#000000";
|
|
1345
|
+
if (!fontsLoaded) {
|
|
1346
|
+
return /* @__PURE__ */ jsx3(AbsoluteFill, { style: { backgroundColor: containerBgColor } });
|
|
1347
|
+
}
|
|
1283
1348
|
return /* @__PURE__ */ jsx3(AbsoluteFill, { style: { backgroundColor: containerBgColor }, children: /* @__PURE__ */ jsxs2(
|
|
1284
1349
|
"div",
|
|
1285
1350
|
{
|
|
@@ -1792,10 +1857,10 @@ function generateOverlayId() {
|
|
|
1792
1857
|
}
|
|
1793
1858
|
|
|
1794
1859
|
// src/hooks/index.ts
|
|
1795
|
-
import { useEffect, useState, useMemo as useMemo6 } from "react";
|
|
1860
|
+
import { useEffect as useEffect2, useState as useState2, useMemo as useMemo6 } from "react";
|
|
1796
1861
|
function useFontsLoaded() {
|
|
1797
|
-
const [loaded, setLoaded] =
|
|
1798
|
-
|
|
1862
|
+
const [loaded, setLoaded] = useState2(areFontsLoaded());
|
|
1863
|
+
useEffect2(() => {
|
|
1799
1864
|
if (!loaded) {
|
|
1800
1865
|
preloadFonts().then(() => setLoaded(true)).catch(console.error);
|
|
1801
1866
|
}
|
|
@@ -1803,8 +1868,8 @@ function useFontsLoaded() {
|
|
|
1803
1868
|
return loaded;
|
|
1804
1869
|
}
|
|
1805
1870
|
function useImageLoader(src) {
|
|
1806
|
-
const [image, setImage] =
|
|
1807
|
-
|
|
1871
|
+
const [image, setImage] = useState2(null);
|
|
1872
|
+
useEffect2(() => {
|
|
1808
1873
|
if (!src) {
|
|
1809
1874
|
setImage(null);
|
|
1810
1875
|
return;
|
|
@@ -1824,9 +1889,9 @@ function useImageLoader(src) {
|
|
|
1824
1889
|
return image;
|
|
1825
1890
|
}
|
|
1826
1891
|
function useImagePreloader(sources) {
|
|
1827
|
-
const [images, setImages] =
|
|
1828
|
-
const [loaded, setLoaded] =
|
|
1829
|
-
|
|
1892
|
+
const [images, setImages] = useState2({});
|
|
1893
|
+
const [loaded, setLoaded] = useState2(false);
|
|
1894
|
+
useEffect2(() => {
|
|
1830
1895
|
const entries = Object.entries(sources);
|
|
1831
1896
|
if (entries.length === 0) {
|
|
1832
1897
|
setLoaded(true);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ugcinc-render",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.21",
|
|
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",
|