ugcinc 4.5.68 → 4.5.70

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,6 +45,7 @@ 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");
48
49
  /**
49
50
  * Calculate the actual width for auto-width text AND the line breaks.
50
51
  * Uses DOM-based measurement to ensure the same fonts are used as CSS rendering.
@@ -161,6 +162,18 @@ function calculateAutoWidthAndLines({ text, maxWidth, paddingLeft, paddingRight,
161
162
  const calculatedWidth = Math.min(widestLineWidth + paddingLeft + paddingRight, maxWidth);
162
163
  return { width: calculatedWidth, lines };
163
164
  }
165
+ /**
166
+ * Replace emoji characters with spaces for the stroke layer.
167
+ * Spaces have zero alpha for the emoji glyphs, so feMorphology won't dilate them.
168
+ * Returns a plain string — no DOM changes, preserving identical vertical metrics.
169
+ */
170
+ function getStrokeText(text) {
171
+ if (!(0, emoji_1.hasEmoji)(text))
172
+ return text;
173
+ return (0, emoji_1.splitTextAndEmojis)(text)
174
+ .map(part => part.type === 'emoji' ? ' ' : part.content)
175
+ .join('');
176
+ }
164
177
  /**
165
178
  * TextElement renders text with full styling support including:
166
179
  * - Font family, size, weight, color
@@ -366,6 +379,7 @@ function TextElement({ segment, scale = 1 }) {
366
379
  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;
367
380
  if (autoWidth) {
368
381
  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)));
382
+ const strokeContent = calculatedLines.map((line, index) => ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [getStrokeText(line), index < calculatedLines.length - 1 && (0, jsx_runtime_1.jsx)("br", {})] }, index)));
369
383
  if (backgroundColor) {
370
384
  return ((0, jsx_runtime_1.jsx)("div", { style: positioningContainerStyle, children: (0, jsx_runtime_1.jsxs)("div", { style: {
371
385
  width: calculatedWidth,
@@ -373,10 +387,10 @@ function TextElement({ segment, scale = 1 }) {
373
387
  backgroundColor: (0, text_1.hexToRgba)(backgroundColor, backgroundOpacity),
374
388
  borderRadius: borderRadiusStyle,
375
389
  ...(hasStroke && { position: 'relative' }),
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 })] }) }));
390
+ }, 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 })] }) }));
377
391
  }
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 })] }) }));
392
+ 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 })] }) }));
379
393
  }
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 })] }) }));
394
+ 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: getStrokeText(segment.text) }), (0, jsx_runtime_1.jsx)("div", { style: textStyle, children: segment.text })] }) }));
381
395
  }
382
396
  exports.default = TextElement;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ugcinc",
3
- "version": "4.5.68",
3
+ "version": "4.5.70",
4
4
  "description": "TypeScript/JavaScript client for the UGC Inc API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",