pxengine 0.1.73 → 0.1.74

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.mjs CHANGED
@@ -38640,6 +38640,8 @@ var PresentationJobCard = ({
38640
38640
  const [showModal, setShowModal] = useState10(false);
38641
38641
  const [currentSlide, setCurrentSlide] = useState10(1);
38642
38642
  const [previewScale, setPreviewScale] = useState10(1);
38643
+ const [iframeReady, setIframeReady] = useState10(false);
38644
+ const [pendingSlide, setPendingSlide] = useState10(null);
38643
38645
  const intervalRef = useRef5(null);
38644
38646
  const previewRef = useRef5(null);
38645
38647
  const iframeRef = useRef5(null);
@@ -38655,6 +38657,10 @@ var PresentationJobCard = ({
38655
38657
  if (previewRef.current) ro.observe(previewRef.current);
38656
38658
  return () => ro.disconnect();
38657
38659
  }, [updateScale, formats.html_url]);
38660
+ useEffect6(() => {
38661
+ setIframeReady(false);
38662
+ setPendingSlide(null);
38663
+ }, [formats.html_url]);
38658
38664
  useEffect6(() => {
38659
38665
  const handler = (e) => {
38660
38666
  if (e.data?.type === "slideChanged") {
@@ -38667,11 +38673,20 @@ var PresentationJobCard = ({
38667
38673
  window.addEventListener("message", handler);
38668
38674
  return () => window.removeEventListener("message", handler);
38669
38675
  }, [slideCount]);
38676
+ useEffect6(() => {
38677
+ if (!iframeReady || pendingSlide === null) return;
38678
+ iframeRef.current?.contentWindow?.postMessage({ type: "goToSlide", slide: pendingSlide }, "*");
38679
+ setPendingSlide(null);
38680
+ }, [iframeReady, pendingSlide]);
38670
38681
  const goToSlide = (n) => {
38671
38682
  const total2 = slideCount || 1;
38672
38683
  const target = (n - 1 + total2) % total2 + 1;
38673
38684
  setCurrentSlide(target);
38674
- iframeRef.current?.contentWindow?.postMessage({ type: "goToSlide", slide: target }, "*");
38685
+ if (iframeReady) {
38686
+ iframeRef.current?.contentWindow?.postMessage({ type: "goToSlide", slide: target }, "*");
38687
+ return;
38688
+ }
38689
+ setPendingSlide(target);
38675
38690
  };
38676
38691
  const isTerminal = status === "complete" || status === "failed";
38677
38692
  useEffect6(() => {
@@ -38771,6 +38786,7 @@ var PresentationJobCard = ({
38771
38786
  ref: iframeRef,
38772
38787
  src: formats.html_url,
38773
38788
  title,
38789
+ onLoad: () => setIframeReady(true),
38774
38790
  sandbox: "allow-same-origin allow-scripts",
38775
38791
  style: {
38776
38792
  width: 1280,