@replohq/canopy-sdk 0.20.0 → 0.20.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.
@@ -1 +1 @@
1
- export declare function DocumentReadyBeacon(): import("react/jsx-runtime").JSX.Element | null;
1
+ export declare function DocumentReadyBeacon(): import("react/jsx-runtime").JSX.Element;
@@ -1,9 +1,6 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  const BEACON_SCRIPT = `if (window.parent !== window) { window.parent.postMessage({ type: "replo:preview:status", status: "ok", phase: "document", route: window.location.pathname }, "*"); }`;
3
3
  function DocumentReadyBeacon() {
4
- if (process.env.NODE_ENV !== "development") {
5
- return null;
6
- }
7
4
  return /* @__PURE__ */ jsx("script", { dangerouslySetInnerHTML: { __html: BEACON_SCRIPT } });
8
5
  }
9
6
  export {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../editor/DocumentReadyBeacon.tsx"],
4
- "sourcesContent": ["// Posts at HTML parse time, pre-hydration; error shells and retry pages are different documents without this script, so receiving it proves the real site's document arrived.\n// phase: \"document\" lets the editor distinguish this from the hydration-time reporter \u2014 document arrival must not disarm its JS-boot watchdog.\nconst BEACON_SCRIPT = `if (window.parent !== window) { window.parent.postMessage({ type: \"replo:preview:status\", status: \"ok\", phase: \"document\", route: window.location.pathname }, \"*\"); }`;\n\nexport function DocumentReadyBeacon() {\n // Editor previews always run next dev (see preview-placeholder.ts); production builds ship none of this.\n if (process.env.NODE_ENV !== \"development\") {\n return null;\n }\n return <script dangerouslySetInnerHTML={{ __html: BEACON_SCRIPT }} />;\n}\n"],
5
- "mappings": "AASS;AAPT,MAAM,gBAAgB;AAEf,SAAS,sBAAsB;AAEpC,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,WAAO;AAAA,EACT;AACA,SAAO,oBAAC,YAAO,yBAAyB,EAAE,QAAQ,cAAc,GAAG;AACrE;",
4
+ "sourcesContent": ["// Posts at HTML parse time, pre-hydration; error shells and retry pages are different documents without this script, so receiving it proves the real site's document arrived.\n// phase: \"document\" lets the editor distinguish this from the hydration-time reporter \u2014 document arrival must not disarm its JS-boot watchdog.\nconst BEACON_SCRIPT = `if (window.parent !== window) { window.parent.postMessage({ type: \"replo:preview:status\", status: \"ok\", phase: \"document\", route: window.location.pathname }, \"*\"); }`;\n\nexport function DocumentReadyBeacon() {\n return <script dangerouslySetInnerHTML={{ __html: BEACON_SCRIPT }} />;\n}\n"],
5
+ "mappings": "AAKS;AAHT,MAAM,gBAAgB;AAEf,SAAS,sBAAsB;AACpC,SAAO,oBAAC,YAAO,yBAAyB,EAAE,QAAQ,cAAc,GAAG;AACrE;",
6
6
  "names": []
7
7
  }
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
  import * as React from "react";
3
- const ERROR_SELECTOR = '[data-next-badge][data-error="true"], [data-nextjs-dialog]';
3
+ const RED_CHROME_SELECTOR = '[data-next-badge][data-error="true"], [data-nextjs-dialog]';
4
+ const BLOCKING_ERROR_SELECTOR = "[data-nextjs-dialog]";
4
5
  const STATUS_LATCH_MS = 500;
5
6
  function NextErrorReporter() {
6
7
  React.useEffect(() => {
@@ -61,11 +62,13 @@ function NextErrorReporter() {
61
62
  });
62
63
  observedRoot = root;
63
64
  }
64
- const showingError = Boolean(
65
- portal.shadowRoot?.querySelector(ERROR_SELECTOR)
65
+ portal.style.display = portal.shadowRoot?.querySelector(
66
+ RED_CHROME_SELECTOR
67
+ ) ? "none" : "";
68
+ const hasBlockingError = Boolean(
69
+ portal.shadowRoot?.querySelector(BLOCKING_ERROR_SELECTOR)
66
70
  );
67
- portal.style.display = showingError ? "none" : "";
68
- post(showingError ? "error" : "ok");
71
+ post(hasBlockingError ? "error" : "ok");
69
72
  };
70
73
  const lightObserver = new MutationObserver(syncOverlayState);
71
74
  lightObserver.observe(document.documentElement, {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../editor/NextErrorReporter.tsx"],
4
- "sourcesContent": ["\"use client\";\n\nimport * as React from \"react\";\n\n/**\n * NOTE (Max, 2026-06-10): This component sends post messages to its embedder (website-builder miniapp)\n * so that it can render a loading / error UI if there's an error on this page.\n *\n * Ideally, we wouldn't need any update to canopy-sdk to achieve this: the miniapp would just read the\n * iframe's content and detect whenever there's a nextjs error overlay.\n * But the preview runs cross-origin from the editor, so the editor can't read the iframe's\n * DOM (browser security).\n *\n * This component has observers that detect when the nextjs error overlay appears or\n * disappears, and sends a post message with a status:\n * - `status`: \"error\" while Next's dev overlay reports an error (build or runtime)\n * - `status`: \"ok\" otherwise. Cleared by Fast Refresh on a fix, so it's also the\n * recovery signal (agent fixed the error, so it's the error -> ok transition)\n *\n * It also hides Next's dev error overlay (`<nextjs-portal>`) at the source the\n * instant an error appears, so the red bubble never paints \u2014 the MutationObserver\n * callback runs as a microtask before paint. `data-error` stays queryable while\n * hidden, so detection is unaffected;\n *\n * The overlay lives in `<nextjs-portal>`'s shadow root, which Next can recreate,\n * so we re-attach the shadow observer whenever it hands us a new root. No polling.\n *\n * This must be mounted OUTSIDE the error boundary (see ReploProvider) so it keeps\n * reporting while the boundary is caught (and showing its neutral cover).\n *\n * I'm unsatisfied with this approach: observing for the nextjs-portal is brittle and ugly.\n * Ideally, the ClientErrorBoundary, which hooks into the render cycle, in componentDidCatch, would\n * just report a post message to the miniapp. I prototyped that, the error detection works\n * great (ok -> error transition).\n * But the error -> ok transition doesn't work for Server components (it only does for Client\n * components). Here's a slack thread with me <> Gabe on it:\n * https://replohq.slack.com/archives/C03AACVP08Y/p1781154057832689?thread_ts=1781029224.564489&cid=C03AACVP08Y.\n */\nconst ERROR_SELECTOR =\n '[data-next-badge][data-error=\"true\"], [data-nextjs-dialog]';\n\n// HMR portal churn flips the overlay for milliseconds in both directions; only a state that persists this long is real.\nconst STATUS_LATCH_MS = 500;\n\ntype PreviewStatus = \"ok\" | \"error\";\n\nexport function NextErrorReporter() {\n // eslint-disable-next-line replo/no-use-effect -- Observes Next's dev error overlay (a shadow-DOM node outside React's tree) and relays its state to the cross-origin embedder. No React alternative applies.\n React.useEffect(() => {\n let lastStatus: PreviewStatus | null = null;\n let shadowObserver: MutationObserver | null = null;\n let observedRoot: ShadowRoot | null = null;\n let pendingPost: { status: PreviewStatus; timeoutId: number } | null = null;\n\n const postNow = (status: PreviewStatus) => {\n if (status === lastStatus) {\n return;\n }\n lastStatus = status;\n window.parent.postMessage(\n {\n type: \"replo:preview:status\",\n status,\n route: window.location.pathname,\n },\n \"*\",\n );\n };\n\n // Latch every transition (the opposite observation cancels a pending one) \u2014 a false error <-> ok flip makes the editor reload the preview. Only the initial \"ok\" posts immediately, as the readiness signal.\n const post = (status: PreviewStatus) => {\n if (pendingPost) {\n if (pendingPost.status === status) {\n return;\n }\n window.clearTimeout(pendingPost.timeoutId);\n pendingPost = null;\n }\n if (status === lastStatus) {\n return;\n }\n if (lastStatus === null && status === \"ok\") {\n postNow(\"ok\");\n return;\n }\n const timeoutId = window.setTimeout(() => {\n pendingPost = null;\n postNow(status);\n }, STATUS_LATCH_MS);\n pendingPost = { status, timeoutId };\n };\n\n // NOTE (Max, 2026-06-10): Reads the dev overlay's current error state and\n // propagates it \u2014 re-attach the shadow observer to the live root, hide the\n // portal while erroring, and post ok/error up to the editor. Runs on init and\n // on every observed DOM mutation.\n const syncOverlayState = () => {\n const portal = document.getElementsByTagName(\"nextjs-portal\")[0];\n if (!(portal instanceof HTMLElement)) {\n post(\"ok\");\n return;\n }\n // NOTE (Max, 2026-06-10): Re-attach whenever Next hands us a fresh shadow\n // root, else we'd keep watching a detached one after the overlay is\n // recreated.\n const root = portal.shadowRoot;\n if (root && root !== observedRoot) {\n shadowObserver?.disconnect();\n shadowObserver = new MutationObserver(syncOverlayState);\n shadowObserver.observe(root, {\n childList: true,\n subtree: true,\n attributes: true,\n attributeFilter: [\"data-error\"],\n });\n observedRoot = root;\n }\n const showingError = Boolean(\n portal.shadowRoot?.querySelector(ERROR_SELECTOR),\n );\n // NOTE (Max, 2026-06-10): Hide the dev overlay at the source so the red\n // bubble never paints.\n portal.style.display = showingError ? \"none\" : \"\";\n post(showingError ? \"error\" : \"ok\");\n };\n\n // NOTE (Max, 2026-06-10): Catches the portal being added/removed in the light\n // DOM; the re-attached shadow observer catches in-overlay changes.\n const lightObserver = new MutationObserver(syncOverlayState);\n lightObserver.observe(document.documentElement, {\n childList: true,\n subtree: true,\n });\n syncOverlayState();\n\n return () => {\n lightObserver.disconnect();\n shadowObserver?.disconnect();\n if (pendingPost) {\n window.clearTimeout(pendingPost.timeoutId);\n }\n };\n }, []);\n\n return null;\n}\n"],
5
- "mappings": ";AAEA,YAAY,WAAW;AAoCvB,MAAM,iBACJ;AAGF,MAAM,kBAAkB;AAIjB,SAAS,oBAAoB;AAElC,QAAM,UAAU,MAAM;AACpB,QAAI,aAAmC;AACvC,QAAI,iBAA0C;AAC9C,QAAI,eAAkC;AACtC,QAAI,cAAmE;AAEvE,UAAM,UAAU,CAAC,WAA0B;AACzC,UAAI,WAAW,YAAY;AACzB;AAAA,MACF;AACA,mBAAa;AACb,aAAO,OAAO;AAAA,QACZ;AAAA,UACE,MAAM;AAAA,UACN;AAAA,UACA,OAAO,OAAO,SAAS;AAAA,QACzB;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAGA,UAAM,OAAO,CAAC,WAA0B;AACtC,UAAI,aAAa;AACf,YAAI,YAAY,WAAW,QAAQ;AACjC;AAAA,QACF;AACA,eAAO,aAAa,YAAY,SAAS;AACzC,sBAAc;AAAA,MAChB;AACA,UAAI,WAAW,YAAY;AACzB;AAAA,MACF;AACA,UAAI,eAAe,QAAQ,WAAW,MAAM;AAC1C,gBAAQ,IAAI;AACZ;AAAA,MACF;AACA,YAAM,YAAY,OAAO,WAAW,MAAM;AACxC,sBAAc;AACd,gBAAQ,MAAM;AAAA,MAChB,GAAG,eAAe;AAClB,oBAAc,EAAE,QAAQ,UAAU;AAAA,IACpC;AAMA,UAAM,mBAAmB,MAAM;AAC7B,YAAM,SAAS,SAAS,qBAAqB,eAAe,EAAE,CAAC;AAC/D,UAAI,EAAE,kBAAkB,cAAc;AACpC,aAAK,IAAI;AACT;AAAA,MACF;AAIA,YAAM,OAAO,OAAO;AACpB,UAAI,QAAQ,SAAS,cAAc;AACjC,wBAAgB,WAAW;AAC3B,yBAAiB,IAAI,iBAAiB,gBAAgB;AACtD,uBAAe,QAAQ,MAAM;AAAA,UAC3B,WAAW;AAAA,UACX,SAAS;AAAA,UACT,YAAY;AAAA,UACZ,iBAAiB,CAAC,YAAY;AAAA,QAChC,CAAC;AACD,uBAAe;AAAA,MACjB;AACA,YAAM,eAAe;AAAA,QACnB,OAAO,YAAY,cAAc,cAAc;AAAA,MACjD;AAGA,aAAO,MAAM,UAAU,eAAe,SAAS;AAC/C,WAAK,eAAe,UAAU,IAAI;AAAA,IACpC;AAIA,UAAM,gBAAgB,IAAI,iBAAiB,gBAAgB;AAC3D,kBAAc,QAAQ,SAAS,iBAAiB;AAAA,MAC9C,WAAW;AAAA,MACX,SAAS;AAAA,IACX,CAAC;AACD,qBAAiB;AAEjB,WAAO,MAAM;AACX,oBAAc,WAAW;AACzB,sBAAgB,WAAW;AAC3B,UAAI,aAAa;AACf,eAAO,aAAa,YAAY,SAAS;AAAA,MAC3C;AAAA,IACF;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO;AACT;",
4
+ "sourcesContent": ["\"use client\";\n\nimport * as React from \"react\";\n\n/**\n * NOTE (Max, 2026-06-10): This component sends post messages to its embedder (website-builder miniapp)\n * so that it can render a loading / error UI if there's an error on this page.\n *\n * Ideally, we wouldn't need any update to canopy-sdk to achieve this: the miniapp would just read the\n * iframe's content and detect whenever there's a nextjs error overlay.\n * But the preview runs cross-origin from the editor, so the editor can't read the iframe's\n * DOM (browser security).\n *\n * This component has observers that detect when the nextjs error overlay appears or\n * disappears, and sends a post message with a status:\n * - `status`: \"error\" while Next's dev overlay opens its blocking error dialog\n * (a real page break \u2014 see the selectors below for why the badge's issue\n * count is deliberately NOT used: it also counts recovered loader misses)\n * - `status`: \"ok\" otherwise. Cleared by Fast Refresh on a fix, so it's also the\n * recovery signal (agent fixed the error, so it's the error -> ok transition)\n *\n * It also hides Next's dev error overlay (`<nextjs-portal>`) at the source the\n * instant an error appears, so the red bubble never paints \u2014 the MutationObserver\n * callback runs as a microtask before paint. `data-error` stays queryable while\n * hidden, so detection is unaffected;\n *\n * The overlay lives in `<nextjs-portal>`'s shadow root, which Next can recreate,\n * so we re-attach the shadow observer whenever it hands us a new root. No polling.\n *\n * This must be mounted OUTSIDE the error boundary (see ReploProvider) so it keeps\n * reporting while the boundary is caught (and showing its neutral cover).\n *\n * I'm unsatisfied with this approach: observing for the nextjs-portal is brittle and ugly.\n * Ideally, the ClientErrorBoundary, which hooks into the render cycle, in componentDidCatch, would\n * just report a post message to the miniapp. I prototyped that, the error detection works\n * great (ok -> error transition).\n * But the error -> ok transition doesn't work for Server components (it only does for Client\n * components). Here's a slack thread with me <> Gabe on it:\n * https://replohq.slack.com/archives/C03AACVP08Y/p1781154057832689?thread_ts=1781029224.564489&cid=C03AACVP08Y.\n */\n// NOTE (Max, 2026-08-04): <nextjs-portal> surfaces two very different things,\n// and only one of them means the page is actually broken:\n// - the dev-tools badge (`[data-next-badge][data-error=\"true\"]`) lights for\n// EVERY collected issue, including a server-side loader error that React\n// already recovered from by streaming the LoaderErrorBoundary fallback. That\n// is a graceful, recoverable miss (product unpublished, deleted collection,\n// \u2026) \u2014 the page renders fine \u2014 and it must NOT be reported as a page error.\n// - the error overlay dialog (`[data-nextjs-dialog]`) only mounts when Next\n// auto-opens the overlay for a genuinely blocking error: the app shell's\n// error boundary catching an uncaught render crash, an unrecoverable SSR\n// error (missing root tags), or a build error. Next never auto-opens the\n// dialog for a recovered error. Verified against next@16.1.7 (the version\n// canopy-sdk and most templates pin) and next@15.3.8: the sole auto-open\n// is AppDevOverlayErrorBoundary's componentDidCatch -> openErrorOverlay,\n// i.e. the shell boundary, which a nested LoaderErrorBoundary never reaches\n// (a caught loader miss only increments the badge count). The badge count\n// opens the dialog only on an explicit user click.\n// So the open dialog \u2014 not the badge's issue count \u2014 is the fatal-vs-recoverable\n// discriminator. Keying off the badge reported recoverable loader misses as\n// full-page errors, blanking a preview that had actually rendered its fallback.\n//\n// We still *hide* the whole portal whenever Next paints red chrome (the errored\n// badge OR the dialog) so no dev overlay bleeds into the preview \u2014 a recovered\n// loader miss shouldn't flash a red dot either. Only the blocking dialog is\n// reported upward as a page error.\nconst RED_CHROME_SELECTOR =\n '[data-next-badge][data-error=\"true\"], [data-nextjs-dialog]';\nconst BLOCKING_ERROR_SELECTOR = \"[data-nextjs-dialog]\";\n\n// HMR portal churn flips the overlay for milliseconds in both directions; only a state that persists this long is real.\nconst STATUS_LATCH_MS = 500;\n\ntype PreviewStatus = \"ok\" | \"error\";\n\nexport function NextErrorReporter() {\n // eslint-disable-next-line replo/no-use-effect -- Observes Next's dev error overlay (a shadow-DOM node outside React's tree) and relays its state to the cross-origin embedder. No React alternative applies.\n React.useEffect(() => {\n let lastStatus: PreviewStatus | null = null;\n let shadowObserver: MutationObserver | null = null;\n let observedRoot: ShadowRoot | null = null;\n let pendingPost: { status: PreviewStatus; timeoutId: number } | null = null;\n\n const postNow = (status: PreviewStatus) => {\n if (status === lastStatus) {\n return;\n }\n lastStatus = status;\n window.parent.postMessage(\n {\n type: \"replo:preview:status\",\n status,\n route: window.location.pathname,\n },\n \"*\",\n );\n };\n\n // Latch every transition (the opposite observation cancels a pending one) \u2014 a false error <-> ok flip makes the editor reload the preview. Only the initial \"ok\" posts immediately, as the readiness signal.\n const post = (status: PreviewStatus) => {\n if (pendingPost) {\n if (pendingPost.status === status) {\n return;\n }\n window.clearTimeout(pendingPost.timeoutId);\n pendingPost = null;\n }\n if (status === lastStatus) {\n return;\n }\n if (lastStatus === null && status === \"ok\") {\n postNow(\"ok\");\n return;\n }\n const timeoutId = window.setTimeout(() => {\n pendingPost = null;\n postNow(status);\n }, STATUS_LATCH_MS);\n pendingPost = { status, timeoutId };\n };\n\n // NOTE (Max, 2026-06-10): Reads the dev overlay's current error state and\n // propagates it \u2014 re-attach the shadow observer to the live root, hide the\n // portal while erroring, and post ok/error up to the editor. Runs on init and\n // on every observed DOM mutation.\n const syncOverlayState = () => {\n const portal = document.getElementsByTagName(\"nextjs-portal\")[0];\n if (!(portal instanceof HTMLElement)) {\n post(\"ok\");\n return;\n }\n // NOTE (Max, 2026-06-10): Re-attach whenever Next hands us a fresh shadow\n // root, else we'd keep watching a detached one after the overlay is\n // recreated.\n const root = portal.shadowRoot;\n if (root && root !== observedRoot) {\n shadowObserver?.disconnect();\n shadowObserver = new MutationObserver(syncOverlayState);\n shadowObserver.observe(root, {\n childList: true,\n subtree: true,\n attributes: true,\n attributeFilter: [\"data-error\"],\n });\n observedRoot = root;\n }\n // NOTE (Max, 2026-06-10): Hide the dev overlay at the source so the red\n // bubble never paints \u2014 for any red chrome, including a recovered miss's\n // errored badge.\n portal.style.display = portal.shadowRoot?.querySelector(\n RED_CHROME_SELECTOR,\n )\n ? \"none\"\n : \"\";\n // Only the blocking overlay dialog means the page actually broke; the\n // badge's issue count also covers recovered loader misses (see selectors).\n const hasBlockingError = Boolean(\n portal.shadowRoot?.querySelector(BLOCKING_ERROR_SELECTOR),\n );\n post(hasBlockingError ? \"error\" : \"ok\");\n };\n\n // NOTE (Max, 2026-06-10): Catches the portal being added/removed in the light\n // DOM; the re-attached shadow observer catches in-overlay changes.\n const lightObserver = new MutationObserver(syncOverlayState);\n lightObserver.observe(document.documentElement, {\n childList: true,\n subtree: true,\n });\n syncOverlayState();\n\n return () => {\n lightObserver.disconnect();\n shadowObserver?.disconnect();\n if (pendingPost) {\n window.clearTimeout(pendingPost.timeoutId);\n }\n };\n }, []);\n\n return null;\n}\n"],
5
+ "mappings": ";AAEA,YAAY,WAAW;AA+DvB,MAAM,sBACJ;AACF,MAAM,0BAA0B;AAGhC,MAAM,kBAAkB;AAIjB,SAAS,oBAAoB;AAElC,QAAM,UAAU,MAAM;AACpB,QAAI,aAAmC;AACvC,QAAI,iBAA0C;AAC9C,QAAI,eAAkC;AACtC,QAAI,cAAmE;AAEvE,UAAM,UAAU,CAAC,WAA0B;AACzC,UAAI,WAAW,YAAY;AACzB;AAAA,MACF;AACA,mBAAa;AACb,aAAO,OAAO;AAAA,QACZ;AAAA,UACE,MAAM;AAAA,UACN;AAAA,UACA,OAAO,OAAO,SAAS;AAAA,QACzB;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAGA,UAAM,OAAO,CAAC,WAA0B;AACtC,UAAI,aAAa;AACf,YAAI,YAAY,WAAW,QAAQ;AACjC;AAAA,QACF;AACA,eAAO,aAAa,YAAY,SAAS;AACzC,sBAAc;AAAA,MAChB;AACA,UAAI,WAAW,YAAY;AACzB;AAAA,MACF;AACA,UAAI,eAAe,QAAQ,WAAW,MAAM;AAC1C,gBAAQ,IAAI;AACZ;AAAA,MACF;AACA,YAAM,YAAY,OAAO,WAAW,MAAM;AACxC,sBAAc;AACd,gBAAQ,MAAM;AAAA,MAChB,GAAG,eAAe;AAClB,oBAAc,EAAE,QAAQ,UAAU;AAAA,IACpC;AAMA,UAAM,mBAAmB,MAAM;AAC7B,YAAM,SAAS,SAAS,qBAAqB,eAAe,EAAE,CAAC;AAC/D,UAAI,EAAE,kBAAkB,cAAc;AACpC,aAAK,IAAI;AACT;AAAA,MACF;AAIA,YAAM,OAAO,OAAO;AACpB,UAAI,QAAQ,SAAS,cAAc;AACjC,wBAAgB,WAAW;AAC3B,yBAAiB,IAAI,iBAAiB,gBAAgB;AACtD,uBAAe,QAAQ,MAAM;AAAA,UAC3B,WAAW;AAAA,UACX,SAAS;AAAA,UACT,YAAY;AAAA,UACZ,iBAAiB,CAAC,YAAY;AAAA,QAChC,CAAC;AACD,uBAAe;AAAA,MACjB;AAIA,aAAO,MAAM,UAAU,OAAO,YAAY;AAAA,QACxC;AAAA,MACF,IACI,SACA;AAGJ,YAAM,mBAAmB;AAAA,QACvB,OAAO,YAAY,cAAc,uBAAuB;AAAA,MAC1D;AACA,WAAK,mBAAmB,UAAU,IAAI;AAAA,IACxC;AAIA,UAAM,gBAAgB,IAAI,iBAAiB,gBAAgB;AAC3D,kBAAc,QAAQ,SAAS,iBAAiB;AAAA,MAC9C,WAAW;AAAA,MACX,SAAS;AAAA,IACX,CAAC;AACD,qBAAiB;AAEjB,WAAO,MAAM;AACX,oBAAc,WAAW;AACzB,sBAAgB,WAAW;AAC3B,UAAI,aAAa;AACf,eAAO,aAAa,YAAY,SAAS;AAAA,MAC3C;AAAA,IACF;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO;AACT;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@replohq/canopy-sdk",
3
- "version": "0.20.0",
3
+ "version": "0.20.2",
4
4
  "description": "Replo Canopy SDK — cart, analytics, data loaders, and editor runtime for agent-built Next.js sites.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -1,4 +1,4 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { AnalyticsProvider } from "../analytics/analytics-provider";
3
3
  import { ReploFirstPartyPixel } from "../analytics/replo-first-party-pixel";
4
4
  import { CartLoader } from "../cart/cart-loader";
@@ -18,10 +18,11 @@ async function ReploProvider({ children }) {
18
18
  } catch {
19
19
  checkoutProvider = "none";
20
20
  }
21
+ const isDevServer = process.env.NODE_ENV === "development";
21
22
  return /* @__PURE__ */ jsx(QueryProvider, { children: /* @__PURE__ */ jsxs(AnalyticsProvider, { checkoutProvider, children: [
22
23
  /* @__PURE__ */ jsx(ReploFirstPartyPixel, {}),
23
- /* @__PURE__ */ jsx(DocumentReadyBeacon, {}),
24
- /* @__PURE__ */ jsxs(CartLoader, { children: [
24
+ isDevServer && /* @__PURE__ */ jsx(DocumentReadyBeacon, {}),
25
+ /* @__PURE__ */ jsx(CartLoader, { children: isDevServer ? /* @__PURE__ */ jsxs(Fragment, { children: [
25
26
  /* @__PURE__ */ jsx(NextErrorReporter, {}),
26
27
  /* @__PURE__ */ jsxs(ClientErrorBoundary, { children: [
27
28
  /* @__PURE__ */ jsx(LinkInterceptor, {}),
@@ -30,7 +31,7 @@ async function ReploProvider({ children }) {
30
31
  /* @__PURE__ */ jsx(DesignLibraryPreview, {}),
31
32
  children
32
33
  ] })
33
- ] })
34
+ ] }) : children })
34
35
  ] }) });
35
36
  }
36
37
  export {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../providers/replo-provider.tsx"],
4
- "sourcesContent": ["import type { CheckoutProvider } from \"../lib/integration-utils\";\n\nimport { AnalyticsProvider } from \"../analytics/analytics-provider\";\nimport { ReploFirstPartyPixel } from \"../analytics/replo-first-party-pixel\";\nimport { CartLoader } from \"../cart/cart-loader\";\nimport { ClientErrorBoundary } from \"../editor/ClientErrorBoundary\";\nimport { DesignLibraryPreview } from \"../editor/design-library-preview/DesignLibraryPreview\";\nimport { DocumentReadyBeacon } from \"../editor/DocumentReadyBeacon\";\nimport LinkInterceptor from \"../editor/LinkInterceptor\";\nimport { NextErrorReporter } from \"../editor/NextErrorReporter\";\nimport PostHogRelay from \"../editor/posthog-relay\";\nimport { EditorSelection } from \"../editor/select-mode/EditorSelection\";\nimport { getCheckoutProvider } from \"../lib/integration-utils\";\nimport { QueryProvider } from \"./query-provider\";\n\nexport async function ReploProvider({ children }: React.PropsWithChildren) {\n // Server-resolved so the analytics layer can suppress checkout-funnel events\n // that Shopify's hosted checkout already reports. Defaults to \"none\" (events\n // fire) if the env can't be read, preserving prior behavior.\n let checkoutProvider: CheckoutProvider = \"none\";\n try {\n checkoutProvider = await getCheckoutProvider();\n } catch {\n checkoutProvider = \"none\";\n }\n\n return (\n <QueryProvider>\n <AnalyticsProvider checkoutProvider={checkoutProvider}>\n <ReploFirstPartyPixel />\n <DocumentReadyBeacon />\n <CartLoader>\n {/* NOTE (Max, 2026-06-08): Outside ClientErrorBoundary on purpose \u2014 when\n the boundary catches a runtime error it swaps its children for a\n neutral cover, which would unmount the reporter and freeze it in the\n error state. It must stay mounted to observe Next's overlay across\n error <-> recover. */}\n <NextErrorReporter />\n <ClientErrorBoundary>\n <LinkInterceptor />\n <PostHogRelay />\n <EditorSelection />\n <DesignLibraryPreview />\n {children}\n </ClientErrorBoundary>\n </CartLoader>\n </AnalyticsProvider>\n </QueryProvider>\n );\n}\n"],
5
- "mappings": "AA6BQ,cASE,YATF;AA3BR,SAAS,yBAAyB;AAClC,SAAS,4BAA4B;AACrC,SAAS,kBAAkB;AAC3B,SAAS,2BAA2B;AACpC,SAAS,4BAA4B;AACrC,SAAS,2BAA2B;AACpC,OAAO,qBAAqB;AAC5B,SAAS,yBAAyB;AAClC,OAAO,kBAAkB;AACzB,SAAS,uBAAuB;AAChC,SAAS,2BAA2B;AACpC,SAAS,qBAAqB;AAE9B,eAAsB,cAAc,EAAE,SAAS,GAA4B;AAIzE,MAAI,mBAAqC;AACzC,MAAI;AACF,uBAAmB,MAAM,oBAAoB;AAAA,EAC/C,QAAQ;AACN,uBAAmB;AAAA,EACrB;AAEA,SACE,oBAAC,iBACC,+BAAC,qBAAkB,kBACjB;AAAA,wBAAC,wBAAqB;AAAA,IACtB,oBAAC,uBAAoB;AAAA,IACrB,qBAAC,cAMC;AAAA,0BAAC,qBAAkB;AAAA,MACnB,qBAAC,uBACC;AAAA,4BAAC,mBAAgB;AAAA,QACjB,oBAAC,gBAAa;AAAA,QACd,oBAAC,mBAAgB;AAAA,QACjB,oBAAC,wBAAqB;AAAA,QACrB;AAAA,SACH;AAAA,OACF;AAAA,KACF,GACF;AAEJ;",
4
+ "sourcesContent": ["import type { CheckoutProvider } from \"../lib/integration-utils\";\n\nimport { AnalyticsProvider } from \"../analytics/analytics-provider\";\nimport { ReploFirstPartyPixel } from \"../analytics/replo-first-party-pixel\";\nimport { CartLoader } from \"../cart/cart-loader\";\nimport { ClientErrorBoundary } from \"../editor/ClientErrorBoundary\";\nimport { DesignLibraryPreview } from \"../editor/design-library-preview/DesignLibraryPreview\";\nimport { DocumentReadyBeacon } from \"../editor/DocumentReadyBeacon\";\nimport LinkInterceptor from \"../editor/LinkInterceptor\";\nimport { NextErrorReporter } from \"../editor/NextErrorReporter\";\nimport PostHogRelay from \"../editor/posthog-relay\";\nimport { EditorSelection } from \"../editor/select-mode/EditorSelection\";\nimport { getCheckoutProvider } from \"../lib/integration-utils\";\nimport { QueryProvider } from \"./query-provider\";\n\nexport async function ReploProvider({ children }: React.PropsWithChildren) {\n // Server-resolved so the analytics layer can suppress checkout-funnel events\n // that Shopify's hosted checkout already reports. Defaults to \"none\" (events\n // fire) if the env can't be read, preserving prior behavior.\n let checkoutProvider: CheckoutProvider = \"none\";\n try {\n checkoutProvider = await getCheckoutProvider();\n } catch {\n checkoutProvider = \"none\";\n }\n\n // The editor only embeds dev servers (`next dev`), so editor-integration components render there only \u2014 production builds ship none of them and behave like plain Next apps.\n const isDevServer = process.env.NODE_ENV === \"development\";\n\n return (\n <QueryProvider>\n <AnalyticsProvider checkoutProvider={checkoutProvider}>\n <ReploFirstPartyPixel />\n {isDevServer && <DocumentReadyBeacon />}\n <CartLoader>\n {isDevServer ? (\n <>\n {/* NOTE (Max, 2026-06-08): Outside ClientErrorBoundary on purpose \u2014 when\n the boundary catches a runtime error it swaps its children for a\n neutral cover, which would unmount the reporter and freeze it in the\n error state. It must stay mounted to observe Next's overlay across\n error <-> recover. */}\n <NextErrorReporter />\n <ClientErrorBoundary>\n <LinkInterceptor />\n <PostHogRelay />\n <EditorSelection />\n <DesignLibraryPreview />\n {children}\n </ClientErrorBoundary>\n </>\n ) : (\n children\n )}\n </CartLoader>\n </AnalyticsProvider>\n </QueryProvider>\n );\n}\n"],
5
+ "mappings": "AAgCQ,SAII,UAJJ,KAWM,YAXN;AA9BR,SAAS,yBAAyB;AAClC,SAAS,4BAA4B;AACrC,SAAS,kBAAkB;AAC3B,SAAS,2BAA2B;AACpC,SAAS,4BAA4B;AACrC,SAAS,2BAA2B;AACpC,OAAO,qBAAqB;AAC5B,SAAS,yBAAyB;AAClC,OAAO,kBAAkB;AACzB,SAAS,uBAAuB;AAChC,SAAS,2BAA2B;AACpC,SAAS,qBAAqB;AAE9B,eAAsB,cAAc,EAAE,SAAS,GAA4B;AAIzE,MAAI,mBAAqC;AACzC,MAAI;AACF,uBAAmB,MAAM,oBAAoB;AAAA,EAC/C,QAAQ;AACN,uBAAmB;AAAA,EACrB;AAGA,QAAM,cAAc,QAAQ,IAAI,aAAa;AAE7C,SACE,oBAAC,iBACC,+BAAC,qBAAkB,kBACjB;AAAA,wBAAC,wBAAqB;AAAA,IACrB,eAAe,oBAAC,uBAAoB;AAAA,IACrC,oBAAC,cACE,wBACC,iCAME;AAAA,0BAAC,qBAAkB;AAAA,MACnB,qBAAC,uBACC;AAAA,4BAAC,mBAAgB;AAAA,QACjB,oBAAC,gBAAa;AAAA,QACd,oBAAC,mBAAgB;AAAA,QACjB,oBAAC,wBAAqB;AAAA,QACrB;AAAA,SACH;AAAA,OACF,IAEA,UAEJ;AAAA,KACF,GACF;AAEJ;",
6
6
  "names": []
7
7
  }