pxengine 0.1.82 → 0.1.83

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
@@ -39485,94 +39485,6 @@ var ExpandIcon2 = () => /* @__PURE__ */ (0, import_jsx_runtime148.jsxs)("svg", {
39485
39485
  /* @__PURE__ */ (0, import_jsx_runtime148.jsx)("line", { x1: "21", y1: "3", x2: "14", y2: "10" }),
39486
39486
  /* @__PURE__ */ (0, import_jsx_runtime148.jsx)("line", { x1: "3", y1: "21", x2: "10", y2: "14" })
39487
39487
  ] });
39488
- var FORMATS2 = [
39489
- {
39490
- key: "pdf_url",
39491
- label: "PDF",
39492
- ext: ".pdf",
39493
- emoji: "\u{1F4C4}",
39494
- desc: "Professional formatted report \u2014 open in any PDF viewer",
39495
- accent: { text: "text-red-400", bg: "bg-red-500/10 border-red-500/20" }
39496
- },
39497
- {
39498
- key: "html_url",
39499
- label: "HTML",
39500
- ext: ".html",
39501
- emoji: "\u{1F310}",
39502
- desc: "Interactive web version \u2014 open in any browser",
39503
- accent: { text: "text-blue-400", bg: "bg-blue-500/10 border-blue-500/20" }
39504
- }
39505
- ];
39506
- var ExportModal2 = ({ formats, title, onClose }) => {
39507
- const available = FORMATS2.filter((f) => formats[f.key]);
39508
- const filename = title.replace(/[^a-z0-9]/gi, "-").toLowerCase();
39509
- const [downloadingKey, setDownloadingKey] = (0, import_react76.useState)(null);
39510
- const handleDownload = async (fmtKey, url, ext) => {
39511
- if (downloadingKey) return;
39512
- const downloadName = `${filename}${ext}`;
39513
- const href = `/api/download?url=${encodeURIComponent(url)}&filename=${encodeURIComponent(downloadName)}`;
39514
- try {
39515
- setDownloadingKey(fmtKey);
39516
- const response = await fetch(href);
39517
- if (!response.ok) throw new Error(`status ${response.status}`);
39518
- const blob = await response.blob();
39519
- const objectUrl = window.URL.createObjectURL(blob);
39520
- const anchor = document.createElement("a");
39521
- anchor.href = objectUrl;
39522
- anchor.download = downloadName;
39523
- document.body.appendChild(anchor);
39524
- anchor.click();
39525
- anchor.remove();
39526
- window.URL.revokeObjectURL(objectUrl);
39527
- } catch {
39528
- window.open(href, "_blank", "noopener,noreferrer");
39529
- } finally {
39530
- setDownloadingKey(null);
39531
- }
39532
- };
39533
- return /* @__PURE__ */ (0, import_jsx_runtime148.jsxs)("div", { className: "fixed inset-0 z-50 flex items-center justify-center p-4", children: [
39534
- /* @__PURE__ */ (0, import_jsx_runtime148.jsx)("div", { className: "absolute inset-0 bg-black/70 backdrop-blur-sm", onClick: onClose }),
39535
- /* @__PURE__ */ (0, import_jsx_runtime148.jsxs)("div", { className: "relative z-10 bg-zinc-900 border border-zinc-800 rounded-2xl w-full max-w-sm p-6 shadow-2xl", children: [
39536
- /* @__PURE__ */ (0, import_jsx_runtime148.jsxs)("div", { className: "flex items-start justify-between mb-5", children: [
39537
- /* @__PURE__ */ (0, import_jsx_runtime148.jsxs)("div", { className: "min-w-0 pr-3", children: [
39538
- /* @__PURE__ */ (0, import_jsx_runtime148.jsx)("h3", { className: "text-sm font-semibold text-zinc-100", children: "Download Report" }),
39539
- /* @__PURE__ */ (0, import_jsx_runtime148.jsx)("p", { className: "text-xs text-zinc-500 mt-0.5 truncate", children: title })
39540
- ] }),
39541
- /* @__PURE__ */ (0, import_jsx_runtime148.jsx)("button", { onClick: onClose, className: "text-zinc-500 hover:text-zinc-200 transition-colors flex-shrink-0 mt-0.5", children: /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(CloseIcon2, {}) })
39542
- ] }),
39543
- /* @__PURE__ */ (0, import_jsx_runtime148.jsxs)("div", { className: "space-y-2.5", children: [
39544
- available.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime148.jsx)("p", { className: "text-sm text-zinc-500 text-center py-6", children: "No formats available yet" }),
39545
- available.map((fmt) => {
39546
- const url = formats[fmt.key];
39547
- const isDownloading = downloadingKey === fmt.key;
39548
- return /* @__PURE__ */ (0, import_jsx_runtime148.jsxs)(
39549
- "button",
39550
- {
39551
- type: "button",
39552
- disabled: Boolean(downloadingKey),
39553
- onClick: () => handleDownload(fmt.key, url, fmt.ext),
39554
- className: cn(
39555
- "flex w-full items-center gap-3.5 p-3.5 rounded-xl border transition-all text-left",
39556
- "hover:brightness-110 disabled:opacity-60 disabled:cursor-not-allowed",
39557
- fmt.accent.bg
39558
- ),
39559
- children: [
39560
- /* @__PURE__ */ (0, import_jsx_runtime148.jsx)("span", { className: "text-xl flex-shrink-0", children: fmt.emoji }),
39561
- /* @__PURE__ */ (0, import_jsx_runtime148.jsxs)("div", { className: "flex-1 min-w-0", children: [
39562
- /* @__PURE__ */ (0, import_jsx_runtime148.jsx)("p", { className: cn("text-sm font-semibold", fmt.accent.text), children: isDownloading ? `Downloading ${fmt.label}...` : fmt.label }),
39563
- /* @__PURE__ */ (0, import_jsx_runtime148.jsx)("p", { className: "text-xs text-zinc-500 mt-0.5 leading-relaxed", children: isDownloading ? "Please wait while the file is being prepared." : fmt.desc })
39564
- ] }),
39565
- /* @__PURE__ */ (0, import_jsx_runtime148.jsx)("span", { className: cn("flex-shrink-0", fmt.accent.text), children: /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(DownloadIcon2, {}) })
39566
- ]
39567
- },
39568
- fmt.key
39569
- );
39570
- })
39571
- ] }),
39572
- /* @__PURE__ */ (0, import_jsx_runtime148.jsx)("p", { className: "text-xs text-zinc-600 mt-4 text-center", children: "Download links expire in 7 days" })
39573
- ] })
39574
- ] });
39575
- };
39576
39488
  var FullscreenPreviewModal = ({ url, title, onClose }) => {
39577
39489
  (0, import_react76.useEffect)(() => {
39578
39490
  const onKey = (e) => {
@@ -39627,7 +39539,7 @@ var ResearchReportJobCard = ({
39627
39539
  word_count: initialWordCount,
39628
39540
  executive_summary: initialSummary,
39629
39541
  key_findings: _initialFindings,
39630
- formats: initialFormats = {},
39542
+ html_url: initialHtmlUrl,
39631
39543
  theme: initialTheme,
39632
39544
  error: initialError,
39633
39545
  pollUrl,
@@ -39643,10 +39555,9 @@ var ResearchReportJobCard = ({
39643
39555
  const [sourceCount, setSourceCount] = (0, import_react76.useState)(initialSourceCount ?? 0);
39644
39556
  const [wordCount, setWordCount] = (0, import_react76.useState)(initialWordCount ?? 0);
39645
39557
  const [summary, setSummary] = (0, import_react76.useState)(initialSummary || "");
39646
- const [formats, setFormats] = (0, import_react76.useState)(initialFormats);
39558
+ const [htmlUrl, setHtmlUrl] = (0, import_react76.useState)(initialHtmlUrl || "");
39647
39559
  const [theme, setTheme] = (0, import_react76.useState)(initialTheme || DEFAULT_THEME);
39648
39560
  const [error, setError] = (0, import_react76.useState)(initialError);
39649
- const [showExport, setShowExport] = (0, import_react76.useState)(false);
39650
39561
  const [showPreview, setShowPreview] = (0, import_react76.useState)(false);
39651
39562
  const [previewScale, setPreviewScale] = (0, import_react76.useState)(1);
39652
39563
  const previewRef = (0, import_react76.useRef)(null);
@@ -39658,7 +39569,7 @@ var ResearchReportJobCard = ({
39658
39569
  onFailedRef.current = onFailed;
39659
39570
  const isTerminal = status === "complete" || status === "failed";
39660
39571
  const primaryColor = theme?.primary || DEFAULT_THEME.primary;
39661
- const hasHTML = Boolean(formats.html_url);
39572
+ const hasHTML = Boolean(htmlUrl);
39662
39573
  const updateScale = (0, import_react76.useCallback)(() => {
39663
39574
  if (previewRef.current) {
39664
39575
  setPreviewScale(previewRef.current.offsetWidth / 800);
@@ -39670,7 +39581,7 @@ var ResearchReportJobCard = ({
39670
39581
  const ro = new ResizeObserver(updateScale);
39671
39582
  if (previewRef.current) ro.observe(previewRef.current);
39672
39583
  return () => ro.disconnect();
39673
- }, [updateScale, formats.html_url]);
39584
+ }, [updateScale, htmlUrl]);
39674
39585
  (0, import_react76.useEffect)(() => {
39675
39586
  if (isTerminal || !pollUrl) return;
39676
39587
  const poll = async () => {
@@ -39692,7 +39603,7 @@ var ResearchReportJobCard = ({
39692
39603
  setSourceCount(output.source_count || 0);
39693
39604
  setWordCount(output.word_count || 0);
39694
39605
  setSummary(output.executive_summary || "");
39695
- setFormats(output.formats || {});
39606
+ setHtmlUrl(output.html_url || "");
39696
39607
  if (output.theme) {
39697
39608
  setTheme(output.theme);
39698
39609
  }
@@ -39753,6 +39664,26 @@ var ResearchReportJobCard = ({
39753
39664
  ] })
39754
39665
  ] }) }) });
39755
39666
  }
39667
+ const handleDownload = async () => {
39668
+ if (!htmlUrl) return;
39669
+ const filename = `${title.replace(/[^a-z0-9]/gi, "-").toLowerCase()}.html`;
39670
+ const href = `/api/download?url=${encodeURIComponent(htmlUrl)}&filename=${encodeURIComponent(filename)}`;
39671
+ try {
39672
+ const response = await fetch(href);
39673
+ if (!response.ok) throw new Error(`status ${response.status}`);
39674
+ const blob = await response.blob();
39675
+ const objectUrl = window.URL.createObjectURL(blob);
39676
+ const anchor = document.createElement("a");
39677
+ anchor.href = objectUrl;
39678
+ anchor.download = filename;
39679
+ document.body.appendChild(anchor);
39680
+ anchor.click();
39681
+ anchor.remove();
39682
+ window.URL.revokeObjectURL(objectUrl);
39683
+ } catch {
39684
+ window.open(htmlUrl, "_blank", "noopener,noreferrer");
39685
+ }
39686
+ };
39756
39687
  return /* @__PURE__ */ (0, import_jsx_runtime148.jsxs)(import_jsx_runtime148.Fragment, { children: [
39757
39688
  /* @__PURE__ */ (0, import_jsx_runtime148.jsx)("div", { className: cn("w-full", className), children: /* @__PURE__ */ (0, import_jsx_runtime148.jsxs)("div", { className: "bg-zinc-900 border border-zinc-800 rounded-2xl overflow-hidden", children: [
39758
39689
  /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(
@@ -39806,14 +39737,15 @@ var ResearchReportJobCard = ({
39806
39737
  /* @__PURE__ */ (0, import_jsx_runtime148.jsxs)(
39807
39738
  "button",
39808
39739
  {
39809
- onClick: () => setShowExport(true),
39810
- className: "flex items-center gap-1.5 px-2.5 h-7 text-white text-xs font-medium rounded-lg transition-colors",
39740
+ onClick: handleDownload,
39741
+ disabled: !hasHTML,
39742
+ className: "flex items-center gap-1.5 px-2.5 h-7 text-white text-xs font-medium rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",
39811
39743
  style: { backgroundColor: primaryColor },
39812
39744
  onMouseEnter: (e) => e.currentTarget.style.filter = "brightness(1.15)",
39813
39745
  onMouseLeave: (e) => e.currentTarget.style.filter = "brightness(1)",
39814
39746
  children: [
39815
39747
  /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(DownloadIcon2, {}),
39816
- /* @__PURE__ */ (0, import_jsx_runtime148.jsx)("span", { children: "Export" })
39748
+ /* @__PURE__ */ (0, import_jsx_runtime148.jsx)("span", { children: "Download" })
39817
39749
  ]
39818
39750
  }
39819
39751
  )
@@ -39831,7 +39763,7 @@ var ResearchReportJobCard = ({
39831
39763
  /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(
39832
39764
  "iframe",
39833
39765
  {
39834
- src: formats.html_url,
39766
+ src: htmlUrl,
39835
39767
  title,
39836
39768
  sandbox: "allow-same-origin",
39837
39769
  style: {
@@ -39855,11 +39787,10 @@ var ResearchReportJobCard = ({
39855
39787
  !hasHTML && summary && /* @__PURE__ */ (0, import_jsx_runtime148.jsx)("div", { className: "mt-4 pt-4 border-t border-zinc-800/60", children: /* @__PURE__ */ (0, import_jsx_runtime148.jsx)("p", { className: "text-sm text-zinc-400 leading-relaxed line-clamp-3", children: summary }) })
39856
39788
  ] })
39857
39789
  ] }) }),
39858
- showExport && /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(ExportModal2, { formats, title, onClose: () => setShowExport(false) }),
39859
39790
  showPreview && hasHTML && /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(
39860
39791
  FullscreenPreviewModal,
39861
39792
  {
39862
- url: formats.html_url,
39793
+ url: htmlUrl,
39863
39794
  title,
39864
39795
  onClose: () => setShowPreview(false)
39865
39796
  }