@decocms/tanstack 7.41.1 → 7.42.0

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.41.1",
3
+ "version": "7.42.0",
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.41.1",
28
- "@decocms/blocks-admin": "7.41.1",
29
- "@decocms/blocks-cli": "7.41.1",
27
+ "@decocms/blocks": "7.42.0",
28
+ "@decocms/blocks-admin": "7.42.0",
29
+ "@decocms/blocks-cli": "7.42.0",
30
30
  "@deco-cx/warp-node": "^0.3.16",
31
31
  "fast-json-patch": "^3.1.0",
32
32
  "ws": "^8.18.0"
@@ -228,6 +228,21 @@ export interface DecoWorkerEntryOptions {
228
228
  */
229
229
  deviceSpecificKeys?: boolean;
230
230
 
231
+ /**
232
+ * Serve pages as structured per-section JSON on `?renderJson` (the mobile
233
+ * page-as-JSON path). Set to `false` to disable the endpoint site-wide —
234
+ * `?renderJson` then just renders the normal HTML page.
235
+ * @default true
236
+ */
237
+ renderJson?: boolean;
238
+
239
+ /**
240
+ * Serve the raw resolved page as JSON on `?asJson` (legacy admin-preview
241
+ * path). Set to `false` to disable it site-wide.
242
+ * @default true
243
+ */
244
+ asJson?: boolean;
245
+
231
246
  /**
232
247
  * Build a full segment key from the incoming request.
233
248
  *
@@ -1743,7 +1758,11 @@ export function createDecoWorkerEntry(
1743
1758
  // ?renderJson — structured JSON of the page for the mobile app. Lean shape
1744
1759
  // ({ name, path, sections:[{ component, props }] }), each section projected
1745
1760
  // through its `renderJson` export. Wins over ?asJson when both are present.
1746
- if (url.searchParams.has("renderJson") && request.method === "GET") {
1761
+ if (
1762
+ options.renderJson !== false &&
1763
+ url.searchParams.has("renderJson") &&
1764
+ request.method === "GET"
1765
+ ) {
1747
1766
  const basePath = url.pathname;
1748
1767
  const cookies: Record<string, string> = {};
1749
1768
  for (const pair of (request.headers.get("cookie") ?? "").split(";")) {
@@ -1868,7 +1887,11 @@ export function createDecoWorkerEntry(
1868
1887
  }
1869
1888
 
1870
1889
  // ?asJson — return resolved page data as JSON (legacy deco compat)
1871
- if (url.searchParams.has("asJson") && request.method === "GET") {
1890
+ if (
1891
+ options.asJson !== false &&
1892
+ url.searchParams.has("asJson") &&
1893
+ request.method === "GET"
1894
+ ) {
1872
1895
  const basePath = url.pathname;
1873
1896
  const cookies: Record<string, string> = {};
1874
1897
  for (const pair of (request.headers.get("cookie") ?? "").split(";")) {