@amplifyup/sdk 0.1.23 → 0.1.24
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 +61 -4
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +62 -5
- package/dist/AmplifyRenderer.mjs.map +1 -1
- package/dist/react.d.mts +20 -1
- package/dist/react.d.ts +20 -1
- package/dist/react.js +126 -5
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +127 -7
- package/dist/react.mjs.map +1 -1
- package/package.json +6 -3
package/dist/AmplifyRenderer.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { createContext, useState, useEffect, Fragment as Fragment$1, useContext } from 'react';
|
|
2
|
+
import { createContext, useState, useEffect, Fragment as Fragment$1, useContext, Component } from 'react';
|
|
3
3
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
4
|
+
import 'marked';
|
|
4
5
|
|
|
5
6
|
/* @amplifyup/sdk - https://amplifyup.ai */
|
|
6
7
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
@@ -2507,6 +2508,53 @@ function useAmplifyUp() {
|
|
|
2507
2508
|
}
|
|
2508
2509
|
return context;
|
|
2509
2510
|
}
|
|
2511
|
+
var ComponentRenderBoundary = class extends Component {
|
|
2512
|
+
constructor() {
|
|
2513
|
+
super(...arguments);
|
|
2514
|
+
this.state = { error: null };
|
|
2515
|
+
}
|
|
2516
|
+
static getDerivedStateFromError(error) {
|
|
2517
|
+
return { error };
|
|
2518
|
+
}
|
|
2519
|
+
componentDidCatch(error) {
|
|
2520
|
+
console.error(
|
|
2521
|
+
`[AmplifyRenderer] "${this.props.componentId}" (${this.props.nodeId}) threw while rendering:`,
|
|
2522
|
+
error
|
|
2523
|
+
);
|
|
2524
|
+
}
|
|
2525
|
+
render() {
|
|
2526
|
+
if (this.state.error) {
|
|
2527
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2528
|
+
return /* @__PURE__ */ jsxs(
|
|
2529
|
+
"div",
|
|
2530
|
+
{
|
|
2531
|
+
"data-amplifyup-render-error": "",
|
|
2532
|
+
"data-component-id": this.props.componentId,
|
|
2533
|
+
"data-node-id": this.props.nodeId,
|
|
2534
|
+
style: {
|
|
2535
|
+
margin: "1rem 0",
|
|
2536
|
+
padding: "0.75rem 1rem",
|
|
2537
|
+
border: "1px solid #fca5a5",
|
|
2538
|
+
borderRadius: "0.5rem",
|
|
2539
|
+
background: "#fef2f2",
|
|
2540
|
+
color: "#991b1b",
|
|
2541
|
+
fontSize: "0.875rem"
|
|
2542
|
+
},
|
|
2543
|
+
children: [
|
|
2544
|
+
'Component "',
|
|
2545
|
+
this.props.componentId,
|
|
2546
|
+
'" failed to render:',
|
|
2547
|
+
" ",
|
|
2548
|
+
this.state.error.message
|
|
2549
|
+
]
|
|
2550
|
+
}
|
|
2551
|
+
);
|
|
2552
|
+
}
|
|
2553
|
+
return null;
|
|
2554
|
+
}
|
|
2555
|
+
return this.props.children;
|
|
2556
|
+
}
|
|
2557
|
+
};
|
|
2510
2558
|
function AmplifyRenderer({
|
|
2511
2559
|
renderComponent,
|
|
2512
2560
|
pageConfig: serverPageConfig,
|
|
@@ -2863,11 +2911,20 @@ function AmplifyRenderer({
|
|
|
2863
2911
|
const slotsToPass = Object.keys(slotChildren).length > 0 ? slotChildren : void 0;
|
|
2864
2912
|
console.log(`[AmplifyRenderer] Calling renderComponent for ${node.componentId}`, {
|
|
2865
2913
|
hasSlots: !!slotsToPass,
|
|
2866
|
-
slotKeys: slotsToPass ? Object.keys(slotsToPass) : []
|
|
2914
|
+
slotKeys: slotsToPass ? Object.keys(slotsToPass) : [],
|
|
2915
|
+
propKeys: Object.keys(node.props || {}),
|
|
2916
|
+
props: node.props || {}
|
|
2867
2917
|
});
|
|
2868
|
-
return /* @__PURE__ */ jsx("div", { "data-node-id": node.id, "data-amplifyup-node": "", children:
|
|
2869
|
-
|
|
2870
|
-
|
|
2918
|
+
return /* @__PURE__ */ jsx("div", { "data-node-id": node.id, "data-amplifyup-node": "", children: /* @__PURE__ */ jsx(
|
|
2919
|
+
ComponentRenderBoundary,
|
|
2920
|
+
{
|
|
2921
|
+
componentId: node.componentId,
|
|
2922
|
+
nodeId: node.id,
|
|
2923
|
+
children: renderComponent(node.componentId, node.props || {}, slotsToPass, {
|
|
2924
|
+
layoutNodeId: node.id
|
|
2925
|
+
})
|
|
2926
|
+
}
|
|
2927
|
+
) });
|
|
2871
2928
|
};
|
|
2872
2929
|
const rawTree = pageConfig.layoutTree;
|
|
2873
2930
|
const layoutTree = Array.isArray(rawTree) ? rawTree : rawTree && typeof rawTree === "object" && rawTree.componentId ? [rawTree] : [];
|