@bookmypuja-tech/bmp-pdf 0.2.17 → 0.2.19

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.d.ts CHANGED
@@ -185,7 +185,10 @@ declare class reportPrinter<T extends IReportOptions> {
185
185
  size: IReportSize;
186
186
  constructor(option: T, size: IReportSize);
187
187
  print(data: ReportDataTypes[T]): Promise<Blob>;
188
- getBlob(data: ReportDataTypes[T]): Promise<Blob>;
188
+ getBlob(data: ReportDataTypes[T], config?: {
189
+ waitTime?: number;
190
+ stabilityCheck?: () => Promise<void> | boolean;
191
+ }): Promise<Blob>;
189
192
  }
190
193
 
191
194
  export { A4Print, type KitchenReportProps as IKitchenReport, type IPrasadDelivery, type IPrasadReport, type IPrintablePuja, type IPujaReceipt, type IPujaList as IPujaReport, type ISummaryPujaList as ISummaryPujaReport, type ITransactionReport, T2Inch, getA4SummaryBlob, getPrintBlob, printDevoteeReceipt2Inch, printQuickPrintReceipt2Inch, printTotalReceipt2Inch, printePujaReport2Inch, reportPrinter };
package/dist/index.js CHANGED
@@ -583,32 +583,35 @@ import { Document as Document3, Image as Image6, Page as Page3, View as View4 }
583
583
  import React8 from "react";
584
584
 
585
585
  // src/components/Text.tsx
586
- import React7, { useEffect as useEffect4 } from "react";
586
+ import React7 from "react";
587
587
  import { Image as Image5, Text as PDFText, View as View3 } from "@react-pdf/renderer";
588
- import axios from "axios";
589
588
  var Text7 = ({ children, style = {} }) => {
590
- const [imagesLinks, setImagesLinks] = React7.useState([]);
589
+ let imagesLinks = [];
591
590
  const childrenStr = typeof children === "string" ? children : String(children);
592
591
  const isMalayalam = containsMalayalam(childrenStr);
593
592
  if (!isMalayalam) {
594
593
  return /* @__PURE__ */ React7.createElement(PDFText, { style }, children);
595
594
  }
596
- useEffect4(() => {
597
- axios.post("/api/text-to-image", {
598
- text: childrenStr
599
- }).then((response) => {
600
- let thisimagesLinks = response.data.images;
601
- console.log("thisimagesLinks", thisimagesLinks);
602
- setImagesLinks(thisimagesLinks);
603
- }).catch((error) => {
604
- console.error("Error:", error);
605
- });
606
- }, []);
595
+ try {
596
+ const xhr = new XMLHttpRequest();
597
+ xhr.open("POST", "/api/text-to-image", false);
598
+ xhr.setRequestHeader("Content-Type", "application/json");
599
+ xhr.send(JSON.stringify({ text: childrenStr }));
600
+ if (xhr.status === 200) {
601
+ const response = JSON.parse(xhr.responseText);
602
+ imagesLinks = response.images || [];
603
+ console.log("Fetched imagesLinks:", imagesLinks);
604
+ } else {
605
+ console.error("Request failed:", xhr.status);
606
+ }
607
+ } catch (error) {
608
+ console.error("Synchronous request error:", error);
609
+ }
607
610
  return /* @__PURE__ */ React7.createElement(View3, { style: { flexDirection: "row", flexWrap: "wrap", gap: 2 } }, imagesLinks.map((imageLink, index) => /* @__PURE__ */ React7.createElement(
608
611
  Image5,
609
612
  {
610
613
  key: index,
611
- src: `${imageLink}`,
614
+ src: `/${imageLink}`,
612
615
  style: {
613
616
  width: "auto",
614
617
  height: style.fontSize || 12,
@@ -2719,10 +2722,20 @@ var reportPrinter = class {
2719
2722
  });
2720
2723
  return blob;
2721
2724
  }
2722
- async getBlob(data) {
2725
+ async getBlob(data, config) {
2723
2726
  const ReportComponent = options[this.option][this.size];
2724
2727
  const document = /* @__PURE__ */ React15.createElement(ReportComponent, { ...data });
2725
- const blob = pdf(document).toBlob();
2728
+ if (config?.stabilityCheck) {
2729
+ if (typeof config.stabilityCheck === "function") {
2730
+ const result = config.stabilityCheck();
2731
+ if (result instanceof Promise) {
2732
+ await result;
2733
+ }
2734
+ }
2735
+ } else if (config?.waitTime) {
2736
+ await new Promise((resolve) => setTimeout(resolve, config.waitTime));
2737
+ }
2738
+ const blob = await pdf(document).toBlob();
2726
2739
  return blob;
2727
2740
  }
2728
2741
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bookmypuja-tech/bmp-pdf",
3
3
  "description": "PDF Report Generation for Temple360 and T-360 by BookMyPuja",
4
- "version": "0.2.17",
4
+ "version": "0.2.19",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",