@amplifyup/sdk 0.1.13 → 0.1.15
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.d.mts +6 -1
- package/dist/AmplifyRenderer.d.ts +6 -1
- package/dist/AmplifyRenderer.js +48 -10
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +48 -10
- package/dist/AmplifyRenderer.mjs.map +1 -1
- package/dist/index.js +34 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -2
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +6 -1
- package/dist/react.d.ts +6 -1
- package/dist/react.js +51 -11
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +51 -11
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -27,7 +27,12 @@ interface AmplifyRendererProps {
|
|
|
27
27
|
* Optional empty state component (when no content is configured)
|
|
28
28
|
*/
|
|
29
29
|
emptyComponent?: ReactNode;
|
|
30
|
+
/**
|
|
31
|
+
* Force Composer page-slot wrapper (avoids SSR miss when window isn't available yet).
|
|
32
|
+
* When true, root components stay under [data-slot-source="page"] so hierarchy can climb to Page.
|
|
33
|
+
*/
|
|
34
|
+
composerPreview?: boolean;
|
|
30
35
|
}
|
|
31
|
-
declare function AmplifyRenderer({ renderComponent, pageConfig: serverPageConfig, loadingComponent, errorComponent, emptyComponent, }: AmplifyRendererProps): react_jsx_runtime.JSX.Element | null;
|
|
36
|
+
declare function AmplifyRenderer({ renderComponent, pageConfig: serverPageConfig, loadingComponent, errorComponent, emptyComponent, composerPreview, }: AmplifyRendererProps): react_jsx_runtime.JSX.Element | null;
|
|
32
37
|
|
|
33
38
|
export { AmplifyRenderer };
|
|
@@ -27,7 +27,12 @@ interface AmplifyRendererProps {
|
|
|
27
27
|
* Optional empty state component (when no content is configured)
|
|
28
28
|
*/
|
|
29
29
|
emptyComponent?: ReactNode;
|
|
30
|
+
/**
|
|
31
|
+
* Force Composer page-slot wrapper (avoids SSR miss when window isn't available yet).
|
|
32
|
+
* When true, root components stay under [data-slot-source="page"] so hierarchy can climb to Page.
|
|
33
|
+
*/
|
|
34
|
+
composerPreview?: boolean;
|
|
30
35
|
}
|
|
31
|
-
declare function AmplifyRenderer({ renderComponent, pageConfig: serverPageConfig, loadingComponent, errorComponent, emptyComponent, }: AmplifyRendererProps): react_jsx_runtime.JSX.Element | null;
|
|
36
|
+
declare function AmplifyRenderer({ renderComponent, pageConfig: serverPageConfig, loadingComponent, errorComponent, emptyComponent, composerPreview, }: AmplifyRendererProps): react_jsx_runtime.JSX.Element | null;
|
|
32
37
|
|
|
33
38
|
export { AmplifyRenderer };
|
package/dist/AmplifyRenderer.js
CHANGED
|
@@ -1225,6 +1225,11 @@ Available Console Commands:
|
|
|
1225
1225
|
`[data-node-id="${nodeId}"]`
|
|
1226
1226
|
);
|
|
1227
1227
|
}
|
|
1228
|
+
if (!element && slotName) {
|
|
1229
|
+
element = document.querySelector(
|
|
1230
|
+
`[data-slot-source="page"][data-slot-id="${slotName}"], [data-slot-source="page"][data-amplifyup-slot="${slotName}"]`
|
|
1231
|
+
);
|
|
1232
|
+
}
|
|
1228
1233
|
if (!element && slotName) {
|
|
1229
1234
|
element = document.querySelector(
|
|
1230
1235
|
`[data-amplifyup-slot="${slotName}"], [data-slot-id="${slotName}"]`
|
|
@@ -1257,12 +1262,28 @@ Available Console Commands:
|
|
|
1257
1262
|
height: rect.height
|
|
1258
1263
|
};
|
|
1259
1264
|
if (window.parent && window.parent !== window) {
|
|
1265
|
+
const hierarchyEls = this.buildComponentHierarchy(element);
|
|
1260
1266
|
window.parent.postMessage({
|
|
1261
1267
|
type: "ELEMENT_POSITION",
|
|
1262
1268
|
componentId: componentId || null,
|
|
1263
1269
|
slotName: slotName || null,
|
|
1264
1270
|
nodeId: nodeId || null,
|
|
1265
|
-
isPageSlot: !!isPageSlot,
|
|
1271
|
+
isPageSlot: !!isPageSlot || element.getAttribute("data-slot-source") === "page",
|
|
1272
|
+
hierarchy: hierarchyEls.map((el, index) => {
|
|
1273
|
+
const elComponentId = el.getAttribute("data-amplifyup-component") || el.getAttribute("data-component-id");
|
|
1274
|
+
const elSlotName = el.getAttribute("data-amplifyup-slot") || el.getAttribute("data-slot-id");
|
|
1275
|
+
const isSlot = !elComponentId && !!elSlotName;
|
|
1276
|
+
const pageSlot = isSlot && el.getAttribute("data-slot-source") === "page";
|
|
1277
|
+
return {
|
|
1278
|
+
index,
|
|
1279
|
+
componentId: elComponentId,
|
|
1280
|
+
componentName: pageSlot ? "Page" : el.getAttribute("data-component-name"),
|
|
1281
|
+
slotName: isSlot ? elSlotName : null,
|
|
1282
|
+
isSlot,
|
|
1283
|
+
isPageSlot: pageSlot,
|
|
1284
|
+
nodeId: el.getAttribute("data-node-id") || (isSlot ? el.getAttribute("data-parent-node-id") : null)
|
|
1285
|
+
};
|
|
1286
|
+
}),
|
|
1266
1287
|
position,
|
|
1267
1288
|
bounds
|
|
1268
1289
|
}, "*");
|
|
@@ -1819,13 +1840,24 @@ Available Console Commands:
|
|
|
1819
1840
|
buildComponentHierarchy(element) {
|
|
1820
1841
|
const hierarchy = [];
|
|
1821
1842
|
let current = element;
|
|
1843
|
+
let sawPageSlot = false;
|
|
1822
1844
|
while (current) {
|
|
1823
1845
|
if (current.hasAttribute("data-amplifyup-component") || current.hasAttribute("data-component-id") || current.hasAttribute("data-amplifyup-slot") || current.hasAttribute("data-slot-id")) {
|
|
1824
1846
|
hierarchy.push(current);
|
|
1847
|
+
if (current.getAttribute("data-slot-source") === "page") {
|
|
1848
|
+
sawPageSlot = true;
|
|
1849
|
+
}
|
|
1825
1850
|
}
|
|
1826
1851
|
current = current.parentElement;
|
|
1827
1852
|
}
|
|
1828
|
-
|
|
1853
|
+
const ordered = hierarchy.reverse();
|
|
1854
|
+
if (!sawPageSlot) {
|
|
1855
|
+
const pageSlot = element.closest('[data-slot-source="page"]');
|
|
1856
|
+
if (pageSlot && !ordered.includes(pageSlot)) {
|
|
1857
|
+
ordered.unshift(pageSlot);
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1860
|
+
return ordered;
|
|
1829
1861
|
}
|
|
1830
1862
|
/**
|
|
1831
1863
|
* Send selection message to orchestrator (includes element bounds for overlay positioning).
|
|
@@ -2002,7 +2034,8 @@ function AmplifyRenderer({
|
|
|
2002
2034
|
pageConfig: serverPageConfig,
|
|
2003
2035
|
loadingComponent,
|
|
2004
2036
|
errorComponent,
|
|
2005
|
-
emptyComponent
|
|
2037
|
+
emptyComponent,
|
|
2038
|
+
composerPreview
|
|
2006
2039
|
}) {
|
|
2007
2040
|
const clientHook = useAmplifyUp();
|
|
2008
2041
|
const pageConfig = serverPageConfig || clientHook.pageConfig || null;
|
|
@@ -2061,7 +2094,9 @@ function AmplifyRenderer({
|
|
|
2061
2094
|
if (!pageConfig) {
|
|
2062
2095
|
return;
|
|
2063
2096
|
}
|
|
2064
|
-
|
|
2097
|
+
const rawTree2 = pageConfig.layoutTree;
|
|
2098
|
+
const normalizedTree = Array.isArray(rawTree2) ? rawTree2 : rawTree2 && typeof rawTree2 === "object" && rawTree2.componentId ? [rawTree2] : [];
|
|
2099
|
+
if (normalizedTree.length === 0) {
|
|
2065
2100
|
if (typeof window !== "undefined" && window.parent && window.parent !== window) {
|
|
2066
2101
|
window.parent.postMessage({
|
|
2067
2102
|
type: "COMPONENT_TREE",
|
|
@@ -2073,6 +2108,7 @@ function AmplifyRenderer({
|
|
|
2073
2108
|
const convertLayoutTreeToComponentTree = (nodes, parentId = null) => {
|
|
2074
2109
|
const result = [];
|
|
2075
2110
|
nodes.forEach((node) => {
|
|
2111
|
+
if (!node) return;
|
|
2076
2112
|
const treeNode = {
|
|
2077
2113
|
id: node.id,
|
|
2078
2114
|
componentId: node.componentId,
|
|
@@ -2083,8 +2119,9 @@ function AmplifyRenderer({
|
|
|
2083
2119
|
};
|
|
2084
2120
|
if (node.slots && node.slots.length > 0) {
|
|
2085
2121
|
node.slots.forEach((slot) => {
|
|
2086
|
-
|
|
2087
|
-
|
|
2122
|
+
const kids = Array.isArray(slot?.children) ? slot.children : [];
|
|
2123
|
+
if (kids.length > 0) {
|
|
2124
|
+
const slotChildren = convertLayoutTreeToComponentTree(kids, node.id);
|
|
2088
2125
|
treeNode.children.push(...slotChildren);
|
|
2089
2126
|
}
|
|
2090
2127
|
});
|
|
@@ -2093,7 +2130,7 @@ function AmplifyRenderer({
|
|
|
2093
2130
|
});
|
|
2094
2131
|
return result;
|
|
2095
2132
|
};
|
|
2096
|
-
const layoutTree2 =
|
|
2133
|
+
const layoutTree2 = normalizedTree;
|
|
2097
2134
|
const componentTree = convertLayoutTreeToComponentTree(layoutTree2);
|
|
2098
2135
|
const describeLayoutTree = (nodes, depth = 0) => {
|
|
2099
2136
|
if (!nodes?.length) return "";
|
|
@@ -2266,11 +2303,12 @@ function AmplifyRenderer({
|
|
|
2266
2303
|
childrenCount: childrenToRender.length
|
|
2267
2304
|
});
|
|
2268
2305
|
} else {
|
|
2269
|
-
childrenToRender = slot.children;
|
|
2306
|
+
childrenToRender = Array.isArray(slot.children) ? slot.children : [];
|
|
2270
2307
|
console.log(`[AmplifyRenderer] Using direct children for slot ${slot.slotId}`, {
|
|
2271
2308
|
childrenCount: childrenToRender.length
|
|
2272
2309
|
});
|
|
2273
2310
|
}
|
|
2311
|
+
const safeChildren = Array.isArray(childrenToRender) ? childrenToRender : [];
|
|
2274
2312
|
slotChildren[slot.slotId] = /* @__PURE__ */ jsxRuntime.jsx(
|
|
2275
2313
|
"div",
|
|
2276
2314
|
{
|
|
@@ -2279,7 +2317,7 @@ function AmplifyRenderer({
|
|
|
2279
2317
|
"data-zone-id": slot.zoneId || void 0,
|
|
2280
2318
|
"data-parent-node-id": node.id,
|
|
2281
2319
|
"data-parent-component-id": node.componentId,
|
|
2282
|
-
children:
|
|
2320
|
+
children: safeChildren.filter(Boolean).map((child) => renderNode(child))
|
|
2283
2321
|
},
|
|
2284
2322
|
slot.slotId
|
|
2285
2323
|
);
|
|
@@ -2303,7 +2341,7 @@ function AmplifyRenderer({
|
|
|
2303
2341
|
if (layoutTree.length === 0) {
|
|
2304
2342
|
return /* @__PURE__ */ jsxRuntime.jsx("main", { children: emptyComponent || /* @__PURE__ */ jsxRuntime.jsx("div", { className: "container mx-auto px-4 py-16", children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground", children: "No content configured for this page." }) }) });
|
|
2305
2343
|
}
|
|
2306
|
-
return /* @__PURE__ */ jsxRuntime.jsx("main", { children: isComposerPreview() ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2344
|
+
return /* @__PURE__ */ jsxRuntime.jsx("main", { children: composerPreview || isComposerPreview() ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2307
2345
|
"div",
|
|
2308
2346
|
{
|
|
2309
2347
|
"data-slot-id": "main",
|