@ai-matrx/canvas 0.9.0 → 0.9.1

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/react.js CHANGED
@@ -2943,8 +2943,23 @@ var Rendered = memo(function Rendered2({
2943
2943
  presentation
2944
2944
  }) {
2945
2945
  const props = { item, data: item.data, paneId, isFocused, isVisible, canvas, windowId, presentation };
2946
- return /* @__PURE__ */ jsx6(ItemBoundary, { item, onClose: () => canvas.close(item.id), onRetry: () => resetKindComponent(kind), children: /* @__PURE__ */ jsx6(Suspense, { fallback: /* @__PURE__ */ jsx6("div", { className: "mxc-loading", "aria-busy": "true" }), children: /* @__PURE__ */ jsx6(KindRender, { kind, props }) }) });
2946
+ const [attempt, setAttempt] = useState4(0);
2947
+ const retry = () => {
2948
+ resetKindComponent(kind);
2949
+ setAttempt((n) => n + 1);
2950
+ };
2951
+ return /* @__PURE__ */ jsx6(ItemBoundary, { item, onClose: () => canvas.close(item.id), onRetry: retry, children: /* @__PURE__ */ jsx6(Suspense, { fallback: /* @__PURE__ */ jsx6(LoadingBody, { onRetry: retry, onClose: () => canvas.close(item.id) }), children: /* @__PURE__ */ jsx6(KindRender, { kind, props }) }, attempt) });
2947
2952
  });
2953
+ var CANVAS_BODY_STALL_MS = 2e4;
2954
+ function LoadingBody({ onRetry, onClose }) {
2955
+ const [stalled, setStalled] = useState4(false);
2956
+ useEffect6(() => {
2957
+ const timer = setTimeout(() => setStalled(true), CANVAS_BODY_STALL_MS);
2958
+ return () => clearTimeout(timer);
2959
+ }, []);
2960
+ if (!stalled) return /* @__PURE__ */ jsx6("div", { className: "mxc-loading", "aria-busy": "true" });
2961
+ return /* @__PURE__ */ jsx6(ItemProblem, { message: "This item is taking a long time to load.", onRetry, onClose });
2962
+ }
2948
2963
  function KindRender({ kind, props }) {
2949
2964
  const Render = kindComponent(kind);
2950
2965
  if (!Render) throw new Error(`[@ai-matrx/canvas] kind "${kind.id}" has nothing to render.`);