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