@decocms/tanstack 7.77.12 → 7.77.14
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 +4 -4
- package/src/sdk/workerEntry.ts +22 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decocms/tanstack",
|
|
3
|
-
"version": "7.77.
|
|
3
|
+
"version": "7.77.14",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Deco framework binding for TanStack Start + Cloudflare Workers",
|
|
6
6
|
"repository": {
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"lint:unused": "knip"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@decocms/blocks": "7.77.
|
|
31
|
-
"@decocms/blocks-admin": "7.77.
|
|
32
|
-
"@decocms/blocks-cli": "7.77.
|
|
30
|
+
"@decocms/blocks": "7.77.14",
|
|
31
|
+
"@decocms/blocks-admin": "7.77.14",
|
|
32
|
+
"@decocms/blocks-cli": "7.77.14",
|
|
33
33
|
"@deco-cx/warp-node": "^0.3.16",
|
|
34
34
|
"fast-json-patch": "^3.1.0",
|
|
35
35
|
"ws": "^8.18.0"
|
package/src/sdk/workerEntry.ts
CHANGED
|
@@ -264,6 +264,16 @@ export interface DecoWorkerEntryOptions {
|
|
|
264
264
|
*/
|
|
265
265
|
renderJson?: boolean;
|
|
266
266
|
|
|
267
|
+
/**
|
|
268
|
+
* `?renderJson` strips the request-derived keys the section mixins inject
|
|
269
|
+
* (`device`, `isMobile`, `currentSearchParam`) from every section. A section
|
|
270
|
+
* whose own loader returns one of them as content (Fresh: `device:
|
|
271
|
+
* ctx.device`, which production's `?renderJson` carries) can keep it here:
|
|
272
|
+
* resolveType suffix (matched like `renderJson.sectionsToIgnore`) → keys to
|
|
273
|
+
* preserve. Example: `{ "Product/ProductDetails.tsx": ["device"] }`.
|
|
274
|
+
*/
|
|
275
|
+
renderJsonKeepKeys?: Record<string, readonly string[]>;
|
|
276
|
+
|
|
267
277
|
/**
|
|
268
278
|
* Serve the raw resolved page as JSON on `?asJson` (legacy admin-preview
|
|
269
279
|
* path). Set to `false` to disable it site-wide.
|
|
@@ -2427,6 +2437,16 @@ export function createDecoWorkerEntry(
|
|
|
2427
2437
|
const getSectionModule = (component: string) => ({
|
|
2428
2438
|
renderJson: getSectionOptions(component)?.renderJson,
|
|
2429
2439
|
});
|
|
2440
|
+
const keepEntries = Object.entries(options.renderJsonKeepKeys ?? {});
|
|
2441
|
+
const keepInjectedKeys =
|
|
2442
|
+
keepEntries.length === 0
|
|
2443
|
+
? undefined
|
|
2444
|
+
: (component: string) => {
|
|
2445
|
+
const keys = keepEntries.flatMap(([suffix, k]) =>
|
|
2446
|
+
component.endsWith(suffix) ? k : [],
|
|
2447
|
+
);
|
|
2448
|
+
return keys.length > 0 ? keys : undefined;
|
|
2449
|
+
};
|
|
2430
2450
|
|
|
2431
2451
|
const jsonHeaders = {
|
|
2432
2452
|
...corsHeaders,
|
|
@@ -2464,7 +2484,7 @@ export function createDecoWorkerEntry(
|
|
|
2464
2484
|
}
|
|
2465
2485
|
const [serialized] = serializeRenderJson(
|
|
2466
2486
|
[{ component: resolved.component, props: resolved.props }],
|
|
2467
|
-
{ getSectionModule, sectionsToIgnore: ignoreSuffixes },
|
|
2487
|
+
{ getSectionModule, sectionsToIgnore: ignoreSuffixes, keepInjectedKeys },
|
|
2468
2488
|
);
|
|
2469
2489
|
if (!serialized) {
|
|
2470
2490
|
return Response.json(
|
|
@@ -2495,6 +2515,7 @@ export function createDecoWorkerEntry(
|
|
|
2495
2515
|
sectionsToIgnore: ignoreSuffixes,
|
|
2496
2516
|
deferred: page.deferredSections.map((d) => ({ component: d.component, index: d.index })),
|
|
2497
2517
|
lazyUrlFor,
|
|
2518
|
+
keepInjectedKeys,
|
|
2498
2519
|
},
|
|
2499
2520
|
);
|
|
2500
2521
|
|