@amplifyup/sdk 0.1.69 → 0.1.70

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.
@@ -1101,33 +1101,11 @@ var AmplifyUpSDK = class {
1101
1101
  }
1102
1102
  }
1103
1103
  /**
1104
- * Detect if we're running in visual editor mode
1105
- * Returns true if:
1106
- * 1. Preview mode flag is set by proxy
1107
- * 2. We're in an iframe AND parent is from orchestrator domain
1108
- * 3. OR visualEditor/preview query parameter is present
1104
+ * Detect if we're running in visual editor mode.
1105
+ * Single source of truth: isComposerPreview() (flag, query, Composer referrer).
1109
1106
  */
1110
1107
  detectVisualEditorMode() {
1111
- if (typeof window === "undefined") return false;
1112
- if (window.__AMPLIFYUP_PREVIEW_MODE__ === true) {
1113
- return true;
1114
- }
1115
- const urlParams = new URLSearchParams(window.location.search);
1116
- if (urlParams.get("visualEditor") === "true" || urlParams.get("preview") === "true") {
1117
- return true;
1118
- }
1119
- const inIframe = window.self !== window.top;
1120
- if (!inIframe) return false;
1121
- try {
1122
- if (document.referrer) {
1123
- const referrerUrl = new URL(document.referrer);
1124
- if (referrerUrl.hostname === "localhost" && referrerUrl.port === "5001" || referrerUrl.pathname.includes("/dashboard/composer") || referrerUrl.pathname.includes("/dashboard/routes/")) {
1125
- return true;
1126
- }
1127
- }
1128
- } catch (e) {
1129
- }
1130
- return false;
1108
+ return isComposerPreview();
1131
1109
  }
1132
1110
  /**
1133
1111
  * Check if we're in preview/composer mode (should disable tracking)
@@ -3476,13 +3454,16 @@ function getSDK(adapter) {
3476
3454
  var trackContentView = (contentId, contentType, properties) => getSDK().trackContentView(contentId, contentType, properties);
3477
3455
  var refreshEventTracking = () => getSDK().refreshEventTracking();
3478
3456
  getSDK();
3479
- function useComposerPreviewFlag(force = false) {
3457
+ function useInComposer(force = false) {
3480
3458
  const [detected, setDetected] = useState(false);
3481
3459
  useEffect(() => {
3482
3460
  if (!force && isComposerPreview()) setDetected(true);
3483
3461
  }, [force]);
3484
3462
  return force || detected;
3485
3463
  }
3464
+ function useComposerPreviewFlag(force = false) {
3465
+ return useInComposer(force);
3466
+ }
3486
3467
  createContext({
3487
3468
  ready: true
3488
3469
  });
@@ -3774,26 +3755,7 @@ function AmplifyRendererInner({
3774
3755
  return () => window.clearTimeout(t);
3775
3756
  }, [variantCache, pageConfig?.id]);
3776
3757
  useEffect(() => {
3777
- const isVisualEditorMode = () => {
3778
- if (typeof window === "undefined") return false;
3779
- const urlParams = new URLSearchParams(window.location.search);
3780
- if (urlParams.get("visualEditor") === "true" || urlParams.get("preview") === "true") {
3781
- return true;
3782
- }
3783
- const inIframe = window.self !== window.top;
3784
- if (!inIframe) return false;
3785
- try {
3786
- if (document.referrer) {
3787
- const referrerUrl = new URL(document.referrer);
3788
- if (referrerUrl.hostname === "localhost" && referrerUrl.port === "5001") {
3789
- return true;
3790
- }
3791
- }
3792
- } catch (e) {
3793
- }
3794
- return false;
3795
- };
3796
- if (!isVisualEditorMode()) {
3758
+ if (!isComposerPreview()) {
3797
3759
  return;
3798
3760
  }
3799
3761
  if (!pageConfig) {