@amplifyup/sdk 0.1.69 → 0.1.71

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