pxengine 0.1.83 → 0.1.84

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
@@ -39096,8 +39096,9 @@ var ExportModal = ({ formats, title, onClose }) => {
39096
39096
  ] })
39097
39097
  ] });
39098
39098
  };
39099
- var FullscreenModal = ({ url, title, slideCount, onClose }) => {
39100
- const [currentSlide, setCurrentSlide] = (0, import_react75.useState)(1);
39099
+ var FullscreenModal = ({ url, title, slideCount, initialSlide = 1, onClose }) => {
39100
+ const [currentSlide, setCurrentSlide] = (0, import_react75.useState)(initialSlide);
39101
+ const [iframeReady, setIframeReady] = (0, import_react75.useState)(false);
39101
39102
  const iframeRef = (0, import_react75.useRef)(null);
39102
39103
  (0, import_react75.useEffect)(() => {
39103
39104
  const onKey = (e) => {
@@ -39105,7 +39106,10 @@ var FullscreenModal = ({ url, title, slideCount, onClose }) => {
39105
39106
  };
39106
39107
  const onMsg = (e) => {
39107
39108
  if (e.data?.type === "presentationExit") onClose();
39108
- if (e.data?.type === "slideChanged") setCurrentSlide(e.data.slide);
39109
+ if (e.data?.type === "slideChanged") {
39110
+ setCurrentSlide(e.data.slide);
39111
+ if (!iframeReady) setIframeReady(true);
39112
+ }
39109
39113
  };
39110
39114
  document.addEventListener("keydown", onKey);
39111
39115
  window.addEventListener("message", onMsg);
@@ -39113,14 +39117,26 @@ var FullscreenModal = ({ url, title, slideCount, onClose }) => {
39113
39117
  document.removeEventListener("keydown", onKey);
39114
39118
  window.removeEventListener("message", onMsg);
39115
39119
  };
39116
- }, [onClose]);
39120
+ }, [onClose, iframeReady]);
39117
39121
  (0, import_react75.useEffect)(() => {
39118
39122
  document.body.style.overflow = "hidden";
39119
39123
  return () => {
39120
39124
  document.body.style.overflow = "";
39121
39125
  };
39122
39126
  }, []);
39123
- const send = (type) => iframeRef.current?.contentWindow?.postMessage({ type }, "*");
39127
+ const sendSlideCommand = (command) => {
39128
+ const iframe = iframeRef.current;
39129
+ if (!iframe?.contentWindow) return;
39130
+ const totalSlides = slideCount || 1;
39131
+ let newSlide = currentSlide;
39132
+ if (command === "nextSlide") {
39133
+ newSlide = currentSlide >= totalSlides ? 1 : currentSlide + 1;
39134
+ } else {
39135
+ newSlide = currentSlide <= 1 ? totalSlides : currentSlide - 1;
39136
+ }
39137
+ setCurrentSlide(newSlide);
39138
+ iframe.contentWindow.postMessage({ type: command }, "*");
39139
+ };
39124
39140
  return /* @__PURE__ */ (0, import_jsx_runtime147.jsxs)("div", { className: "fixed inset-0 z-50 bg-black flex flex-col", children: [
39125
39141
  /* @__PURE__ */ (0, import_jsx_runtime147.jsxs)("div", { className: "flex items-center justify-between gap-4 px-4 h-11 bg-zinc-950/90 border-b border-zinc-800/60 flex-shrink-0", children: [
39126
39142
  /* @__PURE__ */ (0, import_jsx_runtime147.jsxs)("div", { className: "flex items-center gap-3 min-w-0", children: [
@@ -39136,8 +39152,9 @@ var FullscreenModal = ({ url, title, slideCount, onClose }) => {
39136
39152
  /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
39137
39153
  "button",
39138
39154
  {
39139
- onClick: () => send("prevSlide"),
39140
- className: "w-7 h-7 rounded-full border border-zinc-700 bg-zinc-800 hover:border-indigo-500 hover:text-indigo-400 text-zinc-400 flex items-center justify-center transition-colors",
39155
+ onClick: () => sendSlideCommand("prevSlide"),
39156
+ disabled: !iframeReady,
39157
+ className: "w-7 h-7 rounded-full border border-zinc-700 bg-zinc-800 hover:border-indigo-500 hover:text-indigo-400 text-zinc-400 flex items-center justify-center transition-colors disabled:opacity-30 disabled:cursor-not-allowed",
39141
39158
  "aria-label": "Previous slide",
39142
39159
  children: /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(ChevronLeft2, {})
39143
39160
  }
@@ -39145,8 +39162,9 @@ var FullscreenModal = ({ url, title, slideCount, onClose }) => {
39145
39162
  /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
39146
39163
  "button",
39147
39164
  {
39148
- onClick: () => send("nextSlide"),
39149
- className: "w-7 h-7 rounded-full border border-zinc-700 bg-zinc-800 hover:border-indigo-500 hover:text-indigo-400 text-zinc-400 flex items-center justify-center transition-colors",
39165
+ onClick: () => sendSlideCommand("nextSlide"),
39166
+ disabled: !iframeReady,
39167
+ className: "w-7 h-7 rounded-full border border-zinc-700 bg-zinc-800 hover:border-indigo-500 hover:text-indigo-400 text-zinc-400 flex items-center justify-center transition-colors disabled:opacity-30 disabled:cursor-not-allowed",
39150
39168
  "aria-label": "Next slide",
39151
39169
  children: /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(ChevronRight2, {})
39152
39170
  }
@@ -39170,7 +39188,10 @@ var FullscreenModal = ({ url, title, slideCount, onClose }) => {
39170
39188
  ref: iframeRef,
39171
39189
  src: url,
39172
39190
  title,
39173
- onLoad: () => iframeRef.current?.contentWindow?.postMessage({ type: "goToSlide", slide: currentSlide }, "*"),
39191
+ onLoad: () => {
39192
+ setIframeReady(true);
39193
+ iframeRef.current?.contentWindow?.postMessage({ type: "goToSlide", slide: initialSlide }, "*");
39194
+ },
39174
39195
  sandbox: "allow-same-origin allow-scripts allow-fullscreen",
39175
39196
  className: "absolute inset-0 w-full h-full border-0"
39176
39197
  }
@@ -39201,6 +39222,7 @@ var PresentationJobCard = ({
39201
39222
  const [copied, setCopied] = (0, import_react75.useState)(false);
39202
39223
  const [currentSlide, setCurrentSlide] = (0, import_react75.useState)(1);
39203
39224
  const [previewScale, setPreviewScale] = (0, import_react75.useState)(1);
39225
+ const [iframeReady, setIframeReady] = (0, import_react75.useState)(false);
39204
39226
  const intervalRef = (0, import_react75.useRef)(null);
39205
39227
  const previewRef = (0, import_react75.useRef)(null);
39206
39228
  const iframeRef = (0, import_react75.useRef)(null);
@@ -39209,6 +39231,7 @@ var PresentationJobCard = ({
39209
39231
  }, []);
39210
39232
  (0, import_react75.useEffect)(() => {
39211
39233
  updateScale();
39234
+ setIframeReady(false);
39212
39235
  if (typeof ResizeObserver === "undefined") return;
39213
39236
  const ro = new ResizeObserver(updateScale);
39214
39237
  if (previewRef.current) ro.observe(previewRef.current);
@@ -39219,13 +39242,24 @@ var PresentationJobCard = ({
39219
39242
  if (e.data?.type === "slideChanged") {
39220
39243
  setCurrentSlide(e.data.slide);
39221
39244
  if (e.data.total && !slideCount) setSlideCount(e.data.total);
39245
+ if (!iframeReady) setIframeReady(true);
39222
39246
  }
39223
39247
  };
39224
39248
  window.addEventListener("message", handler);
39225
39249
  return () => window.removeEventListener("message", handler);
39226
- }, [slideCount]);
39250
+ }, [slideCount, iframeReady]);
39227
39251
  const sendSlideCommand = (command) => {
39228
- iframeRef.current?.contentWindow?.postMessage({ type: command }, "*");
39252
+ const iframe = iframeRef.current;
39253
+ if (!iframe?.contentWindow) return;
39254
+ const totalSlides = slideCount || 1;
39255
+ let newSlide = currentSlide;
39256
+ if (command === "nextSlide") {
39257
+ newSlide = currentSlide >= totalSlides ? 1 : currentSlide + 1;
39258
+ } else {
39259
+ newSlide = currentSlide <= 1 ? totalSlides : currentSlide - 1;
39260
+ }
39261
+ setCurrentSlide(newSlide);
39262
+ iframe.contentWindow.postMessage({ type: command }, "*");
39229
39263
  };
39230
39264
  const isTerminal = status === "complete" || status === "failed";
39231
39265
  const onCompleteRef = (0, import_react75.useRef)(onComplete);
@@ -39388,6 +39422,7 @@ var PresentationJobCard = ({
39388
39422
  src: formats.html_url,
39389
39423
  title,
39390
39424
  sandbox: "allow-same-origin allow-scripts",
39425
+ onLoad: () => setIframeReady(true),
39391
39426
  style: {
39392
39427
  width: 1280,
39393
39428
  height: 720,
@@ -39414,7 +39449,7 @@ var PresentationJobCard = ({
39414
39449
  e.stopPropagation();
39415
39450
  sendSlideCommand("prevSlide");
39416
39451
  },
39417
- disabled: !hasHtml,
39452
+ disabled: !hasHtml || !iframeReady,
39418
39453
  className: "w-7 h-7 rounded-full border border-zinc-700 bg-zinc-800 hover:border-indigo-500 hover:text-indigo-400 text-zinc-400 flex items-center justify-center transition-colors disabled:opacity-30 disabled:cursor-not-allowed",
39419
39454
  "aria-label": "Previous slide",
39420
39455
  children: /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(ChevronLeft2, {})
@@ -39432,7 +39467,7 @@ var PresentationJobCard = ({
39432
39467
  e.stopPropagation();
39433
39468
  sendSlideCommand("nextSlide");
39434
39469
  },
39435
- disabled: !hasHtml,
39470
+ disabled: !hasHtml || !iframeReady,
39436
39471
  className: "w-7 h-7 rounded-full border border-zinc-700 bg-zinc-800 hover:border-indigo-500 hover:text-indigo-400 text-zinc-400 flex items-center justify-center transition-colors disabled:opacity-30 disabled:cursor-not-allowed",
39437
39472
  "aria-label": "Next slide",
39438
39473
  children: /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(ChevronRight2, {})
@@ -39449,6 +39484,7 @@ var PresentationJobCard = ({
39449
39484
  url: formats.html_url,
39450
39485
  title,
39451
39486
  slideCount,
39487
+ initialSlide: currentSlide,
39452
39488
  onClose: () => setShowFullscreen(false)
39453
39489
  }
39454
39490
  )
@@ -39567,6 +39603,36 @@ var ResearchReportJobCard = ({
39567
39603
  const hasNotifiedRef = (0, import_react76.useRef)(false);
39568
39604
  onCompleteRef.current = onComplete;
39569
39605
  onFailedRef.current = onFailed;
39606
+ (0, import_react76.useEffect)(() => {
39607
+ setStatus(initialStatus);
39608
+ }, [initialStatus]);
39609
+ (0, import_react76.useEffect)(() => {
39610
+ if (initialTitle) setTitle(initialTitle);
39611
+ }, [initialTitle]);
39612
+ (0, import_react76.useEffect)(() => {
39613
+ if (initialHtmlUrl) setHtmlUrl(initialHtmlUrl);
39614
+ }, [initialHtmlUrl]);
39615
+ (0, import_react76.useEffect)(() => {
39616
+ if (initialDepth) setDepth(initialDepth);
39617
+ }, [initialDepth]);
39618
+ (0, import_react76.useEffect)(() => {
39619
+ if (initialSectionCount !== void 0) setSectionCount(initialSectionCount);
39620
+ }, [initialSectionCount]);
39621
+ (0, import_react76.useEffect)(() => {
39622
+ if (initialSourceCount !== void 0) setSourceCount(initialSourceCount);
39623
+ }, [initialSourceCount]);
39624
+ (0, import_react76.useEffect)(() => {
39625
+ if (initialWordCount !== void 0) setWordCount(initialWordCount);
39626
+ }, [initialWordCount]);
39627
+ (0, import_react76.useEffect)(() => {
39628
+ if (initialSummary) setSummary(initialSummary);
39629
+ }, [initialSummary]);
39630
+ (0, import_react76.useEffect)(() => {
39631
+ if (initialTheme) setTheme(initialTheme);
39632
+ }, [initialTheme]);
39633
+ (0, import_react76.useEffect)(() => {
39634
+ if (initialError) setError(initialError);
39635
+ }, [initialError]);
39570
39636
  const isTerminal = status === "complete" || status === "failed";
39571
39637
  const primaryColor = theme?.primary || DEFAULT_THEME.primary;
39572
39638
  const hasHTML = Boolean(htmlUrl);