@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.cjs +9 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +9 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4945,21 +4945,20 @@ function applyTextBackground(obj, cfg) {
|
|
|
4945
4945
|
const oy = Number(shadow.offsetY ?? 0) || 0;
|
|
4946
4946
|
const blur = Math.max(0, Number(shadow.blur ?? 0));
|
|
4947
4947
|
const shadowColor = String(shadow.color);
|
|
4948
|
-
const pad = Math.max(
|
|
4948
|
+
const pad = Math.max(16, Math.ceil(blur * 4) + Math.ceil(Math.max(Math.abs(ox), Math.abs(oy))) + 8);
|
|
4949
4949
|
const bx = -w / 2 - pL - pad;
|
|
4950
4950
|
const by = -h / 2 - pT - pad;
|
|
4951
4951
|
const bw = w + pL + pR + pad * 2;
|
|
4952
4952
|
const bh = h + pT + pB + pad * 2;
|
|
4953
4953
|
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)}"`;
|
|
4954
|
+
const wrapShadow = (markup) => blur <= 0 ? `<g transform="translate(${ox.toFixed(3)} ${oy.toFixed(3)})">${markup}</g>` : `<g class="__pdShadowRaster" ${dataAttrs}>${markup}</g>`;
|
|
4954
4955
|
if (hasBg) {
|
|
4955
4956
|
const shadowBgPath = `<path d="${bgD}" fill="${escapeXmlAttr(shadowColor)}" />`;
|
|
4956
|
-
bgShadowMarker =
|
|
4957
|
+
bgShadowMarker = wrapShadow(shadowBgPath);
|
|
4957
4958
|
}
|
|
4958
4959
|
const inner = extractGInnerMarkup(svg);
|
|
4959
4960
|
const recoloredText = recolorSvgFills(inner, shadowColor);
|
|
4960
|
-
if (recoloredText)
|
|
4961
|
-
textShadowMarker = `<g class="__pdShadowRaster" ${dataAttrs}>${recoloredText}</g>`;
|
|
4962
|
-
}
|
|
4961
|
+
if (recoloredText) textShadowMarker = wrapShadow(recoloredText);
|
|
4963
4962
|
}
|
|
4964
4963
|
const openTagMatch = svg.match(/^\s*<g\b[^>]*>/);
|
|
4965
4964
|
const inserted = bgShadowMarker + bgPath + textShadowMarker;
|
|
@@ -12341,7 +12340,7 @@ function PixldocsPreview(props) {
|
|
|
12341
12340
|
!canvasSettled && /* @__PURE__ */ jsxRuntime.jsx("div", { style: { position: "absolute", inset: 0, display: "flex", alignItems: "center", justifyContent: "center", minHeight: 200 }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: { color: "#888", fontSize: 14 }, children: "Loading preview..." }) })
|
|
12342
12341
|
] });
|
|
12343
12342
|
}
|
|
12344
|
-
const PACKAGE_VERSION = "0.5.
|
|
12343
|
+
const PACKAGE_VERSION = "0.5.48";
|
|
12345
12344
|
let __underlineFixInstalled = false;
|
|
12346
12345
|
function installUnderlineFix(fab) {
|
|
12347
12346
|
var _a;
|
|
@@ -15036,18 +15035,18 @@ async function rasterizeShadowMarkers(svg) {
|
|
|
15036
15035
|
const scale = 2;
|
|
15037
15036
|
const pxW = Math.min(4096, Math.max(8, Math.ceil(bw * scale)));
|
|
15038
15037
|
const pxH = Math.min(4096, Math.max(8, Math.ceil(bh * scale)));
|
|
15039
|
-
const stdDev = Math.max(0, blur
|
|
15038
|
+
const stdDev = Math.max(0, blur);
|
|
15040
15039
|
const filterId = `pdShadowBlur_${Math.random().toString(36).slice(2, 9)}`;
|
|
15041
15040
|
const styleBlock = fontFaceCss ? `<style>${fontFaceCss}</style>` : "";
|
|
15042
|
-
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>`;
|
|
15041
|
+
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>`;
|
|
15043
15042
|
const dataUrl = await rasterSvgToPngDataUrl(miniSvg, pxW, pxH);
|
|
15044
15043
|
if (!dataUrl) {
|
|
15045
15044
|
(_c = marker.parentNode) == null ? void 0 : _c.removeChild(marker);
|
|
15046
15045
|
continue;
|
|
15047
15046
|
}
|
|
15048
15047
|
const img = svg.ownerDocument.createElementNS(SVG_NS, "image");
|
|
15049
|
-
img.setAttribute("x", String(bx
|
|
15050
|
-
img.setAttribute("y", String(by
|
|
15048
|
+
img.setAttribute("x", String(bx));
|
|
15049
|
+
img.setAttribute("y", String(by));
|
|
15051
15050
|
img.setAttribute("width", String(bw));
|
|
15052
15051
|
img.setAttribute("height", String(bh));
|
|
15053
15052
|
img.setAttribute("preserveAspectRatio", "none");
|