@pixldocs/canvas-renderer 0.5.136 → 0.5.138

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("./index-DUHE7WhJ.cjs");
3
+ const index = require("./index-CkbBhnZd.cjs");
4
4
  exports.FONT_FALLBACK_DEVANAGARI = index.FONT_FALLBACK_DEVANAGARI;
5
5
  exports.FONT_FALLBACK_MATH = index.FONT_FALLBACK_MATH;
6
6
  exports.FONT_FALLBACK_SYMBOLS = index.FONT_FALLBACK_SYMBOLS;
package/dist/index.d.ts CHANGED
@@ -259,7 +259,7 @@ export declare function normalizeFontFamily(fontStack: string): string;
259
259
  * Package version banner. Bump alongside package.json so we can confirm
260
260
  * (via browser:log) that the deployed bundle matches the expected build.
261
261
  */
262
- export declare const PACKAGE_VERSION = "0.5.136";
262
+ export declare const PACKAGE_VERSION = "0.5.138";
263
263
 
264
264
  export declare interface PageSettings {
265
265
  backgroundColor?: string;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { F, o, q, s, P, t, u, v, w, x, y, z, B, C, D, E, G, H, I, J, K, b, L, M, N, O, Q, R, S, U, V, W, X, Y, Z } from "./index-BHa3ekoF.js";
1
+ import { F, o, q, s, P, t, u, v, w, x, y, z, B, C, D, E, G, H, I, J, K, b, L, M, N, O, Q, R, S, U, V, W, X, Y, Z } from "./index-D-I6bYGU.js";
2
2
  export {
3
3
  F as FONT_FALLBACK_DEVANAGARI,
4
4
  o as FONT_FALLBACK_MATH,
@@ -1,7 +1,7 @@
1
1
  import { jsPDF, ShadingPattern } from "jspdf";
2
2
  import { svg2pdf } from "svg2pdf.js";
3
3
  import * as fabric from "fabric";
4
- import { g as getCanvasForPage, c as captureFabricCanvasSvgForPdf, f as findNodeById, a as getAbsoluteBounds, p as parseTextMarkdown, r as renderSmartElementToSvg, n as normalizeShapeType, h as hasEdgeFade, b as getProxiedImageUrl, d as bakeEdgeFade, i as isElement, e as isGroup, j as buildRoundedTrianglePath, A as API_URL, k as getImageProxyFetchOptions, l as getRoundedRectRadii, T as TRIANGLE_STROKE_MITER_LIMIT, m as getTrianglePoints } from "./index-BHa3ekoF.js";
4
+ import { g as getCanvasForPage, c as captureFabricCanvasSvgForPdf, f as findNodeById, a as getAbsoluteBounds, p as parseTextMarkdown, r as renderSmartElementToSvg, n as normalizeShapeType, h as hasEdgeFade, b as getProxiedImageUrl, d as bakeEdgeFade, i as isElement, e as isGroup, j as buildRoundedTrianglePath, A as API_URL, k as getImageProxyFetchOptions, l as getRoundedRectRadii, T as TRIANGLE_STROKE_MITER_LIMIT, m as getTrianglePoints } from "./index-D-I6bYGU.js";
5
5
  import { resetPdfFontRegistry, FONT_FALLBACK_SYMBOLS, FONT_FALLBACK_MATH, FONT_FALLBACK_DEVANAGARI, embedFontWithGoogleFallback, getEmbeddedVariantsList, isFontAvailable, isFamilyEmbedded, resolveBestRegisteredVariant, getEmbeddedJsPDFFontName, resolveFontWeight, doesVariantSupportChar } from "./pdfFonts-BVHbPFEz.js";
6
6
  async function embedFontsForSvg(pdf, svgStr) {
7
7
  var _a;
@@ -1141,8 +1141,15 @@ async function bakeTextAnchorPositionsFromLiveSvg(svg) {
1141
1141
  if (!liveText) continue;
1142
1142
  const srcTspans = Array.from(srcText.querySelectorAll("tspan"));
1143
1143
  const liveTspans = Array.from(liveText.querySelectorAll("tspan"));
1144
- const bakeNode = (srcNode, liveNode, isTspan) => {
1145
- const anchor = _resolveAnchor(srcNode);
1144
+ const stripTextAnchorStyle = (node) => {
1145
+ const style = node.getAttribute("style") || "";
1146
+ if (!/text-anchor\s*:/i.test(style)) return;
1147
+ const cleaned = style.split(";").map((p) => p.trim()).filter(Boolean).filter((p) => !/^text-anchor\s*:/i.test(p)).join("; ");
1148
+ if (cleaned) node.setAttribute("style", cleaned);
1149
+ else node.removeAttribute("style");
1150
+ };
1151
+ const bakeNode = (srcNode, liveNode, anchorOverride) => {
1152
+ const anchor = (anchorOverride || _resolveAnchor(srcNode)).trim().toLowerCase();
1146
1153
  if (anchor !== "middle" && anchor !== "end") return;
1147
1154
  try {
1148
1155
  const n = typeof liveNode.getNumberOfChars === "function" ? liveNode.getNumberOfChars() : 0;
@@ -1151,23 +1158,20 @@ async function bakeTextAnchorPositionsFromLiveSvg(svg) {
1151
1158
  if (!Number.isFinite(start == null ? void 0 : start.x)) return;
1152
1159
  srcNode.setAttribute("x", String(start.x));
1153
1160
  srcNode.setAttribute("text-anchor", "start");
1154
- const style = srcNode.getAttribute("style") || "";
1155
- if (/text-anchor\s*:/i.test(style)) {
1156
- const cleaned = style.split(";").map((p) => p.trim()).filter(Boolean).filter((p) => !/^text-anchor\s*:/i.test(p)).join("; ");
1157
- if (cleaned) srcNode.setAttribute("style", cleaned);
1158
- else srcNode.removeAttribute("style");
1159
- }
1161
+ stripTextAnchorStyle(srcNode);
1160
1162
  baked++;
1161
1163
  } catch {
1162
1164
  }
1163
1165
  };
1164
1166
  if (srcTspans.length > 0) {
1165
- bakeNode(srcText, liveText, false);
1167
+ const parentAnchor = _resolveAnchor(srcText);
1168
+ const tspanAnchors = srcTspans.map((tspan) => _resolveAnchor(tspan));
1169
+ bakeNode(srcText, liveText, parentAnchor);
1166
1170
  for (let j = 0; j < srcTspans.length; j++) {
1167
- if (liveTspans[j]) bakeNode(srcTspans[j], liveTspans[j], true);
1171
+ if (liveTspans[j]) bakeNode(srcTspans[j], liveTspans[j], tspanAnchors[j]);
1168
1172
  }
1169
1173
  } else {
1170
- bakeNode(srcText, liveText, false);
1174
+ bakeNode(srcText, liveText);
1171
1175
  }
1172
1176
  }
1173
1177
  } finally {
@@ -2223,7 +2227,7 @@ async function fetchSvgAsElement(imageUrl, colorMap) {
2223
2227
  async function getRecoloredSvgDataUrl(imageUrl, colorMap) {
2224
2228
  if (!colorMap || Object.keys(colorMap).length === 0) return null;
2225
2229
  try {
2226
- const { getNormalizedSvgUrl } = await import("./index-BHa3ekoF.js").then((n) => n._);
2230
+ const { getNormalizedSvgUrl } = await import("./index-D-I6bYGU.js").then((n) => n._);
2227
2231
  return await getNormalizedSvgUrl(imageUrl, colorMap);
2228
2232
  } catch {
2229
2233
  return null;
@@ -3004,7 +3008,7 @@ async function fetchImageAsBase64(imageUrl, opts = {}) {
3004
3008
  }
3005
3009
  let fetchUrl = imageUrl;
3006
3010
  if (imageUrl.startsWith("http://") || imageUrl.startsWith("https://")) {
3007
- const { isPrivateUrl } = await import("./index-BHa3ekoF.js").then((n) => n._);
3011
+ const { isPrivateUrl } = await import("./index-D-I6bYGU.js").then((n) => n._);
3008
3012
  if (isPrivateUrl(imageUrl)) return null;
3009
3013
  const proxyUrl = new URL(`${API_URL}/image-proxy`);
3010
3014
  proxyUrl.searchParams.set("url", imageUrl);
@@ -4987,4 +4991,4 @@ export {
4987
4991
  preparePagesForExport,
4988
4992
  rewriteSvgFontsForJsPDFWithSourceMeta
4989
4993
  };
4990
- //# sourceMappingURL=vectorPdfExport-D3L64sAJ.js.map
4994
+ //# sourceMappingURL=vectorPdfExport-BGqNP_R0.js.map