@amplifyup/sdk 0.1.30 → 0.1.32

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.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { P as PageConfig, C as ContentSource, A as AmplifyContentMeta, E as EventTrackingConfig$1, a as CDPAdapter, b as AmplifyUpConfig, c as EventProperties, I as IdentifyInput, d as IdentifyTraits, e as ProfileFieldsInput, f as AmplifyUpTarget } from './types-6qEnwLda.mjs';
2
- export { Z as ZoneConfig, i as isAmplifyUpTarget, n as normalizeAmplifyUpTarget, r as resolveAmplifyUpTarget, g as resolveAmplifyUpUrls } from './types-6qEnwLda.mjs';
1
+ import { P as PageConfig, C as ContentSource, A as AmplifyContentMeta, E as EventTrackingConfig$1, a as CDPAdapter, b as AmplifyUpConfig, c as EventProperties, I as IdentifyInput, d as IdentifyTraits, e as ProfileFieldsInput, f as AmplifyUpTarget } from './types-npF_lNoq.mjs';
2
+ export { Z as ZoneConfig, i as isAmplifyUpTarget, n as normalizeAmplifyUpTarget, r as resolveAmplifyUpTarget, g as resolveAmplifyUpUrls } from './types-npF_lNoq.mjs';
3
3
  export { i as isComposerPreview, a as isPreviewRequest } from './preview-BMrIgUvp.mjs';
4
4
 
5
5
  interface FetchContentResult {
@@ -122,6 +122,7 @@ interface EventTrackingConfig {
122
122
  selector?: string;
123
123
  description?: string;
124
124
  properties?: string[];
125
+ staticProperties?: Record<string, string>;
125
126
  enabled?: boolean;
126
127
  componentId?: string | null;
127
128
  componentName?: string | null;
@@ -145,6 +146,8 @@ declare class AmplifyUpSDK {
145
146
  private showZonesEnabled;
146
147
  private componentRegistry;
147
148
  private messageListener;
149
+ private composerBoundsRaf;
150
+ private composerBoundsScrollListener;
148
151
  private mutationObserver;
149
152
  private composerDragHandlers;
150
153
  /** Last slot highlighted during Composer drag — avoid clear/re-add flicker. */
@@ -414,6 +417,9 @@ declare class AmplifyUpSDK {
414
417
  private teardownComposerDragDrop;
415
418
  private clearComposerSelection;
416
419
  private markComposerSelection;
420
+ private postComposerSelectionBounds;
421
+ private setupComposerBoundsTracking;
422
+ private teardownComposerBoundsTracking;
417
423
  /** Visual outlines for Composer (direct iframe path — no preview-frame proxy). */
418
424
  private injectComposerHighlightStyles;
419
425
  /**
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { P as PageConfig, C as ContentSource, A as AmplifyContentMeta, E as EventTrackingConfig$1, a as CDPAdapter, b as AmplifyUpConfig, c as EventProperties, I as IdentifyInput, d as IdentifyTraits, e as ProfileFieldsInput, f as AmplifyUpTarget } from './types-6qEnwLda.js';
2
- export { Z as ZoneConfig, i as isAmplifyUpTarget, n as normalizeAmplifyUpTarget, r as resolveAmplifyUpTarget, g as resolveAmplifyUpUrls } from './types-6qEnwLda.js';
1
+ import { P as PageConfig, C as ContentSource, A as AmplifyContentMeta, E as EventTrackingConfig$1, a as CDPAdapter, b as AmplifyUpConfig, c as EventProperties, I as IdentifyInput, d as IdentifyTraits, e as ProfileFieldsInput, f as AmplifyUpTarget } from './types-npF_lNoq.js';
2
+ export { Z as ZoneConfig, i as isAmplifyUpTarget, n as normalizeAmplifyUpTarget, r as resolveAmplifyUpTarget, g as resolveAmplifyUpUrls } from './types-npF_lNoq.js';
3
3
  export { i as isComposerPreview, a as isPreviewRequest } from './preview-BMrIgUvp.js';
4
4
 
5
5
  interface FetchContentResult {
@@ -122,6 +122,7 @@ interface EventTrackingConfig {
122
122
  selector?: string;
123
123
  description?: string;
124
124
  properties?: string[];
125
+ staticProperties?: Record<string, string>;
125
126
  enabled?: boolean;
126
127
  componentId?: string | null;
127
128
  componentName?: string | null;
@@ -145,6 +146,8 @@ declare class AmplifyUpSDK {
145
146
  private showZonesEnabled;
146
147
  private componentRegistry;
147
148
  private messageListener;
149
+ private composerBoundsRaf;
150
+ private composerBoundsScrollListener;
148
151
  private mutationObserver;
149
152
  private composerDragHandlers;
150
153
  /** Last slot highlighted during Composer drag — avoid clear/re-add flicker. */
@@ -414,6 +417,9 @@ declare class AmplifyUpSDK {
414
417
  private teardownComposerDragDrop;
415
418
  private clearComposerSelection;
416
419
  private markComposerSelection;
420
+ private postComposerSelectionBounds;
421
+ private setupComposerBoundsTracking;
422
+ private teardownComposerBoundsTracking;
417
423
  /** Visual outlines for Composer (direct iframe path — no preview-frame proxy). */
418
424
  private injectComposerHighlightStyles;
419
425
  /**
package/dist/index.js CHANGED
@@ -556,6 +556,8 @@ var AmplifyUpSDK = class {
556
556
  this.showZonesEnabled = false;
557
557
  this.componentRegistry = [];
558
558
  this.messageListener = null;
559
+ this.composerBoundsRaf = 0;
560
+ this.composerBoundsScrollListener = null;
559
561
  this.mutationObserver = null;
560
562
  this.composerDragHandlers = null;
561
563
  /** Last slot highlighted during Composer drag — avoid clear/re-add flicker. */
@@ -1609,6 +1611,11 @@ Available Console Commands:
1609
1611
  if (config.componentName) {
1610
1612
  properties.componentName = config.componentName;
1611
1613
  }
1614
+ if (config.staticProperties) {
1615
+ for (const [key, value] of Object.entries(config.staticProperties)) {
1616
+ if (key) properties[key] = value;
1617
+ }
1618
+ }
1612
1619
  if (config.properties && config.properties.length > 0) {
1613
1620
  config.properties.forEach((prop) => {
1614
1621
  const dataAttrValue = element.getAttribute(`data-${prop}`);
@@ -1975,13 +1982,23 @@ Available Console Commands:
1975
1982
  document.removeEventListener("click", this.eventSelectionClickHandler, true);
1976
1983
  this.eventSelectionClickHandler = null;
1977
1984
  }
1985
+ if (enabled && typeof window !== "undefined" && window.__AMPLIFYUP_PREVIEW_MODE__) {
1986
+ return;
1987
+ }
1978
1988
  if (enabled) {
1979
1989
  this.eventSelectionClickHandler = (e) => {
1980
- const target = e.target;
1981
- if (!target) return;
1990
+ const raw = e.target;
1991
+ if (!raw) return;
1992
+ const interactive = raw.closest(
1993
+ 'a, button, [role="button"], input, select, textarea, [data-el], [data-amplifyup-component], [data-component-id]'
1994
+ );
1995
+ const target = interactive instanceof HTMLElement ? interactive : raw;
1996
+ e.preventDefault();
1997
+ e.stopPropagation();
1998
+ e.stopImmediatePropagation();
1982
1999
  const selector = this.generateSelectorForElement(target);
1983
2000
  const tagName = target.tagName.toLowerCase();
1984
- const text = target.textContent?.trim().substring(0, 50) || "";
2001
+ const text = (target.textContent || "").replace(/\s+/g, " ").trim().substring(0, 80);
1985
2002
  if (window.parent && window.parent !== window) {
1986
2003
  window.parent.postMessage({
1987
2004
  type: "ELEMENT_CLICKED_FOR_EVENT",
@@ -1990,9 +2007,6 @@ Available Console Commands:
1990
2007
  text
1991
2008
  }, "*");
1992
2009
  }
1993
- if (tagName === "a") {
1994
- e.preventDefault();
1995
- }
1996
2010
  };
1997
2011
  document.addEventListener("click", this.eventSelectionClickHandler, true);
1998
2012
  if (this.config?.debug) {
@@ -2202,6 +2216,7 @@ Available Console Commands:
2202
2216
  this.applyComponentHighlights(highlightComponents, showZones);
2203
2217
  this.setupMutationObserver();
2204
2218
  this.setupComposerDragDrop();
2219
+ this.setupComposerBoundsTracking();
2205
2220
  }
2206
2221
  previouslySelected.forEach((el) => {
2207
2222
  if (document.contains(el)) {
@@ -2356,6 +2371,52 @@ Available Console Commands:
2356
2371
  this.clearComposerSelection();
2357
2372
  element.classList.add("amplifyup-selected");
2358
2373
  }
2374
+ postComposerSelectionBounds() {
2375
+ if (typeof document === "undefined") return;
2376
+ if (!window.parent || window.parent === window) return;
2377
+ const el = document.querySelector(".amplifyup-selected");
2378
+ if (!el) return;
2379
+ const rect = el.getBoundingClientRect();
2380
+ window.parent.postMessage(
2381
+ {
2382
+ type: "SELECTION_BOUNDS",
2383
+ bounds: {
2384
+ top: rect.top,
2385
+ left: rect.left,
2386
+ width: rect.width,
2387
+ height: rect.height
2388
+ }
2389
+ },
2390
+ "*"
2391
+ );
2392
+ }
2393
+ setupComposerBoundsTracking() {
2394
+ if (typeof document === "undefined") return;
2395
+ this.teardownComposerBoundsTracking();
2396
+ const onScroll = () => {
2397
+ if (this.composerBoundsRaf) return;
2398
+ this.composerBoundsRaf = requestAnimationFrame(() => {
2399
+ this.composerBoundsRaf = 0;
2400
+ this.postComposerSelectionBounds();
2401
+ });
2402
+ };
2403
+ this.composerBoundsScrollListener = onScroll;
2404
+ document.addEventListener("scroll", onScroll, { capture: true, passive: true });
2405
+ window.addEventListener("scroll", onScroll, { capture: true, passive: true });
2406
+ window.addEventListener("resize", onScroll);
2407
+ }
2408
+ teardownComposerBoundsTracking() {
2409
+ const onScroll = this.composerBoundsScrollListener;
2410
+ this.composerBoundsScrollListener = null;
2411
+ if (this.composerBoundsRaf) {
2412
+ cancelAnimationFrame(this.composerBoundsRaf);
2413
+ this.composerBoundsRaf = 0;
2414
+ }
2415
+ if (!onScroll || typeof document === "undefined") return;
2416
+ document.removeEventListener("scroll", onScroll, true);
2417
+ window.removeEventListener("scroll", onScroll, true);
2418
+ window.removeEventListener("resize", onScroll);
2419
+ }
2359
2420
  /** Visual outlines for Composer (direct iframe path — no preview-frame proxy). */
2360
2421
  injectComposerHighlightStyles(highlightComponents, showZones) {
2361
2422
  if (typeof document === "undefined") return;
@@ -2523,6 +2584,7 @@ Available Console Commands:
2523
2584
  if (typeof document === "undefined") return;
2524
2585
  const clearSelection = opts?.clearSelection !== false;
2525
2586
  this.highlightingEnabled = false;
2587
+ this.teardownComposerBoundsTracking();
2526
2588
  this.teardownComposerDragDrop();
2527
2589
  if (opts?.clearSelection !== false && typeof window !== "undefined") {
2528
2590
  window.__AMPLIFYUP_COMPOSER_EDIT__ = false;