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