ugcinc 4.5.63 → 4.5.65
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.
|
@@ -160,23 +160,6 @@ function calculateAutoWidthAndLines({ text, maxWidth, paddingLeft, paddingRight,
|
|
|
160
160
|
}
|
|
161
161
|
document.body.removeChild(measureSpan);
|
|
162
162
|
const calculatedWidth = Math.min(widestLineWidth + paddingLeft + paddingRight, maxWidth);
|
|
163
|
-
// CONDENSED DEBUG LOG
|
|
164
|
-
console.log('[TextElement] WIDTH_CALC:', JSON.stringify({
|
|
165
|
-
text: text.substring(0, 30),
|
|
166
|
-
fontFamily: fontFamily.split(',')[0],
|
|
167
|
-
computedFont: computedFontFamily.split(',')[0],
|
|
168
|
-
fontLoaded: requestedFontLoaded,
|
|
169
|
-
fontSize,
|
|
170
|
-
fontWeight,
|
|
171
|
-
letterSpacing,
|
|
172
|
-
mWidth: Math.round(mWidth * 100) / 100,
|
|
173
|
-
widestLine: Math.round(widestLineWidth * 100) / 100,
|
|
174
|
-
paddingL: paddingLeft,
|
|
175
|
-
paddingR: paddingRight,
|
|
176
|
-
calcWidth: Math.round(calculatedWidth * 100) / 100,
|
|
177
|
-
maxWidth,
|
|
178
|
-
lines: lines.length,
|
|
179
|
-
}));
|
|
180
163
|
return { width: calculatedWidth, lines };
|
|
181
164
|
}
|
|
182
165
|
/**
|
|
@@ -338,20 +321,6 @@ function TextElement({ segment, scale = 1 }) {
|
|
|
338
321
|
}, [autoWidth, calculatedWidth, width, backgroundColor, backgroundOpacity, borderRadiusStyle]);
|
|
339
322
|
const hasStroke = strokeWidth > 0 && !!strokeColor;
|
|
340
323
|
const filterId = `te-stroke-${react_1.default.useId().replace(/:/g, '')}`;
|
|
341
|
-
if (hasStroke) {
|
|
342
|
-
console.log('[TextElement] STROKE_DEBUG:', JSON.stringify({
|
|
343
|
-
text: segment.text.substring(0, 50),
|
|
344
|
-
strokeWidth,
|
|
345
|
-
strokeColor,
|
|
346
|
-
filterId,
|
|
347
|
-
paddingTop, paddingRight, paddingBottom, paddingLeft,
|
|
348
|
-
fontSize,
|
|
349
|
-
strokePadPct: Math.max(50, Math.ceil((strokeWidth / fontSize) * 200)),
|
|
350
|
-
autoWidth,
|
|
351
|
-
width,
|
|
352
|
-
calculatedWidth,
|
|
353
|
-
}));
|
|
354
|
-
}
|
|
355
324
|
// Text style (fill layer)
|
|
356
325
|
const textStyle = (0, react_1.useMemo)(() => ({
|
|
357
326
|
fontFamily,
|
|
@@ -371,15 +340,13 @@ function TextElement({ segment, scale = 1 }) {
|
|
|
371
340
|
flex: 1,
|
|
372
341
|
minHeight: 0,
|
|
373
342
|
}),
|
|
374
|
-
...(hasStroke && { position: 'relative' }),
|
|
343
|
+
...(hasStroke && { position: 'relative', zIndex: 1 }),
|
|
375
344
|
}), [
|
|
376
345
|
fontFamily, fontSize, fontWeight, color, lineHeight, letterSpacing, alignment,
|
|
377
346
|
paddingTop, paddingRight, paddingBottom, paddingLeft,
|
|
378
347
|
autoWidth, verticalAlign, hasStroke
|
|
379
348
|
]);
|
|
380
|
-
// Stroke underlay style —
|
|
381
|
-
// dilated outline stays inside the div and doesn't clip at text edges.
|
|
382
|
-
// Extra padding compensates so text wraps identically to the fill layer.
|
|
349
|
+
// Stroke underlay style — same size as fill div, SVG filter handles overflow.
|
|
383
350
|
const strokeTextStyle = (0, react_1.useMemo)(() => {
|
|
384
351
|
if (!hasStroke)
|
|
385
352
|
return undefined;
|
|
@@ -388,23 +355,27 @@ function TextElement({ segment, scale = 1 }) {
|
|
|
388
355
|
color: strokeColor,
|
|
389
356
|
filter: `url(#${filterId})`,
|
|
390
357
|
position: 'absolute',
|
|
391
|
-
top:
|
|
392
|
-
left:
|
|
393
|
-
right:
|
|
394
|
-
bottom:
|
|
395
|
-
padding: `${paddingTop + strokeWidth}px ${paddingRight + strokeWidth}px ${paddingBottom + strokeWidth}px ${paddingLeft + strokeWidth}px`,
|
|
358
|
+
top: 0,
|
|
359
|
+
left: 0,
|
|
360
|
+
right: 0,
|
|
361
|
+
bottom: 0,
|
|
396
362
|
};
|
|
397
|
-
console.log('[TextElement] STROKE_STYLE:', JSON.stringify({
|
|
398
|
-
filter: style.filter,
|
|
399
|
-
top: style.top,
|
|
400
|
-
left: style.left,
|
|
401
|
-
right: style.right,
|
|
402
|
-
bottom: style.bottom,
|
|
403
|
-
padding: style.padding,
|
|
404
|
-
color: style.color,
|
|
405
|
-
}));
|
|
406
363
|
return style;
|
|
407
364
|
}, [hasStroke, textStyle, strokeColor, filterId, strokeWidth, paddingTop, paddingRight, paddingBottom, paddingLeft]);
|
|
365
|
+
if (hasStroke) {
|
|
366
|
+
console.log('[TextElement] STROKE_DIAG:', JSON.stringify({
|
|
367
|
+
text: segment.text.substring(0, 30),
|
|
368
|
+
strokeWidth,
|
|
369
|
+
fontSize,
|
|
370
|
+
fillZ: textStyle.zIndex,
|
|
371
|
+
fillPos: textStyle.position,
|
|
372
|
+
strokeZ: strokeTextStyle?.zIndex,
|
|
373
|
+
strokePos: strokeTextStyle?.position,
|
|
374
|
+
strokeFilter: strokeTextStyle?.filter,
|
|
375
|
+
autoWidth,
|
|
376
|
+
hasBg: !!backgroundColor,
|
|
377
|
+
}));
|
|
378
|
+
}
|
|
408
379
|
// SVG filter for smooth text outline (avoids miter spikes from -webkit-text-stroke)
|
|
409
380
|
const strokePadPct = Math.max(50, Math.ceil((strokeWidth / fontSize) * 200));
|
|
410
381
|
const strokeFilterSvg = hasStroke ? ((0, jsx_runtime_1.jsx)("svg", { style: { position: 'absolute', width: 0, height: 0, overflow: 'hidden' }, "aria-hidden": "true", children: (0, jsx_runtime_1.jsx)("defs", { children: (0, jsx_runtime_1.jsxs)("filter", { id: filterId, x: `-${strokePadPct}%`, y: `-${strokePadPct}%`, width: `${100 + 2 * strokePadPct}%`, height: `${100 + 2 * strokePadPct}%`, children: [(0, jsx_runtime_1.jsx)("feMorphology", { in: "SourceAlpha", operator: "dilate", radius: strokeWidth, result: "dilated" }), (0, jsx_runtime_1.jsx)("feFlood", { floodColor: strokeColor, result: "color" }), (0, jsx_runtime_1.jsx)("feComposite", { in: "color", in2: "dilated", operator: "in" })] }) }) })) : null;
|
|
@@ -413,15 +384,10 @@ function TextElement({ segment, scale = 1 }) {
|
|
|
413
384
|
// keep layout identical to the fill layer.
|
|
414
385
|
const renderStrokeText = (text) => {
|
|
415
386
|
const parts = (0, emoji_1.splitTextAndEmojis)(text);
|
|
416
|
-
console.log('[TextElement] EMOJI_DEBUG:', JSON.stringify({
|
|
417
|
-
text: text.substring(0, 50),
|
|
418
|
-
partsCount: parts.length,
|
|
419
|
-
parts: parts.map(p => ({ type: p.type, content: p.content.substring(0, 10) })),
|
|
420
|
-
}));
|
|
421
387
|
if (parts.every(p => p.type === 'text'))
|
|
422
388
|
return text;
|
|
423
389
|
return parts.map((part, i) => part.type === 'emoji'
|
|
424
|
-
? (0, jsx_runtime_1.jsx)("span", { style: {
|
|
390
|
+
? (0, jsx_runtime_1.jsx)("span", { style: { visibility: 'hidden' }, children: part.content }, i)
|
|
425
391
|
: (0, jsx_runtime_1.jsx)(react_1.default.Fragment, { children: part.content }, i));
|
|
426
392
|
};
|
|
427
393
|
if (autoWidth) {
|
|
@@ -75,18 +75,6 @@ function elementToTextSegment(elem) {
|
|
|
75
75
|
autoWidth: elem.autoWidth,
|
|
76
76
|
boxAlign: elem.boxAlign,
|
|
77
77
|
};
|
|
78
|
-
// CONDENSED DEBUG LOG
|
|
79
|
-
console.log('[Composition] ELEMENT:', JSON.stringify({
|
|
80
|
-
id: elem.id,
|
|
81
|
-
text: (elem.text ?? '').substring(0, 20),
|
|
82
|
-
w: elem.width,
|
|
83
|
-
h: elem.height,
|
|
84
|
-
font: elem.font,
|
|
85
|
-
fontSize: elem.fontSize,
|
|
86
|
-
autoWidth: elem.autoWidth,
|
|
87
|
-
pL: elem.paddingLeft,
|
|
88
|
-
pR: elem.paddingRight,
|
|
89
|
-
}));
|
|
90
78
|
return segment;
|
|
91
79
|
}
|
|
92
80
|
/**
|