@decocms/nextjs 8.5.2 → 8.6.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/README.md +81 -14
- package/dist/assignments.d.ts +95 -0
- package/dist/assignments.d.ts.map +1 -0
- package/dist/assignments.js +229 -0
- package/dist/assignments.js.map +1 -0
- package/dist/draft.d.ts +9 -7
- package/dist/draft.d.ts.map +1 -1
- package/dist/draft.js +10 -8
- package/dist/draft.js.map +1 -1
- package/dist/drafts.d.ts +29 -60
- package/dist/drafts.d.ts.map +1 -1
- package/dist/drafts.js +38 -117
- package/dist/drafts.js.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/instrumentation/index.d.ts +1 -1
- package/dist/instrumentation/index.js +3 -3
- package/dist/instrumentation/index.js.map +1 -1
- package/dist/proxy/index.d.ts +134 -30
- package/dist/proxy/index.d.ts.map +1 -1
- package/dist/proxy/index.js +169 -37
- package/dist/proxy/index.js.map +1 -1
- package/dist/server/index.d.ts +59 -20
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +129 -25
- package/dist/server/index.js.map +1 -1
- package/dist/server/slot.d.ts +19 -4
- package/dist/server/slot.d.ts.map +1 -1
- package/dist/server/slot.js +3 -9
- package/dist/server/slot.js.map +1 -1
- package/dist/visitor.d.ts +16 -0
- package/dist/visitor.d.ts.map +1 -0
- package/dist/visitor.js +16 -0
- package/dist/visitor.js.map +1 -0
- package/package.json +3 -3
- package/src/assignments.ts +278 -0
- package/src/draft.ts +10 -8
- package/src/drafts.ts +38 -126
- package/src/index.ts +5 -2
- package/src/instrumentation/index.ts +3 -3
- package/src/proxy/index.ts +269 -56
- package/src/server/index.ts +152 -33
- package/src/server/slot.ts +18 -5
- package/src/visitor.ts +16 -0
package/src/server/slot.ts
CHANGED
|
@@ -1,14 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* What a request renders, held for the request's Server Components: the
|
|
3
|
+
* version (a draft, or an old release, with its preview's moment and switched
|
|
4
|
+
* tests and campaigns), the visitor and the tests and campaigns the proxy
|
|
5
|
+
* decided. React's `cache()` gives one slot per request in the React Server
|
|
4
6
|
* Components graph, the scope a draft needs; no `next/headers` here, so the
|
|
5
7
|
* root components can read it without binding anything.
|
|
6
8
|
*/
|
|
9
|
+
import type { RequestVersion } from "@decocms/blocks";
|
|
10
|
+
import type { Visitor } from "@decocms/blocks/experiments";
|
|
7
11
|
import { cache } from "react";
|
|
12
|
+
import type { PathAssignments } from "../assignments.ts";
|
|
8
13
|
|
|
9
|
-
|
|
14
|
+
interface DraftSlot {
|
|
15
|
+
version: RequestVersion | null;
|
|
16
|
+
visitor: Visitor | null;
|
|
17
|
+
assignments: PathAssignments | null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const draftSlot = cache(
|
|
21
|
+
(): DraftSlot => ({ version: null, visitor: null, assignments: null }),
|
|
22
|
+
);
|
|
10
23
|
|
|
11
|
-
/** The
|
|
24
|
+
/** The version bound to this request (`bindDraft`), or `null` when it renders the current release. */
|
|
12
25
|
export function activeDraftPointer(): string | null {
|
|
13
|
-
return draftSlot().
|
|
26
|
+
return draftSlot().version?.version ?? null;
|
|
14
27
|
}
|
package/src/visitor.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How the proxy hands the pages the visitor: the request header it forwards
|
|
3
|
+
* once it read the visitor (`readVisitor` from `@decocms/blocks/experiments`,
|
|
4
|
+
* a new one on a first visit). The proxy writes it (`visitorRequestHeaders`
|
|
5
|
+
* from `@decocms/nextjs/proxy`); the pages read it (`bindDraft`, then
|
|
6
|
+
* `contentClient`, from `@decocms/nextjs/server`). The package's own copy: it
|
|
7
|
+
* never imports `@decocms/tanstack`. No imports, no state: safe in every
|
|
8
|
+
* bundle.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The request header carrying the visitor, in its stored form (the
|
|
13
|
+
* `deco_segment` cookie's value, `serializeVisitor`). The proxy removes any
|
|
14
|
+
* copy that arrives from outside (`draftRequestHeaders`).
|
|
15
|
+
*/
|
|
16
|
+
export const VISITOR_HEADER = "x-deco-visitor";
|