@amplifyup/sdk 0.1.16 → 0.1.18

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
@@ -356,6 +356,9 @@ var AmplifyUpSDK = class {
356
356
  this.attachedEventListeners = [];
357
357
  this.trackingIntervals = [];
358
358
  this.trackingCleanup = null;
359
+ this.componentViewObservers = [];
360
+ this.componentViewSeen = /* @__PURE__ */ new Set();
361
+ this.pageEngagementActive = false;
359
362
  this.adapter = adapter || new AWSAdapter();
360
363
  if (typeof window !== "undefined") {
361
364
  this.isVisualEditorMode = this.detectVisualEditorMode();
@@ -528,6 +531,7 @@ var AmplifyUpSDK = class {
528
531
  this.initialPageSent = true;
529
532
  const url = window.location.pathname;
530
533
  this.page(url);
534
+ this.setupPageEngagement();
531
535
  }
532
536
  }
533
537
  if (this.config?.debug && this.initialized) {
@@ -560,6 +564,168 @@ var AmplifyUpSDK = class {
560
564
  }
561
565
  this.trackingIntervals.forEach((id) => clearInterval(id));
562
566
  this.trackingIntervals = [];
567
+ this.cleanupComponentViewTracking();
568
+ this.pageEngagementActive = false;
569
+ }
570
+ /** Current page path for engagement attribution. */
571
+ currentPath() {
572
+ if (typeof window === "undefined") return "/";
573
+ return window.location.pathname || "/";
574
+ }
575
+ /**
576
+ * Automatic page-level Scroll Depth + Time on Page (dwell heartbeat).
577
+ */
578
+ setupPageEngagement() {
579
+ if (typeof window === "undefined" || typeof document === "undefined") return;
580
+ if (this.isPreviewMode() || this.pageEngagementActive) return;
581
+ this.pageEngagementActive = true;
582
+ const milestones = [25, 50, 75, 100];
583
+ const reached = /* @__PURE__ */ new Set();
584
+ let visibleMs = 0;
585
+ let visibleSince = document.visibilityState === "visible" ? Date.now() : null;
586
+ let lastDwellSecondsSent = 0;
587
+ let scrollRaf = null;
588
+ const path = () => this.currentPath();
589
+ const measureScrollPercent = () => {
590
+ const doc = document.documentElement;
591
+ const body = document.body;
592
+ const scrollTop = window.scrollY || doc.scrollTop || body?.scrollTop || 0;
593
+ const scrollHeight = Math.max(
594
+ doc.scrollHeight,
595
+ body?.scrollHeight || 0,
596
+ doc.offsetHeight,
597
+ body?.offsetHeight || 0
598
+ );
599
+ const clientHeight = window.innerHeight || doc.clientHeight || 0;
600
+ const traversable = Math.max(scrollHeight - clientHeight, 0);
601
+ if (traversable <= 0) return 100;
602
+ return Math.min(100, Math.round(scrollTop / traversable * 100));
603
+ };
604
+ const checkScroll = () => {
605
+ if (this.isPreviewMode()) return;
606
+ const pct = measureScrollPercent();
607
+ for (const milestone of milestones) {
608
+ if (pct >= milestone && !reached.has(milestone)) {
609
+ reached.add(milestone);
610
+ this.track("Scroll Depth", {
611
+ percentage: milestone,
612
+ path: path()
613
+ });
614
+ }
615
+ }
616
+ };
617
+ const onScroll = () => {
618
+ if (scrollRaf != null) return;
619
+ scrollRaf = window.requestAnimationFrame(() => {
620
+ scrollRaf = null;
621
+ checkScroll();
622
+ });
623
+ };
624
+ const accumulateVisible = () => {
625
+ if (visibleSince == null) return;
626
+ visibleMs += Date.now() - visibleSince;
627
+ visibleSince = Date.now();
628
+ };
629
+ const emitDwell = (force = false) => {
630
+ if (this.isPreviewMode()) return;
631
+ accumulateVisible();
632
+ const seconds = Math.floor(visibleMs / 1e3);
633
+ if (seconds <= 0) return;
634
+ if (!force && seconds <= lastDwellSecondsSent) return;
635
+ lastDwellSecondsSent = seconds;
636
+ this.track("Time on Page", {
637
+ seconds,
638
+ path: path()
639
+ });
640
+ };
641
+ const onVisibility = () => {
642
+ if (document.visibilityState === "visible") {
643
+ visibleSince = Date.now();
644
+ } else {
645
+ emitDwell(true);
646
+ visibleSince = null;
647
+ }
648
+ };
649
+ const onPageHide = () => {
650
+ emitDwell(true);
651
+ };
652
+ window.addEventListener("scroll", onScroll, { passive: true });
653
+ document.addEventListener("visibilitychange", onVisibility);
654
+ window.addEventListener("pagehide", onPageHide);
655
+ checkScroll();
656
+ const heartbeat = setInterval(() => {
657
+ if (document.visibilityState === "visible") {
658
+ emitDwell(false);
659
+ }
660
+ }, 15e3);
661
+ this.trackingIntervals.push(heartbeat);
662
+ const previousCleanup = this.trackingCleanup;
663
+ this.trackingCleanup = () => {
664
+ window.removeEventListener("scroll", onScroll);
665
+ document.removeEventListener("visibilitychange", onVisibility);
666
+ window.removeEventListener("pagehide", onPageHide);
667
+ if (scrollRaf != null) {
668
+ window.cancelAnimationFrame(scrollRaf);
669
+ scrollRaf = null;
670
+ }
671
+ previousCleanup?.();
672
+ this.pageEngagementActive = false;
673
+ };
674
+ if (this.config?.debug) {
675
+ console.log("[AmplifyUp SDK] Page engagement tracking enabled");
676
+ }
677
+ }
678
+ /**
679
+ * Automatic Component View when component hosts enter the viewport.
680
+ */
681
+ setupComponentViewTracking() {
682
+ if (typeof document === "undefined" || typeof IntersectionObserver === "undefined") {
683
+ return;
684
+ }
685
+ if (this.isPreviewMode()) return;
686
+ this.cleanupComponentViewTracking();
687
+ const hosts = document.querySelectorAll("[data-amplifyup-component]");
688
+ if (hosts.length === 0) {
689
+ if (this.config?.debug) {
690
+ console.log("[AmplifyUp SDK] No component hosts found for Component View");
691
+ }
692
+ return;
693
+ }
694
+ const observer = new IntersectionObserver(
695
+ (entries) => {
696
+ entries.forEach((entry) => {
697
+ if (!entry.isIntersecting) return;
698
+ const el = entry.target;
699
+ const componentId = el.getAttribute("data-amplifyup-component") || el.getAttribute("data-component-id");
700
+ if (!componentId || this.componentViewSeen.has(componentId)) {
701
+ observer.unobserve(el);
702
+ return;
703
+ }
704
+ this.componentViewSeen.add(componentId);
705
+ const componentName = el.getAttribute("data-component-name") || void 0;
706
+ this.track("Component View", {
707
+ componentId,
708
+ componentName,
709
+ path: this.currentPath()
710
+ });
711
+ observer.unobserve(el);
712
+ });
713
+ },
714
+ { threshold: 0.5 }
715
+ );
716
+ hosts.forEach((host) => observer.observe(host));
717
+ this.componentViewObservers.push(observer);
718
+ if (this.config?.debug) {
719
+ console.log(
720
+ "[AmplifyUp SDK] Component View tracking enabled for",
721
+ hosts.length,
722
+ "hosts"
723
+ );
724
+ }
725
+ }
726
+ cleanupComponentViewTracking() {
727
+ this.componentViewObservers.forEach((obs) => obs.disconnect());
728
+ this.componentViewObservers = [];
563
729
  }
564
730
  /**
565
731
  * Track a page view
@@ -599,9 +765,13 @@ var AmplifyUpSDK = class {
599
765
  instanceId,
600
766
  trackingId: this.config?.trackingId,
601
767
  url: typeof window !== "undefined" ? window.location.href : void 0,
768
+ path: properties?.path || (typeof window !== "undefined" ? window.location.pathname : void 0),
602
769
  // Timestamp is included in event payload
603
770
  ...properties
604
771
  };
772
+ if (!trackProperties.path && typeof window !== "undefined") {
773
+ trackProperties.path = window.location.pathname;
774
+ }
605
775
  this.adapter.track(eventName, trackProperties);
606
776
  }
607
777
  /**
@@ -890,6 +1060,13 @@ Available Console Commands:
890
1060
  if (pageConfig?.eventTracking) {
891
1061
  this.setupEventTracking(pageConfig.eventTracking);
892
1062
  }
1063
+ if (typeof window !== "undefined") {
1064
+ window.setTimeout(() => this.setupComponentViewTracking(), 150);
1065
+ window.setTimeout(() => {
1066
+ this.setupComponentViewTracking();
1067
+ this.refreshEventTracking();
1068
+ }, 800);
1069
+ }
893
1070
  return pageConfig;
894
1071
  }
895
1072
  /**
@@ -897,10 +1074,10 @@ Available Console Commands:
897
1074
  */
898
1075
  setupEventTracking(eventConfig) {
899
1076
  if (typeof document === "undefined") return;
900
- this.cleanupEventTracking();
901
- this.eventTrackingConfig = eventConfig;
1077
+ this.detachEventListeners();
1078
+ this.eventTrackingConfig = Array.isArray(eventConfig) ? [...eventConfig] : [];
902
1079
  if (this.config?.debug) {
903
- console.log("[AmplifyUp SDK] Setting up event tracking:", eventConfig.length, "events");
1080
+ console.log("[AmplifyUp SDK] Setting up event tracking:", this.eventTrackingConfig.length, "events");
904
1081
  }
905
1082
  if (document.readyState === "loading") {
906
1083
  document.addEventListener("DOMContentLoaded", () => this.attachEventListeners());
@@ -915,19 +1092,35 @@ Available Console Commands:
915
1092
  if (typeof document === "undefined") return;
916
1093
  this.eventTrackingConfig.forEach((eventConfig) => {
917
1094
  if (eventConfig.enabled === false) return;
1095
+ if (!eventConfig.selector) {
1096
+ if (this.config?.debug) {
1097
+ console.warn(`[AmplifyUp SDK] Event ${eventConfig.eventName} has no selector, skipping`);
1098
+ }
1099
+ return;
1100
+ }
918
1101
  let targetElements = [];
919
- if (eventConfig.selector) {
920
- try {
921
- targetElements = document.querySelectorAll(eventConfig.selector);
922
- } catch (e) {
1102
+ try {
1103
+ const escapeAttr = (value) => typeof CSS !== "undefined" && typeof CSS.escape === "function" ? CSS.escape(value) : value.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
1104
+ const scopeRoot = eventConfig.componentId ? document.querySelector(
1105
+ `[data-amplifyup-component="${escapeAttr(eventConfig.componentId)}"], [data-component-id="${escapeAttr(eventConfig.componentId)}"]`
1106
+ ) : document;
1107
+ if (!scopeRoot) {
923
1108
  if (this.config?.debug) {
924
- console.warn(`[AmplifyUp SDK] Invalid selector: ${eventConfig.selector}`, e);
1109
+ console.log(
1110
+ `[AmplifyUp SDK] Component host not found for ${eventConfig.componentId}`
1111
+ );
925
1112
  }
926
1113
  return;
927
1114
  }
928
- } else {
1115
+ targetElements = Array.from(
1116
+ scopeRoot.querySelectorAll(eventConfig.selector)
1117
+ );
1118
+ if (scopeRoot instanceof Element && scopeRoot !== document.documentElement && scopeRoot.matches?.(eventConfig.selector)) {
1119
+ targetElements.unshift(scopeRoot);
1120
+ }
1121
+ } catch (e) {
929
1122
  if (this.config?.debug) {
930
- console.warn(`[AmplifyUp SDK] Event ${eventConfig.eventName} has no selector, skipping`);
1123
+ console.warn(`[AmplifyUp SDK] Invalid selector: ${eventConfig.selector}`, e);
931
1124
  }
932
1125
  return;
933
1126
  }
@@ -983,8 +1176,15 @@ Available Console Commands:
983
1176
  handleTrackedEvent(event, config, element) {
984
1177
  const properties = {
985
1178
  eventType: config.eventType,
986
- selector: config.selector
1179
+ selector: config.selector,
1180
+ path: this.currentPath()
987
1181
  };
1182
+ if (config.componentId) {
1183
+ properties.componentId = config.componentId;
1184
+ }
1185
+ if (config.componentName) {
1186
+ properties.componentName = config.componentName;
1187
+ }
988
1188
  if (config.properties && config.properties.length > 0) {
989
1189
  config.properties.forEach((prop) => {
990
1190
  const dataAttrValue = element.getAttribute(`data-${prop}`);
@@ -1055,9 +1255,9 @@ Available Console Commands:
1055
1255
  element._amplifyupViewObserver = observer;
1056
1256
  }
1057
1257
  /**
1058
- * Clean up all attached event listeners
1258
+ * Detach listeners/observers without clearing the saved event config.
1059
1259
  */
1060
- cleanupEventTracking() {
1260
+ detachEventListeners() {
1061
1261
  this.attachedEventListeners.forEach(({ element, eventType, handler }) => {
1062
1262
  element.removeEventListener(eventType, handler);
1063
1263
  });
@@ -1071,6 +1271,12 @@ Available Console Commands:
1071
1271
  }
1072
1272
  });
1073
1273
  }
1274
+ }
1275
+ /**
1276
+ * Clean up all attached event listeners and clear config
1277
+ */
1278
+ cleanupEventTracking() {
1279
+ this.detachEventListeners();
1074
1280
  this.eventTrackingConfig = [];
1075
1281
  if (this.config?.debug) {
1076
1282
  console.log("[AmplifyUp SDK] Cleaned up event tracking");
@@ -1080,11 +1286,13 @@ Available Console Commands:
1080
1286
  * Manually trigger event tracking setup (useful after dynamic content loads)
1081
1287
  */
1082
1288
  refreshEventTracking() {
1083
- if (this.eventTrackingConfig.length > 0) {
1084
- this.cleanupEventTracking();
1085
- const config = [...this.eventTrackingConfig];
1086
- this.eventTrackingConfig = config;
1087
- this.attachEventListeners();
1289
+ if (this.eventTrackingConfig.length === 0) return;
1290
+ const config = [...this.eventTrackingConfig];
1291
+ this.detachEventListeners();
1292
+ this.eventTrackingConfig = config;
1293
+ this.attachEventListeners();
1294
+ if (this.config?.debug) {
1295
+ console.log("[AmplifyUp SDK] Refreshed event tracking:", config.length, "events");
1088
1296
  }
1089
1297
  }
1090
1298
  /** Origins allowed to send Composer postMessage commands to the SDK. */
@@ -1195,6 +1403,10 @@ Available Console Commands:
1195
1403
  this.clearComposerDragHighlight();
1196
1404
  return;
1197
1405
  }
1406
+ if (event.data?.type === "CLEAR_SELECTION") {
1407
+ this.clearComposerSelection();
1408
+ return;
1409
+ }
1198
1410
  if (event.data?.type === "GET_ELEMENT_POSITION") {
1199
1411
  const { componentId, slotName, nodeId, isPageSlot } = event.data;
1200
1412
  let element = null;
@@ -1236,6 +1448,7 @@ Available Console Commands:
1236
1448
  found: !!element
1237
1449
  });
1238
1450
  if (element) {
1451
+ this.markComposerSelection(element);
1239
1452
  const rect = element.getBoundingClientRect();
1240
1453
  const position = {
1241
1454
  x: rect.left + rect.width / 2,
@@ -1303,6 +1516,7 @@ Available Console Commands:
1303
1516
  break;
1304
1517
  case "SHOW_COMPONENT_TOOLTIP":
1305
1518
  case "HIDE_ALL_TOOLTIPS":
1519
+ this.clearComposerSelection();
1306
1520
  break;
1307
1521
  case "ENABLE_EVENT_SELECTION":
1308
1522
  console.log("[AmplifyUp SDK] Enable event selection mode:", message.enabled);
@@ -1540,29 +1754,46 @@ Available Console Commands:
1540
1754
  */
1541
1755
  enableHighlighting(componentRegistry, highlightComponents, showZones) {
1542
1756
  if (typeof document === "undefined") return;
1757
+ const previouslySelected = Array.from(
1758
+ document.querySelectorAll(".amplifyup-selected")
1759
+ );
1543
1760
  this.componentRegistry = componentRegistry;
1544
1761
  this.highlightingEnabled = true;
1545
1762
  this.highlightComponentsEnabled = highlightComponents;
1546
1763
  this.showZonesEnabled = showZones;
1547
- this.disableHighlighting();
1764
+ this.disableHighlighting({ clearSelection: false });
1548
1765
  this.highlightingEnabled = true;
1549
1766
  this.injectComposerHighlightStyles(highlightComponents, showZones);
1550
1767
  if (highlightComponents || showZones) {
1551
1768
  this.applyComponentHighlights(highlightComponents, showZones);
1552
1769
  this.setupMutationObserver();
1553
- }
1554
- if (showZones) {
1555
1770
  this.setupComposerDragDrop();
1556
1771
  }
1772
+ previouslySelected.forEach((el) => {
1773
+ if (document.contains(el)) {
1774
+ el.classList.add("amplifyup-selected");
1775
+ }
1776
+ });
1557
1777
  }
1558
1778
  /** Document-level drag/drop for cross-iframe drags from Composer sidebar. */
1559
1779
  setupComposerDragDrop() {
1560
1780
  if (typeof document === "undefined") return;
1561
1781
  this.teardownComposerDragDrop();
1562
1782
  const slotSelector = "[data-slot-id], [data-amplifyup-slot]";
1783
+ const componentSelector = "[data-amplifyup-component], [data-component-id]";
1563
1784
  const clearDragOverState = () => {
1564
1785
  this.clearComposerDragHighlight();
1565
1786
  };
1787
+ const clearComponentHover = () => {
1788
+ document.querySelectorAll(".amplifyup-component-hover").forEach((el) => {
1789
+ el.classList.remove("amplifyup-component-hover");
1790
+ });
1791
+ };
1792
+ const clearSlotHover = () => {
1793
+ document.querySelectorAll(`${slotSelector}.amplifyup-slot-hover`).forEach((el) => {
1794
+ el.classList.remove("amplifyup-slot-hover");
1795
+ });
1796
+ };
1566
1797
  const dragenter = (e) => {
1567
1798
  e.preventDefault();
1568
1799
  };
@@ -1593,31 +1824,59 @@ Available Console Commands:
1593
1824
  this.postDropOnSlot(slot);
1594
1825
  };
1595
1826
  const mouseover = (e) => {
1596
- if (!this.showZonesEnabled) return;
1827
+ if (!this.highlightComponentsEnabled && !this.showZonesEnabled) return;
1597
1828
  const target = e.target;
1598
- const slot = target?.closest?.(slotSelector);
1599
- if (!slot) return;
1600
- document.querySelectorAll(`${slotSelector}.amplifyup-slot-hover`).forEach((el) => {
1601
- el.classList.remove("amplifyup-slot-hover");
1602
- });
1603
- slot.classList.add("amplifyup-slot-hover");
1829
+ if (!target?.closest) return;
1830
+ const component = target.closest(componentSelector);
1831
+ const slot = target.closest(slotSelector);
1832
+ if (this.highlightComponentsEnabled && component) {
1833
+ if (!component.classList.contains("amplifyup-component-hover")) {
1834
+ clearComponentHover();
1835
+ component.classList.add("amplifyup-component-hover");
1836
+ }
1837
+ if (slot && !component.contains(slot)) {
1838
+ clearSlotHover();
1839
+ }
1840
+ return;
1841
+ }
1842
+ clearComponentHover();
1843
+ if (this.showZonesEnabled && slot) {
1844
+ if (!slot.classList.contains("amplifyup-slot-hover")) {
1845
+ clearSlotHover();
1846
+ slot.classList.add("amplifyup-slot-hover");
1847
+ }
1848
+ }
1604
1849
  };
1605
1850
  const mouseout = (e) => {
1606
- if (!this.showZonesEnabled) return;
1851
+ if (!this.highlightComponentsEnabled && !this.showZonesEnabled) return;
1607
1852
  const related = e.relatedTarget;
1608
- if (!related?.closest?.(slotSelector)) {
1609
- document.querySelectorAll(`${slotSelector}.amplifyup-slot-hover`).forEach((el) => {
1610
- el.classList.remove("amplifyup-slot-hover");
1611
- });
1853
+ if (this.highlightComponentsEnabled) {
1854
+ if (!related?.closest?.(componentSelector)) {
1855
+ clearComponentHover();
1856
+ }
1857
+ }
1858
+ if (this.showZonesEnabled) {
1859
+ if (!related?.closest?.(slotSelector)) {
1860
+ clearSlotHover();
1861
+ }
1612
1862
  }
1613
1863
  };
1614
- document.addEventListener("dragenter", dragenter, false);
1615
- document.addEventListener("dragover", dragover, false);
1616
- document.addEventListener("dragleave", dragleave, false);
1617
- document.addEventListener("drop", drop, false);
1618
1864
  document.addEventListener("mouseover", mouseover, true);
1619
1865
  document.addEventListener("mouseout", mouseout, true);
1620
- this.composerDragHandlers = { dragenter, dragover, dragleave, drop, mouseover, mouseout };
1866
+ if (this.showZonesEnabled) {
1867
+ document.addEventListener("dragenter", dragenter, false);
1868
+ document.addEventListener("dragover", dragover, false);
1869
+ document.addEventListener("dragleave", dragleave, false);
1870
+ document.addEventListener("drop", drop, false);
1871
+ }
1872
+ this.composerDragHandlers = {
1873
+ dragenter,
1874
+ dragover,
1875
+ dragleave,
1876
+ drop,
1877
+ mouseover,
1878
+ mouseout
1879
+ };
1621
1880
  }
1622
1881
  teardownComposerDragDrop() {
1623
1882
  if (!this.composerDragHandlers || typeof document === "undefined") return;
@@ -1640,6 +1899,20 @@ Available Console Commands:
1640
1899
  document.querySelectorAll("[data-slot-id].amplifyup-slot-hover, [data-amplifyup-slot].amplifyup-slot-hover").forEach((el) => {
1641
1900
  el.classList.remove("amplifyup-slot-hover");
1642
1901
  });
1902
+ document.querySelectorAll(".amplifyup-component-hover").forEach((el) => {
1903
+ el.classList.remove("amplifyup-component-hover");
1904
+ });
1905
+ }
1906
+ clearComposerSelection() {
1907
+ if (typeof document === "undefined") return;
1908
+ document.querySelectorAll(
1909
+ "[data-slot-id].amplifyup-selected, [data-amplifyup-slot].amplifyup-selected, [data-amplifyup-component].amplifyup-selected, [data-component-id].amplifyup-selected"
1910
+ ).forEach((el) => el.classList.remove("amplifyup-selected"));
1911
+ }
1912
+ markComposerSelection(element) {
1913
+ if (typeof document === "undefined") return;
1914
+ this.clearComposerSelection();
1915
+ element.classList.add("amplifyup-selected");
1643
1916
  }
1644
1917
  /** Visual outlines for Composer (direct iframe path — no preview-frame proxy). */
1645
1918
  injectComposerHighlightStyles(highlightComponents, showZones) {
@@ -1647,16 +1920,29 @@ Available Console Commands:
1647
1920
  if (!highlightComponents && !showZones) return;
1648
1921
  const existing = document.getElementById("amplifyup-preview-highlights");
1649
1922
  if (existing) existing.remove();
1923
+ const primary = "hsl(82 92% 42%)";
1650
1924
  const lines = [];
1651
1925
  if (highlightComponents) {
1652
1926
  lines.push(
1653
1927
  "[data-amplifyup-component], [data-component-id] {",
1654
- " outline: 1px dashed rgba(59, 130, 246, 0.8) !important;",
1655
- " outline-offset: 2px !important;",
1656
1928
  " cursor: pointer !important;",
1657
1929
  "}",
1658
- "[data-amplifyup-component]:hover, [data-component-id]:hover {",
1659
- " outline-color: rgba(59, 130, 246, 1) !important;",
1930
+ "[data-amplifyup-component].amplifyup-selected, [data-component-id].amplifyup-selected {",
1931
+ ` outline: 2px solid ${primary} !important;`,
1932
+ " outline-offset: -2px !important;",
1933
+ " box-shadow: inset 0 0 0 1px hsl(82 92% 42% / 0.25) !important;",
1934
+ "}",
1935
+ "[data-amplifyup-component].amplifyup-component-hover:not(.amplifyup-selected),",
1936
+ "[data-component-id].amplifyup-component-hover:not(.amplifyup-selected) {",
1937
+ ` outline: 2px solid ${primary} !important;`,
1938
+ " outline-offset: -2px !important;",
1939
+ "}"
1940
+ );
1941
+ }
1942
+ if (highlightComponents || showZones) {
1943
+ lines.push(
1944
+ "[data-slot-id].amplifyup-selected, [data-amplifyup-slot].amplifyup-selected {",
1945
+ " background-color: rgba(245, 245, 220, 0.35) !important;",
1660
1946
  "}"
1661
1947
  );
1662
1948
  }
@@ -1791,8 +2077,9 @@ Available Console Commands:
1791
2077
  /**
1792
2078
  * Disable component highlighting
1793
2079
  */
1794
- disableHighlighting() {
2080
+ disableHighlighting(opts) {
1795
2081
  if (typeof document === "undefined") return;
2082
+ const clearSelection = opts?.clearSelection !== false;
1796
2083
  this.highlightingEnabled = false;
1797
2084
  this.teardownComposerDragDrop();
1798
2085
  if (this.mutationObserver) {
@@ -1821,10 +2108,10 @@ Available Console Commands:
1821
2108
  delete htmlEl._amplifyupSlotHandlers;
1822
2109
  htmlEl.classList.remove("amplifyup-slot-highlight");
1823
2110
  });
2111
+ if (clearSelection) {
2112
+ this.clearComposerSelection();
2113
+ }
1824
2114
  }
1825
- /**
1826
- * Build component hierarchy for ancestor selection
1827
- */
1828
2115
  buildComponentHierarchy(element) {
1829
2116
  const hierarchy = [];
1830
2117
  let current = element;
@@ -1888,6 +2175,7 @@ Available Console Commands:
1888
2175
  window.parent.postMessage(message, "*");
1889
2176
  console.log("[AmplifyUp SDK] Sent selection message:", message);
1890
2177
  }
2178
+ this.markComposerSelection(element);
1891
2179
  }
1892
2180
  /**
1893
2181
  * Send component tree to orchestrator
@@ -2020,6 +2308,7 @@ var fetchPageConfig = (route, preview) => getSDK().fetchPageConfig(route, previe
2020
2308
  var setupEventTracking = (config) => getSDK().setupEventTracking(config);
2021
2309
  var cleanupEventTracking = () => getSDK().cleanupEventTracking();
2022
2310
  var refreshEventTracking = () => getSDK().refreshEventTracking();
2311
+ var setupComponentViewTracking = () => getSDK().setupComponentViewTracking();
2023
2312
  var getDiagnostics = () => getSDK().getDiagnostics();
2024
2313
  var getStatus = () => {
2025
2314
  const status = getSDK().getStatus();
@@ -2035,6 +2324,6 @@ var verifyAWSConnection = () => {
2035
2324
  };
2036
2325
  var index_default = getSDK();
2037
2326
 
2038
- export { AmplifyUpSDK, buildLayoutProviderUrl, buildPageRenderUrl, cleanupEventTracking, index_default as default, fetchPageConfig, getDiagnostics, getInstanceId2 as getInstanceId, getOrchestratorUrl, getSDK, getStatus, getTarget, getTrackingId, getUserId2 as getUserId, identify, init, isAmplifyUpTarget, isComposerPreview, isPreviewRequest, normalizeAmplifyUpTarget, page, refreshEventTracking, reset, resolveAmplifyUpTarget, resolveAmplifyUpUrls, setupEventTracking, testTracking, track, trackClick, trackContentEngagement, trackContentView, trackFormFieldInteraction, trackFormSubmit, verifyAWSConnection };
2327
+ export { AmplifyUpSDK, buildLayoutProviderUrl, buildPageRenderUrl, cleanupEventTracking, index_default as default, fetchPageConfig, getDiagnostics, getInstanceId2 as getInstanceId, getOrchestratorUrl, getSDK, getStatus, getTarget, getTrackingId, getUserId2 as getUserId, identify, init, isAmplifyUpTarget, isComposerPreview, isPreviewRequest, normalizeAmplifyUpTarget, page, refreshEventTracking, reset, resolveAmplifyUpTarget, resolveAmplifyUpUrls, setupComponentViewTracking, setupEventTracking, testTracking, track, trackClick, trackContentEngagement, trackContentView, trackFormFieldInteraction, trackFormSubmit, verifyAWSConnection };
2039
2328
  //# sourceMappingURL=index.mjs.map
2040
2329
  //# sourceMappingURL=index.mjs.map