ugcinc-render 1.8.66 → 1.8.68
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 +94 -1
- package/dist/index.mjs +94 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1922,7 +1922,17 @@ function calculateSegmentTimings(config, fps) {
|
|
|
1922
1922
|
const offsetFrames = Math.round(offsetMs / 1e3 * fps);
|
|
1923
1923
|
const startFrame = currentFrame + offsetFrames;
|
|
1924
1924
|
let durationMs;
|
|
1925
|
-
if (segment.
|
|
1925
|
+
if (segment.type === "sequence") {
|
|
1926
|
+
const sequenceSegment = segment;
|
|
1927
|
+
const items = sequenceSegment.items ?? [];
|
|
1928
|
+
if (items.length > 0) {
|
|
1929
|
+
durationMs = items.reduce((total, item) => {
|
|
1930
|
+
return total + (item.duration ?? sequenceSegment.defaultDuration);
|
|
1931
|
+
}, 0);
|
|
1932
|
+
} else {
|
|
1933
|
+
durationMs = sequenceSegment.defaultDuration;
|
|
1934
|
+
}
|
|
1935
|
+
} else if (segment.duration) {
|
|
1926
1936
|
durationMs = segment.duration.type === "absolute" ? segment.duration.value : 5e3;
|
|
1927
1937
|
} else {
|
|
1928
1938
|
durationMs = 5e3;
|
|
@@ -2059,6 +2069,88 @@ function VideoEditorComposition({
|
|
|
2059
2069
|
segment.id
|
|
2060
2070
|
);
|
|
2061
2071
|
}
|
|
2072
|
+
if (segment.type === "sequence") {
|
|
2073
|
+
const sequenceSegment = segment;
|
|
2074
|
+
const items = sequenceSegment.items ?? [];
|
|
2075
|
+
if (items.length === 0) {
|
|
2076
|
+
return null;
|
|
2077
|
+
}
|
|
2078
|
+
const frameIntoSegment = frame - startFrame;
|
|
2079
|
+
let accumulatedFrames = 0;
|
|
2080
|
+
let currentItem = null;
|
|
2081
|
+
let itemStartFrame = startFrame;
|
|
2082
|
+
for (const item of items) {
|
|
2083
|
+
const itemDurationMs = item.duration ?? sequenceSegment.defaultDuration;
|
|
2084
|
+
const itemDurationFrames = Math.round(itemDurationMs / 1e3 * fps);
|
|
2085
|
+
if (frameIntoSegment < accumulatedFrames + itemDurationFrames) {
|
|
2086
|
+
currentItem = item;
|
|
2087
|
+
itemStartFrame = startFrame + accumulatedFrames;
|
|
2088
|
+
break;
|
|
2089
|
+
}
|
|
2090
|
+
accumulatedFrames += itemDurationFrames;
|
|
2091
|
+
}
|
|
2092
|
+
if (!currentItem) {
|
|
2093
|
+
return null;
|
|
2094
|
+
}
|
|
2095
|
+
if (currentItem.type === "image") {
|
|
2096
|
+
const syntheticImageSegment = {
|
|
2097
|
+
id: `${segment.id}-item`,
|
|
2098
|
+
type: "image",
|
|
2099
|
+
source: currentItem.url,
|
|
2100
|
+
order: segment.order,
|
|
2101
|
+
offset: { type: "absolute", value: 0 },
|
|
2102
|
+
xOffset: sequenceSegment.xOffset,
|
|
2103
|
+
yOffset: sequenceSegment.yOffset,
|
|
2104
|
+
width: sequenceSegment.width,
|
|
2105
|
+
height: sequenceSegment.height,
|
|
2106
|
+
fit: sequenceSegment.fit,
|
|
2107
|
+
rotation: sequenceSegment.rotation,
|
|
2108
|
+
opacity: sequenceSegment.opacity,
|
|
2109
|
+
zIndex: sequenceSegment.zIndex,
|
|
2110
|
+
fadeIn: sequenceSegment.fadeIn
|
|
2111
|
+
};
|
|
2112
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2113
|
+
ImageElement,
|
|
2114
|
+
{
|
|
2115
|
+
segment: syntheticImageSegment,
|
|
2116
|
+
src: currentItem.url,
|
|
2117
|
+
startFrame: itemStartFrame,
|
|
2118
|
+
scale: 1
|
|
2119
|
+
},
|
|
2120
|
+
`${segment.id}-${currentItem.url}`
|
|
2121
|
+
);
|
|
2122
|
+
} else {
|
|
2123
|
+
const itemDurationMs = currentItem.duration ?? sequenceSegment.defaultDuration;
|
|
2124
|
+
const itemDurationFrames = Math.round(itemDurationMs / 1e3 * fps);
|
|
2125
|
+
const syntheticVideoSegment = {
|
|
2126
|
+
id: `${segment.id}-item`,
|
|
2127
|
+
type: "video",
|
|
2128
|
+
source: currentItem.url,
|
|
2129
|
+
order: segment.order,
|
|
2130
|
+
offset: { type: "absolute", value: 0 },
|
|
2131
|
+
xOffset: sequenceSegment.xOffset,
|
|
2132
|
+
yOffset: sequenceSegment.yOffset,
|
|
2133
|
+
width: sequenceSegment.width,
|
|
2134
|
+
height: sequenceSegment.height,
|
|
2135
|
+
fit: sequenceSegment.fit,
|
|
2136
|
+
rotation: sequenceSegment.rotation,
|
|
2137
|
+
opacity: sequenceSegment.opacity,
|
|
2138
|
+
zIndex: sequenceSegment.zIndex,
|
|
2139
|
+
fadeIn: sequenceSegment.fadeIn
|
|
2140
|
+
};
|
|
2141
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2142
|
+
VideoElement,
|
|
2143
|
+
{
|
|
2144
|
+
segment: syntheticVideoSegment,
|
|
2145
|
+
src: currentItem.url,
|
|
2146
|
+
startFrame: itemStartFrame,
|
|
2147
|
+
durationInFrames: itemDurationFrames,
|
|
2148
|
+
scale: 1
|
|
2149
|
+
},
|
|
2150
|
+
`${segment.id}-${currentItem.url}`
|
|
2151
|
+
);
|
|
2152
|
+
}
|
|
2153
|
+
}
|
|
2062
2154
|
return null;
|
|
2063
2155
|
}),
|
|
2064
2156
|
audioTimings.map(({ segment, startFrame, durationInFrames: durationInFrames2 }) => {
|
|
@@ -2810,6 +2902,7 @@ function DebugOverlay({
|
|
|
2810
2902
|
);
|
|
2811
2903
|
const handleMouseDown = (0, import_react7.useCallback)((e) => {
|
|
2812
2904
|
if (e.target.tagName === "BUTTON") return;
|
|
2905
|
+
e.preventDefault();
|
|
2813
2906
|
setIsDragging(true);
|
|
2814
2907
|
setLastDragPos({ x: e.clientX, y: e.clientY });
|
|
2815
2908
|
}, []);
|
package/dist/index.mjs
CHANGED
|
@@ -1030,7 +1030,17 @@ function calculateSegmentTimings(config, fps) {
|
|
|
1030
1030
|
const offsetFrames = Math.round(offsetMs / 1e3 * fps);
|
|
1031
1031
|
const startFrame = currentFrame + offsetFrames;
|
|
1032
1032
|
let durationMs;
|
|
1033
|
-
if (segment.
|
|
1033
|
+
if (segment.type === "sequence") {
|
|
1034
|
+
const sequenceSegment = segment;
|
|
1035
|
+
const items = sequenceSegment.items ?? [];
|
|
1036
|
+
if (items.length > 0) {
|
|
1037
|
+
durationMs = items.reduce((total, item) => {
|
|
1038
|
+
return total + (item.duration ?? sequenceSegment.defaultDuration);
|
|
1039
|
+
}, 0);
|
|
1040
|
+
} else {
|
|
1041
|
+
durationMs = sequenceSegment.defaultDuration;
|
|
1042
|
+
}
|
|
1043
|
+
} else if (segment.duration) {
|
|
1034
1044
|
durationMs = segment.duration.type === "absolute" ? segment.duration.value : 5e3;
|
|
1035
1045
|
} else {
|
|
1036
1046
|
durationMs = 5e3;
|
|
@@ -1167,6 +1177,88 @@ function VideoEditorComposition({
|
|
|
1167
1177
|
segment.id
|
|
1168
1178
|
);
|
|
1169
1179
|
}
|
|
1180
|
+
if (segment.type === "sequence") {
|
|
1181
|
+
const sequenceSegment = segment;
|
|
1182
|
+
const items = sequenceSegment.items ?? [];
|
|
1183
|
+
if (items.length === 0) {
|
|
1184
|
+
return null;
|
|
1185
|
+
}
|
|
1186
|
+
const frameIntoSegment = frame - startFrame;
|
|
1187
|
+
let accumulatedFrames = 0;
|
|
1188
|
+
let currentItem = null;
|
|
1189
|
+
let itemStartFrame = startFrame;
|
|
1190
|
+
for (const item of items) {
|
|
1191
|
+
const itemDurationMs = item.duration ?? sequenceSegment.defaultDuration;
|
|
1192
|
+
const itemDurationFrames = Math.round(itemDurationMs / 1e3 * fps);
|
|
1193
|
+
if (frameIntoSegment < accumulatedFrames + itemDurationFrames) {
|
|
1194
|
+
currentItem = item;
|
|
1195
|
+
itemStartFrame = startFrame + accumulatedFrames;
|
|
1196
|
+
break;
|
|
1197
|
+
}
|
|
1198
|
+
accumulatedFrames += itemDurationFrames;
|
|
1199
|
+
}
|
|
1200
|
+
if (!currentItem) {
|
|
1201
|
+
return null;
|
|
1202
|
+
}
|
|
1203
|
+
if (currentItem.type === "image") {
|
|
1204
|
+
const syntheticImageSegment = {
|
|
1205
|
+
id: `${segment.id}-item`,
|
|
1206
|
+
type: "image",
|
|
1207
|
+
source: currentItem.url,
|
|
1208
|
+
order: segment.order,
|
|
1209
|
+
offset: { type: "absolute", value: 0 },
|
|
1210
|
+
xOffset: sequenceSegment.xOffset,
|
|
1211
|
+
yOffset: sequenceSegment.yOffset,
|
|
1212
|
+
width: sequenceSegment.width,
|
|
1213
|
+
height: sequenceSegment.height,
|
|
1214
|
+
fit: sequenceSegment.fit,
|
|
1215
|
+
rotation: sequenceSegment.rotation,
|
|
1216
|
+
opacity: sequenceSegment.opacity,
|
|
1217
|
+
zIndex: sequenceSegment.zIndex,
|
|
1218
|
+
fadeIn: sequenceSegment.fadeIn
|
|
1219
|
+
};
|
|
1220
|
+
return /* @__PURE__ */ jsx5(
|
|
1221
|
+
ImageElement,
|
|
1222
|
+
{
|
|
1223
|
+
segment: syntheticImageSegment,
|
|
1224
|
+
src: currentItem.url,
|
|
1225
|
+
startFrame: itemStartFrame,
|
|
1226
|
+
scale: 1
|
|
1227
|
+
},
|
|
1228
|
+
`${segment.id}-${currentItem.url}`
|
|
1229
|
+
);
|
|
1230
|
+
} else {
|
|
1231
|
+
const itemDurationMs = currentItem.duration ?? sequenceSegment.defaultDuration;
|
|
1232
|
+
const itemDurationFrames = Math.round(itemDurationMs / 1e3 * fps);
|
|
1233
|
+
const syntheticVideoSegment = {
|
|
1234
|
+
id: `${segment.id}-item`,
|
|
1235
|
+
type: "video",
|
|
1236
|
+
source: currentItem.url,
|
|
1237
|
+
order: segment.order,
|
|
1238
|
+
offset: { type: "absolute", value: 0 },
|
|
1239
|
+
xOffset: sequenceSegment.xOffset,
|
|
1240
|
+
yOffset: sequenceSegment.yOffset,
|
|
1241
|
+
width: sequenceSegment.width,
|
|
1242
|
+
height: sequenceSegment.height,
|
|
1243
|
+
fit: sequenceSegment.fit,
|
|
1244
|
+
rotation: sequenceSegment.rotation,
|
|
1245
|
+
opacity: sequenceSegment.opacity,
|
|
1246
|
+
zIndex: sequenceSegment.zIndex,
|
|
1247
|
+
fadeIn: sequenceSegment.fadeIn
|
|
1248
|
+
};
|
|
1249
|
+
return /* @__PURE__ */ jsx5(
|
|
1250
|
+
VideoElement,
|
|
1251
|
+
{
|
|
1252
|
+
segment: syntheticVideoSegment,
|
|
1253
|
+
src: currentItem.url,
|
|
1254
|
+
startFrame: itemStartFrame,
|
|
1255
|
+
durationInFrames: itemDurationFrames,
|
|
1256
|
+
scale: 1
|
|
1257
|
+
},
|
|
1258
|
+
`${segment.id}-${currentItem.url}`
|
|
1259
|
+
);
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1170
1262
|
return null;
|
|
1171
1263
|
}),
|
|
1172
1264
|
audioTimings.map(({ segment, startFrame, durationInFrames: durationInFrames2 }) => {
|
|
@@ -1918,6 +2010,7 @@ function DebugOverlay({
|
|
|
1918
2010
|
);
|
|
1919
2011
|
const handleMouseDown = useCallback((e) => {
|
|
1920
2012
|
if (e.target.tagName === "BUTTON") return;
|
|
2013
|
+
e.preventDefault();
|
|
1921
2014
|
setIsDragging(true);
|
|
1922
2015
|
setLastDragPos({ x: e.clientX, y: e.clientY });
|
|
1923
2016
|
}, []);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ugcinc-render",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.68",
|
|
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",
|