@decocms/tanstack 8.6.0 → 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 (40) hide show
  1. package/README.md +4 -4
  2. package/dist/draft.d.ts +21 -5
  3. package/dist/draft.d.ts.map +1 -1
  4. package/dist/draft.js +23 -7
  5. package/dist/draft.js.map +1 -1
  6. package/dist/react/DecoDocument.d.ts.map +1 -1
  7. package/dist/react/DecoDocument.js +4 -4
  8. package/dist/react/DecoDocument.js.map +1 -1
  9. package/dist/react/pageValues.d.ts +3 -0
  10. package/dist/react/pageValues.d.ts.map +1 -1
  11. package/dist/react/pageValues.js +13 -4
  12. package/dist/react/pageValues.js.map +1 -1
  13. package/dist/scope/server.d.ts +5 -0
  14. package/dist/scope/server.d.ts.map +1 -1
  15. package/dist/scope/server.js.map +1 -1
  16. package/dist/server/index.d.ts +5 -3
  17. package/dist/server/index.d.ts.map +1 -1
  18. package/dist/server/index.js +6 -2
  19. package/dist/server/index.js.map +1 -1
  20. package/dist/worker/cache.d.ts +4 -2
  21. package/dist/worker/cache.d.ts.map +1 -1
  22. package/dist/worker/cache.js +6 -2
  23. package/dist/worker/cache.js.map +1 -1
  24. package/dist/worker/drafts.d.ts +32 -3
  25. package/dist/worker/drafts.d.ts.map +1 -1
  26. package/dist/worker/drafts.js +59 -4
  27. package/dist/worker/drafts.js.map +1 -1
  28. package/dist/worker/index.d.ts +8 -3
  29. package/dist/worker/index.d.ts.map +1 -1
  30. package/dist/worker/index.js +79 -35
  31. package/dist/worker/index.js.map +1 -1
  32. package/package.json +2 -2
  33. package/src/draft.ts +27 -7
  34. package/src/react/DecoDocument.tsx +20 -4
  35. package/src/react/pageValues.ts +12 -4
  36. package/src/scope/server.ts +5 -0
  37. package/src/server/index.ts +11 -5
  38. package/src/worker/cache.ts +6 -2
  39. package/src/worker/drafts.ts +81 -6
  40. package/src/worker/index.ts +93 -41
package/README.md CHANGED
@@ -19,7 +19,7 @@ export default createDecoWorker({
19
19
  });
20
20
  ```
21
21
 
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, `no-store`, `noindex`); 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`.
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`.
23
23
 
24
24
  Options, each for a value a site needs to change: `csp`, `pageCache`, `preload` and `routes`.
25
25
 
@@ -27,7 +27,7 @@ The worker caches no page: the page cache is the site's, as on Next.js. Without
27
27
 
28
28
  ### Draft hosts
29
29
 
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).
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
31
 
32
32
  ### The visitor, the assignments and the client
33
33
 
@@ -37,7 +37,7 @@ The worker decides once per request, at the edge. On every page and server-funct
37
37
 
38
38
  ### The page cache
39
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, 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.
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
41
 
42
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
43
 
@@ -58,7 +58,7 @@ A complete worker entry with a page cache is [`examples/tanstack-worker-smoke/sr
58
58
 
59
59
  ### Names and Studio's origins
60
60
 
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(version)` (`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.
62
62
 
63
63
  ```ts
64
64
  import { STUDIO_ORIGINS, VERSION_HEADER } from "@decocms/tanstack";
package/dist/draft.d.ts CHANGED
@@ -27,10 +27,26 @@ export declare const DRAFT_COOKIE = "__deco_draft";
27
27
  */
28
28
  export declare const VERSION_HEADER = "x-deco-version";
29
29
  /**
30
- * The response headers of a page rendered from a draft: never stored by a
31
- * browser or a CDN (`Cache-Control: no-store, private`, `Vary: Cookie`) and
32
- * never indexed (`X-Robots-Tag: noindex, nofollow`). `{}` when `version` is
33
- * `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.
34
35
  */
35
- export declare function draftResponseHeaders(version: 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>;
36
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;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,mBAAmB,CAAC;AAE/C;;;;;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
@@ -27,16 +27,32 @@ export const DRAFT_COOKIE = "__deco_draft";
27
27
  */
28
28
  export const VERSION_HEADER = "x-deco-version";
29
29
  /**
30
- * The response headers of a page rendered from a draft: never stored by a
31
- * browser or a CDN (`Cache-Control: no-store, private`, `Vary: Cookie`) and
32
- * never indexed (`X-Robots-Tag: noindex, nofollow`). `{}` when `version` is
33
- * `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.
34
35
  */
35
- export function draftResponseHeaders(version) {
36
- if (!version)
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)
37
53
  return {};
38
54
  return {
39
- "Cache-Control": "no-store, private",
55
+ "Cache-Control": DRAFT_CACHE_CONTROL,
40
56
  Vary: "Cookie",
41
57
  "X-Robots-Tag": "noindex, nofollow",
42
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;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,gBAAgB,CAAC;AAE/C;;;;;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;AAC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,iEAAiE;IACjE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,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,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L,gBAAM,IAAI,EAAE,IAAI,gBAAa,OAAO,EAAC,wBAAwB,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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,CAAC,gBAAgB;QAAE,KAAK,CAAC,IAAI,CAAC,UAAU,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"}
@@ -3,6 +3,11 @@ export interface RequestScope {
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,kHAAkH;IAClH,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"}
@@ -7,9 +7,11 @@
7
7
  * outside: the version on `x-deco-version` (a Studio link's draft or old
8
8
  * release, after the host allowlist), the visitor on `x-deco-visitor`
9
9
  * (`readVisitor` from `@decocms/blocks/experiments`) and each test and
10
- * campaign on or off on `x-deco-assignments`. These read them, and
11
- * `contentClient` builds `cms.client({ version, experiments, campaigns })`
12
- * from them: the page decides nothing again.
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.
13
15
  */
14
16
  import type { Client, CMS } from "@decocms/blocks";
15
17
  import { type Visitor } from "@decocms/blocks/experiments";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAgB,KAAK,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAEzE,OAAO,EAAsB,KAAK,kBAAkB,EAAoB,MAAM,mBAAmB,CAAC;AAIlG;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,GAAE,O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,OAAO,GAAE,OAAsB,GAAG,OAAO,CAEvE;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,IAAI,IAAI,CAGlC;AAED,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { parseVisitor } from "@decocms/blocks/experiments";
2
2
  import { getRequest, setResponseHeader } from "@tanstack/react-start/server";
3
3
  import { ASSIGNMENTS_HEADER, parseAssignments } from "../assignments.js";
4
- import { VERSION_HEADER } from "../draft.js";
4
+ import { RELEASE_CHECK_HEADER, VERSION_HEADER } from "../draft.js";
5
5
  import { VISITOR_HEADER } from "../visitor.js";
6
6
  /**
7
7
  * The version `request` renders (a Studio link's draft pointer or release
@@ -36,8 +36,12 @@ export function requestAssignments(request = getRequest()) {
36
36
  */
37
37
  export function contentClient(cms, request = getRequest()) {
38
38
  const decided = requestAssignments(request);
39
+ const version = requestVersion(request);
40
+ // The worker's release check for this draft request: the draft waits for it, never one of its own.
41
+ const releaseCheck = version === null ? null : request.headers.get(RELEASE_CHECK_HEADER);
39
42
  return cms.client({
40
- version: requestVersion(request),
43
+ version,
44
+ ...(releaseCheck ? { releaseCheck } : {}),
41
45
  visitor: requestVisitor(request),
42
46
  experiments: decided?.experiments,
43
47
  campaigns: decided?.campaigns,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,YAAY,EAAgB,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAA2B,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAClG,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,OAAO,GAAY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ACP,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzC,OAAO,EAAE,cAAc,CAAC,OAAO,CAAC;QAChC,WAAW,EAAE,OAAO,EAAE,WAAW;QACjC,SAAS,EAAE,OAAO,EAAE,SAAS;KAC9B,CAAC,CAAC;AACL,CAAC;AAED,gGAAgG;AAChG,MAAM,UAAU,cAAc,CAAC,OAAO,GAAY,UAAU,EAAE;IAC5D,OAAO,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;AACjE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW;IACzB,IAAI,CAAC,cAAc,EAAE;QAAE,OAAO;IAC9B,iBAAiB,CAAC,eAAe,EAAE,mBAAmB,CAAC,CAAC;AAC1D,CAAC;AAED,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC"}
@@ -8,8 +8,10 @@ import type { CMS } from "@decocms/blocks";
8
8
  /**
9
9
  * Whether a request may be served from or stored in a shared cache at all:
10
10
  * a GET of the current release (`version` `null`: never a preview, a draft
11
- * or an old release), outside local development, without `Authorization`,
12
- * and not one of TanStack Start's own `/_build` files. The worker calls a
11
+ * or an old release), carrying no draft signal at all (no `?__draft=`, `off`
12
+ * included, and no draft cookie: a preview always renders), outside local
13
+ * development, without `Authorization`, and not one of TanStack Start's own
14
+ * `/_build` files. The worker calls a
13
15
  * site's `pageCache` only for these.
14
16
  */
15
17
  export declare function isCacheable(request: Pick<Request, "method" | "url" | "headers">, inputs: {
@@ -1 +1 @@
1
- {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/worker/cache.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAG3C;;;;;;GAMG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,QAAQ,GAAG,KAAK,GAAG,SAAS,CAAC,EACpD,MAAM,EAAE;IAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,GAAG,CAAC,EAAE,OAAO,CAAA;CAAE,GAChD,OAAO,CAQT;AAED;;;;GAIG;AACH,wBAAsB,YAAY,CAChC,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,YAAY,CAAC,EAC5B,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,CAAC,CAQjB;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,GAAG,MAAM,GAAG,IAAI,CAE/E"}
1
+ {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/worker/cache.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAI3C;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,QAAQ,GAAG,KAAK,GAAG,SAAS,CAAC,EACpD,MAAM,EAAE;IAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,GAAG,CAAC,EAAE,OAAO,CAAA;CAAE,GAChD,OAAO,CAST;AAED;;;;GAIG;AACH,wBAAsB,YAAY,CAChC,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,YAAY,CAAC,EAC5B,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,CAAC,CAQjB;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,GAAG,MAAM,GAAG,IAAI,CAE/E"}
@@ -1,9 +1,12 @@
1
1
  import { VERSION_HEADER } from "../draft.js";
2
+ import { hasDraftSignal } from "./drafts.js";
2
3
  /**
3
4
  * Whether a request may be served from or stored in a shared cache at all:
4
5
  * a GET of the current release (`version` `null`: never a preview, a draft
5
- * or an old release), outside local development, without `Authorization`,
6
- * and not one of TanStack Start's own `/_build` files. The worker calls a
6
+ * or an old release), carrying no draft signal at all (no `?__draft=`, `off`
7
+ * included, and no draft cookie: a preview always renders), outside local
8
+ * development, without `Authorization`, and not one of TanStack Start's own
9
+ * `/_build` files. The worker calls a
7
10
  * site's `pageCache` only for these.
8
11
  */
9
12
  export function isCacheable(request, inputs) {
@@ -11,6 +14,7 @@ export function isCacheable(request, inputs) {
11
14
  inputs.version === null &&
12
15
  inputs.dev !== true &&
13
16
  !request.headers.has("authorization") &&
17
+ !hasDraftSignal(request) &&
14
18
  !new URL(request.url).pathname.startsWith("/_build"));
15
19
  }
16
20
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"cache.js","sourceRoot":"","sources":["../../src/worker/cache.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CACzB,OAAoD,EACpD,MAAiD;IAEjD,OAAO,CACL,OAAO,CAAC,MAAM,KAAK,KAAK;QACxB,MAAM,CAAC,OAAO,KAAK,IAAI;QACvB,MAAM,CAAC,GAAG,KAAK,IAAI;QACnB,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;QACrC,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CACrD,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,GAA4B,EAC5B,SAAiB;IAEjB,IAAI,QAAQ,GAAG,EAAE,CAAC;IAClB,IAAI,CAAC;QACH,QAAQ,GAAG,MAAM,GAAG,CAAC,UAAU,EAAE,CAAC,QAAQ,EAAE,CAAC;IAC/C,CAAC;IAAC,MAAM,CAAC;QACP,kDAAkD;IACp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C;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,OAAiC;IAC9D,OAAO,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,IAAI,CAAC;AACrD,CAAC"}
@@ -22,6 +22,13 @@ import { type CMS, type RequestVersion } from "@decocms/blocks";
22
22
  * for a value that doesn't parse.
23
23
  */
24
24
  export declare function readDraftVersion(request: Request): RequestVersion | null;
25
+ /**
26
+ * Whether a request carries a draft signal at all: `?__draft=` with any value
27
+ * (`off` and a value that doesn't parse too) or the draft cookie. Such a
28
+ * request is a preview: it never goes through a page cache and its response
29
+ * is never cached (`draftResponseHeaders`), whatever the host check decides.
30
+ */
31
+ export declare function hasDraftSignal(request: Pick<Request, "url" | "headers">): boolean;
25
32
  export interface DraftDecision {
26
33
  /**
27
34
  * What this request's Studio link asks for, after the host check: the
@@ -30,9 +37,31 @@ export interface DraftDecision {
30
37
  * `cms.client()`'s options; `null` for the current release.
31
38
  */
32
39
  version: RequestVersion | null;
33
- /** The `Set-Cookie` the response carries: storing a link's version, or ending a preview. */
40
+ /**
41
+ * The `Set-Cookie` the response carries: storing a link's version (the
42
+ * worker sends it only with a response below 500), or ending a preview.
43
+ */
34
44
  setCookie: string | null;
45
+ /**
46
+ * The link named a draft that can't be read (deleted, or its host
47
+ * failing): the request renders the release, the cookie is expired when
48
+ * the draft is gone (a failure that may pass leaves it), and the page says so calmly (`DraftBadge`'s `unavailable`), never a 500.
49
+ */
50
+ unavailable?: true;
51
+ /**
52
+ * The release check made for this draft request (`cms.checkRelease()`):
53
+ * the host check, the read below and the page's draft reads all wait for
54
+ * it, so the request reads `latest.json` once.
55
+ */
56
+ releaseCheck?: string;
35
57
  }
36
- /** The version a request renders, and the cookie its response sets. */
37
- export declare function decideDraft(cms: Pick<CMS, "readVersion">, request: Request): Promise<DraftDecision>;
58
+ /**
59
+ * The version a request renders, and the cookie its response sets. A draft
60
+ * request first checks for the latest release, once (`cms.checkRelease()`),
61
+ * and the host check and every draft read share that check. A draft
62
+ * pointer is read once before the page renders (`forDraft(...).revision()`,
63
+ * the same read the page makes, shared while in flight): a draft that can't
64
+ * be read gives the release and `unavailable`, never an error page.
65
+ */
66
+ export declare function decideDraft(cms: Pick<CMS, "readVersion" | "forDraft" | "checkRelease">, request: Request): Promise<DraftDecision>;
38
67
  //# sourceMappingURL=drafts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"drafts.d.ts","sourceRoot":"","sources":["../../src/worker/drafts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,KAAK,GAAG,EAAgB,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAuB9E;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,cAAc,GAAG,IAAI,CAMxE;AAeD,MAAM,WAAW,aAAa;IAC5B;;;;;OAKG;IACH,OAAO,EAAE,cAAc,GAAG,IAAI,CAAC;IAC/B,4FAA4F;IAC5F,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,uEAAuE;AACvE,wBAAsB,WAAW,CAC/B,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,aAAa,CAAC,EAC7B,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,aAAa,CAAC,CAcxB"}
1
+ {"version":3,"file":"drafts.d.ts","sourceRoot":"","sources":["../../src/worker/drafts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,KAAK,GAAG,EAAmC,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAyBjG;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,cAAc,GAAG,IAAI,CAMxE;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,KAAK,GAAG,SAAS,CAAC,GAAG,OAAO,CAKjF;AAqBD,MAAM,WAAW,aAAa;IAC5B;;;;;OAKG;IACH,OAAO,EAAE,cAAc,GAAG,IAAI,CAAC;IAC/B;;;OAGG;IACH,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB;;;;OAIG;IACH,WAAW,CAAC,EAAE,IAAI,CAAC;IACnB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;GAOG;AACH,wBAAsB,WAAW,CAC/B,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,aAAa,GAAG,UAAU,GAAG,cAAc,CAAC,EAC3D,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,aAAa,CAAC,CA6BxB"}
@@ -15,9 +15,11 @@
15
15
  * Both pass the same host check: a visitor on the live site never picks a
16
16
  * version.
17
17
  */
18
- import { parseVersion } from "@decocms/blocks";
18
+ import { parseDraftPointer, parseVersion } from "@decocms/blocks";
19
19
  import { DRAFT_COOKIE, DRAFT_PARAM } from "../draft.js";
20
20
  const DRAFT_OFF = "off";
21
+ /** A draft pointer's version that names no draft: the release, nothing fetched. */
22
+ const LOCAL_VERSION = "local";
21
23
  function draftParam(url) {
22
24
  return url.searchParams.get(DRAFT_PARAM);
23
25
  }
@@ -51,6 +53,21 @@ export function readDraftVersion(request) {
51
53
  return fromLink;
52
54
  return parseVersion(readCookie(request.headers.get("cookie"), DRAFT_COOKIE));
53
55
  }
56
+ /**
57
+ * Whether a request carries a draft signal at all: `?__draft=` with any value
58
+ * (`off` and a value that doesn't parse too) or the draft cookie. Such a
59
+ * request is a preview: it never goes through a page cache and its response
60
+ * is never cached (`draftResponseHeaders`), whatever the host check decides.
61
+ */
62
+ export function hasDraftSignal(request) {
63
+ return (draftParam(new URL(request.url)) !== null ||
64
+ readCookie(request.headers.get("cookie"), DRAFT_COOKIE) !== null);
65
+ }
66
+ /** Whether a version names a saved draft (a pointer, not a release's SHA and not `local`). */
67
+ function namesDraft(version) {
68
+ const parsed = parseDraftPointer(version);
69
+ return parsed !== null && parsed.version !== LOCAL_VERSION;
70
+ }
54
71
  function serializeCookie(value, extra) {
55
72
  // The same cookie `cms.draftCookie` writes (a test holds the two together).
56
73
  return [
@@ -63,23 +80,61 @@ function serializeCookie(value, extra) {
63
80
  "Partitioned",
64
81
  ].join("; ");
65
82
  }
66
- /** The version a request renders, and the cookie its response sets. */
83
+ /**
84
+ * The version a request renders, and the cookie its response sets. A draft
85
+ * request first checks for the latest release, once (`cms.checkRelease()`),
86
+ * and the host check and every draft read share that check. A draft
87
+ * pointer is read once before the page renders (`forDraft(...).revision()`,
88
+ * the same read the page makes, shared while in flight): a draft that can't
89
+ * be read gives the release and `unavailable`, never an error page.
90
+ */
67
91
  export async function decideDraft(cms, request) {
68
92
  const url = new URL(request.url);
69
93
  const param = draftParam(url);
70
94
  // Ending a preview is allowed on any host, so a cookie set earlier always goes.
71
95
  if (param === DRAFT_OFF)
72
- return { version: null, setCookie: serializeCookie("", ["Max-Age=0"]) };
96
+ return { version: null, setCookie: expiredCookie() };
73
97
  const version = readDraftVersion(request);
74
98
  if (version === null)
75
99
  return { version: null, setCookie: null };
76
- if ((await cms.readVersion(request)) === null)
100
+ // One release check per draft request, shared below and by the page.
101
+ const releaseCheck = namesDraft(version.version) ? await cms.checkRelease() : undefined;
102
+ if ((await cms.readVersion(request, { releaseCheck })) === null) {
77
103
  return { version: null, setCookie: null };
104
+ }
105
+ if (releaseCheck !== undefined) {
106
+ try {
107
+ await cms.forDraft(version.version, { releaseCheck }).revision();
108
+ }
109
+ catch (error) {
110
+ // Gone (deleted): the preview ends. Any other failure (the drafts' host
111
+ // down, a timeout) leaves the cookie alone, so the next request tries again.
112
+ const setCookie = isDraftGone(error) ? expiredCookie() : null;
113
+ return { version: null, setCookie, unavailable: true };
114
+ }
115
+ }
78
116
  // The link's own value goes in the cookie, its preview parameters with it.
79
117
  const fromLink = param !== null && parseVersion(param) !== null;
80
118
  return {
81
119
  version,
82
120
  setCookie: fromLink ? serializeCookie(encodeURIComponent(param), []) : null,
121
+ ...(releaseCheck === undefined ? {} : { releaseCheck }),
83
122
  };
84
123
  }
124
+ /**
125
+ * Whether a draft read failed because the drafts' host no longer has the
126
+ * draft (`404`/`410`), as opposed to a failure that may pass (a `5xx`, a
127
+ * timeout, a network error). Reads the error and its causes.
128
+ */
129
+ function isDraftGone(error) {
130
+ for (let e = error, depth = 0; e instanceof Error && depth < 5; e = e.cause, depth++) {
131
+ if (/draft changes: HTTP (404|410)\b/.test(e.message))
132
+ return true;
133
+ }
134
+ return false;
135
+ }
136
+ /** The `Set-Cookie` that ends a preview. */
137
+ function expiredCookie() {
138
+ return serializeCookie("", ["Max-Age=0"]);
139
+ }
85
140
  //# sourceMappingURL=drafts.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"drafts.js","sourceRoot":"","sources":["../../src/worker/drafts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAY,YAAY,EAAuB,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAExD,MAAM,SAAS,GAAG,KAAK,CAAC;AAExB,SAAS,UAAU,CAAC,GAAQ;IAC1B,OAAO,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;AAC3C,CAAC;AAED,SAAS,UAAU,CAAC,MAAqB,EAAE,IAAY;IACrD,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACzB,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QACrC,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC7B,IAAI,EAAE,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,IAAI;YAAE,SAAS;QAC7D,IAAI,CAAC;YACH,OAAO,kBAAkB,CAAC,IAAI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