ugcinc 4.5.12 → 4.5.13
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.
|
@@ -26,6 +26,12 @@ export interface ImageEditorNodeConfig {
|
|
|
26
26
|
elements: ImageEditorElement[];
|
|
27
27
|
/** Background type: 'image' for image input, 'color' for solid color */
|
|
28
28
|
backgroundType?: 'image' | 'color';
|
|
29
|
+
/** Whether background image comes from a variable input port (default: true for backwards compat) */
|
|
30
|
+
backgroundIsVariable?: boolean;
|
|
31
|
+
/** Media library ID for static background image */
|
|
32
|
+
backgroundMediaId?: string | null;
|
|
33
|
+
/** URL for static background image */
|
|
34
|
+
backgroundMediaUrl?: string | null;
|
|
29
35
|
/** Background color (hex) when backgroundType is 'color' */
|
|
30
36
|
backgroundColor?: string;
|
|
31
37
|
/** How the background image fits the canvas */
|
|
@@ -20,6 +20,7 @@ const definition = (0, types_1.defineNode)({
|
|
|
20
20
|
aspectRatio: '9:16',
|
|
21
21
|
dimensionPreset: '9:16',
|
|
22
22
|
backgroundType: 'image',
|
|
23
|
+
backgroundIsVariable: false,
|
|
23
24
|
elements: [],
|
|
24
25
|
},
|
|
25
26
|
outputMode: 'per-input',
|
|
@@ -29,8 +30,8 @@ const definition = (0, types_1.defineNode)({
|
|
|
29
30
|
const editorConfig = config?.imageEditor;
|
|
30
31
|
const inputs = [];
|
|
31
32
|
if (editorConfig) {
|
|
32
|
-
// Add background input if backgroundType is not 'color'
|
|
33
|
-
if (editorConfig.backgroundType !== 'color') {
|
|
33
|
+
// Add background input if backgroundType is not 'color' AND is variable
|
|
34
|
+
if (editorConfig.backgroundType !== 'color' && editorConfig.backgroundIsVariable !== false) {
|
|
34
35
|
inputs.push({
|
|
35
36
|
id: 'background',
|
|
36
37
|
type: 'image',
|
|
@@ -40,7 +41,7 @@ const definition = (0, types_1.defineNode)({
|
|
|
40
41
|
}
|
|
41
42
|
// Add inputs for each element with inputId or textInputId
|
|
42
43
|
editorConfig.elements.forEach(elem => {
|
|
43
|
-
if (elem.type === 'image' && elem.inputId) {
|
|
44
|
+
if (elem.type === 'image' && elem.inputId && elem.imageIsVariable !== false) {
|
|
44
45
|
inputs.push({
|
|
45
46
|
id: elem.inputId,
|
|
46
47
|
type: 'image',
|
|
@@ -101,17 +102,31 @@ const definition = (0, types_1.defineNode)({
|
|
|
101
102
|
return null;
|
|
102
103
|
const sources = {};
|
|
103
104
|
const textContent = {};
|
|
104
|
-
// Add background URL
|
|
105
|
-
if (editorConfig.
|
|
106
|
-
|
|
105
|
+
// Add background URL: use static URL when not variable, otherwise use preview URL
|
|
106
|
+
if (editorConfig.backgroundIsVariable === false) {
|
|
107
|
+
if (editorConfig.backgroundMediaUrl) {
|
|
108
|
+
sources['background'] = editorConfig.backgroundMediaUrl;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
if (editorConfig.previewBackgroundUrl) {
|
|
113
|
+
sources['background'] = editorConfig.previewBackgroundUrl;
|
|
114
|
+
}
|
|
107
115
|
}
|
|
108
116
|
// Resolve image elements: inputId -> element.id
|
|
109
117
|
// Resolve text elements: textInputId -> element.id
|
|
110
118
|
for (const elem of editorConfig.elements) {
|
|
111
119
|
if (elem.type === 'image' && elem.inputId) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
120
|
+
if (elem.imageIsVariable === false) {
|
|
121
|
+
if (elem.imageMediaUrl) {
|
|
122
|
+
sources[elem.id] = elem.imageMediaUrl;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
const url = editorConfig.previewImageUrls?.[elem.inputId];
|
|
127
|
+
if (url) {
|
|
128
|
+
sources[elem.id] = url;
|
|
129
|
+
}
|
|
115
130
|
}
|
|
116
131
|
}
|
|
117
132
|
else if (elem.type === 'text' && elem.textInputId) {
|
|
@@ -161,17 +176,31 @@ function prepareImageComposerInput(editorConfig, inputs) {
|
|
|
161
176
|
// Build imageUrls map from inputs
|
|
162
177
|
const imageUrls = {};
|
|
163
178
|
const textValues = {};
|
|
164
|
-
// Add background URL
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
179
|
+
// Add background URL: use static URL when not variable, otherwise from inputs
|
|
180
|
+
if (editorConfig.backgroundIsVariable === false) {
|
|
181
|
+
if (editorConfig.backgroundMediaUrl) {
|
|
182
|
+
imageUrls.background = editorConfig.backgroundMediaUrl;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
const bgValue = inputs.background;
|
|
187
|
+
if (bgValue && typeof bgValue === 'object' && typeof bgValue.url === 'string') {
|
|
188
|
+
imageUrls.background = bgValue.url;
|
|
189
|
+
}
|
|
168
190
|
}
|
|
169
191
|
// Process each element to extract image URLs and text values
|
|
170
192
|
for (const elem of editorConfig.elements) {
|
|
171
193
|
if (elem.type === 'image' && elem.inputId) {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
194
|
+
if (elem.imageIsVariable === false) {
|
|
195
|
+
if (elem.imageMediaUrl) {
|
|
196
|
+
imageUrls[elem.inputId] = elem.imageMediaUrl;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
const value = inputs[elem.inputId];
|
|
201
|
+
if (value && typeof value === 'object' && typeof value.url === 'string') {
|
|
202
|
+
imageUrls[elem.inputId] = value.url;
|
|
203
|
+
}
|
|
175
204
|
}
|
|
176
205
|
}
|
|
177
206
|
else if (elem.type === 'text' && elem.textInputId) {
|
|
@@ -97,6 +97,12 @@ export interface ImageEditorElement {
|
|
|
97
97
|
boxAlign?: 'left' | 'center' | 'right';
|
|
98
98
|
/** Maps to input port (e.g., "image_1", "image_2") */
|
|
99
99
|
inputId?: string;
|
|
100
|
+
/** Whether this image comes from a variable input port (default: true for backwards compat) */
|
|
101
|
+
imageIsVariable?: boolean;
|
|
102
|
+
/** Media library ID for static image selection */
|
|
103
|
+
imageMediaId?: string | null;
|
|
104
|
+
/** URL for static image selection */
|
|
105
|
+
imageMediaUrl?: string | null;
|
|
100
106
|
/** How the image fits its container */
|
|
101
107
|
fit?: FitMode;
|
|
102
108
|
/** Opacity percentage 0-100 */
|