ugcinc 4.5.67 → 4.5.69

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.
@@ -46,20 +46,6 @@ const defaults_1 = require("../utils/defaults");
46
46
  const fonts_1 = require("../utils/fonts");
47
47
  const text_1 = require("../utils/text");
48
48
  const emoji_1 = require("../utils/emoji");
49
- /**
50
- * Render text with emojis wrapped in spans — used by BOTH fill and stroke
51
- * divs so they share identical DOM structure and vertical metrics.
52
- * In the stroke layer, emoji spans get visibility:hidden so the SVG filter
53
- * doesn't dilate them.
54
- */
55
- function renderTextWithEmojiSpans(text, hideEmojis) {
56
- const parts = (0, emoji_1.splitTextAndEmojis)(text);
57
- if (parts.every(p => p.type === 'text'))
58
- return text;
59
- return parts.map((part, i) => part.type === 'emoji'
60
- ? (0, jsx_runtime_1.jsx)("span", { style: hideEmojis ? { visibility: 'hidden' } : undefined, children: part.content }, i)
61
- : (0, jsx_runtime_1.jsx)(react_1.default.Fragment, { children: part.content }, i));
62
- }
63
49
  /**
64
50
  * Calculate the actual width for auto-width text AND the line breaks.
65
51
  * Uses DOM-based measurement to ensure the same fonts are used as CSS rendering.
@@ -176,6 +162,19 @@ function calculateAutoWidthAndLines({ text, maxWidth, paddingLeft, paddingRight,
176
162
  const calculatedWidth = Math.min(widestLineWidth + paddingLeft + paddingRight, maxWidth);
177
163
  return { width: calculatedWidth, lines };
178
164
  }
165
+ /**
166
+ * Render text with emojis hidden (opacity:0) for the stroke layer.
167
+ * Emojis become invisible so feMorphology won't dilate their alpha.
168
+ * Uses inline spans to preserve text flow.
169
+ */
170
+ function renderStrokeText(text) {
171
+ if (!(0, emoji_1.hasEmoji)(text))
172
+ return text;
173
+ const parts = (0, emoji_1.splitTextAndEmojis)(text);
174
+ return parts.map((part, i) => part.type === 'emoji'
175
+ ? (0, jsx_runtime_1.jsx)("span", { style: { opacity: 0 }, children: part.content }, i)
176
+ : part.content);
177
+ }
179
178
  /**
180
179
  * TextElement renders text with full styling support including:
181
180
  * - Font family, size, weight, color
@@ -380,8 +379,8 @@ function TextElement({ segment, scale = 1 }) {
380
379
  const strokePadPct = Math.max(50, Math.ceil((strokeWidth / fontSize) * 200));
381
380
  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;
382
381
  if (autoWidth) {
383
- const fillContent = calculatedLines.map((line, index) => ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [hasStroke ? renderTextWithEmojiSpans(line, false) : line, index < calculatedLines.length - 1 && (0, jsx_runtime_1.jsx)("br", {})] }, index)));
384
- const strokeContent = hasStroke ? calculatedLines.map((line, index) => ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [renderTextWithEmojiSpans(line, true), index < calculatedLines.length - 1 && (0, jsx_runtime_1.jsx)("br", {})] }, index))) : null;
382
+ 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)));
383
+ 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)));
385
384
  if (backgroundColor) {
386
385
  return ((0, jsx_runtime_1.jsx)("div", { style: positioningContainerStyle, children: (0, jsx_runtime_1.jsxs)("div", { style: {
387
386
  width: calculatedWidth,
@@ -389,10 +388,10 @@ function TextElement({ segment, scale = 1 }) {
389
388
  backgroundColor: (0, text_1.hexToRgba)(backgroundColor, backgroundOpacity),
390
389
  borderRadius: borderRadiusStyle,
391
390
  ...(hasStroke && { position: 'relative' }),
392
- }, 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: fillContent })] }) }));
391
+ }, 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 })] }) }));
393
392
  }
394
- 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: fillContent })] }) }));
393
+ 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 })] }) }));
395
394
  }
396
- 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: hasStroke ? renderTextWithEmojiSpans(segment.text, true) : segment.text }), (0, jsx_runtime_1.jsx)("div", { style: textStyle, children: hasStroke ? renderTextWithEmojiSpans(segment.text, false) : segment.text })] }) }));
395
+ 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 })] }) }));
397
396
  }
398
397
  exports.default = TextElement;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ugcinc",
3
- "version": "4.5.67",
3
+ "version": "4.5.69",
4
4
  "description": "TypeScript/JavaScript client for the UGC Inc API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",