ugcinc-render 1.5.25 → 1.5.26

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.d.mts CHANGED
@@ -1365,6 +1365,9 @@ declare function useResolvedPositions(elements: ImageEditorElement[], textValues
1365
1365
  *
1366
1366
  * This file registers all available compositions with the renderer.
1367
1367
  * It serves as the entry point for the renderer bundler.
1368
+ *
1369
+ * Uses calculateMetadata for ImageEditorComposition to determine
1370
+ * dynamic crop dimensions in the browser environment (with DOM access).
1368
1371
  */
1369
1372
 
1370
1373
  declare const RenderRoot: React.FC;
package/dist/index.d.ts CHANGED
@@ -1365,6 +1365,9 @@ declare function useResolvedPositions(elements: ImageEditorElement[], textValues
1365
1365
  *
1366
1366
  * This file registers all available compositions with the renderer.
1367
1367
  * It serves as the entry point for the renderer bundler.
1368
+ *
1369
+ * Uses calculateMetadata for ImageEditorComposition to determine
1370
+ * dynamic crop dimensions in the browser environment (with DOM access).
1368
1371
  */
1369
1372
 
1370
1373
  declare const RenderRoot: React.FC;
package/dist/index.js CHANGED
@@ -2126,6 +2126,55 @@ var defaultVideoProps = {
2126
2126
  };
2127
2127
  var ImageComp = ImageEditorComposition;
2128
2128
  var VideoComp = VideoEditorComposition;
2129
+ var calculateImageMetadata = async ({ props }) => {
2130
+ console.log("[calculateMetadata] Starting metadata calculation...");
2131
+ const canvasWidth = props.width ?? props.config?.width ?? 1080;
2132
+ const canvasHeight = props.height ?? props.config?.height ?? 1920;
2133
+ const defaultResult = {
2134
+ width: canvasWidth,
2135
+ height: canvasHeight,
2136
+ fps: 30,
2137
+ durationInFrames: 1
2138
+ };
2139
+ if (!props.elements || !props.dynamicCrop) {
2140
+ console.log("[calculateMetadata] No elements or dynamicCrop, using default dimensions:", canvasWidth, "x", canvasHeight);
2141
+ return defaultResult;
2142
+ }
2143
+ if (!isDynamicCropEnabled(props.dynamicCrop)) {
2144
+ console.log("[calculateMetadata] Dynamic crop not enabled, using default dimensions:", canvasWidth, "x", canvasHeight);
2145
+ return defaultResult;
2146
+ }
2147
+ console.log("[calculateMetadata] Dynamic crop enabled, loading fonts for accurate measurement...");
2148
+ try {
2149
+ await preloadFonts();
2150
+ console.log("[calculateMetadata] Fonts loaded successfully");
2151
+ } catch (err) {
2152
+ console.error("[calculateMetadata] Font loading failed:", err);
2153
+ }
2154
+ await new Promise((resolve) => setTimeout(resolve, 50));
2155
+ console.log("[calculateMetadata] Resolving element positions with DOM measurement...");
2156
+ const { elements: resolvedElements } = resolveElementPositions(
2157
+ props.elements,
2158
+ props.textValues ?? {}
2159
+ );
2160
+ console.log("[calculateMetadata] Element positions resolved");
2161
+ const cropBounds = calculateCropBounds(
2162
+ resolvedElements,
2163
+ props.dynamicCrop,
2164
+ canvasWidth,
2165
+ canvasHeight,
2166
+ props.textValues
2167
+ );
2168
+ const outputWidth = Math.round(cropBounds.width);
2169
+ const outputHeight = Math.round(cropBounds.height);
2170
+ console.log(`[calculateMetadata] Crop bounds calculated: ${canvasWidth}x${canvasHeight} -> ${outputWidth}x${outputHeight} (offset: ${cropBounds.x}, ${cropBounds.y})`);
2171
+ return {
2172
+ width: outputWidth,
2173
+ height: outputHeight,
2174
+ fps: 30,
2175
+ durationInFrames: 1
2176
+ };
2177
+ };
2129
2178
  var RenderRoot = () => {
2130
2179
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
2131
2180
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
@@ -2133,8 +2182,9 @@ var RenderRoot = () => {
2133
2182
  {
2134
2183
  id: "ImageEditorComposition",
2135
2184
  component: ImageComp,
2185
+ calculateMetadata: calculateImageMetadata,
2136
2186
  durationInFrames: 1,
2137
- fps: 1,
2187
+ fps: 30,
2138
2188
  width: 1080,
2139
2189
  height: 1920,
2140
2190
  defaultProps: defaultImageProps
package/dist/index.mjs CHANGED
@@ -2040,6 +2040,55 @@ var defaultVideoProps = {
2040
2040
  };
2041
2041
  var ImageComp = ImageEditorComposition;
2042
2042
  var VideoComp = VideoEditorComposition;
2043
+ var calculateImageMetadata = async ({ props }) => {
2044
+ console.log("[calculateMetadata] Starting metadata calculation...");
2045
+ const canvasWidth = props.width ?? props.config?.width ?? 1080;
2046
+ const canvasHeight = props.height ?? props.config?.height ?? 1920;
2047
+ const defaultResult = {
2048
+ width: canvasWidth,
2049
+ height: canvasHeight,
2050
+ fps: 30,
2051
+ durationInFrames: 1
2052
+ };
2053
+ if (!props.elements || !props.dynamicCrop) {
2054
+ console.log("[calculateMetadata] No elements or dynamicCrop, using default dimensions:", canvasWidth, "x", canvasHeight);
2055
+ return defaultResult;
2056
+ }
2057
+ if (!isDynamicCropEnabled(props.dynamicCrop)) {
2058
+ console.log("[calculateMetadata] Dynamic crop not enabled, using default dimensions:", canvasWidth, "x", canvasHeight);
2059
+ return defaultResult;
2060
+ }
2061
+ console.log("[calculateMetadata] Dynamic crop enabled, loading fonts for accurate measurement...");
2062
+ try {
2063
+ await preloadFonts();
2064
+ console.log("[calculateMetadata] Fonts loaded successfully");
2065
+ } catch (err) {
2066
+ console.error("[calculateMetadata] Font loading failed:", err);
2067
+ }
2068
+ await new Promise((resolve) => setTimeout(resolve, 50));
2069
+ console.log("[calculateMetadata] Resolving element positions with DOM measurement...");
2070
+ const { elements: resolvedElements } = resolveElementPositions(
2071
+ props.elements,
2072
+ props.textValues ?? {}
2073
+ );
2074
+ console.log("[calculateMetadata] Element positions resolved");
2075
+ const cropBounds = calculateCropBounds(
2076
+ resolvedElements,
2077
+ props.dynamicCrop,
2078
+ canvasWidth,
2079
+ canvasHeight,
2080
+ props.textValues
2081
+ );
2082
+ const outputWidth = Math.round(cropBounds.width);
2083
+ const outputHeight = Math.round(cropBounds.height);
2084
+ console.log(`[calculateMetadata] Crop bounds calculated: ${canvasWidth}x${canvasHeight} -> ${outputWidth}x${outputHeight} (offset: ${cropBounds.x}, ${cropBounds.y})`);
2085
+ return {
2086
+ width: outputWidth,
2087
+ height: outputHeight,
2088
+ fps: 30,
2089
+ durationInFrames: 1
2090
+ };
2091
+ };
2043
2092
  var RenderRoot = () => {
2044
2093
  return /* @__PURE__ */ jsxs4(Fragment, { children: [
2045
2094
  /* @__PURE__ */ jsx6(
@@ -2047,8 +2096,9 @@ var RenderRoot = () => {
2047
2096
  {
2048
2097
  id: "ImageEditorComposition",
2049
2098
  component: ImageComp,
2099
+ calculateMetadata: calculateImageMetadata,
2050
2100
  durationInFrames: 1,
2051
- fps: 1,
2101
+ fps: 30,
2052
2102
  width: 1080,
2053
2103
  height: 1920,
2054
2104
  defaultProps: defaultImageProps
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ugcinc-render",
3
- "version": "1.5.25",
3
+ "version": "1.5.26",
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",