pxengine 0.1.114 → 0.1.115

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
@@ -17200,6 +17200,7 @@ var ResearchReportJobCard = (props) => {
17200
17200
  executive_summary: initialSummary,
17201
17201
  key_findings: _initialFindings,
17202
17202
  html_url: initialHtmlUrl,
17203
+ pdf_url: initialPdfUrl,
17203
17204
  generation_mode: initialGenerationMode,
17204
17205
  template_id: initialTemplateId,
17205
17206
  template_version_id: initialTemplateVersionId,
@@ -17229,6 +17230,7 @@ var ResearchReportJobCard = (props) => {
17229
17230
  const [wordCount, setWordCount] = (0, import_react79.useState)(initialWordCount ?? 0);
17230
17231
  const [summary, setSummary] = (0, import_react79.useState)(initialSummary || "");
17231
17232
  const [htmlUrl, setHtmlUrl] = (0, import_react79.useState)(initialHtmlUrl || "");
17233
+ const [pdfUrl, setPdfUrl] = (0, import_react79.useState)(initialPdfUrl || "");
17232
17234
  const [generationMode, setGenerationMode] = (0, import_react79.useState)(
17233
17235
  initialGenerationMode || (initialHtmlUrl ? "template" : "")
17234
17236
  );
@@ -17356,6 +17358,7 @@ var ResearchReportJobCard = (props) => {
17356
17358
  setWordCount(output.word_count || 0);
17357
17359
  setSummary(output.executive_summary || "");
17358
17360
  setHtmlUrl(output.html_url || "");
17361
+ setPdfUrl(output.pdf_url || "");
17359
17362
  if (output.generation_mode) setGenerationMode(output.generation_mode);
17360
17363
  if (output.template_id) setTemplateId(output.template_id);
17361
17364
  if (output.template_version_id) setTemplateVersionId(output.template_version_id);
@@ -17383,6 +17386,7 @@ var ResearchReportJobCard = (props) => {
17383
17386
  const applyRegeneratedOutput = (0, import_react79.useCallback)(
17384
17387
  (out) => {
17385
17388
  if (out.html_url) setHtmlUrl(out.html_url);
17389
+ setPdfUrl(out.pdf_url || "");
17386
17390
  if (out.template_id) setTemplateId(out.template_id);
17387
17391
  setReviewStatus("pending_review");
17388
17392
  setTemplateVersionId("");
@@ -17399,6 +17403,7 @@ var ResearchReportJobCard = (props) => {
17399
17403
  word_count: out.word_count ?? wordCount,
17400
17404
  executive_summary: out.executive_summary ?? summary,
17401
17405
  html_url: out.html_url ?? htmlUrl,
17406
+ pdf_url: out.pdf_url ?? pdfUrl,
17402
17407
  generation_mode: "template",
17403
17408
  template_id: out.template_id ?? templateId,
17404
17409
  template_version_id: void 0,
@@ -17406,7 +17411,7 @@ var ResearchReportJobCard = (props) => {
17406
17411
  theme: out.theme ?? theme
17407
17412
  });
17408
17413
  },
17409
- [title, depth, sectionCount, sourceCount, wordCount, summary, htmlUrl, templateId, theme]
17414
+ [title, depth, sectionCount, sourceCount, wordCount, summary, htmlUrl, pdfUrl, templateId, theme]
17410
17415
  );
17411
17416
  useSharedPoll(
17412
17417
  {
@@ -17450,6 +17455,7 @@ var ResearchReportJobCard = (props) => {
17450
17455
  if (out.word_count !== void 0) setWordCount(out.word_count);
17451
17456
  if (out.executive_summary) setSummary(out.executive_summary);
17452
17457
  if (out.html_url) setHtmlUrl(out.html_url);
17458
+ setPdfUrl(out.pdf_url || "");
17453
17459
  if (out.generation_mode) setGenerationMode(out.generation_mode);
17454
17460
  if (out.template_id) setTemplateId(out.template_id);
17455
17461
  setTemplateVersionId(out.template_version_id || "");
@@ -17735,6 +17741,26 @@ var ResearchReportJobCard = (props) => {
17735
17741
  window.open(htmlUrl, "_blank", "noopener,noreferrer");
17736
17742
  }
17737
17743
  };
17744
+ const handleDownloadPdf = async () => {
17745
+ if (!pdfUrl) return;
17746
+ const filename = `${(title ?? "").replace(/[^a-z0-9]/gi, "-").toLowerCase()}.pdf`;
17747
+ const href = `/api/download?url=${encodeURIComponent(pdfUrl)}&filename=${encodeURIComponent(filename)}`;
17748
+ try {
17749
+ const response = await fetch(href);
17750
+ if (!response.ok) throw new Error(`status ${response.status}`);
17751
+ const blob = await response.blob();
17752
+ const objectUrl = window.URL.createObjectURL(blob);
17753
+ const anchor = document.createElement("a");
17754
+ anchor.href = objectUrl;
17755
+ anchor.download = filename;
17756
+ document.body.appendChild(anchor);
17757
+ anchor.click();
17758
+ anchor.remove();
17759
+ window.URL.revokeObjectURL(objectUrl);
17760
+ } catch {
17761
+ window.open(pdfUrl, "_blank", "noopener,noreferrer");
17762
+ }
17763
+ };
17738
17764
  const resolveShareLink = () => {
17739
17765
  if (shareUrl) return shareUrl;
17740
17766
  if (typeof window !== "undefined" && job_id) {
@@ -17787,6 +17813,7 @@ var ResearchReportJobCard = (props) => {
17787
17813
  word_count: wordCount,
17788
17814
  executive_summary: summary,
17789
17815
  html_url: htmlUrl,
17816
+ pdf_url: pdfUrl,
17790
17817
  generation_mode: generationMode,
17791
17818
  template_id: data.template_id || templateId,
17792
17819
  template_version_id: data.template_version_id || templateVersionId,
@@ -17924,6 +17951,18 @@ var ResearchReportJobCard = (props) => {
17924
17951
  ]
17925
17952
  }
17926
17953
  ),
17954
+ pdfUrl && /* @__PURE__ */ (0, import_jsx_runtime148.jsxs)(
17955
+ "button",
17956
+ {
17957
+ onClick: handleDownloadPdf,
17958
+ title: "Download PDF",
17959
+ className: "flex items-center gap-1.5 px-2.5 h-7 rounded-lg border border-zinc-700 bg-zinc-800 hover:border-zinc-500 text-zinc-400 hover:text-zinc-200 text-xs font-medium transition-colors",
17960
+ children: [
17961
+ /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(DownloadIcon2, {}),
17962
+ /* @__PURE__ */ (0, import_jsx_runtime148.jsx)("span", { children: "PDF" })
17963
+ ]
17964
+ }
17965
+ ),
17927
17966
  /* @__PURE__ */ (0, import_jsx_runtime148.jsxs)(
17928
17967
  "button",
17929
17968
  {