ugcinc 4.5.64 → 4.5.66

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.
@@ -45,7 +45,6 @@ const react_1 = __importStar(require("react"));
45
45
  const defaults_1 = require("../utils/defaults");
46
46
  const fonts_1 = require("../utils/fonts");
47
47
  const text_1 = require("../utils/text");
48
- const emoji_1 = require("../utils/emoji");
49
48
  /**
50
49
  * Calculate the actual width for auto-width text AND the line breaks.
51
50
  * Uses DOM-based measurement to ensure the same fonts are used as CSS rendering.
@@ -160,23 +159,6 @@ function calculateAutoWidthAndLines({ text, maxWidth, paddingLeft, paddingRight,
160
159
  }
161
160
  document.body.removeChild(measureSpan);
162
161
  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
162
  return { width: calculatedWidth, lines };
181
163
  }
182
164
  /**
@@ -338,20 +320,6 @@ function TextElement({ segment, scale = 1 }) {
338
320
  }, [autoWidth, calculatedWidth, width, backgroundColor, backgroundOpacity, borderRadiusStyle]);
339
321
  const hasStroke = strokeWidth > 0 && !!strokeColor;
340
322
  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
323
  // Text style (fill layer)
356
324
  const textStyle = (0, react_1.useMemo)(() => ({
357
325
  fontFamily,
@@ -377,55 +345,27 @@ function TextElement({ segment, scale = 1 }) {
377
345
  paddingTop, paddingRight, paddingBottom, paddingLeft,
378
346
  autoWidth, verticalAlign, hasStroke
379
347
  ]);
380
- // Stroke underlay style — extended by strokeWidth on all sides so the
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.
348
+ // Stroke underlay style — same size as fill div, SVG filter handles overflow.
383
349
  const strokeTextStyle = (0, react_1.useMemo)(() => {
384
350
  if (!hasStroke)
385
351
  return undefined;
386
- const style = {
352
+ return {
387
353
  ...textStyle,
388
354
  color: strokeColor,
389
355
  filter: `url(#${filterId})`,
390
356
  position: 'absolute',
357
+ zIndex: 0,
391
358
  top: 0,
392
359
  left: 0,
393
360
  right: 0,
394
361
  bottom: 0,
395
362
  };
396
- console.log('[TextElement] STROKE_STYLE:', JSON.stringify({
397
- filter: style.filter,
398
- top: style.top,
399
- left: style.left,
400
- right: style.right,
401
- bottom: style.bottom,
402
- padding: style.padding,
403
- color: style.color,
404
- }));
405
- return style;
406
- }, [hasStroke, textStyle, strokeColor, filterId, strokeWidth, paddingTop, paddingRight, paddingBottom, paddingLeft]);
363
+ }, [hasStroke, textStyle, strokeColor, filterId]);
407
364
  // SVG filter for smooth text outline (avoids miter spikes from -webkit-text-stroke)
408
365
  const strokePadPct = Math.max(50, Math.ceil((strokeWidth / fontSize) * 200));
409
366
  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;
410
- // Render text with emojis made invisible (opacity 0) so the stroke
411
- // filter doesn't dilate around them. Emojis still occupy space to
412
- // keep layout identical to the fill layer.
413
- const renderStrokeText = (text) => {
414
- const parts = (0, emoji_1.splitTextAndEmojis)(text);
415
- console.log('[TextElement] EMOJI_DEBUG:', JSON.stringify({
416
- text: text.substring(0, 50),
417
- partsCount: parts.length,
418
- parts: parts.map(p => ({ type: p.type, content: p.content.substring(0, 10) })),
419
- }));
420
- if (parts.every(p => p.type === 'text'))
421
- return text;
422
- return parts.map((part, i) => part.type === 'emoji'
423
- ? (0, jsx_runtime_1.jsx)("span", { style: { visibility: 'hidden' }, children: part.content }, i)
424
- : (0, jsx_runtime_1.jsx)(react_1.default.Fragment, { children: part.content }, i));
425
- };
426
367
  if (autoWidth) {
427
368
  const textContent = calculatedLines.map((line, index) => ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [line, index < calculatedLines.length - 1 && (0, jsx_runtime_1.jsx)("br", {})] }, index)));
428
- const strokeContent = calculatedLines.map((line, index) => ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [renderStrokeText(line), index < calculatedLines.length - 1 && (0, jsx_runtime_1.jsx)("br", {})] }, index)));
429
369
  if (backgroundColor) {
430
370
  return ((0, jsx_runtime_1.jsx)("div", { style: positioningContainerStyle, children: (0, jsx_runtime_1.jsxs)("div", { style: {
431
371
  width: calculatedWidth,
@@ -433,10 +373,10 @@ function TextElement({ segment, scale = 1 }) {
433
373
  backgroundColor: (0, text_1.hexToRgba)(backgroundColor, backgroundOpacity),
434
374
  borderRadius: borderRadiusStyle,
435
375
  ...(hasStroke && { position: 'relative' }),
436
- }, children: [strokeFilterSvg, strokeTextStyle && (0, jsx_runtime_1.jsx)("div", { style: strokeTextStyle, "aria-hidden": "true", children: strokeContent }), (0, jsx_runtime_1.jsx)("div", { style: textStyle, children: textContent })] }) }));
376
+ }, children: [strokeFilterSvg, strokeTextStyle && (0, jsx_runtime_1.jsx)("div", { style: strokeTextStyle, "aria-hidden": "true", children: textContent }), (0, jsx_runtime_1.jsx)("div", { style: textStyle, children: textContent })] }) }));
437
377
  }
438
- return ((0, jsx_runtime_1.jsx)("div", { style: positioningContainerStyle, children: (0, jsx_runtime_1.jsxs)("div", { style: { width: calculatedWidth, maxWidth: width, ...(hasStroke && { position: 'relative' }) }, children: [strokeFilterSvg, strokeTextStyle && (0, jsx_runtime_1.jsx)("div", { style: strokeTextStyle, "aria-hidden": "true", children: strokeContent }), (0, jsx_runtime_1.jsx)("div", { style: textStyle, children: textContent })] }) }));
378
+ return ((0, jsx_runtime_1.jsx)("div", { style: positioningContainerStyle, children: (0, jsx_runtime_1.jsxs)("div", { style: { width: calculatedWidth, maxWidth: width, ...(hasStroke && { position: 'relative' }) }, children: [strokeFilterSvg, strokeTextStyle && (0, jsx_runtime_1.jsx)("div", { style: strokeTextStyle, "aria-hidden": "true", children: textContent }), (0, jsx_runtime_1.jsx)("div", { style: textStyle, children: textContent })] }) }));
439
379
  }
440
- return ((0, jsx_runtime_1.jsx)("div", { style: positioningContainerStyle, children: (0, jsx_runtime_1.jsxs)("div", { style: { ...backgroundBoxStyle, ...(hasStroke && { position: 'relative' }) }, children: [strokeFilterSvg, strokeTextStyle && (0, jsx_runtime_1.jsx)("div", { style: strokeTextStyle, "aria-hidden": "true", children: renderStrokeText(segment.text) }), (0, jsx_runtime_1.jsx)("div", { style: textStyle, children: segment.text })] }) }));
380
+ return ((0, jsx_runtime_1.jsx)("div", { style: positioningContainerStyle, children: (0, jsx_runtime_1.jsxs)("div", { style: { ...backgroundBoxStyle, ...(hasStroke && { position: 'relative' }) }, children: [strokeFilterSvg, strokeTextStyle && (0, jsx_runtime_1.jsx)("div", { style: strokeTextStyle, "aria-hidden": "true", children: segment.text }), (0, jsx_runtime_1.jsx)("div", { style: textStyle, children: segment.text })] }) }));
441
381
  }
442
382
  exports.default = TextElement;
@@ -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
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ugcinc",
3
- "version": "4.5.64",
3
+ "version": "4.5.66",
4
4
  "description": "TypeScript/JavaScript client for the UGC Inc API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",