pxengine 0.1.77 → 0.1.78

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.cts CHANGED
@@ -3114,6 +3114,11 @@ interface PresentationFormats {
3114
3114
  pptx_url?: string;
3115
3115
  pdf_url?: string;
3116
3116
  }
3117
+ interface PresentationJobOutput {
3118
+ title: string;
3119
+ slide_count: number;
3120
+ formats: PresentationFormats;
3121
+ }
3117
3122
  interface PresentationJobCardProps {
3118
3123
  job_id: string;
3119
3124
  title: string;
@@ -3128,6 +3133,11 @@ interface PresentationJobCardProps {
3128
3133
  * e.g. /api/agents-proxy/jobs/{job_id}/status
3129
3134
  */
3130
3135
  pollUrl?: string;
3136
+ /**
3137
+ * Bearer token for authenticated polling requests.
3138
+ * If provided, will be sent as Authorization header.
3139
+ */
3140
+ authToken?: string;
3131
3141
  /**
3132
3142
  * Shareable link copied when the user clicks Share.
3133
3143
  * Falls back to formats.html_url if not provided.
@@ -3137,6 +3147,15 @@ interface PresentationJobCardProps {
3137
3147
  className?: string;
3138
3148
  onAction?: (action: string, payload?: any) => void;
3139
3149
  sendMessage?: (message: string) => void;
3150
+ /**
3151
+ * Called when the job completes successfully via polling.
3152
+ * Use this to persist the job result to session state.
3153
+ */
3154
+ onComplete?: (output: PresentationJobOutput) => void;
3155
+ /**
3156
+ * Called when the job fails via polling.
3157
+ */
3158
+ onFailed?: (error: string) => void;
3140
3159
  }
3141
3160
 
3142
3161
  declare const PresentationJobCard: React__default.FC<PresentationJobCardProps>;
package/dist/index.d.ts CHANGED
@@ -3114,6 +3114,11 @@ interface PresentationFormats {
3114
3114
  pptx_url?: string;
3115
3115
  pdf_url?: string;
3116
3116
  }
3117
+ interface PresentationJobOutput {
3118
+ title: string;
3119
+ slide_count: number;
3120
+ formats: PresentationFormats;
3121
+ }
3117
3122
  interface PresentationJobCardProps {
3118
3123
  job_id: string;
3119
3124
  title: string;
@@ -3128,6 +3133,11 @@ interface PresentationJobCardProps {
3128
3133
  * e.g. /api/agents-proxy/jobs/{job_id}/status
3129
3134
  */
3130
3135
  pollUrl?: string;
3136
+ /**
3137
+ * Bearer token for authenticated polling requests.
3138
+ * If provided, will be sent as Authorization header.
3139
+ */
3140
+ authToken?: string;
3131
3141
  /**
3132
3142
  * Shareable link copied when the user clicks Share.
3133
3143
  * Falls back to formats.html_url if not provided.
@@ -3137,6 +3147,15 @@ interface PresentationJobCardProps {
3137
3147
  className?: string;
3138
3148
  onAction?: (action: string, payload?: any) => void;
3139
3149
  sendMessage?: (message: string) => void;
3150
+ /**
3151
+ * Called when the job completes successfully via polling.
3152
+ * Use this to persist the job result to session state.
3153
+ */
3154
+ onComplete?: (output: PresentationJobOutput) => void;
3155
+ /**
3156
+ * Called when the job fails via polling.
3157
+ */
3158
+ onFailed?: (error: string) => void;
3140
3159
  }
3141
3160
 
3142
3161
  declare const PresentationJobCard: React__default.FC<PresentationJobCardProps>;
package/dist/index.mjs CHANGED
@@ -38675,7 +38675,6 @@ var ShareIcon = () => /* @__PURE__ */ jsxs108("svg", { width: "14", height: "14"
38675
38675
  /* @__PURE__ */ jsx147("path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" })
38676
38676
  ] });
38677
38677
  var CheckIcon = () => /* @__PURE__ */ jsx147("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx147("polyline", { points: "20 6 9 17 4 12" }) });
38678
- var Skel = ({ className, style }) => /* @__PURE__ */ jsx147("div", { className: cn("animate-pulse rounded-md bg-zinc-800/60", className), style });
38679
38678
  var FORMATS = [
38680
38679
  {
38681
38680
  key: "pdf_url",
@@ -38845,6 +38844,23 @@ var FullscreenModal = ({ url, title, slideCount, onClose }) => {
38845
38844
  ) })
38846
38845
  ] });
38847
38846
  };
38847
+ var PROCESSING_STAGES = [
38848
+ { minProgress: 0, message: "Initializing..." },
38849
+ { minProgress: 12, message: "Analyzing request..." },
38850
+ { minProgress: 25, message: "Generating content..." },
38851
+ { minProgress: 45, message: "Building slides..." },
38852
+ { minProgress: 65, message: "Applying design..." },
38853
+ { minProgress: 80, message: "Rendering outputs..." },
38854
+ { minProgress: 92, message: "Finalizing..." }
38855
+ ];
38856
+ function getStageMessage(progress) {
38857
+ for (let i = PROCESSING_STAGES.length - 1; i >= 0; i--) {
38858
+ if (progress >= PROCESSING_STAGES[i].minProgress) {
38859
+ return PROCESSING_STAGES[i].message;
38860
+ }
38861
+ }
38862
+ return PROCESSING_STAGES[0].message;
38863
+ }
38848
38864
  var PresentationJobCard = ({
38849
38865
  job_id: _job_id,
38850
38866
  title: initialTitle,
@@ -38853,8 +38869,11 @@ var PresentationJobCard = ({
38853
38869
  formats: initialFormats = {},
38854
38870
  error: initialError,
38855
38871
  pollUrl,
38872
+ authToken,
38856
38873
  shareUrl,
38857
- className
38874
+ className,
38875
+ onComplete,
38876
+ onFailed
38858
38877
  }) => {
38859
38878
  const [status, setStatus] = useState10(initialStatus);
38860
38879
  const [title, setTitle] = useState10(initialTitle);
@@ -38868,9 +38887,40 @@ var PresentationJobCard = ({
38868
38887
  const [previewScale, setPreviewScale] = useState10(1);
38869
38888
  const [iframeReady, setIframeReady] = useState10(false);
38870
38889
  const [pendingSlide, setPendingSlide] = useState10(null);
38890
+ const [progress, setProgress] = useState10(0);
38891
+ const startTimeRef = useRef5(Date.now());
38871
38892
  const intervalRef = useRef5(null);
38893
+ const progressIntervalRef = useRef5(null);
38872
38894
  const previewRef = useRef5(null);
38873
38895
  const iframeRef = useRef5(null);
38896
+ useEffect6(() => {
38897
+ const isLoading = status === "pending" || status === "running";
38898
+ if (!isLoading) {
38899
+ if (progressIntervalRef.current) {
38900
+ clearInterval(progressIntervalRef.current);
38901
+ progressIntervalRef.current = null;
38902
+ }
38903
+ if (status === "complete") setProgress(100);
38904
+ return;
38905
+ }
38906
+ startTimeRef.current = Date.now();
38907
+ progressIntervalRef.current = setInterval(() => {
38908
+ const elapsed = (Date.now() - startTimeRef.current) / 1e3;
38909
+ const estimated = Math.min(90, 90 * (1 - Math.exp(-elapsed / 60)));
38910
+ setProgress((prev) => Math.max(prev, Math.round(estimated)));
38911
+ }, 500);
38912
+ return () => {
38913
+ if (progressIntervalRef.current) {
38914
+ clearInterval(progressIntervalRef.current);
38915
+ progressIntervalRef.current = null;
38916
+ }
38917
+ };
38918
+ }, [status]);
38919
+ useEffect6(() => {
38920
+ if (status === "running") {
38921
+ setProgress((prev) => Math.max(prev, 15));
38922
+ }
38923
+ }, [status]);
38874
38924
  const updateScale = useCallback4(() => {
38875
38925
  if (previewRef.current) setPreviewScale(previewRef.current.offsetWidth / 1280);
38876
38926
  }, []);
@@ -38915,21 +38965,48 @@ var PresentationJobCard = ({
38915
38965
  setPendingSlide(target);
38916
38966
  };
38917
38967
  const isTerminal = status === "complete" || status === "failed";
38968
+ const onCompleteRef = useRef5(onComplete);
38969
+ const onFailedRef = useRef5(onFailed);
38970
+ const hasNotifiedRef = useRef5(false);
38971
+ onCompleteRef.current = onComplete;
38972
+ onFailedRef.current = onFailed;
38918
38973
  useEffect6(() => {
38919
38974
  if (isTerminal || !pollUrl) return;
38920
38975
  const poll = async () => {
38921
38976
  try {
38922
- const res = await fetch(pollUrl);
38977
+ const headers = {};
38978
+ if (authToken) {
38979
+ headers["Authorization"] = `Bearer ${authToken}`;
38980
+ }
38981
+ const res = await fetch(pollUrl, { headers });
38923
38982
  if (!res.ok) return;
38924
38983
  const data = await res.json();
38925
38984
  const newStatus = data.status;
38926
38985
  setStatus(newStatus);
38927
38986
  if (newStatus === "complete" && data.output) {
38928
- if (data.output.title) setTitle(data.output.title);
38929
- if (data.output.slide_count) setSlideCount(data.output.slide_count);
38930
- if (data.output.formats) setFormats(data.output.formats);
38987
+ const newTitle = data.output.title || initialTitle;
38988
+ const newSlideCount = data.output.slide_count || 0;
38989
+ const newFormats = data.output.formats || {};
38990
+ setTitle(newTitle);
38991
+ setSlideCount(newSlideCount);
38992
+ setFormats(newFormats);
38993
+ if (!hasNotifiedRef.current && onCompleteRef.current) {
38994
+ hasNotifiedRef.current = true;
38995
+ onCompleteRef.current({
38996
+ title: newTitle,
38997
+ slide_count: newSlideCount,
38998
+ formats: newFormats
38999
+ });
39000
+ }
39001
+ }
39002
+ if (newStatus === "failed") {
39003
+ const errorMsg = data.error || "Job failed";
39004
+ setError(errorMsg);
39005
+ if (!hasNotifiedRef.current && onFailedRef.current) {
39006
+ hasNotifiedRef.current = true;
39007
+ onFailedRef.current(errorMsg);
39008
+ }
38931
39009
  }
38932
- if (newStatus === "failed" && data.error) setError(data.error);
38933
39010
  } catch {
38934
39011
  }
38935
39012
  };
@@ -38938,7 +39015,7 @@ var PresentationJobCard = ({
38938
39015
  return () => {
38939
39016
  if (intervalRef.current) clearInterval(intervalRef.current);
38940
39017
  };
38941
- }, [isTerminal, pollUrl]);
39018
+ }, [isTerminal, pollUrl, authToken, initialTitle]);
38942
39019
  useEffect6(() => {
38943
39020
  if (isTerminal && intervalRef.current) {
38944
39021
  clearInterval(intervalRef.current);
@@ -38957,18 +39034,63 @@ var PresentationJobCard = ({
38957
39034
  }
38958
39035
  };
38959
39036
  if (status === "pending" || status === "running") {
38960
- return /* @__PURE__ */ jsx147("div", { className: cn("w-full", className), children: /* @__PURE__ */ jsxs108("div", { className: "bg-zinc-900 border border-zinc-800 rounded-2xl p-5", children: [
38961
- /* @__PURE__ */ jsxs108("div", { className: "flex items-center gap-3 mb-5", children: [
38962
- /* @__PURE__ */ jsx147(Skel, { className: "w-10 h-10 rounded-xl flex-shrink-0" }),
38963
- /* @__PURE__ */ jsxs108("div", { className: "flex-1 space-y-2", children: [
38964
- /* @__PURE__ */ jsx147(Skel, { className: "h-3.5 w-44" }),
38965
- /* @__PURE__ */ jsx147(Skel, { className: "h-3 w-28" })
39037
+ const stageMessage = getStageMessage(progress);
39038
+ return /* @__PURE__ */ jsx147("div", { className: cn("w-full", className), children: /* @__PURE__ */ jsxs108("div", { className: "bg-zinc-900 border border-zinc-800 rounded-2xl overflow-hidden", children: [
39039
+ /* @__PURE__ */ jsx147("div", { className: "h-1 bg-zinc-800", children: /* @__PURE__ */ jsx147(
39040
+ "div",
39041
+ {
39042
+ className: "h-full bg-gradient-to-r from-indigo-500 via-violet-500 to-purple-500 transition-all duration-500 ease-out",
39043
+ style: { width: `${progress}%` }
39044
+ }
39045
+ ) }),
39046
+ /* @__PURE__ */ jsxs108("div", { className: "p-5", children: [
39047
+ /* @__PURE__ */ jsxs108("div", { className: "flex items-center gap-3 mb-5", children: [
39048
+ /* @__PURE__ */ jsx147("div", { className: "w-10 h-10 rounded-xl bg-indigo-500/10 border border-indigo-500/20 flex items-center justify-center flex-shrink-0", children: /* @__PURE__ */ jsx147(SlidesIcon, {}) }),
39049
+ /* @__PURE__ */ jsxs108("div", { className: "flex-1 min-w-0", children: [
39050
+ /* @__PURE__ */ jsx147("p", { className: "text-sm font-semibold text-zinc-100 truncate leading-tight", children: title || "Generating presentation..." }),
39051
+ /* @__PURE__ */ jsx147("p", { className: "text-xs text-zinc-500 mt-0.5", children: "Creating slides..." })
39052
+ ] })
39053
+ ] }),
39054
+ /* @__PURE__ */ jsx147("div", { className: "rounded-2xl border border-zinc-800/70 bg-zinc-950/80 p-3 sm:p-4 mb-4", children: /* @__PURE__ */ jsxs108("div", { className: "relative overflow-hidden rounded-xl bg-zinc-900 shadow-[0_0_0_1px_rgba(255,255,255,0.02)] aspect-[16/9] min-h-[320px] sm:min-h-[420px] lg:min-h-[500px]", children: [
39055
+ /* @__PURE__ */ jsx147("div", { className: "absolute inset-0 bg-[radial-gradient(circle_at_14%_16%,rgba(99,102,241,0.18),transparent_30%),radial-gradient(circle_at_86%_84%,rgba(168,85,247,0.16),transparent_28%),linear-gradient(135deg,rgba(50,54,86,0.96),rgba(18,18,30,0.98))]" }),
39056
+ /* @__PURE__ */ jsx147("div", { className: "absolute left-0 top-0 h-full w-[64%] bg-gradient-to-br from-indigo-500/90 via-violet-600/85 to-purple-700/90" }),
39057
+ /* @__PURE__ */ jsx147("div", { className: "absolute right-0 top-0 h-full w-[36%] bg-zinc-950/95" }),
39058
+ /* @__PURE__ */ jsx147("div", { className: "absolute left-[6%] top-[10%] h-24 w-24 rounded-full bg-white/8 blur-2xl" }),
39059
+ /* @__PURE__ */ jsx147("div", { className: "absolute right-[7%] bottom-[10%] h-28 w-28 rounded-full bg-white/6 blur-2xl" }),
39060
+ /* @__PURE__ */ jsx147("div", { className: "absolute left-[5%] top-[14%] h-5 w-32 rounded-full bg-white/10 animate-pulse" }),
39061
+ /* @__PURE__ */ jsx147("div", { className: "absolute left-[5%] top-[33%] h-4 w-[42%] rounded-full bg-white/12 animate-pulse", style: { animationDelay: "120ms" } }),
39062
+ /* @__PURE__ */ jsx147("div", { className: "absolute left-[5%] top-[40%] h-4 w-[35%] rounded-full bg-white/12 animate-pulse", style: { animationDelay: "220ms" } }),
39063
+ /* @__PURE__ */ jsx147("div", { className: "absolute left-[5%] bottom-[24%] h-5 w-[18%] rounded-full bg-white/12 animate-pulse", style: { animationDelay: "320ms" } }),
39064
+ /* @__PURE__ */ jsx147("div", { className: "absolute right-[6%] top-[14%] h-3 w-28 rounded-full bg-amber-300/70 animate-pulse", style: { animationDelay: "150ms" } }),
39065
+ /* @__PURE__ */ jsx147("div", { className: "absolute right-[6%] top-[28%] h-[84px] w-[72%] rounded-xl border border-amber-300/15 bg-white/5 animate-pulse", style: { animationDelay: "220ms" } }),
39066
+ /* @__PURE__ */ jsx147("div", { className: "absolute right-[6%] top-[50%] h-[84px] w-[72%] rounded-xl border border-violet-300/15 bg-white/5 animate-pulse", style: { animationDelay: "320ms" } }),
39067
+ /* @__PURE__ */ jsx147("div", { className: "absolute right-[6%] top-[72%] h-[84px] w-[72%] rounded-xl border border-purple-300/15 bg-white/5 animate-pulse", style: { animationDelay: "420ms" } }),
39068
+ /* @__PURE__ */ jsxs108("div", { className: "absolute inset-x-0 bottom-0 flex items-center justify-between px-4 py-3 bg-gradient-to-t from-black/30 to-transparent", children: [
39069
+ /* @__PURE__ */ jsxs108("div", { className: "flex items-center gap-2", children: [
39070
+ /* @__PURE__ */ jsx147("span", { className: "h-8 w-8 rounded-full border border-zinc-600 bg-zinc-800/70 flex items-center justify-center text-zinc-400", children: /* @__PURE__ */ jsx147(ChevronLeft2, {}) }),
39071
+ /* @__PURE__ */ jsx147("span", { className: "text-sm text-zinc-300 font-medium tabular-nums", children: "1 / 1" }),
39072
+ /* @__PURE__ */ jsx147("span", { className: "h-8 w-8 rounded-full border border-zinc-700 bg-zinc-800/50 flex items-center justify-center text-zinc-500 opacity-70", children: /* @__PURE__ */ jsx147(ChevronRight2, {}) })
39073
+ ] }),
39074
+ /* @__PURE__ */ jsxs108("div", { className: "flex items-center gap-2 text-xs text-zinc-400", children: [
39075
+ /* @__PURE__ */ jsx147("span", { className: "inline-flex h-2 w-2 rounded-full bg-indigo-400 animate-pulse" }),
39076
+ "Building preview"
39077
+ ] })
39078
+ ] }),
39079
+ /* @__PURE__ */ jsx147("div", { className: "absolute inset-0 -translate-x-full animate-[shimmer_2s_infinite] bg-gradient-to-r from-transparent via-white/8 to-transparent" })
39080
+ ] }) }),
39081
+ /* @__PURE__ */ jsxs108("div", { className: "flex items-center justify-between pt-4 border-t border-zinc-800/60", children: [
39082
+ /* @__PURE__ */ jsxs108("div", { className: "flex items-center gap-2.5", children: [
39083
+ /* @__PURE__ */ jsxs108("span", { className: "relative flex h-2 w-2", children: [
39084
+ /* @__PURE__ */ jsx147("span", { className: "animate-ping absolute inline-flex h-full w-full rounded-full bg-indigo-500 opacity-75" }),
39085
+ /* @__PURE__ */ jsx147("span", { className: "relative inline-flex rounded-full h-2 w-2 bg-indigo-500" })
39086
+ ] }),
39087
+ /* @__PURE__ */ jsx147("span", { className: "text-xs text-indigo-400/80 font-medium", children: stageMessage })
39088
+ ] }),
39089
+ /* @__PURE__ */ jsxs108("span", { className: "text-xs text-zinc-500 tabular-nums font-medium", children: [
39090
+ progress,
39091
+ "%"
39092
+ ] })
38966
39093
  ] })
38967
- ] }),
38968
- /* @__PURE__ */ jsx147("div", { className: "grid grid-cols-3 gap-3", children: [0, 1, 2].map((i) => /* @__PURE__ */ jsx147(Skel, { className: "aspect-video rounded-lg", style: { animationDelay: `${i * 150}ms` } }, i)) }),
38969
- /* @__PURE__ */ jsxs108("div", { className: "flex items-center gap-2.5 mt-4 pt-4 border-t border-zinc-800/60", children: [
38970
- /* @__PURE__ */ jsx147("span", { className: "w-2 h-2 rounded-full bg-indigo-500 animate-pulse flex-shrink-0" }),
38971
- /* @__PURE__ */ jsx147(Skel, { className: "h-3 w-36" })
38972
39094
  ] })
38973
39095
  ] }) });
38974
39096
  }
@@ -45371,11 +45493,14 @@ var PXEngineRenderer = ({
45371
45493
  props = {},
45372
45494
  children = [],
45373
45495
  id,
45496
+ key: _extractedKey,
45497
+ // Extract key to prevent React warning about spreading key prop
45374
45498
  ...remainingProps
45375
45499
  } = component;
45376
45500
  const componentName = name || type || componentType;
45377
45501
  if (!componentName || typeof componentName !== "string") return null;
45378
45502
  const rawProps = { ...remainingProps, ...props };
45503
+ delete rawProps.key;
45379
45504
  if (disabled !== void 0 && rawProps.disabled === void 0) {
45380
45505
  rawProps.disabled = disabled;
45381
45506
  }