@accelerated-agency/visual-editor 0.4.2 → 0.4.4

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.js CHANGED
@@ -4657,7 +4657,6 @@ function PlatformVisualEditor({
4657
4657
  }),
4658
4658
  [experiment]
4659
4659
  );
4660
- console.log("loadPayload", loadPayload);
4661
4660
  useEffect(() => {
4662
4661
  if (!editorReady) return;
4663
4662
  const payloadKey = JSON.stringify(loadPayload);
@@ -4807,6 +4806,7 @@ function PlatformVisualEditorV2({
4807
4806
  // channel kept for API compatibility; VvvebJs uses its own internal channel
4808
4807
  embeddedGlobalKey = "__CONVERSION_EMBEDDED__",
4809
4808
  proxyBaseUrl = "",
4809
+ conversionProxyBaseUrl = "",
4810
4810
  strictObserverFreeze = false,
4811
4811
  trackingMarkers = [],
4812
4812
  className = "fixed inset-0 z-[9999] flex flex-col bg-white",
@@ -4839,6 +4839,7 @@ function PlatformVisualEditorV2({
4839
4839
  }) {
4840
4840
  const iframeRef = useRef(null);
4841
4841
  const [editorReady, setEditorReady] = useState(false);
4842
+ const [iframeLoaded, setIframeLoaded] = useState(false);
4842
4843
  const [isSaving, setIsSaving] = useState(false);
4843
4844
  const [dirty, setDirty] = useState(false);
4844
4845
  const dirtyRef = useRef(false);
@@ -4870,11 +4871,12 @@ function PlatformVisualEditorV2({
4870
4871
  status: experiment?.status,
4871
4872
  pageUrl: experiment?.pageUrl,
4872
4873
  editorPassword: experiment?.editorPassword,
4874
+ conversionProxyBaseUrl: typeof conversionProxyBaseUrl === "string" ? conversionProxyBaseUrl.trim().replace(/\/+$/, "") : "",
4873
4875
  strictObserverFreeze: !!strictObserverFreeze,
4874
4876
  trackingMarkers: Array.isArray(trackingMarkers) ? trackingMarkers.filter((m) => typeof m === "string" && m.trim().length > 0) : [],
4875
4877
  variations: experiment?.variations ?? []
4876
4878
  }),
4877
- [experiment, strictObserverFreeze, trackingMarkers]
4879
+ [conversionProxyBaseUrl, experiment, strictObserverFreeze, trackingMarkers]
4878
4880
  );
4879
4881
  const editorSrc = useMemo(() => {
4880
4882
  const safeBaseUrl = normalizeProxyBaseUrl(proxyBaseUrl);
@@ -4968,6 +4970,23 @@ function PlatformVisualEditorV2({
4968
4970
  window.addEventListener("message", listener);
4969
4971
  return () => window.removeEventListener("message", listener);
4970
4972
  }, [handleMessage]);
4973
+ useEffect(() => {
4974
+ if (!iframeLoaded || editorReady) return;
4975
+ let attempts = 0;
4976
+ const maxAttempts = 12;
4977
+ const tickMs = 500;
4978
+ const tryBootstrap = () => {
4979
+ if (editorReady) return;
4980
+ attempts += 1;
4981
+ sendToVvveb("load-experiment", loadPayload);
4982
+ if (attempts >= maxAttempts) {
4983
+ clearInterval(timer);
4984
+ }
4985
+ };
4986
+ tryBootstrap();
4987
+ const timer = window.setInterval(tryBootstrap, tickMs);
4988
+ return () => window.clearInterval(timer);
4989
+ }, [iframeLoaded, editorReady, loadPayload, sendToVvveb]);
4971
4990
  useCallback(
4972
4991
  (tab) => onTabChange?.(tab),
4973
4992
  [onTabChange]
@@ -4987,7 +5006,8 @@ function PlatformVisualEditorV2({
4987
5006
  src: editorSrc,
4988
5007
  className: "w-full h-full border-0",
4989
5008
  title: "Vvveb Visual Editor",
4990
- allow: "same-origin"
5009
+ allow: "same-origin",
5010
+ onLoad: () => setIframeLoaded(true)
4991
5011
  }
4992
5012
  ) }) });
4993
5013
  }