@amplifyup/sdk 0.2.0 → 0.2.2
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/AmplifyRenderer.js +83 -110
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +83 -110
- package/dist/AmplifyRenderer.mjs.map +1 -1
- package/dist/index.js +82 -103
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +82 -103
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +103 -178
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +103 -178
- package/dist/react.mjs.map +1 -1
- package/dist/server.js +1 -1
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +1 -1
- package/dist/server.mjs.map +1 -1
- package/package.json +1 -1
package/dist/AmplifyRenderer.mjs
CHANGED
|
@@ -421,7 +421,7 @@ function isComposerPreview() {
|
|
|
421
421
|
if (window.self !== window.top && document.referrer) {
|
|
422
422
|
try {
|
|
423
423
|
const refUrl = new URL(document.referrer);
|
|
424
|
-
if (refUrl.hostname === "amplifyup.ai" || refUrl.hostname.endsWith(".amplifyup.ai") || refUrl.hostname === "localhost" && refUrl.port === "5001" || refUrl.pathname.includes("/dashboard/composer")
|
|
424
|
+
if (refUrl.hostname === "amplifyup.ai" || refUrl.hostname.endsWith(".amplifyup.ai") || refUrl.hostname === "localhost" && refUrl.port === "5001" || refUrl.pathname.includes("/dashboard/composer")) {
|
|
425
425
|
return true;
|
|
426
426
|
}
|
|
427
427
|
} catch {
|
|
@@ -1192,7 +1192,7 @@ var AmplifyUpSDK = class {
|
|
|
1192
1192
|
if (document.referrer) {
|
|
1193
1193
|
try {
|
|
1194
1194
|
const referrerUrl = new URL(document.referrer);
|
|
1195
|
-
if (referrerUrl.hostname === "localhost" && referrerUrl.port === "5001" || referrerUrl.pathname.includes("/dashboard/composer")
|
|
1195
|
+
if (referrerUrl.hostname === "localhost" && referrerUrl.port === "5001" || referrerUrl.pathname.includes("/dashboard/composer")) {
|
|
1196
1196
|
return true;
|
|
1197
1197
|
}
|
|
1198
1198
|
} catch {
|
|
@@ -1469,11 +1469,7 @@ var AmplifyUpSDK = class {
|
|
|
1469
1469
|
this.page(resumePath, { resumed: true });
|
|
1470
1470
|
this.lastTrackedPath = resumePath;
|
|
1471
1471
|
if (this.config?.debug) {
|
|
1472
|
-
console.log(
|
|
1473
|
-
"[AmplifyUp SDK] Idle resume page view",
|
|
1474
|
-
resumePath,
|
|
1475
|
-
`(hidden ${Math.round(idleMs / 6e4)}m)`
|
|
1476
|
-
);
|
|
1472
|
+
console.log("[AmplifyUp SDK] Idle resume page view", resumePath, `(hidden ${Math.round(idleMs / 6e4)}m)`);
|
|
1477
1473
|
}
|
|
1478
1474
|
}
|
|
1479
1475
|
noteActivity();
|
|
@@ -1493,12 +1489,7 @@ var AmplifyUpSDK = class {
|
|
|
1493
1489
|
}
|
|
1494
1490
|
state.visibleSince = null;
|
|
1495
1491
|
};
|
|
1496
|
-
const activityEvents = [
|
|
1497
|
-
"pointerdown",
|
|
1498
|
-
"keydown",
|
|
1499
|
-
"scroll",
|
|
1500
|
-
"touchstart"
|
|
1501
|
-
];
|
|
1492
|
+
const activityEvents = ["pointerdown", "keydown", "scroll", "touchstart"];
|
|
1502
1493
|
const onActivity = () => noteActivity();
|
|
1503
1494
|
window.addEventListener("scroll", onScroll, { passive: true });
|
|
1504
1495
|
document.addEventListener("visibilitychange", onVisibility);
|
|
@@ -1646,11 +1637,7 @@ var AmplifyUpSDK = class {
|
|
|
1646
1637
|
hosts.forEach((host) => observer.observe(host));
|
|
1647
1638
|
this.componentViewObservers.push(observer);
|
|
1648
1639
|
if (this.config?.debug) {
|
|
1649
|
-
console.log(
|
|
1650
|
-
"[AmplifyUp SDK] Component View tracking enabled for",
|
|
1651
|
-
hosts.length,
|
|
1652
|
-
"hosts"
|
|
1653
|
-
);
|
|
1640
|
+
console.log("[AmplifyUp SDK] Component View tracking enabled for", hosts.length, "hosts");
|
|
1654
1641
|
}
|
|
1655
1642
|
}
|
|
1656
1643
|
cleanupComponentViewTracking() {
|
|
@@ -2224,15 +2211,11 @@ Available Console Commands:
|
|
|
2224
2211
|
) : document;
|
|
2225
2212
|
if (!scopeRoot) {
|
|
2226
2213
|
if (this.config?.debug) {
|
|
2227
|
-
console.log(
|
|
2228
|
-
`[AmplifyUp SDK] Component host not found for ${eventConfig.componentId}`
|
|
2229
|
-
);
|
|
2214
|
+
console.log(`[AmplifyUp SDK] Component host not found for ${eventConfig.componentId}`);
|
|
2230
2215
|
}
|
|
2231
2216
|
return;
|
|
2232
2217
|
}
|
|
2233
|
-
targetElements = Array.from(
|
|
2234
|
-
scopeRoot.querySelectorAll(eventConfig.selector)
|
|
2235
|
-
);
|
|
2218
|
+
targetElements = Array.from(scopeRoot.querySelectorAll(eventConfig.selector));
|
|
2236
2219
|
if (scopeRoot instanceof Element && scopeRoot !== document.documentElement && scopeRoot.matches?.(eventConfig.selector)) {
|
|
2237
2220
|
targetElements.unshift(scopeRoot);
|
|
2238
2221
|
}
|
|
@@ -2265,7 +2248,9 @@ Available Console Commands:
|
|
|
2265
2248
|
});
|
|
2266
2249
|
}
|
|
2267
2250
|
if (this.config?.debug) {
|
|
2268
|
-
console.log(
|
|
2251
|
+
console.log(
|
|
2252
|
+
`[AmplifyUp SDK] Attached ${eventConfig.eventType} listener for ${eventConfig.eventName} on selector: ${eventConfig.selector}`
|
|
2253
|
+
);
|
|
2269
2254
|
}
|
|
2270
2255
|
});
|
|
2271
2256
|
});
|
|
@@ -2275,16 +2260,16 @@ Available Console Commands:
|
|
|
2275
2260
|
*/
|
|
2276
2261
|
mapEventType(eventType) {
|
|
2277
2262
|
const eventMap = {
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2263
|
+
click: "click",
|
|
2264
|
+
submit: "submit",
|
|
2265
|
+
focus: "focus",
|
|
2266
|
+
blur: "blur",
|
|
2267
|
+
hover: "mouseenter",
|
|
2268
|
+
change: "change",
|
|
2269
|
+
scroll: "scroll",
|
|
2270
|
+
view: "view",
|
|
2286
2271
|
// Handled separately with IntersectionObserver
|
|
2287
|
-
|
|
2272
|
+
custom: "custom"
|
|
2288
2273
|
};
|
|
2289
2274
|
return eventMap[eventType] || eventType;
|
|
2290
2275
|
}
|
|
@@ -2360,11 +2345,7 @@ Available Console Commands:
|
|
|
2360
2345
|
(entries) => {
|
|
2361
2346
|
entries.forEach((entry) => {
|
|
2362
2347
|
if (entry.isIntersecting) {
|
|
2363
|
-
this.handleTrackedEvent(
|
|
2364
|
-
new CustomEvent("view"),
|
|
2365
|
-
config,
|
|
2366
|
-
element
|
|
2367
|
-
);
|
|
2348
|
+
this.handleTrackedEvent(new CustomEvent("view"), config, element);
|
|
2368
2349
|
observer.unobserve(element);
|
|
2369
2350
|
}
|
|
2370
2351
|
});
|
|
@@ -2507,21 +2488,15 @@ Available Console Commands:
|
|
|
2507
2488
|
return;
|
|
2508
2489
|
}
|
|
2509
2490
|
if (event.data?.type === "AMPLIFYUP_FIELD_PATCH") {
|
|
2510
|
-
window.dispatchEvent(
|
|
2511
|
-
new CustomEvent("amplifyup:field-patch", { detail: event.data })
|
|
2512
|
-
);
|
|
2491
|
+
window.dispatchEvent(new CustomEvent("amplifyup:field-patch", { detail: event.data }));
|
|
2513
2492
|
return;
|
|
2514
2493
|
}
|
|
2515
2494
|
if (event.data?.type === "AMPLIFYUP_PROPS_PATCH") {
|
|
2516
|
-
window.dispatchEvent(
|
|
2517
|
-
new CustomEvent("amplifyup:props-patch", { detail: event.data })
|
|
2518
|
-
);
|
|
2495
|
+
window.dispatchEvent(new CustomEvent("amplifyup:props-patch", { detail: event.data }));
|
|
2519
2496
|
return;
|
|
2520
2497
|
}
|
|
2521
2498
|
if (event.data?.type === "AMPLIFYUP_LAYOUT_PATCH") {
|
|
2522
|
-
window.dispatchEvent(
|
|
2523
|
-
new CustomEvent("amplifyup:layout-patch", { detail: event.data })
|
|
2524
|
-
);
|
|
2499
|
+
window.dispatchEvent(new CustomEvent("amplifyup:layout-patch", { detail: event.data }));
|
|
2525
2500
|
return;
|
|
2526
2501
|
}
|
|
2527
2502
|
if (event.data?.type === "COMPONENT_DELETABLE_STATUS") {
|
|
@@ -2584,9 +2559,7 @@ Available Console Commands:
|
|
|
2584
2559
|
const { componentId, slotName, nodeId, isPageSlot } = event.data;
|
|
2585
2560
|
let element = null;
|
|
2586
2561
|
if (isPageSlot || slotName === "main" && !nodeId && !componentId) {
|
|
2587
|
-
element = document.querySelector(
|
|
2588
|
-
'[data-slot-source="page"]'
|
|
2589
|
-
);
|
|
2562
|
+
element = document.querySelector('[data-slot-source="page"]');
|
|
2590
2563
|
}
|
|
2591
2564
|
if (!element && nodeId && slotName) {
|
|
2592
2565
|
element = document.querySelector(
|
|
@@ -2594,9 +2567,7 @@ Available Console Commands:
|
|
|
2594
2567
|
);
|
|
2595
2568
|
}
|
|
2596
2569
|
if (!element && nodeId && !slotName) {
|
|
2597
|
-
element = document.querySelector(
|
|
2598
|
-
`[data-node-id="${nodeId}"]`
|
|
2599
|
-
);
|
|
2570
|
+
element = document.querySelector(`[data-node-id="${nodeId}"]`);
|
|
2600
2571
|
}
|
|
2601
2572
|
if (!element && slotName) {
|
|
2602
2573
|
element = document.querySelector(
|
|
@@ -2637,30 +2608,33 @@ Available Console Commands:
|
|
|
2637
2608
|
};
|
|
2638
2609
|
if (window.parent && window.parent !== window) {
|
|
2639
2610
|
const hierarchyEls = this.buildComponentHierarchy(element);
|
|
2640
|
-
window.parent.postMessage(
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2611
|
+
window.parent.postMessage(
|
|
2612
|
+
{
|
|
2613
|
+
type: "ELEMENT_POSITION",
|
|
2614
|
+
componentId: componentId || null,
|
|
2615
|
+
slotName: slotName || null,
|
|
2616
|
+
nodeId: nodeId || null,
|
|
2617
|
+
isPageSlot: !!isPageSlot || element.getAttribute("data-slot-source") === "page",
|
|
2618
|
+
hierarchy: hierarchyEls.map((el, index) => {
|
|
2619
|
+
const elComponentId = el.getAttribute("data-amplifyup-component") || el.getAttribute("data-component-id");
|
|
2620
|
+
const elSlotName = el.getAttribute("data-amplifyup-slot") || el.getAttribute("data-slot-id");
|
|
2621
|
+
const isSlot = !elComponentId && !!elSlotName;
|
|
2622
|
+
const pageSlot = isSlot && el.getAttribute("data-slot-source") === "page";
|
|
2623
|
+
return {
|
|
2624
|
+
index,
|
|
2625
|
+
componentId: elComponentId,
|
|
2626
|
+
componentName: pageSlot ? "Page" : el.getAttribute("data-component-name"),
|
|
2627
|
+
slotName: isSlot ? elSlotName : null,
|
|
2628
|
+
isSlot,
|
|
2629
|
+
isPageSlot: pageSlot,
|
|
2630
|
+
nodeId: el.getAttribute("data-node-id") || (isSlot ? el.getAttribute("data-parent-node-id") : null)
|
|
2631
|
+
};
|
|
2632
|
+
}),
|
|
2633
|
+
position,
|
|
2634
|
+
bounds
|
|
2635
|
+
},
|
|
2636
|
+
"*"
|
|
2637
|
+
);
|
|
2664
2638
|
}
|
|
2665
2639
|
} else {
|
|
2666
2640
|
console.warn("[AmplifyUp SDK] Element not found for position request");
|
|
@@ -2676,7 +2650,11 @@ Available Console Commands:
|
|
|
2676
2650
|
switch (message.type) {
|
|
2677
2651
|
case "ENABLE_HIGHLIGHTING":
|
|
2678
2652
|
case "UPDATE_HIGHLIGHTING":
|
|
2679
|
-
console.log(
|
|
2653
|
+
console.log(
|
|
2654
|
+
"[AmplifyUp SDK] Enabling highlighting with registry:",
|
|
2655
|
+
message.componentRegistry?.length || 0,
|
|
2656
|
+
"components"
|
|
2657
|
+
);
|
|
2680
2658
|
this.enableHighlighting(
|
|
2681
2659
|
message.componentRegistry || [],
|
|
2682
2660
|
message.highlightComponents ?? true,
|
|
@@ -2736,12 +2714,15 @@ Available Console Commands:
|
|
|
2736
2714
|
const tagName = target.tagName.toLowerCase();
|
|
2737
2715
|
const text = (target.textContent || "").replace(/\s+/g, " ").trim().substring(0, 80);
|
|
2738
2716
|
if (window.parent && window.parent !== window) {
|
|
2739
|
-
window.parent.postMessage(
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2717
|
+
window.parent.postMessage(
|
|
2718
|
+
{
|
|
2719
|
+
type: "ELEMENT_CLICKED_FOR_EVENT",
|
|
2720
|
+
selector,
|
|
2721
|
+
tagName,
|
|
2722
|
+
text
|
|
2723
|
+
},
|
|
2724
|
+
"*"
|
|
2725
|
+
);
|
|
2745
2726
|
}
|
|
2746
2727
|
};
|
|
2747
2728
|
document.addEventListener("click", this.eventSelectionClickHandler, true);
|
|
@@ -2767,9 +2748,7 @@ Available Console Commands:
|
|
|
2767
2748
|
return "[" + attr.name + '="' + attr.value + '"]';
|
|
2768
2749
|
}
|
|
2769
2750
|
if (el.className && typeof el.className === "string") {
|
|
2770
|
-
const classes = el.className.split(" ").filter(
|
|
2771
|
-
(c) => c && !c.startsWith("has-") && !c.includes("selectable") && !c.includes("selected")
|
|
2772
|
-
);
|
|
2751
|
+
const classes = el.className.split(" ").filter((c) => c && !c.startsWith("has-") && !c.includes("selectable") && !c.includes("selected"));
|
|
2773
2752
|
if (classes.length > 0) {
|
|
2774
2753
|
return el.tagName.toLowerCase() + "." + classes[0];
|
|
2775
2754
|
}
|
|
@@ -2819,9 +2798,7 @@ Available Console Commands:
|
|
|
2819
2798
|
}
|
|
2820
2799
|
});
|
|
2821
2800
|
if (containing.length === 0) return null;
|
|
2822
|
-
const innermost = containing.filter(
|
|
2823
|
-
(el) => !containing.some((other) => other !== el && el.contains(other))
|
|
2824
|
-
);
|
|
2801
|
+
const innermost = containing.filter((el) => !containing.some((other) => other !== el && el.contains(other)));
|
|
2825
2802
|
if (innermost.length === 1) return innermost[0];
|
|
2826
2803
|
let best = innermost[0];
|
|
2827
2804
|
let bestArea = Infinity;
|
|
@@ -2938,9 +2915,7 @@ Available Console Commands:
|
|
|
2938
2915
|
*/
|
|
2939
2916
|
enableHighlighting(componentRegistry, highlightComponents, showZones) {
|
|
2940
2917
|
if (typeof document === "undefined") return;
|
|
2941
|
-
const previouslySelected = Array.from(
|
|
2942
|
-
document.querySelectorAll(".amplifyup-selected")
|
|
2943
|
-
);
|
|
2918
|
+
const previouslySelected = Array.from(document.querySelectorAll(".amplifyup-selected"));
|
|
2944
2919
|
this.componentRegistry = componentRegistry;
|
|
2945
2920
|
this.highlightingEnabled = true;
|
|
2946
2921
|
this.highlightComponentsEnabled = highlightComponents;
|
|
@@ -3313,10 +3288,7 @@ Available Console Commands:
|
|
|
3313
3288
|
if (shouldReapply && this.highlightingEnabled) {
|
|
3314
3289
|
setTimeout(() => {
|
|
3315
3290
|
if (this.highlightingEnabled) {
|
|
3316
|
-
this.applyComponentHighlights(
|
|
3317
|
-
this.highlightComponentsEnabled,
|
|
3318
|
-
this.showZonesEnabled
|
|
3319
|
-
);
|
|
3291
|
+
this.applyComponentHighlights(this.highlightComponentsEnabled, this.showZonesEnabled);
|
|
3320
3292
|
}
|
|
3321
3293
|
}, 100);
|
|
3322
3294
|
}
|
|
@@ -3325,7 +3297,13 @@ Available Console Commands:
|
|
|
3325
3297
|
childList: true,
|
|
3326
3298
|
subtree: true,
|
|
3327
3299
|
attributes: true,
|
|
3328
|
-
attributeFilter: [
|
|
3300
|
+
attributeFilter: [
|
|
3301
|
+
"data-amplifyup-component",
|
|
3302
|
+
"data-component-id",
|
|
3303
|
+
"data-amplifyup-slot",
|
|
3304
|
+
"data-slot-id",
|
|
3305
|
+
"data-slot-empty"
|
|
3306
|
+
]
|
|
3329
3307
|
});
|
|
3330
3308
|
}
|
|
3331
3309
|
/**
|
|
@@ -3339,9 +3317,7 @@ Available Console Commands:
|
|
|
3339
3317
|
this.teardownComposerDragDrop();
|
|
3340
3318
|
if (opts?.clearSelection !== false && typeof window !== "undefined") {
|
|
3341
3319
|
window.__AMPLIFYUP_COMPOSER_EDIT__ = false;
|
|
3342
|
-
window.dispatchEvent(
|
|
3343
|
-
new CustomEvent("amplifyup:composer-edit", { detail: { enabled: false } })
|
|
3344
|
-
);
|
|
3320
|
+
window.dispatchEvent(new CustomEvent("amplifyup:composer-edit", { detail: { enabled: false } }));
|
|
3345
3321
|
}
|
|
3346
3322
|
if (this.mutationObserver) {
|
|
3347
3323
|
this.mutationObserver.disconnect();
|
|
@@ -3499,7 +3475,10 @@ Available Console Commands:
|
|
|
3499
3475
|
e.stopPropagation();
|
|
3500
3476
|
this.sendSelectionMessage(htmlEl, hierarchy);
|
|
3501
3477
|
if (window.parent && window.parent !== window) {
|
|
3502
|
-
window.parent.postMessage(
|
|
3478
|
+
window.parent.postMessage(
|
|
3479
|
+
{ type: "CHECK_COMPONENT_DELETABLE", componentId: component.component_id },
|
|
3480
|
+
"*"
|
|
3481
|
+
);
|
|
3503
3482
|
}
|
|
3504
3483
|
};
|
|
3505
3484
|
htmlEl.addEventListener("click", handleClick);
|
|
@@ -3719,13 +3698,7 @@ function ComponentContextProvider({
|
|
|
3719
3698
|
componentId
|
|
3720
3699
|
}) {
|
|
3721
3700
|
const next = hydratePageResourceProps(props || {}, getPageResourceFields());
|
|
3722
|
-
return /* @__PURE__ */ jsx(
|
|
3723
|
-
ComponentContext.Provider,
|
|
3724
|
-
{
|
|
3725
|
-
value: { slots, props: next, layoutNodeId, componentId },
|
|
3726
|
-
children
|
|
3727
|
-
}
|
|
3728
|
-
);
|
|
3701
|
+
return /* @__PURE__ */ jsx(ComponentContext.Provider, { value: { slots, props: next, layoutNodeId, componentId }, children });
|
|
3729
3702
|
}
|
|
3730
3703
|
var REGISTRY_BRAND = Symbol.for("amplifyup.componentRegistry");
|
|
3731
3704
|
var isComponentRegistry = (value) => !!value && typeof value === "object" && value[REGISTRY_BRAND] === true;
|