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.cjs CHANGED
@@ -38962,6 +38962,8 @@ var PresentationJobCard = ({
38962
38962
  const [showModal, setShowModal] = (0, import_react74.useState)(false);
38963
38963
  const [currentSlide, setCurrentSlide] = (0, import_react74.useState)(1);
38964
38964
  const [previewScale, setPreviewScale] = (0, import_react74.useState)(1);
38965
+ const [iframeReady, setIframeReady] = (0, import_react74.useState)(false);
38966
+ const [pendingSlide, setPendingSlide] = (0, import_react74.useState)(null);
38965
38967
  const intervalRef = (0, import_react74.useRef)(null);
38966
38968
  const previewRef = (0, import_react74.useRef)(null);
38967
38969
  const iframeRef = (0, import_react74.useRef)(null);
@@ -38977,6 +38979,10 @@ var PresentationJobCard = ({
38977
38979
  if (previewRef.current) ro.observe(previewRef.current);
38978
38980
  return () => ro.disconnect();
38979
38981
  }, [updateScale, formats.html_url]);
38982
+ (0, import_react74.useEffect)(() => {
38983
+ setIframeReady(false);
38984
+ setPendingSlide(null);
38985
+ }, [formats.html_url]);
38980
38986
  (0, import_react74.useEffect)(() => {
38981
38987
  const handler = (e) => {
38982
38988
  if (e.data?.type === "slideChanged") {
@@ -38989,11 +38995,20 @@ var PresentationJobCard = ({
38989
38995
  window.addEventListener("message", handler);
38990
38996
  return () => window.removeEventListener("message", handler);
38991
38997
  }, [slideCount]);
38998
+ (0, import_react74.useEffect)(() => {
38999
+ if (!iframeReady || pendingSlide === null) return;
39000
+ iframeRef.current?.contentWindow?.postMessage({ type: "goToSlide", slide: pendingSlide }, "*");
39001
+ setPendingSlide(null);
39002
+ }, [iframeReady, pendingSlide]);
38992
39003
  const goToSlide = (n) => {
38993
39004
  const total2 = slideCount || 1;
38994
39005
  const target = (n - 1 + total2) % total2 + 1;
38995
39006
  setCurrentSlide(target);
38996
- iframeRef.current?.contentWindow?.postMessage({ type: "goToSlide", slide: target }, "*");
39007
+ if (iframeReady) {
39008
+ iframeRef.current?.contentWindow?.postMessage({ type: "goToSlide", slide: target }, "*");
39009
+ return;
39010
+ }
39011
+ setPendingSlide(target);
38997
39012
  };
38998
39013
  const isTerminal = status === "complete" || status === "failed";
38999
39014
  (0, import_react74.useEffect)(() => {
@@ -39093,6 +39108,7 @@ var PresentationJobCard = ({
39093
39108
  ref: iframeRef,
39094
39109
  src: formats.html_url,
39095
39110
  title,
39111
+ onLoad: () => setIframeReady(true),
39096
39112
  sandbox: "allow-same-origin allow-scripts",
39097
39113
  style: {
39098
39114
  width: 1280,