@pixldocs/canvas-renderer 0.5.495 → 0.5.497

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-DaaT4Mo7.cjs");
3
+ const index = require("./index-CZm1oVfa.cjs");
4
4
  exports.DEPLOYMENT_VERSION_MARKER = index.DEPLOYMENT_VERSION_MARKER;
5
5
  exports.FONT_FALLBACK_DEVANAGARI = index.FONT_FALLBACK_DEVANAGARI;
6
6
  exports.FONT_FALLBACK_MATH = index.FONT_FALLBACK_MATH;
@@ -29,6 +29,7 @@ exports.getPublishedTemplate = index.getPublishedTemplate;
29
29
  exports.getTemplateForm = index.getTemplateForm;
30
30
  exports.hasAnyPreviewBlur = index.hasAnyPreviewBlur;
31
31
  exports.injectPreviewBlur = index.injectPreviewBlur;
32
+ exports.injectWatermark = index.injectWatermark;
32
33
  exports.isBundledAssetUrl = index.isBundledAssetUrl;
33
34
  exports.isFontAvailable = index.isFontAvailable;
34
35
  exports.isPrivateUrl = index.isPrivateUrl;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.d.ts CHANGED
@@ -5,6 +5,7 @@ import { getProxiedImageUrl } from '../../../src/lib/canvasImageLoader';
5
5
  import { hasAnyPreviewBlur } from '../../../src/lib/previewBlur';
6
6
  import { InferredSection } from '../../../src/lib/inferFormSchemaFromTemplate';
7
7
  import { injectPreviewBlur } from '../../../src/lib/previewBlur';
8
+ import { injectWatermark } from '../../../src/lib/canvasWatermark';
8
9
  import { isBundledAssetUrl } from '../../../src/lib/canvasImageLoader';
9
10
  import { isPrivateUrl } from '../../../src/lib/canvasImageLoader';
10
11
  import { jsPDF } from 'jspdf';
@@ -286,6 +287,8 @@ export { InferredSection }
286
287
 
287
288
  export { injectPreviewBlur }
288
289
 
290
+ export { injectWatermark }
291
+
289
292
  export { isBundledAssetUrl }
290
293
 
291
294
  /** Check if a font is in our local mapping */
@@ -567,6 +570,8 @@ export declare class PixldocsRenderer {
567
570
  maxImageEdgePx?: number;
568
571
  compressImages?: boolean;
569
572
  compressionQuality?: number;
573
+ watermark?: boolean;
574
+ watermarkOptions?: WatermarkOptions;
570
575
  }): Promise<PdfRenderResult>;
571
576
  /**
572
577
  * Resolve from V2 sectionState and render a vector PDF.
@@ -632,6 +637,28 @@ export declare class PixldocsRenderer {
632
637
  * renderer.
633
638
  */
634
639
  private awaitFontsForConfig;
640
+ /**
641
+ * Flush BOTH process-global text-measurement caches after fonts are ready
642
+ * and BEFORE the capture canvas mounts.
643
+ *
644
+ * Why: anything that measured text before the webfonts finished loading —
645
+ * most notably `applyContentBoundsPagination` running inside
646
+ * `resolveFromForm` on a cold page (the EC2/MCP flow: resolve + render in
647
+ * one browser context) — populates the app measurement cache and Fabric's
648
+ * global char-width cache with FALLBACK metrics. `createText` then places
649
+ * center/right-aligned lines from those stale widths, so a right-aligned
650
+ * grid cell on a continuation page drew shifted left by
651
+ * (fallbackWidth − realWidth) px vs the editor (caught by
652
+ * tests/parity `auto-paginate`, a 9px shift). The later
653
+ * `waitForStableTextMetrics` pass re-primes glyph bounds but never moves
654
+ * the already-positioned box, so the flush must happen pre-mount.
655
+ *
656
+ * Only called from the headless PNG paths (`render`/`renderAllPages`),
657
+ * which already default to clearing the global char cache in
658
+ * `waitForStableTextMetrics` — the live-preview-adjacent PDF path keeps
659
+ * its `clearGlobalCharCache: false` behaviour untouched.
660
+ */
661
+ private flushTextMeasurementCaches;
635
662
  private getNormalizedGradientStops;
636
663
  private paintPageBackground;
637
664
  private renderPageViaPreviewCanvas;
@@ -775,6 +802,10 @@ export declare interface RenderFromFormOptions extends Omit<RenderOptions, 'page
775
802
  export declare interface RenderOptions {
776
803
  /** Page index to render (default: 0) */
777
804
  pageIndex?: number;
805
+ /** Inject the PixlDocs watermark before rendering (test/demo-key renders). */
806
+ watermark?: boolean;
807
+ /** Customize watermark text/opacity/fontSize/angle. */
808
+ watermarkOptions?: WatermarkOptions;
778
809
  /** Output format (default: 'png') */
779
810
  format?: 'png' | 'jpeg' | 'webp';
780
811
  /** Quality for jpeg/webp (0-1, default: 0.92) */
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { D, F, q, s, t, P, u, v, w, x, y, z, B, C, E, G, H, I, J, K, L, M, N, b, O, Q, R, S, U, V, W, X, Y, Z, _, $, a0, a1, a2, a3, a4, a5, a6, a7 } from "./index-Cvi3YYOq.js";
1
+ import { D, F, q, s, t, P, u, v, w, x, y, z, B, C, E, G, H, I, J, K, L, M, N, b, O, Q, R, S, U, V, W, X, Y, Z, _, $, a0, a1, a2, a3, a4, a5, a6, a7, a8 } from "./index-CKhnRi3S.js";
2
2
  export {
3
3
  D as DEPLOYMENT_VERSION_MARKER,
4
4
  F as FONT_FALLBACK_DEVANAGARI,
@@ -28,21 +28,22 @@ export {
28
28
  Q as getTemplateForm,
29
29
  R as hasAnyPreviewBlur,
30
30
  S as injectPreviewBlur,
31
- U as isBundledAssetUrl,
32
- V as isFontAvailable,
33
- W as isPrivateUrl,
34
- X as listPublishedTemplates,
35
- Y as loadGoogleFontCSS,
36
- Z as normalizeFontFamily,
37
- _ as resolveBlurElementExactIdsFromFlatFormKeys,
38
- $ as resolveFontWeight,
39
- a0 as resolveForRender,
40
- a1 as resolveFromForm,
41
- a2 as resolveTemplateData,
42
- a3 as rewriteSvgFontsForJsPDF,
43
- a4 as setAutoShrinkDebug,
44
- a5 as setBundledAssetPrefixes,
45
- a6 as warmResolvedTemplateForPreview,
46
- a7 as warmTemplateFromForm
31
+ U as injectWatermark,
32
+ V as isBundledAssetUrl,
33
+ W as isFontAvailable,
34
+ X as isPrivateUrl,
35
+ Y as listPublishedTemplates,
36
+ Z as loadGoogleFontCSS,
37
+ _ as normalizeFontFamily,
38
+ $ as resolveBlurElementExactIdsFromFlatFormKeys,
39
+ a0 as resolveFontWeight,
40
+ a1 as resolveForRender,
41
+ a2 as resolveFromForm,
42
+ a3 as resolveTemplateData,
43
+ a4 as rewriteSvgFontsForJsPDF,
44
+ a5 as setAutoShrinkDebug,
45
+ a6 as setBundledAssetPrefixes,
46
+ a7 as warmResolvedTemplateForPreview,
47
+ a8 as warmTemplateFromForm
47
48
  };
48
49
  //# sourceMappingURL=index.js.map
@@ -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 { p as parseTextMarkdown, r as renderSmartElementToSvg, g as getCanvasForPage, c as captureFabricCanvasSvgForPdf, f as findNodeById, a as getAbsoluteBounds, b as getProxiedImageUrl, d as getImageProxyFetchOptions, A as API_URL, n as normalizeShapeType, i as isElement, e as isGroup, h as buildRoundedTrianglePath, j as hasEdgeFade, k as bakeEdgeFade, l as getRoundedRectRadii, T as TRIANGLE_STROKE_MITER_LIMIT, m as getTrianglePoints, o as getWorldAngleDeg } from "./index-Cvi3YYOq.js";
4
+ import { p as parseTextMarkdown, r as renderSmartElementToSvg, g as getCanvasForPage, c as captureFabricCanvasSvgForPdf, f as findNodeById, a as getAbsoluteBounds, b as getProxiedImageUrl, d as getImageProxyFetchOptions, A as API_URL, n as normalizeShapeType, i as isElement, e as isGroup, h as buildRoundedTrianglePath, j as hasEdgeFade, k as bakeEdgeFade, l as getRoundedRectRadii, T as TRIANGLE_STROKE_MITER_LIMIT, m as getTrianglePoints, o as getWorldAngleDeg } from "./index-CKhnRi3S.js";
5
5
  import { resetPdfFontRegistry, FONT_FALLBACK_SYMBOLS, FONT_FALLBACK_MATH, FONT_FALLBACK_DEVANAGARI, embedFontWithGoogleFallback, getEmbeddedVariantsList, isFontAvailable, isFamilyEmbedded, resolveBestRegisteredVariant, getEmbeddedJsPDFFontName, resolveFontWeight, doesVariantSupportChar } from "./pdfFonts-B_rPB0OF.js";
6
6
  async function embedFontsForSvg(pdf, svgStr) {
7
7
  var _a;
@@ -3252,7 +3252,7 @@ async function fetchSvgAsElement(imageUrl, colorMap) {
3252
3252
  async function getRecoloredSvgDataUrl(imageUrl, colorMap) {
3253
3253
  if (!colorMap || Object.keys(colorMap).length === 0) return null;
3254
3254
  try {
3255
- const { getNormalizedSvgUrl } = await import("./index-Cvi3YYOq.js").then((n) => n.a8);
3255
+ const { getNormalizedSvgUrl } = await import("./index-CKhnRi3S.js").then((n) => n.a9);
3256
3256
  return await getNormalizedSvgUrl(imageUrl, colorMap);
3257
3257
  } catch {
3258
3258
  return null;
@@ -4061,7 +4061,7 @@ async function fetchImageAsBase64(imageUrl, opts = {}) {
4061
4061
  }
4062
4062
  let fetchUrl = imageUrl;
4063
4063
  if (imageUrl.startsWith("http://") || imageUrl.startsWith("https://")) {
4064
- const { isPrivateUrl } = await import("./index-Cvi3YYOq.js").then((n) => n.a8);
4064
+ const { isPrivateUrl } = await import("./index-CKhnRi3S.js").then((n) => n.a9);
4065
4065
  if (isPrivateUrl(imageUrl)) return null;
4066
4066
  const proxyUrl = new URL(`${API_URL}/image-proxy`);
4067
4067
  proxyUrl.searchParams.set("url", imageUrl);
@@ -6209,4 +6209,4 @@ export {
6209
6209
  preparePagesForExport,
6210
6210
  rewriteSvgFontsForJsPDFWithSourceMeta
6211
6211
  };
6212
- //# sourceMappingURL=vectorPdfExport-B6m8o09g.js.map
6212
+ //# sourceMappingURL=vectorPdfExport-DV-TJwjP.js.map