@pixldocs/canvas-renderer 0.5.47 → 0.5.49

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.
package/dist/index.d.ts CHANGED
@@ -221,7 +221,7 @@ export declare function normalizeFontFamily(fontStack: string): string;
221
221
  * Package version banner. Bump alongside package.json so we can confirm
222
222
  * (via browser:log) that the deployed bundle matches the expected build.
223
223
  */
224
- export declare const PACKAGE_VERSION = "0.5.47";
224
+ export declare const PACKAGE_VERSION = "0.5.48";
225
225
 
226
226
  export declare interface PageSettings {
227
227
  backgroundColor?: string;
package/dist/index.js CHANGED
@@ -4926,21 +4926,20 @@ function applyTextBackground(obj, cfg) {
4926
4926
  const oy = Number(shadow.offsetY ?? 0) || 0;
4927
4927
  const blur = Math.max(0, Number(shadow.blur ?? 0));
4928
4928
  const shadowColor = String(shadow.color);
4929
- const pad = Math.max(8, Math.ceil(blur * 3) + Math.ceil(Math.max(Math.abs(ox), Math.abs(oy))) + 4);
4929
+ const pad = Math.max(16, Math.ceil(blur * 4) + Math.ceil(Math.max(Math.abs(ox), Math.abs(oy))) + 8);
4930
4930
  const bx = -w / 2 - pL - pad;
4931
4931
  const by = -h / 2 - pT - pad;
4932
4932
  const bw = w + pL + pR + pad * 2;
4933
4933
  const bh = h + pT + pB + pad * 2;
4934
4934
  const dataAttrs = `data-blur="${blur.toFixed(3)}" data-ox="${ox.toFixed(3)}" data-oy="${oy.toFixed(3)}" data-bx="${bx.toFixed(3)}" data-by="${by.toFixed(3)}" data-bw="${bw.toFixed(3)}" data-bh="${bh.toFixed(3)}" data-color="${escapeXmlAttr(shadowColor)}"`;
4935
+ const wrapShadow = (markup) => blur <= 0 ? `<g transform="translate(${ox.toFixed(3)} ${oy.toFixed(3)})">${markup}</g>` : `<g class="__pdShadowRaster" ${dataAttrs}>${markup}</g>`;
4935
4936
  if (hasBg) {
4936
4937
  const shadowBgPath = `<path d="${bgD}" fill="${escapeXmlAttr(shadowColor)}" />`;
4937
- bgShadowMarker = `<g class="__pdShadowRaster" ${dataAttrs}>${shadowBgPath}</g>`;
4938
+ bgShadowMarker = wrapShadow(shadowBgPath);
4938
4939
  }
4939
4940
  const inner = extractGInnerMarkup(svg);
4940
4941
  const recoloredText = recolorSvgFills(inner, shadowColor);
4941
- if (recoloredText) {
4942
- textShadowMarker = `<g class="__pdShadowRaster" ${dataAttrs}>${recoloredText}</g>`;
4943
- }
4942
+ if (recoloredText) textShadowMarker = wrapShadow(recoloredText);
4944
4943
  }
4945
4944
  const openTagMatch = svg.match(/^\s*<g\b[^>]*>/);
4946
4945
  const inserted = bgShadowMarker + bgPath + textShadowMarker;
@@ -12322,7 +12321,7 @@ function PixldocsPreview(props) {
12322
12321
  !canvasSettled && /* @__PURE__ */ jsx("div", { style: { position: "absolute", inset: 0, display: "flex", alignItems: "center", justifyContent: "center", minHeight: 200 }, children: /* @__PURE__ */ jsx("div", { style: { color: "#888", fontSize: 14 }, children: "Loading preview..." }) })
12323
12322
  ] });
12324
12323
  }
12325
- const PACKAGE_VERSION = "0.5.47";
12324
+ const PACKAGE_VERSION = "0.5.48";
12326
12325
  let __underlineFixInstalled = false;
12327
12326
  function installUnderlineFix(fab) {
12328
12327
  var _a;
@@ -15017,18 +15016,18 @@ async function rasterizeShadowMarkers(svg) {
15017
15016
  const scale = 2;
15018
15017
  const pxW = Math.min(4096, Math.max(8, Math.ceil(bw * scale)));
15019
15018
  const pxH = Math.min(4096, Math.max(8, Math.ceil(bh * scale)));
15020
- const stdDev = Math.max(0, blur / 2);
15019
+ const stdDev = Math.max(0, blur);
15021
15020
  const filterId = `pdShadowBlur_${Math.random().toString(36).slice(2, 9)}`;
15022
15021
  const styleBlock = fontFaceCss ? `<style>${fontFaceCss}</style>` : "";
15023
- const miniSvg = `<svg xmlns="${SVG_NS}" xmlns:xlink="${XLINK_NS}" width="${pxW}" height="${pxH}" viewBox="${bx} ${by} ${bw} ${bh}"><defs>${styleBlock}<filter id="${filterId}" x="-50%" y="-50%" width="200%" height="200%" color-interpolation-filters="sRGB"><feGaussianBlur stdDeviation="${stdDev}" /></filter></defs><g filter="url(#${filterId})">${innerXml}</g></svg>`;
15022
+ const miniSvg = `<svg xmlns="${SVG_NS}" xmlns:xlink="${XLINK_NS}" width="${pxW}" height="${pxH}" viewBox="${bx} ${by} ${bw} ${bh}"><defs>${styleBlock}<filter id="${filterId}" x="-50%" y="-50%" width="200%" height="200%" color-interpolation-filters="sRGB"><feOffset dx="${ox}" dy="${oy}" result="offsetShadow" /><feGaussianBlur in="offsetShadow" stdDeviation="${stdDev}" /></filter></defs><g filter="url(#${filterId})">${innerXml}</g></svg>`;
15024
15023
  const dataUrl = await rasterSvgToPngDataUrl(miniSvg, pxW, pxH);
15025
15024
  if (!dataUrl) {
15026
15025
  (_c = marker.parentNode) == null ? void 0 : _c.removeChild(marker);
15027
15026
  continue;
15028
15027
  }
15029
15028
  const img = svg.ownerDocument.createElementNS(SVG_NS, "image");
15030
- img.setAttribute("x", String(bx + ox));
15031
- img.setAttribute("y", String(by + oy));
15029
+ img.setAttribute("x", String(bx));
15030
+ img.setAttribute("y", String(by));
15032
15031
  img.setAttribute("width", String(bw));
15033
15032
  img.setAttribute("height", String(bh));
15034
15033
  img.setAttribute("preserveAspectRatio", "none");