@pixldocs/canvas-renderer 0.5.217 → 0.5.219

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-CDrMSTDa.cjs");
3
+ const index = require("./index-CBB2UdwF.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;
package/dist/index.d.ts CHANGED
@@ -97,6 +97,22 @@ export declare function collectImageUrls(config: TemplateConfig): string[];
97
97
  */
98
98
  export declare function configHasAutoShrinkText(config: TemplateConfig | null | undefined): boolean;
99
99
 
100
+ export declare interface DeliveryChannelResult {
101
+ channel: 'email' | 'whatsapp' | string;
102
+ status: 'sent' | 'failed' | 'pending_setup';
103
+ error?: string;
104
+ }
105
+
106
+ /** Recipient info for delivery. */
107
+ export declare interface DeliveryRecipient {
108
+ /** Required for email delivery. */
109
+ email: string;
110
+ /** Used as "Hi {name}" in the email body. Optional. */
111
+ name?: string;
112
+ /** E.164 phone (e.g. "+919876543210"). Reserved for future WhatsApp delivery. */
113
+ phone?: string;
114
+ }
115
+
100
116
  export declare const DEPLOYMENT_VERSION_MARKER: string;
101
117
 
102
118
  export declare function dumpSvgTextDiagnostics(svgStr: string, pageIndex: number, tag: string, stage: string, maxItems?: number): void;
@@ -552,6 +568,28 @@ export declare class PixldocsRenderer {
552
568
  * This is the primary PDF export API — mirrors renderFromForm() but returns a PDF.
553
569
  */
554
570
  renderPdfFromForm(options: PdfFromFormOptions): Promise<PdfRenderResult>;
571
+ /**
572
+ * Render the template AND deliver the resulting PDF to the user — currently
573
+ * via email (SendGrid). The PDF is rendered server-side on EC2, uploaded to
574
+ * S3 (returned as `pdfUrl` for download fallback), and emailed with the PDF
575
+ * attached.
576
+ *
577
+ * Every delivery is logged in the `delivery_log` table for audit + admin
578
+ * resend. The same `pdfUrl` is returned to the caller so the host app can
579
+ * also offer a "Download" button on the success screen.
580
+ *
581
+ * ```ts
582
+ * const result = await renderer.renderAndDeliver({
583
+ * templateId, formSchemaId, sectionState,
584
+ * project: 'biomaker',
585
+ * recipient: { email: 'user@example.com', name: 'Anya' },
586
+ * });
587
+ * // → { jobId, pdfUrl, deliveries: [{ channel: 'email', status: 'sent' }] }
588
+ * ```
589
+ *
590
+ * Requires `RendererConfig.deliveryServerUrl` to be set.
591
+ */
592
+ renderAndDeliver(options: RenderAndDeliverOptions): Promise<RenderAndDeliverResult>;
555
593
  renderById(templateId: string, formData?: Record<string, any>, options?: RenderOptions): Promise<RenderResult>;
556
594
  /**
557
595
  * Convenience: fetch by ID with flat data and render ALL pages.
@@ -631,6 +669,38 @@ export declare interface PublishedTemplate {
631
669
  updated_at: string;
632
670
  }
633
671
 
672
+ /** Options for renderAndDeliver — renders the template and emails it to the recipient. */
673
+ export declare interface RenderAndDeliverOptions {
674
+ templateId: string;
675
+ formSchemaId: string;
676
+ sectionState: SectionFormState;
677
+ /**
678
+ * Project key — selects which sender profile (from address, subject, branding)
679
+ * the EC2 server uses. Currently supported: `'biomaker'`, `'pixldocs'`.
680
+ */
681
+ project: 'biomaker' | 'pixldocs' | string;
682
+ recipient: DeliveryRecipient;
683
+ /** Delivery channels. Default: `['email']`. Future: `'whatsapp'`. */
684
+ channels?: Array<'email' | 'whatsapp'>;
685
+ themeId?: string;
686
+ /** Force watermark on/off. Default: server decides based on template price. */
687
+ watermark?: boolean;
688
+ /** Render scale 1–4 (default 2). */
689
+ scale?: number;
690
+ }
691
+
692
+ export declare interface RenderAndDeliverResult {
693
+ /** Unique job ID — links all retries/resends of the same render. */
694
+ jobId: string;
695
+ /** Public/signed download URL of the rendered PDF on S3. */
696
+ pdfUrl: string;
697
+ /** S3 key (e.g. "deliveries/{jobId}.pdf"). */
698
+ s3Key?: string;
699
+ /** Per-channel delivery result. */
700
+ deliveries: DeliveryChannelResult[];
701
+ elapsedMs?: number;
702
+ }
703
+
634
704
  export declare interface RendererConfig {
635
705
  /** Supabase project URL for fetching templates */
636
706
  supabaseUrl: string;
@@ -671,6 +741,12 @@ export declare interface RendererConfig {
671
741
  * Default: auto-normalize data:image sources to `2048`; pass `0` to disable.
672
742
  */
673
743
  maxImageEdgePx?: number;
744
+ /**
745
+ * Base URL of the PixlDocs PDF/delivery server (EC2). Required by
746
+ * `renderAndDeliver()`. Example: `'https://pdf.pixldocs.com'`. If omitted,
747
+ * `renderAndDeliver` will throw — the rest of the SDK works without it.
748
+ */
749
+ deliveryServerUrl?: string;
674
750
  }
675
751
 
676
752
  /** Options for renderFromForm — matches the server API payload */
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { D, F, o, q, s, P, t, u, v, w, x, y, z, B, C, E, G, H, I, J, K, L, M, b, N, O, Q, R, S, U, V, W, X, Y, Z, _, $, a0, a1, a2, a3, a4, a5 } from "./index-Ci5YA_Ps.js";
1
+ import { D, F, o, q, s, P, t, u, v, w, x, y, z, B, C, E, G, H, I, J, K, L, M, b, N, O, Q, R, S, U, V, W, X, Y, Z, _, $, a0, a1, a2, a3, a4, a5 } from "./index-DbUPI6zs.js";
2
2
  export {
3
3
  D as DEPLOYMENT_VERSION_MARKER,
4
4
  F as FONT_FALLBACK_DEVANAGARI,
@@ -3,7 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jspdf = require("jspdf");
4
4
  const svg2pdf_js = require("svg2pdf.js");
5
5
  const fabric = require("fabric");
6
- const index = require("./index-CDrMSTDa.cjs");
6
+ const index = require("./index-CBB2UdwF.cjs");
7
7
  const pdfFonts = require("./pdfFonts-BTj2f465.cjs");
8
8
  function _interopNamespaceDefault(e) {
9
9
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
@@ -2099,7 +2099,7 @@ async function rasterizeShadowMarkers(svg) {
2099
2099
  const by = parseFloat(marker.getAttribute("data-by") || "0");
2100
2100
  const bw = parseFloat(marker.getAttribute("data-bw") || "0");
2101
2101
  const bh = parseFloat(marker.getAttribute("data-bh") || "0");
2102
- const spread = parseFloat(marker.getAttribute("data-spread") || "0");
2102
+ const spread = 0;
2103
2103
  const alphaRaw = parseFloat(marker.getAttribute("data-alpha") || "1");
2104
2104
  const shadowAlpha = Number.isFinite(alphaRaw) ? Math.max(0, Math.min(1, alphaRaw)) : 1;
2105
2105
  if (!Number.isFinite(bw) || !Number.isFinite(bh) || bw <= 0 || bh <= 0) {
@@ -2974,7 +2974,7 @@ async function fetchSvgAsElement(imageUrl, colorMap) {
2974
2974
  async function getRecoloredSvgDataUrl(imageUrl, colorMap) {
2975
2975
  if (!colorMap || Object.keys(colorMap).length === 0) return null;
2976
2976
  try {
2977
- const { getNormalizedSvgUrl } = await Promise.resolve().then(() => require("./index-CDrMSTDa.cjs")).then((n) => n.canvasImageLoader);
2977
+ const { getNormalizedSvgUrl } = await Promise.resolve().then(() => require("./index-CBB2UdwF.cjs")).then((n) => n.canvasImageLoader);
2978
2978
  return await getNormalizedSvgUrl(imageUrl, colorMap);
2979
2979
  } catch {
2980
2980
  return null;
@@ -3783,7 +3783,7 @@ async function fetchImageAsBase64(imageUrl, opts = {}) {
3783
3783
  }
3784
3784
  let fetchUrl = imageUrl;
3785
3785
  if (imageUrl.startsWith("http://") || imageUrl.startsWith("https://")) {
3786
- const { isPrivateUrl } = await Promise.resolve().then(() => require("./index-CDrMSTDa.cjs")).then((n) => n.canvasImageLoader);
3786
+ const { isPrivateUrl } = await Promise.resolve().then(() => require("./index-CBB2UdwF.cjs")).then((n) => n.canvasImageLoader);
3787
3787
  if (isPrivateUrl(imageUrl)) return null;
3788
3788
  const proxyUrl = new URL(`${index.API_URL}/image-proxy`);
3789
3789
  proxyUrl.searchParams.set("url", imageUrl);
@@ -5882,4 +5882,4 @@ exports.exportMultiPagePdf = exportMultiPagePdf;
5882
5882
  exports.logTextMeasurementDiagnostic = logTextMeasurementDiagnostic;
5883
5883
  exports.preparePagesForExport = preparePagesForExport;
5884
5884
  exports.rewriteSvgFontsForJsPDFWithSourceMeta = rewriteSvgFontsForJsPDFWithSourceMeta;
5885
- //# sourceMappingURL=vectorPdfExport-B8uqWQoW.cjs.map
5885
+ //# sourceMappingURL=vectorPdfExport-CwyiHDGD.cjs.map