@syntrologie/runtime-sdk 0.2.12 → 0.2.13

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.
@@ -32159,7 +32159,8 @@ var SyntrologieSDK = (() => {
32159
32159
  overlayRecipe: response.overlayRecipe,
32160
32160
  overlayRecipes: response.overlayRecipes,
32161
32161
  theme: response.theme,
32162
- launcher: response.launcher
32162
+ launcher: response.launcher,
32163
+ routes: response.routes
32163
32164
  });
32164
32165
  } catch (err) {
32165
32166
  setState((prev) => ({
@@ -38518,6 +38519,23 @@ var SyntrologieSDK = (() => {
38518
38519
 
38519
38520
  // src/SmartCanvasApp.tsx
38520
38521
  var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
38522
+ function isRouteAllowed(routes, pathname) {
38523
+ if (!routes) return true;
38524
+ if (routes.include?.length) {
38525
+ return routes.include.some((pattern) => matchRoute(pattern, pathname));
38526
+ }
38527
+ if (routes.exclude?.length) {
38528
+ return !routes.exclude.some((pattern) => matchRoute(pattern, pathname));
38529
+ }
38530
+ return true;
38531
+ }
38532
+ function matchRoute(pattern, pathname) {
38533
+ if (pattern.endsWith("/*")) {
38534
+ const prefix = pattern.slice(0, -2);
38535
+ return pathname === prefix || pathname.startsWith(prefix + "/");
38536
+ }
38537
+ return pathname === pattern;
38538
+ }
38521
38539
  function SmartCanvasApp({
38522
38540
  controller,
38523
38541
  fetcher,
@@ -38539,6 +38557,29 @@ var SyntrologieSDK = (() => {
38539
38557
  theme
38540
38558
  }) {
38541
38559
  const [open, setOpen] = (0, import_react10.useState)(controller.getState().open);
38560
+ const [pathname, setPathname] = (0, import_react10.useState)(
38561
+ () => typeof window !== "undefined" ? window.location.pathname : "/"
38562
+ );
38563
+ (0, import_react10.useEffect)(() => {
38564
+ if (typeof window === "undefined") return;
38565
+ const updatePathname = () => setPathname(window.location.pathname);
38566
+ window.addEventListener("popstate", updatePathname);
38567
+ const originalPushState = history.pushState;
38568
+ const originalReplaceState = history.replaceState;
38569
+ history.pushState = function(...args) {
38570
+ originalPushState.apply(this, args);
38571
+ updatePathname();
38572
+ };
38573
+ history.replaceState = function(...args) {
38574
+ originalReplaceState.apply(this, args);
38575
+ updatePathname();
38576
+ };
38577
+ return () => {
38578
+ window.removeEventListener("popstate", updatePathname);
38579
+ history.pushState = originalPushState;
38580
+ history.replaceState = originalReplaceState;
38581
+ };
38582
+ }, []);
38542
38583
  const derivedFetcher = (0, import_react10.useMemo)(() => {
38543
38584
  if (fetcher) return fetcher;
38544
38585
  return createCanvasConfigFetcher({
@@ -38598,7 +38639,8 @@ var SyntrologieSDK = (() => {
38598
38639
  // any direct overrides from theme prop
38599
38640
  };
38600
38641
  }, [configState.theme, theme]);
38601
- if (!configState.isLoading && !hasContent) {
38642
+ const routeAllowed = isRouteAllowed(configState.routes, pathname);
38643
+ if (!configState.isLoading && (!hasContent || !routeAllowed)) {
38602
38644
  return null;
38603
38645
  }
38604
38646
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(