@pixldocs/canvas-renderer 0.5.44 → 0.5.46
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 +46 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +46 -31
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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.
|
|
224
|
+
export declare const PACKAGE_VERSION = "0.5.46";
|
|
225
225
|
|
|
226
226
|
export declare interface PageSettings {
|
|
227
227
|
backgroundColor?: string;
|
package/dist/index.js
CHANGED
|
@@ -4919,7 +4919,8 @@ function applyTextBackground(obj, cfg) {
|
|
|
4919
4919
|
const bgPath = hasBg ? `<path d="${bgD}" fill="${escapeXmlAttr(bgFill)}" />` : "";
|
|
4920
4920
|
svg = svg.replace(/style="[^"]*filter:\s*url\([^)]+\)[^"]*"/i, "");
|
|
4921
4921
|
svg = svg.replace(/<filter[\s\S]*?<\/filter>/gi, "");
|
|
4922
|
-
let
|
|
4922
|
+
let bgShadowLayer = "";
|
|
4923
|
+
let textShadowLayer = "";
|
|
4923
4924
|
if (hasShadow) {
|
|
4924
4925
|
const ox = Number(shadow.offsetX ?? 0) || 0;
|
|
4925
4926
|
const oy = Number(shadow.offsetY ?? 0) || 0;
|
|
@@ -4928,41 +4929,25 @@ function applyTextBackground(obj, cfg) {
|
|
|
4928
4929
|
const shadowBgPath = hasBg ? `<path d="${bgD}" fill="${escapeXmlAttr(shadowColor)}" />` : "";
|
|
4929
4930
|
const inner = extractGInnerMarkup(svg);
|
|
4930
4931
|
const recoloredText = recolorSvgFills(inner, shadowColor);
|
|
4931
|
-
const
|
|
4932
|
+
const bgLayers = [];
|
|
4933
|
+
const textLayers = [];
|
|
4934
|
+
const pushShadowPass = (tx, ty, opacity) => {
|
|
4935
|
+
const attrs = `transform="translate(${tx.toFixed(3)} ${ty.toFixed(3)})"${opacity ? ` opacity="${opacity}"` : ""}`;
|
|
4936
|
+
if (shadowBgPath) bgLayers.push(`<g ${attrs}>${shadowBgPath}</g>`);
|
|
4937
|
+
if (recoloredText) textLayers.push(`<g ${attrs}>${recoloredText}</g>`);
|
|
4938
|
+
};
|
|
4932
4939
|
if (blur > 0) {
|
|
4933
|
-
const
|
|
4934
|
-
|
|
4935
|
-
const t = i / ringCount;
|
|
4936
|
-
const dist = blur * t * 0.6;
|
|
4937
|
-
const op = (0.18 * (1 - t * 0.7)).toFixed(3);
|
|
4938
|
-
const ringOffsets = [
|
|
4939
|
-
[dist, 0],
|
|
4940
|
-
[-dist, 0],
|
|
4941
|
-
[0, dist],
|
|
4942
|
-
[0, -dist],
|
|
4943
|
-
[dist * 0.7, dist * 0.7],
|
|
4944
|
-
[-dist * 0.7, dist * 0.7],
|
|
4945
|
-
[dist * 0.7, -dist * 0.7],
|
|
4946
|
-
[-dist * 0.7, -dist * 0.7]
|
|
4947
|
-
];
|
|
4948
|
-
for (const [dx, dy] of ringOffsets) {
|
|
4949
|
-
layers.push(
|
|
4950
|
-
`<g transform="translate(${(ox + dx).toFixed(3)} ${(oy + dy).toFixed(3)})" opacity="${op}">${shadowBgPath}${recoloredText}</g>`
|
|
4951
|
-
);
|
|
4952
|
-
}
|
|
4940
|
+
for (const pass of buildNormalizedShadowPasses(blur)) {
|
|
4941
|
+
pushShadowPass(ox + pass.dx, oy + pass.dy, pass.opacity);
|
|
4953
4942
|
}
|
|
4954
|
-
layers.push(
|
|
4955
|
-
`<g transform="translate(${ox.toFixed(3)} ${oy.toFixed(3)})" opacity="0.25">${shadowBgPath}${recoloredText}</g>`
|
|
4956
|
-
);
|
|
4957
4943
|
} else {
|
|
4958
|
-
|
|
4959
|
-
`<g transform="translate(${ox.toFixed(3)} ${oy.toFixed(3)})">${shadowBgPath}${recoloredText}</g>`
|
|
4960
|
-
);
|
|
4944
|
+
pushShadowPass(ox, oy);
|
|
4961
4945
|
}
|
|
4962
|
-
|
|
4946
|
+
bgShadowLayer = bgLayers.join("");
|
|
4947
|
+
textShadowLayer = textLayers.join("");
|
|
4963
4948
|
}
|
|
4964
4949
|
const openTagMatch = svg.match(/^\s*<g\b[^>]*>/);
|
|
4965
|
-
const inserted =
|
|
4950
|
+
const inserted = bgShadowLayer + bgPath + textShadowLayer;
|
|
4966
4951
|
if (openTagMatch) {
|
|
4967
4952
|
const openTag = openTagMatch[0];
|
|
4968
4953
|
return svg.replace(openTag, openTag + inserted);
|
|
@@ -4990,6 +4975,36 @@ function recolorSvgFills(svg, color) {
|
|
|
4990
4975
|
);
|
|
4991
4976
|
return out;
|
|
4992
4977
|
}
|
|
4978
|
+
function buildNormalizedShadowPasses(blur) {
|
|
4979
|
+
const safeBlur = Math.max(0, Number(blur) || 0);
|
|
4980
|
+
const ringCount = Math.min(5, Math.max(2, Math.round(safeBlur / 5)));
|
|
4981
|
+
const targetOpacity = Math.max(0.16, Math.min(0.38, 0.46 - safeBlur * 0.01));
|
|
4982
|
+
const weighted = [
|
|
4983
|
+
{ dx: 0, dy: 0, weight: 0.7 }
|
|
4984
|
+
];
|
|
4985
|
+
for (let i = 1; i <= ringCount; i++) {
|
|
4986
|
+
const t = i / ringCount;
|
|
4987
|
+
const dist = safeBlur * t * 0.42;
|
|
4988
|
+
const weight = Math.exp(-2.4 * t * t);
|
|
4989
|
+
const diag = dist * 0.7071;
|
|
4990
|
+
weighted.push(
|
|
4991
|
+
{ dx: dist, dy: 0, weight },
|
|
4992
|
+
{ dx: -dist, dy: 0, weight },
|
|
4993
|
+
{ dx: 0, dy: dist, weight },
|
|
4994
|
+
{ dx: 0, dy: -dist, weight },
|
|
4995
|
+
{ dx: diag, dy: diag, weight: weight * 0.72 },
|
|
4996
|
+
{ dx: -diag, dy: diag, weight: weight * 0.72 },
|
|
4997
|
+
{ dx: diag, dy: -diag, weight: weight * 0.72 },
|
|
4998
|
+
{ dx: -diag, dy: -diag, weight: weight * 0.72 }
|
|
4999
|
+
);
|
|
5000
|
+
}
|
|
5001
|
+
const totalWeight = weighted.reduce((sum, pass) => sum + pass.weight, 0) || 1;
|
|
5002
|
+
return weighted.map((pass) => ({
|
|
5003
|
+
dx: pass.dx,
|
|
5004
|
+
dy: pass.dy,
|
|
5005
|
+
opacity: Math.max(3e-3, targetOpacity * pass.weight / totalWeight).toFixed(4)
|
|
5006
|
+
}));
|
|
5007
|
+
}
|
|
4993
5008
|
function buildRoundedRectPathD(x, y, w, h, rTL, rTR, rBR, rBL) {
|
|
4994
5009
|
const maxR = Math.min(w, h) / 2;
|
|
4995
5010
|
const tl = Math.min(Math.max(0, rTL), maxR);
|
|
@@ -12341,7 +12356,7 @@ function PixldocsPreview(props) {
|
|
|
12341
12356
|
!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..." }) })
|
|
12342
12357
|
] });
|
|
12343
12358
|
}
|
|
12344
|
-
const PACKAGE_VERSION = "0.5.
|
|
12359
|
+
const PACKAGE_VERSION = "0.5.46";
|
|
12345
12360
|
let __underlineFixInstalled = false;
|
|
12346
12361
|
function installUnderlineFix(fab) {
|
|
12347
12362
|
var _a;
|