@decocms/tanstack 8.5.2 → 8.7.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.
Files changed (86) hide show
  1. package/README.md +35 -8
  2. package/dist/assignments.d.ts +31 -0
  3. package/dist/assignments.d.ts.map +1 -0
  4. package/dist/assignments.js +61 -0
  5. package/dist/assignments.js.map +1 -0
  6. package/dist/draft.d.ts +28 -9
  7. package/dist/draft.d.ts.map +1 -1
  8. package/dist/draft.js +30 -11
  9. package/dist/draft.js.map +1 -1
  10. package/dist/index.d.ts +3 -1
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +3 -1
  13. package/dist/index.js.map +1 -1
  14. package/dist/react/DecoDocument.d.ts.map +1 -1
  15. package/dist/react/DecoDocument.js +4 -4
  16. package/dist/react/DecoDocument.js.map +1 -1
  17. package/dist/react/pageValues.d.ts +3 -0
  18. package/dist/react/pageValues.d.ts.map +1 -1
  19. package/dist/react/pageValues.js +13 -4
  20. package/dist/react/pageValues.js.map +1 -1
  21. package/dist/scope/server.d.ts +6 -1
  22. package/dist/scope/server.d.ts.map +1 -1
  23. package/dist/scope/server.js.map +1 -1
  24. package/dist/server/index.d.ts +37 -8
  25. package/dist/server/index.d.ts.map +1 -1
  26. package/dist/server/index.js +45 -9
  27. package/dist/server/index.js.map +1 -1
  28. package/dist/shared.d.ts +5 -5
  29. package/dist/shared.js +5 -5
  30. package/dist/start/index.d.ts +3 -3
  31. package/dist/start/index.js +3 -3
  32. package/dist/visitor.d.ts +14 -0
  33. package/dist/visitor.d.ts.map +1 -0
  34. package/dist/visitor.js +14 -0
  35. package/dist/visitor.js.map +1 -0
  36. package/dist/worker/assignments.d.ts +44 -0
  37. package/dist/worker/assignments.d.ts.map +1 -0
  38. package/dist/worker/assignments.js +114 -0
  39. package/dist/worker/assignments.js.map +1 -0
  40. package/dist/worker/cache.d.ts +35 -0
  41. package/dist/worker/cache.d.ts.map +1 -0
  42. package/dist/worker/cache.js +45 -0
  43. package/dist/worker/cache.js.map +1 -0
  44. package/dist/worker/cookies.d.ts +1 -5
  45. package/dist/worker/cookies.d.ts.map +1 -1
  46. package/dist/worker/cookies.js +1 -26
  47. package/dist/worker/cookies.js.map +1 -1
  48. package/dist/worker/drafts.d.ts +54 -46
  49. package/dist/worker/drafts.d.ts.map +1 -1
  50. package/dist/worker/drafts.js +88 -88
  51. package/dist/worker/drafts.js.map +1 -1
  52. package/dist/worker/index.d.ts +82 -51
  53. package/dist/worker/index.d.ts.map +1 -1
  54. package/dist/worker/index.js +197 -372
  55. package/dist/worker/index.js.map +1 -1
  56. package/dist/worker/segment.d.ts +7 -6
  57. package/dist/worker/segment.d.ts.map +1 -1
  58. package/dist/worker/segment.js +6 -5
  59. package/dist/worker/segment.js.map +1 -1
  60. package/dist/worker/serverFn.d.ts +12 -0
  61. package/dist/worker/serverFn.d.ts.map +1 -0
  62. package/dist/worker/serverFn.js +44 -0
  63. package/dist/worker/serverFn.js.map +1 -0
  64. package/package.json +3 -3
  65. package/src/assignments.ts +77 -0
  66. package/src/draft.ts +34 -11
  67. package/src/index.ts +3 -1
  68. package/src/react/DecoDocument.tsx +20 -4
  69. package/src/react/pageValues.ts +12 -4
  70. package/src/scope/server.ts +6 -1
  71. package/src/server/index.ts +57 -12
  72. package/src/shared.ts +5 -5
  73. package/src/start/index.ts +3 -3
  74. package/src/visitor.ts +14 -0
  75. package/src/worker/assignments.ts +146 -0
  76. package/src/worker/cache.ts +61 -0
  77. package/src/worker/cookies.ts +1 -27
  78. package/src/worker/drafts.ts +113 -98
  79. package/src/worker/index.ts +276 -436
  80. package/src/worker/segment.ts +7 -7
  81. package/src/worker/serverFn.ts +36 -0
  82. package/dist/worker/cacheProfiles.d.ts +0 -43
  83. package/dist/worker/cacheProfiles.d.ts.map +0 -1
  84. package/dist/worker/cacheProfiles.js +0 -162
  85. package/dist/worker/cacheProfiles.js.map +0 -1
  86. package/src/worker/cacheProfiles.ts +0 -180
package/README.md CHANGED
@@ -7,7 +7,7 @@ Peers: `@decocms/blocks` (same version), `@tanstack/react-start`, `@tanstack/rea
7
7
  ## The worker
8
8
 
9
9
  ```ts
10
- // src/worker-entry.ts (wrangler.jsonc "main")
10
+ // src/worker-entry.ts (wrangler.jsonc "main"), without a page cache
11
11
  import { createDecoWorker } from "@decocms/tanstack/worker";
12
12
  import handler, { createServerEntry } from "@tanstack/react-start/server-entry";
13
13
  import { cms } from "./cms";
@@ -15,26 +15,53 @@ import { cms } from "./cms";
15
15
  export default createDecoWorker({
16
16
  serverEntry: createServerEntry({ fetch: handler.fetch }),
17
17
  cms,
18
- site: "my-store",
19
- buildHash: __BUILD_HASH__,
20
18
  dev: import.meta.env.DEV,
21
19
  });
22
20
  ```
23
21
 
24
- Always on: `/deco/_liveness`; 404 for v7's admin paths; Studio may frame the site (`frame-ancestors`, no `X-Frame-Options`) and the security headers; drafts (the host allowlist, the draft cookie, never cached, `noindex`); the CMS redirects; an edge cache keyed on the build, the content revision, the device and your `segment`, with stale-while-revalidate and stale-if-error; CDN caching of client-side navigation data under a checked `__cseg` token; one `Set-Cookie` per cookie; `x-page-status`; and `http.server.request.duration` for every request, in the CMS's telemetry through `recordServerRequest` from `@decocms/blocks/metrics` (nothing without a `token` or an `endpoint`, and then the page template is never looked up), labelled `http.route` (the content's page template, `redirect` for every CMS redirect, a fixed one such as `/_serverFn/*` or `/assets/*`, otherwise `unmatched`), `http.request.method`, `status_class`, `cache` (`HIT`, `MISS`, `BYPASS` or `DRAFT`) and `device`.
22
+ Always on: `/deco/_liveness`; 404 for v7's admin paths; Studio may frame the site (`frame-ancestors`, no `X-Frame-Options`) and the security headers; drafts (the CMS's preview hosts, the draft cookie, set only with a response below 500; any request with `?__draft=`, `off` included, or the draft cookie is a preview: it never reaches `pageCache` and answers exactly `Cache-Control: max-age=0, no-cache, must-revalidate`, `Vary: Cookie` and `noindex`, a fingerprinted asset excepted; a link to a draft that can't be read anymore renders the release, expires the cookie and shows `DecoPreview`'s calm notice, never a 500); the CMS redirects; one `Set-Cookie` per cookie; `x-page-status`; `CDN-Cache-Control: no-store` on every response that names none; and `http.server.request.duration` for every request, in the CMS's telemetry through `recordServerRequest` from `@decocms/blocks/metrics` (nothing without a `token` or an `endpoint`, and then the page template is never looked up), labelled `http.route` (the content's page template, `redirect` for every CMS redirect, a fixed one such as `/_serverFn/*` or `/assets/*`, otherwise `unmatched`), `http.request.method`, `status_class`, `cache` (`DRAFT` for a preview; otherwise the `X-Cache` your `pageCache` answered with, `HIT` for `HIT`, `STALE-HIT` and `STALE-ERROR`, `MISS`, else `BYPASS`) and `device`.
25
23
 
26
- Options, each for a value a site needs to change: `csp`, `segment`, `cacheProfiles`, `safeCookies`, `purgeToken`, `preload`, `previewHosts`, `routes` and `onCache`.
24
+ Options, each for a value a site needs to change: `csp`, `pageCache`, `preload` and `routes`.
25
+
26
+ The worker caches no page: the page cache is the site's, as on Next.js. Without `pageCache` every request renders. [The page cache](#the-page-cache) below links a complete worker entry with one.
27
27
 
28
28
  ### Draft hosts
29
29
 
30
- A draft link (`?__draft=`) previews where v7 allowed it: on the preview hosts the site declares (the `CMS` block's `preview.hosts`, or `createCMS`'s) and always on the hosts Deco runs the site on, `<site>.deco.site` and `<site>.deco-cx.workers.dev`. A site that declares no hosts previews only on those two, not on every host. `previewHosts: [...]` replaces the declared list with exact hosts (`["localhost:5173"]` for local development), as v7's `DECO_ALLOWED_PREVIEW_HOSTS` did; `previewHosts: "none"` turns previews off on every host. The worker passes the accepted draft to the app in the `x-deco-draft` request header: read it with `contentClient(cms)` from `@decocms/tanstack/server`.
30
+ A draft link (`?__draft=`) previews on the hosts the CMS allows, which `cms.readVersion` checks: the addresses Studio writes into the current release's metadata (`previewHosts` in `latest.json`, so `createCMS` needs the site's `site` for them), plus `createCMS({ preview: { hosts } })`. The site lists nothing else. With no list, every host previews: a site with no `latest.json` on the CDN yet, or one published before Studio wrote `previewHosts` (its next publish writes the list), and content with no `site` unless `preview.hosts` lists hosts (such as `["localhost"]`). If `latest.json` can't be read (a network error, a 5xx, a malformed file), previews stay closed, besides `preview.hosts`, until a read succeeds. A link on any other host gets the release, never an error. The same link can carry a published release's commit SHA instead of a draft (Studio's "Preview this version"), and either one can carry a preview time (`__at`) and tests and campaigns switched on or off (`__test`, `__campaign`), which `cms.readVersion` reads as the client's `date`, `experiments` and `campaigns`; all of it passes the same host check, so a visitor on the live site never picks a version. The worker passes the accepted version, alone, to the app in the `x-deco-version` request header (`requestVersion(request)` reads it in a `routes` handler). A draft request checks for the latest release once (`cms.checkRelease()`): the host check, the worker's read of the draft, its redirects and assignments and the page's `contentClient` all wait for that one check, whose id the worker forwards on `x-deco-release-check` (removing any copy sent from outside), so one preview request fetches `latest.json` once and shows the release published a moment ago.
31
+
32
+ ### The visitor, the assignments and the client
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.
35
+
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
+
38
+ ### The page cache
39
+
40
+ `pageCache(page)` is the site's own cache around the app. The worker calls it for every page and server-function request `isCacheable` accepts (a `GET` of the current release with no `?__draft=` and no draft cookie, outside `vite dev`, without `Authorization`, not `/_build`: never a preview, a draft or an old release), with `page.request` (as the app gets it), `page.url`, `page.visitor` (the visitor the page renders for, a first visit's new one included), `page.assignments` (each test and campaign on or off, as the page renders them), `page.device`, `env`, `ctx` and `page.render(scope?)`, which renders the page. Answer from your cache, or call `render()`; set `X-Cache` on the answer for the request metric. A page request with `Authorization` never reaches it and answers `Cache-Control: private, no-cache, no-store, must-revalidate`, whatever the app set, so no shared cache keeps one caller's page.
41
+
42
+ The visitor's first-visit cookie is never in what `render()` returns: the worker adds it to whatever `pageCache` answers, a cached copy included. So a stored copy never carries a visitor's cookie, and a new visitor served from the cache still gets theirs. Never store a response that sets any other cookie.
43
+
44
+ What the key needs, from `@decocms/tanstack/worker`, the same names as `@decocms/nextjs/proxy`'s where both have them:
45
+
46
+ - `assignmentsKey(page.assignments)`: the tests on and the campaigns running, as one string (`x=<tests>|c=<campaigns>`, `""` for none), never the visitor's id. Visitors on the same side of every test share one entry, the other side gets its own, and a campaign starting or ending moves every page to new entries. `liveAssignmentKeys(cms)` lists every key a live request can carry now (each subset of the saved tests, with the running campaigns and with none), for a purge.
47
+ - `cacheVersion(cms, buildHash)`: `<build>.<content revision>`, so a deploy or a published release gets new entries at once.
48
+ - `detectDevice(userAgent)` (v7's classes: `mobile`, `tablet`, `desktop`), `segmentKey(segment)` (a segment's parts as one stable string) and `segmentToken(segment, version)`: the `__cseg` token. Pass it as `render({ csegToken })` and `DecoDocument` publishes it; `decoServerFnFetch` sends it back on the page's navigation data (`CSEG_PARAM`), and your cache may let the CDN keep that response when the token matches the request's own.
49
+ - `isCacheable(request, { version, dev })`, `requestVersion(request)`, `isServerFnPath(pathname)`, `serverFnPagePath(url)` (the page a server-function page load asks for, from its payload) and `DEGRADED_HEADER` (a page whose loader failed: never store it).
50
+
51
+ A complete worker entry with a page cache is [`examples/tanstack-worker-smoke/src/worker-entry.ts`](https://github.com/decocms/blocks/blob/main/examples/tanstack-worker-smoke/src/worker-entry.ts): copy it to your `src/worker-entry.ts` and change what your site needs. It is v7's edge cache on the Cloudflare Cache API, and every part of it is yours:
52
+
53
+ - **The key**: the path (tracking parameters and `__cseg` dropped), the device and your segment's own parts (`buildSegment`, v7's: a region, a sales channel), `assignmentsKey(page.assignments)` and `cacheVersion(cms, __BUILD_HASH__)`. A signed-in shopper (`loggedIn: true` from `buildSegment`), a private response and a degraded one are never stored.
54
+ - **The profiles**: v7's cache profiles per URL (`PROFILES`), each with how long a page stays fresh, how long it is served stale while it revalidates, and how long when the app fails.
55
+ - **The purge**: v7's `POST /_cache/purge` with `Authorization: Bearer <PURGE_TOKEN>` and a body of `{ "paths": ["/", "/shoes"] }`, optionally with `"segments": [{ "device": "desktop", "salesChannel": "2" }]` (your own parts). It drops each exact path (`/shoes` never drops `/shoes?page=2`) under the current version, for each segment (the devices when the body names none), each assignments key, as a navigation and as a server-function fetch, and answers `{ "purged": [...], "total": n }`. The Cache API is per data center, so a purge reaches the copies of the data center that serves it.
56
+
57
+ `__BUILD_HASH__` is the build id `decoTanstack()` defines (declare it once: `declare const __BUILD_HASH__: string;`), and `PURGE_TOKEN` a Worker secret. The example runs that file as its worker entry, with its tests (`worker-entry.test.ts` next to it).
31
58
 
32
59
  ### Names and Studio's origins
33
60
 
34
- The root export holds what the worker, `/server` and `DecoDocument` share, for a site's own code: the draft names (`DRAFT_PARAM` `__draft`, `DRAFT_COOKIE` `__deco_draft`, `DRAFT_HEADER` `x-deco-draft`), `draftResponseHeaders(pointer)` (`no-store, private`, `Vary: Cookie`, `noindex`), and Studio's origins: `STUDIO_ORIGINS`, `STUDIO_FRAME_ANCESTORS` (what the worker's `frame-ancestors` starts from) and `isStudioOrigin`. `DecoDocument` passes `STUDIO_ORIGINS` to the Studio bridge.
61
+ The root export holds what the worker, `/server` and `DecoDocument` share, for a site's own code: the draft names (`DRAFT_PARAM` `__draft`, `DRAFT_COOKIE` `__deco_draft`), the headers the worker hands the app (`VERSION_HEADER` `x-deco-version`, `VISITOR_HEADER` `x-deco-visitor`, `ASSIGNMENTS_HEADER` `x-deco-assignments`), `draftResponseHeaders(preview)` (`max-age=0, no-cache, must-revalidate`, `Vary: Cookie`, `noindex`; pass the version, or `true` for any request with a draft signal), and Studio's origins: `STUDIO_ORIGINS`, `STUDIO_FRAME_ANCESTORS` (what the worker's `frame-ancestors` starts from) and `isStudioOrigin`. `DecoDocument` passes `STUDIO_ORIGINS` to the Studio bridge.
35
62
 
36
63
  ```ts
37
- import { DRAFT_HEADER, STUDIO_ORIGINS } from "@decocms/tanstack";
64
+ import { STUDIO_ORIGINS, VERSION_HEADER } from "@decocms/tanstack";
38
65
  ```
39
66
 
40
67
  ## The app
@@ -0,0 +1,31 @@
1
+ /**
2
+ * How the worker hands the app what it decided: each test of the saved
3
+ * `experiments` block on or off for the request's visitor and each campaign
4
+ * of the saved `campaigns` block running or not, as one request header. The
5
+ * worker writes it (`./worker/index.ts`); the app reads it (`contentClient`
6
+ * from `@decocms/tanstack/server`), so the page builds
7
+ * `cms.client({ version, experiments, campaigns })` and decides nothing
8
+ * again. Type imports only, no state: safe in every bundle.
9
+ */
10
+ import type { Assignments } from "@decocms/blocks/experiments";
11
+ /**
12
+ * The request header carrying the decided tests and campaigns
13
+ * (`serializeAssignments`). The worker removes any copy that arrives from
14
+ * outside, so a client can't send one itself.
15
+ */
16
+ export declare const ASSIGNMENTS_HEADER = "x-deco-assignments";
17
+ /** The tests and campaigns of one request, every name on or off. */
18
+ export interface DecidedAssignments {
19
+ /** Each test of the saved `experiments` block: on or off. */
20
+ experiments: Readonly<Assignments>;
21
+ /** Each campaign of the saved `campaigns` block: running or not. */
22
+ campaigns: Readonly<Assignments>;
23
+ }
24
+ /**
25
+ * The tests and campaigns as one header value, every name with its state:
26
+ * `x=+on,-off|c=+running,-not` (names URL-encoded and sorted), `-` for none.
27
+ */
28
+ export declare function serializeAssignments(assignments: DecidedAssignments): string;
29
+ /** What `serializeAssignments` wrote; `null` for anything else (absent, malformed, spelled another way). */
30
+ export declare function parseAssignments(value: string | null | undefined): DecidedAssignments | null;
31
+ //# sourceMappingURL=assignments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assignments.d.ts","sourceRoot":"","sources":["../src/assignments.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE/D;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AAEvD,oEAAoE;AACpE,MAAM,WAAW,kBAAkB;IACjC,6DAA6D;IAC7D,WAAW,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;IACnC,oEAAoE;IACpE,SAAS,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;CAClC;AAeD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,kBAAkB,GAAG,MAAM,CAO5E;AAED,4GAA4G;AAC5G,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,kBAAkB,GAAG,IAAI,CAuB5F"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * The request header carrying the decided tests and campaigns
3
+ * (`serializeAssignments`). The worker removes any copy that arrives from
4
+ * outside, so a client can't send one itself.
5
+ */
6
+ export const ASSIGNMENTS_HEADER = "x-deco-assignments";
7
+ /** Plain code-unit order, the same on every server and locale. */
8
+ const byCodeUnit = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
9
+ const record = () => Object.create(null);
10
+ /** `+name` on, `-name` off, names URL-encoded and sorted. */
11
+ function encodeStates(states) {
12
+ return Object.keys(states)
13
+ .sort(byCodeUnit)
14
+ .map((name) => `${states[name] === true ? "+" : "-"}${encodeURIComponent(name)}`)
15
+ .join(",");
16
+ }
17
+ /**
18
+ * The tests and campaigns as one header value, every name with its state:
19
+ * `x=+on,-off|c=+running,-not` (names URL-encoded and sorted), `-` for none.
20
+ */
21
+ export function serializeAssignments(assignments) {
22
+ const parts = [];
23
+ const tests = encodeStates(assignments.experiments);
24
+ const campaigns = encodeStates(assignments.campaigns);
25
+ if (tests)
26
+ parts.push(`x=${tests}`);
27
+ if (campaigns)
28
+ parts.push(`c=${campaigns}`);
29
+ return parts.length === 0 ? "-" : parts.join("|");
30
+ }
31
+ /** What `serializeAssignments` wrote; `null` for anything else (absent, malformed, spelled another way). */
32
+ export function parseAssignments(value) {
33
+ if (typeof value !== "string" || value === "")
34
+ return null;
35
+ const parsed = { experiments: record(), campaigns: record() };
36
+ if (value === "-")
37
+ return parsed;
38
+ const seen = new Set();
39
+ try {
40
+ for (const part of value.split("|")) {
41
+ const eq = part.indexOf("=");
42
+ const tag = part.slice(0, eq);
43
+ const list = part.slice(eq + 1);
44
+ if (eq <= 0 || list === "" || seen.has(tag) || (tag !== "x" && tag !== "c"))
45
+ return null;
46
+ seen.add(tag);
47
+ const target = (tag === "x" ? parsed.experiments : parsed.campaigns);
48
+ for (const entry of list.split(",")) {
49
+ const state = entry[0];
50
+ if (state !== "+" && state !== "-")
51
+ return null;
52
+ target[decodeURIComponent(entry.slice(1))] = state === "+";
53
+ }
54
+ }
55
+ }
56
+ catch {
57
+ return null;
58
+ }
59
+ return serializeAssignments(parsed) === value ? parsed : null;
60
+ }
61
+ //# sourceMappingURL=assignments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assignments.js","sourceRoot":"","sources":["../src/assignments.ts"],"names":[],"mappings":"AAWA;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,oBAAoB,CAAC;AAUvD,kEAAkE;AAClE,MAAM,UAAU,GAAG,CAAC,CAAS,EAAE,CAAS,EAAU,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,C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AAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;AAChE,CAAC"}
package/dist/draft.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * The draft names and headers of a Deco TanStack site: the `?__draft=` link,
3
3
  * the cookie that keeps a preview going, the request header the worker hands
4
- * the app, and the response headers of a page rendered from a draft. The
4
+ * the app the version on, and the response headers of a page rendered from a draft. The
5
5
  * worker reads and writes them (`./worker/drafts.ts`); the app reads the
6
6
  * header (`@decocms/tanstack/server`). No imports, no state: safe in every
7
7
  * bundle.
@@ -19,15 +19,34 @@ export declare const DRAFT_PARAM = "__draft";
19
19
  export declare const DRAFT_COOKIE = "__deco_draft";
20
20
  /**
21
21
  * The request header the worker sets on the request it hands the app once it
22
- * accepted the draft: the pointer, already checked. The worker removes any
23
- * copy that arrives from outside, so a client can't send one itself.
22
+ * accepted a Studio link: the version (a draft pointer or a release's commit
23
+ * SHA), already checked, without the preview's moment and switched tests
24
+ * (those are decided in the worker: `ASSIGNMENTS_HEADER`). The worker
25
+ * removes any copy that arrives from outside, so a client can't send one
26
+ * itself.
24
27
  */
25
- export declare const DRAFT_HEADER = "x-deco-draft";
28
+ export declare const VERSION_HEADER = "x-deco-version";
26
29
  /**
27
- * The response headers of a page rendered from a draft: never stored by a
28
- * browser or a CDN (`Cache-Control: no-store, private`, `Vary: Cookie`) and
29
- * never indexed (`X-Robots-Tag: noindex, nofollow`). `{}` when `pointer` is
30
- * `null`, so the result of the draft decision applies as is.
30
+ * The request header the worker sets on a draft request: the id of the
31
+ * release check it made for it (`cms.checkRelease()`), so the page's draft
32
+ * reads wait for that check instead of making their own (one `latest.json`
33
+ * read per preview request). The worker removes any copy that arrives from
34
+ * outside; an id the CMS didn't make is a check of its own anyway.
31
35
  */
32
- export declare function draftResponseHeaders(pointer: string | null | undefined): Record<string, string>;
36
+ export declare const RELEASE_CHECK_HEADER = "x-deco-release-check";
37
+ /**
38
+ * The `Cache-Control` of every response to a preview request (a request with
39
+ * `?__draft=`, whatever its value, or the draft cookie): always revalidated,
40
+ * never answered from a cache (PO 2026-10-23).
41
+ */
42
+ export declare const DRAFT_CACHE_CONTROL = "max-age=0, no-cache, must-revalidate";
43
+ /**
44
+ * The response headers of a preview: never answered from a browser's or a
45
+ * CDN's cache (`Cache-Control: max-age=0, no-cache, must-revalidate`, `Vary:
46
+ * Cookie`) and never indexed (`X-Robots-Tag: noindex, nofollow`). `{}` when
47
+ * `preview` is `null`, `false` or empty, so the result of the draft decision
48
+ * applies as is: pass the version, or whether the request carries a draft
49
+ * signal at all (`?__draft=off` and a refused or unavailable draft too).
50
+ */
51
+ export declare function draftResponseHeaders(preview: string | boolean | null | undefined): Record<string, string>;
33
52
  //# sourceMappingURL=draft.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"draft.d.ts","sourceRoot":"","sources":["../src/draft.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;GAIG;AACH,eAAO,MAAM,WAAW,YAAY,CAAC;AAErC;;;GAGG;AACH,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAE3C;;;;GAIG;AACH,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAE3C;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAO/F"}
1
+ {"version":3,"file":"draft.d.ts","sourceRoot":"","sources":["../src/draft.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;GAIG;AACH,eAAO,MAAM,WAAW,YAAY,CAAC;AAErC;;;GAGG;AACH,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAE3C;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,mBAAmB,CAAC;AAE/C;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,yBAAyB,CAAC;AAE3D;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,yCAAyC,CAAC;AAE1E;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,GAC3C,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAOxB"}
package/dist/draft.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * The draft names and headers of a Deco TanStack site: the `?__draft=` link,
3
3
  * the cookie that keeps a preview going, the request header the worker hands
4
- * the app, and the response headers of a page rendered from a draft. The
4
+ * the app the version on, and the response headers of a page rendered from a draft. The
5
5
  * worker reads and writes them (`./worker/drafts.ts`); the app reads the
6
6
  * header (`@decocms/tanstack/server`). No imports, no state: safe in every
7
7
  * bundle.
@@ -19,21 +19,40 @@ export const DRAFT_PARAM = "__draft";
19
19
  export const DRAFT_COOKIE = "__deco_draft";
20
20
  /**
21
21
  * The request header the worker sets on the request it hands the app once it
22
- * accepted the draft: the pointer, already checked. The worker removes any
23
- * copy that arrives from outside, so a client can't send one itself.
22
+ * accepted a Studio link: the version (a draft pointer or a release's commit
23
+ * SHA), already checked, without the preview's moment and switched tests
24
+ * (those are decided in the worker: `ASSIGNMENTS_HEADER`). The worker
25
+ * removes any copy that arrives from outside, so a client can't send one
26
+ * itself.
24
27
  */
25
- export const DRAFT_HEADER = "x-deco-draft";
28
+ export const VERSION_HEADER = "x-deco-version";
26
29
  /**
27
- * The response headers of a page rendered from a draft: never stored by a
28
- * browser or a CDN (`Cache-Control: no-store, private`, `Vary: Cookie`) and
29
- * never indexed (`X-Robots-Tag: noindex, nofollow`). `{}` when `pointer` is
30
- * `null`, so the result of the draft decision applies as is.
30
+ * The request header the worker sets on a draft request: the id of the
31
+ * release check it made for it (`cms.checkRelease()`), so the page's draft
32
+ * reads wait for that check instead of making their own (one `latest.json`
33
+ * read per preview request). The worker removes any copy that arrives from
34
+ * outside; an id the CMS didn't make is a check of its own anyway.
31
35
  */
32
- export function draftResponseHeaders(pointer) {
33
- if (!pointer)
36
+ export const RELEASE_CHECK_HEADER = "x-deco-release-check";
37
+ /**
38
+ * The `Cache-Control` of every response to a preview request (a request with
39
+ * `?__draft=`, whatever its value, or the draft cookie): always revalidated,
40
+ * never answered from a cache (PO 2026-10-23).
41
+ */
42
+ export const DRAFT_CACHE_CONTROL = "max-age=0, no-cache, must-revalidate";
43
+ /**
44
+ * The response headers of a preview: never answered from a browser's or a
45
+ * CDN's cache (`Cache-Control: max-age=0, no-cache, must-revalidate`, `Vary:
46
+ * Cookie`) and never indexed (`X-Robots-Tag: noindex, nofollow`). `{}` when
47
+ * `preview` is `null`, `false` or empty, so the result of the draft decision
48
+ * applies as is: pass the version, or whether the request carries a draft
49
+ * signal at all (`?__draft=off` and a refused or unavailable draft too).
50
+ */
51
+ export function draftResponseHeaders(preview) {
52
+ if (!preview)
34
53
  return {};
35
54
  return {
36
- "Cache-Control": "no-store, private",
55
+ "Cache-Control": DRAFT_CACHE_CONTROL,
37
56
  Vary: "Cookie",
38
57
  "X-Robots-Tag": "noindex, nofollow",
39
58
  };
package/dist/draft.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"draft.js","sourceRoot":"","sources":["../src/draft.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,SAAS,CAAC;AAErC;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,cAAc,CAAC;AAE3C;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,cAAc,CAAC;AAE3C;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAkC;IACrE,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,CAAC;IACxB,OAAO;QACL,eAAe,EAAE,mBAAmB;QACpC,IAAI,EAAE,QAAQ;QACd,cAAc,EAAE,mBAAmB;KACpC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"draft.js","sourceRoot":"","sources":["../src/draft.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,SAAS,CAAC;AAErC;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,cAAc,CAAC;AAE3C;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,gBAAgB,CAAC;AAE/C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,sBAAsB,CAAC;AAE3D;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,sCAAsC,CAAC;AAE1E;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAClC,OAA4C;IAE5C,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,CAAC;IACxB,OAAO;QACL,eAAe,EAAE,mBAAmB;QACpC,IAAI,EAAE,QAAQ;QACd,cAAc,EAAE,mBAAmB;KACpC,CAAC;AACJ,CAAC"}
package/dist/index.d.ts CHANGED
@@ -4,6 +4,8 @@
4
4
  * that sets its own headers, a CSP it writes itself). No imports, no state:
5
5
  * safe in every bundle.
6
6
  */
7
- export { DRAFT_COOKIE, DRAFT_HEADER, DRAFT_PARAM, draftResponseHeaders } from "./draft.ts";
7
+ export { ASSIGNMENTS_HEADER } from "./assignments.ts";
8
+ export { DRAFT_COOKIE, DRAFT_PARAM, draftResponseHeaders, VERSION_HEADER } from "./draft.ts";
8
9
  export { isStudioOrigin, STUDIO_FRAME_ANCESTORS, STUDIO_ORIGINS } from "./studio.ts";
10
+ export { VISITOR_HEADER } from "./visitor.ts";
9
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAC3F,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC7F,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACrF,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC"}
package/dist/index.js CHANGED
@@ -4,6 +4,8 @@
4
4
  * that sets its own headers, a CSP it writes itself). No imports, no state:
5
5
  * safe in every bundle.
6
6
  */
7
- export { DRAFT_COOKIE, DRAFT_HEADER, DRAFT_PARAM, draftResponseHeaders } from "./draft.js";
7
+ export { ASSIGNMENTS_HEADER } from "./assignments.js";
8
+ export { DRAFT_COOKIE, DRAFT_PARAM, draftResponseHeaders, VERSION_HEADER } from "./draft.js";
8
9
  export { isStudioOrigin, STUDIO_FRAME_ANCESTORS, STUDIO_ORIGINS } from "./studio.js";
10
+ export { VISITOR_HEADER } from "./visitor.js";
9
11
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAC3F,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,oBAAoB,EAAE,cAAc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vB,kFAAkF;IAClF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2EAA2E;IAC3E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0GAA0G;IAC1G,MAAM,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IACxB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,wEAAwE;IACxE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,wBAAgB,YAAY,CAAC,EAC3B,IAAI,EACJ,IAAW,EACX,aAA+C,EAC/C,OAAY,EACZ,UAAgB,EAChB,MAAe,EACf,YAAY,EACZ,KAAK,EACL,QAAQ,GACT,EAAE,iBAAiB,+BA6CnB"}
@@ -62,11 +62,11 @@ function studioPageOf(matches) {
62
62
  return undefined;
63
63
  }
64
64
  /** The Studio bridge, with the page on screen, and the badge for the request's draft. */
65
- function StudioPieces({ site, editShortcut, nonce, draft, }) {
65
+ function StudioPieces({ site, editShortcut, nonce, draft, draftUnavailable, }) {
66
66
  // Two primitives, so a navigation that keeps the page doesn't re-render the document.
67
67
  const pathTemplate = useRouterState({ select: (s) => studioPageOf(s.matches)?.pathTemplate });
68
68
  const pageId = useRouterState({ select: (s) => studioPageOf(s.matches)?.id });
69
- return (_jsxs(_Fragment, { children: [_jsx(StudioBridge, { site: site, trustedOrigins: STUDIO_ORIGINS, editShortcut: editShortcut, page: { pathTemplate, id: pageId }, nonce: nonce }), _jsx(DraftBadge, { pointer: draft ?? null })] }));
69
+ return (_jsxs(_Fragment, { children: [_jsx(StudioBridge, { site: site, trustedOrigins: STUDIO_ORIGINS, editShortcut: editShortcut, page: { pathTemplate, id: pageId }, nonce: nonce }), _jsx(DraftBadge, { pointer: draft ?? null, unavailable: draftUnavailable })] }));
70
70
  }
71
71
  /**
72
72
  * What `DecoDocument` mounts for Studio and draft previews, for a site that
@@ -77,7 +77,7 @@ function StudioPieces({ site, editShortcut, nonce, draft, }) {
77
77
  export function DecoPreview({ site, editShortcut, nonce }) {
78
78
  const values = pageValues();
79
79
  const publish = publishScript(values);
80
- return (_jsxs(_Fragment, { children: [publish && (_jsx("script", { nonce: nonce, suppressHydrationWarning: true, dangerouslySetInnerHTML: { __html: publish } })), _jsx(StudioPieces, { site: site, editShortcut: editShortcut, nonce: nonce, draft: values.draft })] }));
80
+ return (_jsxs(_Fragment, { children: [publish && (_jsx("script", { nonce: nonce, suppressHydrationWarning: true, dangerouslySetInnerHTML: { __html: publish } })), _jsx(StudioPieces, { site: site, editShortcut: editShortcut, nonce: nonce, draft: values.draft, draftUnavailable: values.draftUnavailable })] }));
81
81
  }
82
82
  export function DecoDocument({ site, lang = "en", bodyClassName = "bg-base-200 text-base-content", account = "", readyDelay = 500, outlet = "main", editShortcut, nonce, children, }) {
83
83
  // Pages wait for this signal before running work that must follow hydration.
@@ -91,6 +91,6 @@ export function DecoDocument({ site, lang = "en", bodyClassName = "bg-base-200 t
91
91
  const values = pageValues();
92
92
  const publish = publishScript(values);
93
93
  const Outer = outlet;
94
- return (_jsxs("html", { lang: lang, "data-theme": "light", suppressHydrationWarning: true, children: [_jsxs("head", { children: [_jsx(HeadContent, {}), publish && (_jsx("script", { nonce: nonce, suppressHydrationWarning: true, dangerouslySetInnerHTML: { __html: publish } }))] }), _jsxs("body", { className: bodyClassName, suppressHydrationWarning: true, children: [_jsx(ScriptOnce, { children: eventsBootstrap(account) }), _jsx(NavigationProgress, {}), _jsx(Outer, { children: _jsx(StableOutlet, {}) }), children, _jsx(StudioPieces, { site: site, editShortcut: editShortcut, nonce: nonce, draft: values.draft }), _jsx(ScriptOnce, { children: DATA_EVENT_OBSERVER }), _jsx(Scripts, {})] })] }));
94
+ return (_jsxs("html", { lang: lang, "data-theme": "light", suppressHydrationWarning: true, children: [_jsxs("head", { children: [_jsx(HeadContent, {}), publish && (_jsx("script", { nonce: nonce, suppressHydrationWarning: true, dangerouslySetInnerHTML: { __html: publish } }))] }), _jsxs("body", { className: bodyClassName, suppressHydrationWarning: true, children: [_jsx(ScriptOnce, { children: eventsBootstrap(account) }), _jsx(NavigationProgress, {}), _jsx(Outer, { children: _jsx(StableOutlet, {}) }), children, _jsx(StudioPieces, { site: site, editShortcut: editShortcut, nonce: nonce, draft: values.draft, draftUnavailable: values.draftUnavailable }), _jsx(ScriptOnce, { children: DATA_EVENT_OBSERVER }), _jsx(Scripts, {})] })] }));
95
95
  }
96
96
  //# sourceMappingURL=DecoDocument.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DecoDocument.js","sourceRoot":"","sources":["../../src/react/DecoDocument.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAClG,OAAO,EAAkB,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAalF,0EAA0E;AAC1E,MAAM,UAAU,kBAAkB,CAAC,EACjC,KAAK,GAAG,8CAA8C,GAC9B;IACxB,MAAM,SAAS,GAAG,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC;IACjE,IAAI,CAAC,SAAS;QAAE,OAAO,IAAI,CAAC;IAC5B,OAAO,CACL,eACE,SAAS,EAAC,yDAAyD,EACnE,KAAK,EAAE,EAAE,KAAK,EAAE,EAChB,IAAI,EAAC,aAAa,gBACP,wBAAmB,aAE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BAAwB,mBAC3D,2BACE,KAAC,WAAW,KAAG,EACd,OAAO,IAAI,CACV,iBACE,KAAK,EAAE,KAAK,EACZ,wBAAwB,QACxB,uBAAuB,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,GAC5C,CACH,IACI,EACP,gBAAM,SAAS,EAAE,aAAa,EAAE,wBAAwB,mBACtD,KAAC,UAAU,cAAE,eAAe,CAAC,OAAO,CAAC,GAAc,EACnD,KAAC,kBAAkB,KAAG,EACtB,KAAC,KAAK,cACJ,KAAC,YAAY,KAAG,GACV,EACP,QAAQ,EACT,KAAC,YAAY,IACX,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,MAAM,CAAC,KAAK,EACnB,gBAAgB,EAAE,MAAM,CAAC,gBAAgB,GACzC,EACF,KAAC,UAAU,cAAE,mBAAmB,GAAc,EAC9C,KAAC,OAAO,KAAG,IACN,IACF,CACR,CAAC;AACJ,CAAC"}
@@ -1,7 +1,10 @@
1
1
  export declare const DRAFT_GLOBAL = "__DECO_DRAFT";
2
+ export declare const DRAFT_UNAVAILABLE_GLOBAL = "__DECO_DRAFT_UNAVAILABLE";
2
3
  export interface PageValues {
3
4
  cseg?: string;
4
5
  draft?: string;
6
+ /** The link named a draft that can't be read anymore: the page shows the release. */
7
+ draftUnavailable?: boolean;
5
8
  }
6
9
  /** On the server, the request scope; in the browser, what the server published on `window`. */
7
10
  export declare function pageValues(): PageValues;
@@ -1 +1 @@
1
- {"version":3,"file":"pageValues.d.ts","sourceRoot":"","sources":["../../src/react/pageValues.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAE3C,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,+FAA+F;AAC/F,wBAAgB,UAAU,IAAI,UAAU,CASvC;AAED,kGAAkG;AAClG,wBAAgB,aAAa,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,CAO/D"}
1
+ {"version":3,"file":"pageValues.d.ts","sourceRoot":"","sources":["../../src/react/pageValues.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAC3C,eAAO,MAAM,wBAAwB,6BAA6B,CAAC;AAEnE,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qFAAqF;IACrF,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,+FAA+F;AAC/F,wBAAgB,UAAU,IAAI,UAAU,CAavC;AAED,kGAAkG;AAClG,wBAAgB,aAAa,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,CAQ/D"}
@@ -1,19 +1,26 @@
1
1
  /**
2
- * What the worker handed this request's render (the CDN segment token and the
3
- * draft), and the inline script that publishes it to the browser.
2
+ * What the worker handed this request's render (the CDN segment token, the
3
+ * draft, and whether the link's draft can't be read anymore), and the inline script that publishes it to the browser.
4
4
  */
5
5
  import { currentScope } from "@decocms/tanstack/scope";
6
6
  import { CSEG_GLOBAL } from "../shared.js";
7
7
  export const DRAFT_GLOBAL = "__DECO_DRAFT";
8
+ export const DRAFT_UNAVAILABLE_GLOBAL = "__DECO_DRAFT_UNAVAILABLE";
8
9
  /** On the server, the request scope; in the browser, what the server published on `window`. */
9
10
  export function pageValues() {
10
11
  if (typeof window !== "undefined") {
11
12
  const w = window;
12
13
  const pick = (k) => typeof w[k] === "string" && w[k] !== "" ? w[k] : undefined;
13
- return { cseg: pick(CSEG_GLOBAL), draft: pick(DRAFT_GLOBAL) };
14
+ const values = { cseg: pick(CSEG_GLOBAL), draft: pick(DRAFT_GLOBAL) };
15
+ if (w[DRAFT_UNAVAILABLE_GLOBAL] === true)
16
+ values.draftUnavailable = true;
17
+ return values;
14
18
  }
15
19
  const scope = currentScope();
16
- return { cseg: scope?.csegToken, draft: scope?.draft };
20
+ const values = { cseg: scope?.csegToken, draft: scope?.draft };
21
+ if (scope?.draftUnavailable === true)
22
+ values.draftUnavailable = true;
23
+ return values;
17
24
  }
18
25
  /** The script that publishes `pageValues()`; the same markup on the server and in the browser. */
19
26
  export function publishScript(values) {
@@ -24,6 +31,8 @@ export function publishScript(values) {
24
31
  parts.push(`window.${CSEG_GLOBAL}=${literal(values.cseg)}`);
25
32
  if (values.draft)
26
33
  parts.push(`window.${DRAFT_GLOBAL}=${literal(values.draft)}`);
34
+ if (values.draftUnavailable)
35
+ parts.push(`window.${DRAFT_UNAVAILABLE_GLOBAL}=true`);
27
36
  return parts.length ? parts.join(";") : null;
28
37
  }
29
38
  //# sourceMappingURL=pageValues.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pageValues.js","sourceRoot":"","sources":["../../src/react/pageValues.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,MAAM,CAAC,MAAM,YAAY,GAAG,cAAc,CAAC;AAO3C,+FAA+F;AAC/F,MAAM,UAAU,UAAU;IACxB,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QAClC,MAAM,CAAC,GAAG,MAA4C,CAAC;QACvD,MAAM,IAAI,GAAG,CAAC,CAAS,EAAE,EAAE,CACzB,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC,CAAY,CAAC,CAAC,CAAC,SAAS,CAAC;QACzE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC;IAChE,CAAC;IACD,MAAM,KAAK,GAAG,YAAY,EAAE,CAAC;IAC7B,OAA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AU,wBAAwB,OAAO,CAAC,CAAC;IACnF,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC/C,CAAC"}
@@ -1,8 +1,13 @@
1
1
  export interface RequestScope {
2
- /** The CDN segment token for this request's page, or undefined when it may not be cached. */
2
+ /** The CDN segment token for this request's page (the site's `pageCache` passes it to `render`), or undefined. */
3
3
  csegToken?: string;
4
4
  /** The draft this request renders (after the worker's host check). */
5
5
  draft?: string;
6
+ /**
7
+ * The request's link named a draft that can't be read anymore: the page
8
+ * renders the release, and `DecoPreview` says so calmly (outside Studio's frame).
9
+ */
10
+ draftUnavailable?: boolean;
6
11
  }
7
12
  /** Runs `fn` with `scope` as the request's scope. */
8
13
  export declare function runInScope<T>(scope: RequestScope, fn: () => T): T;
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/scope/server.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,YAAY;IAC3B,6FAA6F;IAC7F,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sEAAsE;IACtE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAQD,qDAAqD;AACrD,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAEjE;AAED,4FAA4F;AAC5F,wBAAgB,YAAY,IAAI,YAAY,GAAG,SAAS,CAEvD;AAED,4EAA4E;AAC5E,eAAO,MAAM,oBAAoB,EAA4B,qBAAqB,GAAG,cAAc,CAAC"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/scope/server.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,YAAY;IAC3B,kHAAkH;IAClH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sEAAsE;IACtE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAQD,qDAAqD;AACrD,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAEjE;AAED,4FAA4F;AAC5F,wBAAgB,YAAY,IAAI,YAAY,GAAG,SAAS,CAEvD;AAED,4EAA4E;AAC5E,eAAO,MAAM,oBAAoB,EAA4B,qBAAqB,GAAG,cAAc,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/scope/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AASrD,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;AACxD,MAAM,MAAM,GAAG,UAAoF,CAAC;AACpG,MAAM,OAAO,GACX,MAAM,CAAC,GAAG,CAAC,IAAI,IAAI,iBAAiB,EAAgB,CAAC;AACvD,MAAM,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC;AAEtB,qDAAqD;AACrD,MAAM,UAAU,UAAU,CAAI,KAAmB,EAAE,EAAW;IAC5D,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAChC,CAAC;AAED,4FAA4F;AAC5F,MAAM,UAAU,YAAY;IAC1B,OAAO,OAAO,CAAC,QAAQ,EAAE,CAAC;AAC5B,CAAC;AAED,4EAA4E;AAC5E,MAAM,CAAC,MAAM,oBAAoB,GAAG,qBAA+D,CAAC"}
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/scope/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAcrD,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;AACxD,MAAM,MAAM,GAAG,UAAoF,CAAC;AACpG,MAAM,OAAO,GACX,MAAM,CAAC,GAAG,CAAC,IAAI,IAAI,iBAAiB,EAAgB,CAAC;AACvD,MAAM,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC;AAEtB,qDAAqD;AACrD,MAAM,UAAU,UAAU,CAAI,KAAmB,EAAE,EAAW;IAC5D,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAChC,CAAC;AAED,4FAA4F;AAC5F,MAAM,UAAU,YAAY;IAC1B,OAAO,OAAO,CAAC,QAAQ,EAAE,CAAC;AAC5B,CAAC;AAED,4EAA4E;AAC5E,MAAM,CAAC,MAAM,oBAAoB,GAAG,qBAA+D,CAAC"}
@@ -2,23 +2,52 @@
2
2
  * Server-only helpers for a site's server functions and page loader. Never
3
3
  * import this from a component that ships to the browser.
4
4
  *
5
- * The draft a request renders is decided once, by `createDecoWorker` (its host
6
- * allowlist), and handed to the app in the `x-deco-draft` request header; the
7
- * worker removes any copy that arrives from outside. These read that header.
5
+ * What a request reads is decided once, by `createDecoWorker`, and handed to
6
+ * the app in request headers the worker removes when they arrive from
7
+ * outside: the version on `x-deco-version` (a Studio link's draft or old
8
+ * release, after the host allowlist), the visitor on `x-deco-visitor`
9
+ * (`readVisitor` from `@decocms/blocks/experiments`) and each test and
10
+ * campaign on or off on `x-deco-assignments`, and for a draft the release
11
+ * check it made on `x-deco-release-check`. These read them, and
12
+ * `contentClient` builds `cms.client({ version, releaseCheck, experiments,
13
+ * campaigns })` from them: the page decides nothing again, and its draft
14
+ * reads share the worker's check of the latest release.
8
15
  */
9
16
  import type { Client, CMS } from "@decocms/blocks";
10
- /** The draft `request` renders (checked by the worker), or `null` for the release. */
11
- export declare function requestDraft(request?: Request): string | null;
17
+ import { type Visitor } from "@decocms/blocks/experiments";
18
+ import { type DecidedAssignments } from "../assignments.ts";
12
19
  /**
13
- * The content client for a request: its draft's, or the release's. Without
14
- * `request`, the request being served (`getRequest()`).
20
+ * The version `request` renders (a Studio link's draft pointer or release
21
+ * SHA, checked by the worker), or `null` for the current release.
22
+ */
23
+ export declare function requestVersion(request?: Request): string | null;
24
+ /**
25
+ * The visitor the worker read for `request`, or `null` when there is none (a
26
+ * request that didn't come through `createDecoWorker`).
27
+ */
28
+ export declare function requestVisitor(request?: Request): Visitor | null;
29
+ /**
30
+ * Each test and campaign on or off as the worker decided them for `request`,
31
+ * or `null` when it decided none (a request that didn't come through
32
+ * `createDecoWorker`).
33
+ */
34
+ export declare function requestAssignments(request?: Request): DecidedAssignments | null;
35
+ /**
36
+ * The content client for a request: `cms.client({ version, experiments,
37
+ * campaigns })` with what the worker decided, so the page renders the tests
38
+ * and campaigns the worker keyed its cache on and a preview reads its draft
39
+ * or old release. The visitor rides along (`client.visitor`) but decides
40
+ * nothing the worker already did; without the worker's decisions (a request
41
+ * that didn't come through it) the visitor decides. Create one per request.
42
+ * Without `request`, the request being served (`getRequest()`).
15
43
  */
16
44
  export declare function contentClient(cms: CMS, request?: Request): Client;
17
45
  /** True when the browser called a server function over HTTP; false while a document renders. */
18
46
  export declare function isServerFnCall(request?: Request): boolean;
19
47
  /**
20
48
  * Marks a server function's response as per-visitor (`Cache-Control: private,
21
- * no-store`): the worker never stores it and the CDN never keeps it. Only when
49
+ * no-store`): a site's page cache never stores it (the example worker entry the README links) and
50
+ * the CDN never keeps it. Only when
22
51
  * the browser called the function over HTTP; while a document renders the
23
52
  * function is a plain call and the header would land on the page.
24
53
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAInD,sFAAsF;AACtF,wBAAgB,YAAY,CAAC,OAAO,GAAE,OAAsB,GAAG,MAAM,GAAG,IAAI,CAE3E;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,G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