@decocms/tanstack 8.18.0 → 8.19.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 CHANGED
@@ -31,7 +31,7 @@ A draft link (`?__draft=`) previews on the hosts the CMS allows, which `cms.read
31
31
 
32
32
  ### The visitor, the assignments and the client
33
33
 
34
- The worker decides once per request, at the edge. On every page and server-function request it reads the visitor with `readVisitor` from `@decocms/blocks/experiments` (the `deco_segment` cookie, or a new visitor), then each test and campaign on or off for it: `readAssignments(cms, { visitor, ...version })`, which resolves the saved `experiments` and `campaigns` blocks through `cms.client({ visitor, version, date, experiments, campaigns })` with the Studio link's version, moment and switched tests and campaigns. It hands the visitor to the app on `x-deco-visitor` and the decisions on `x-deco-assignments`, removing any copy sent from outside, and the decisions to the site's `pageCache` as `page.assignments`, for its key. It sends the visitor's cookie on a first visit only (a visitor with no id yet), never from a preview.
34
+ The worker decides once per request, at the edge. On every page and server-function request it reads the visitor with `readVisitor` from `@decocms/blocks/experiments` (the `deco_vid` cookie, or a new visitor), then each test and campaign on or off for it: `readAssignments(cms, { visitor, ...version })`, which resolves the saved `experiments` and `campaigns` blocks through `cms.client({ visitor, version, date, experiments, campaigns })` with the Studio link's version, moment and switched tests and campaigns. It hands the visitor to the app on `x-deco-visitor` and the decisions on `x-deco-assignments`, removing any copy sent from outside, and the decisions to the site's `pageCache` as `page.assignments`, for its key. It sends the visitor's cookie on a first visit only (a visitor with no id yet), never from a preview.
35
35
 
36
36
  `contentClient(cms)` from `@decocms/tanstack/server` builds `cms.client({ version, experiments, campaigns })` from the headers, every test and campaign as the worker decided it, so the page renders exactly what the cache keyed on and decides nothing again; `requestVersion()`, `requestVisitor()` and `requestAssignments()` return them for a site's own code. They trust those headers: behind `createDecoWorker` they hold what the worker decided, since it removes any copy sent from outside. A request that reaches the app without the worker (another entry, or an app that doesn't use `createDecoWorker`) is read the same way, with whatever `x-deco-version`, `x-deco-visitor` and `x-deco-assignments` it arrives with; with none, its visitor decides, and without one every test is off. Which requests go through the worker, and how the others are protected, is the site's call.
37
37
 
package/dist/visitor.d.ts CHANGED
@@ -7,7 +7,7 @@
7
7
  */
8
8
  /**
9
9
  * The request header carrying the visitor, in its stored form (the
10
- * `deco_segment` cookie's value, `serializeVisitor`). The worker removes any
10
+ * `deco_vid` cookie's value, `serializeVisitor`). The worker removes any
11
11
  * copy that arrives from outside, so a client can't send one itself.
12
12
  */
13
13
  export declare const VISITOR_HEADER = "x-deco-visitor";
package/dist/visitor.js CHANGED
@@ -7,7 +7,7 @@
7
7
  */
8
8
  /**
9
9
  * The request header carrying the visitor, in its stored form (the
10
- * `deco_segment` cookie's value, `serializeVisitor`). The worker removes any
10
+ * `deco_vid` cookie's value, `serializeVisitor`). The worker removes any
11
11
  * copy that arrives from outside, so a client can't send one itself.
12
12
  */
13
13
  export const VISITOR_HEADER = "x-deco-visitor";
@@ -28,7 +28,7 @@
28
28
  * `script-src`: the Studio channel's list, `studioOrigins`); immutable fingerprinted
29
29
  * assets; one `Set-Cookie` per cookie; `x-page-status`.
30
30
  * - The visitor: on a page or server-function request, `readVisitor` from
31
- * `@decocms/blocks/experiments` (the `deco_segment` cookie, or a new
31
+ * `@decocms/blocks/experiments` (the `deco_vid` cookie, or a new
32
32
  * visitor), handed to the app on `x-deco-visitor`; the cookie is sent on a
33
33
  * first visit only, never from a preview.
34
34
  * - What the request's content gives it, decided once per request: each test
@@ -28,7 +28,7 @@
28
28
  * `script-src`: the Studio channel's list, `studioOrigins`); immutable fingerprinted
29
29
  * assets; one `Set-Cookie` per cookie; `x-page-status`.
30
30
  * - The visitor: on a page or server-function request, `readVisitor` from
31
- * `@decocms/blocks/experiments` (the `deco_segment` cookie, or a new
31
+ * `@decocms/blocks/experiments` (the `deco_vid` cookie, or a new
32
32
  * visitor), handed to the app on `x-deco-visitor`; the cookie is sent on a
33
33
  * first visit only, never from a preview.
34
34
  * - What the request's content gives it, decided once per request: each test
@@ -205,7 +205,7 @@ export function createDecoWorker(options) {
205
205
  }
206
206
  /**
207
207
  * What a page or server-function request reads, decided once: the visitor
208
- * (`readVisitor`: the `deco_segment` cookie, or a new visitor) on
208
+ * (`readVisitor`: the `deco_vid` cookie, or a new visitor) on
209
209
  * `x-deco-visitor`, each test and campaign on or off for it and the
210
210
  * request's version (`readAssignments`) on `x-deco-assignments`, and the
211
211
  * cookie to send when the visitor had no id. A preview (a draft, or an old
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/tanstack",
3
- "version": "8.18.0",
3
+ "version": "8.19.0",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=24"
@@ -94,7 +94,7 @@
94
94
  }
95
95
  },
96
96
  "devDependencies": {
97
- "@decocms/blocks": "8.18.0",
97
+ "@decocms/blocks": "8.19.0",
98
98
  "@tanstack/react-router": "1.170.39",
99
99
  "@tanstack/react-start": "1.168.58",
100
100
  "@types/react": "^19.0.0",
package/src/visitor.ts CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  /**
10
10
  * The request header carrying the visitor, in its stored form (the
11
- * `deco_segment` cookie's value, `serializeVisitor`). The worker removes any
11
+ * `deco_vid` cookie's value, `serializeVisitor`). The worker removes any
12
12
  * copy that arrives from outside, so a client can't send one itself.
13
13
  */
14
14
  export const VISITOR_HEADER = "x-deco-visitor";
@@ -28,7 +28,7 @@
28
28
  * `script-src`: the Studio channel's list, `studioOrigins`); immutable fingerprinted
29
29
  * assets; one `Set-Cookie` per cookie; `x-page-status`.
30
30
  * - The visitor: on a page or server-function request, `readVisitor` from
31
- * `@decocms/blocks/experiments` (the `deco_segment` cookie, or a new
31
+ * `@decocms/blocks/experiments` (the `deco_vid` cookie, or a new
32
32
  * visitor), handed to the app on `x-deco-visitor`; the cookie is sent on a
33
33
  * first visit only, never from a preview.
34
34
  * - What the request's content gives it, decided once per request: each test
@@ -341,13 +341,13 @@ export function createDecoWorker<Env = unknown>(options: DecoWorkerOptions<Env>)
341
341
  routed?: true;
342
342
  /** A CMS redirect. */
343
343
  redirect?: true;
344
- /** The visitor's `deco_segment` cookie, on a first visit to the live site. */
344
+ /** The visitor's `deco_vid` cookie, on a first visit to the live site. */
345
345
  visitorCookie?: string;
346
346
  }
347
347
 
348
348
  /**
349
349
  * What a page or server-function request reads, decided once: the visitor
350
- * (`readVisitor`: the `deco_segment` cookie, or a new visitor) on
350
+ * (`readVisitor`: the `deco_vid` cookie, or a new visitor) on
351
351
  * `x-deco-visitor`, each test and campaign on or off for it and the
352
352
  * request's version (`readAssignments`) on `x-deco-assignments`, and the
353
353
  * cookie to send when the visitor had no id. A preview (a draft, or an old