@decocms/tanstack 7.48.1 → 7.48.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/tanstack",
3
- "version": "7.48.1",
3
+ "version": "7.48.2",
4
4
  "type": "module",
5
5
  "description": "Deco framework binding for TanStack Start + Cloudflare Workers",
6
6
  "repository": {
@@ -24,9 +24,9 @@
24
24
  "lint:unused": "knip"
25
25
  },
26
26
  "dependencies": {
27
- "@decocms/blocks": "7.48.1",
28
- "@decocms/blocks-admin": "7.48.1",
29
- "@decocms/blocks-cli": "7.48.1",
27
+ "@decocms/blocks": "7.48.2",
28
+ "@decocms/blocks-admin": "7.48.2",
29
+ "@decocms/blocks-cli": "7.48.2",
30
30
  "@deco-cx/warp-node": "^0.3.16",
31
31
  "fast-json-patch": "^3.1.0",
32
32
  "ws": "^8.18.0"
@@ -1,5 +1,5 @@
1
1
  import { useEffect, type ReactNode } from "react";
2
- import { HeadContent, Scripts, ScriptOnce } from "@tanstack/react-router";
2
+ import { HeadContent, Scripts, ScriptOnce, useRouterState } from "@tanstack/react-router";
3
3
  import { LiveControls } from "@decocms/blocks/hooks";
4
4
  import {
5
5
  ANALYTICS_SCRIPT,
@@ -112,6 +112,28 @@ export function DecoRootLayout({
112
112
  return () => clearTimeout(id);
113
113
  }, [decoReadyDelay]);
114
114
 
115
+ // Pull the resolved CMS page's route pattern (`path` = pathTemplate) and block
116
+ // id (`blockKey`) out of the current route's loader data so LiveControls sends
117
+ // the admin the page the user is actually on — not the hardcoded "/*" fallback.
118
+ // The CMS page loader (cmsRoute) spreads both fields onto its loader data;
119
+ // we scan matches deepest-first to find the one that carries them.
120
+ const page = useRouterState({
121
+ select: (state) => {
122
+ for (let i = state.matches.length - 1; i >= 0; i--) {
123
+ const data = state.matches[i]?.loaderData as
124
+ | { path?: unknown; blockKey?: unknown }
125
+ | undefined;
126
+ if (data && typeof data.path === "string") {
127
+ return {
128
+ id: typeof data.blockKey === "string" ? data.blockKey : undefined,
129
+ pathTemplate: data.path,
130
+ };
131
+ }
132
+ }
133
+ return undefined;
134
+ },
135
+ });
136
+
115
137
  // Worker-entry option wins; prop is a per-root override. Undefined → disabled.
116
138
  const speculation = speculationRules ?? getSpeculationRules();
117
139
 
@@ -145,7 +167,7 @@ export function DecoRootLayout({
145
167
  </main>
146
168
  {children}
147
169
  <DraftPreviewIndicator />
148
- <LiveControls site={siteName} />
170
+ <LiveControls site={siteName} page={page} />
149
171
  <ScriptOnce children={ANALYTICS_SCRIPT} />
150
172
  <Scripts />
151
173
  </body>