payload-live-preview 2.2.2 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -30
- package/dist/adapters/astro/PreviewBoundary.astro +17 -4
- package/dist/adapters/astro/RichText.astro +13 -2
- package/dist/adapters/astro/index.d.ts +7 -7
- package/dist/adapters/astro/index.js +1 -1
- package/dist/adapters/astro/index.js.map +1 -1
- package/dist/adapters/astro/middleware-entry.d.ts +3 -3
- package/dist/adapters/astro/middleware-entry.js +1 -1
- package/dist/adapters/astro/middleware-entry.js.map +1 -1
- package/dist/adapters/nextjs/index.d.ts +2 -2
- package/dist/adapters/nextjs/index.js +1 -1
- package/dist/adapters/nextjs/index.js.map +1 -1
- package/dist/adapters/nuxt/index.d.ts +4 -4
- package/dist/adapters/nuxt/index.js +1 -1
- package/dist/adapters/nuxt/index.js.map +1 -1
- package/dist/adapters/nuxt/module.d.ts +1 -1
- package/dist/adapters/react/index.d.ts +2 -2
- package/dist/adapters/react/index.js +1 -1
- package/dist/adapters/react/index.js.map +1 -1
- package/dist/adapters/sveltekit/index.d.ts +5 -5
- package/dist/adapters/sveltekit/index.js +1 -1
- package/dist/adapters/sveltekit/index.js.map +1 -1
- package/dist/adapters/vue/index.d.ts +2 -2
- package/dist/adapters/vue/index.js +1 -1
- package/dist/adapters/vue/index.js.map +1 -1
- package/dist/client.cjs +1 -1
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +15 -3
- package/dist/client.d.ts +15 -3
- package/dist/client.js +1 -1
- package/dist/client.js.map +1 -1
- package/dist/codegen-astro.js +1 -1
- package/dist/codegen-astro.js.map +1 -1
- package/dist/codegen-cli.js +1 -1
- package/dist/codegen-cli.js.map +1 -1
- package/dist/codegen.cjs +1 -1
- package/dist/codegen.cjs.map +1 -1
- package/dist/codegen.js +1 -1
- package/dist/codegen.js.map +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +139 -4
- package/dist/core.d.ts +139 -4
- package/dist/core.js +1 -1
- package/dist/core.js.map +1 -1
- package/dist/doctor-cli.d.ts +1 -1
- package/dist/doctor-cli.js +1 -1
- package/dist/doctor-cli.js.map +1 -1
- package/dist/doctor.d.ts +2 -2
- package/dist/doctor.js +1 -1
- package/dist/doctor.js.map +1 -1
- package/dist/{document-session-Bkd181PV.d.ts → document-session-BuYuO3ae.d.ts} +27 -2
- package/dist/{fragment-endpoint-CLRpNQ3n.d.ts → fragment-endpoint-CQE_7MKi.d.ts} +1 -1
- package/dist/fragment.cjs +1 -1
- package/dist/fragment.cjs.map +1 -1
- package/dist/fragment.d.cts +6 -2
- package/dist/fragment.d.ts +6 -2
- package/dist/fragment.js +1 -1
- package/dist/fragment.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +73 -12
- package/dist/index.d.ts +73 -12
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lean.cjs +1 -1
- package/dist/lean.cjs.map +1 -1
- package/dist/lean.js +1 -1
- package/dist/lean.js.map +1 -1
- package/dist/lexical.cjs +1 -1
- package/dist/lexical.cjs.map +1 -1
- package/dist/lexical.d.cts +16 -4
- package/dist/lexical.d.ts +16 -4
- package/dist/lexical.js +1 -1
- package/dist/lexical.js.map +1 -1
- package/dist/{locals-zz2gi9dj.d.ts → locals-CyzDKfKU.d.ts} +7 -1
- package/dist/{middleware-CI-UTf6R.d.ts → middleware-Dnt6u4nF.d.ts} +2 -2
- package/dist/{options-CnYybG51.d.ts → options-DTzhFVJ4.d.ts} +13 -1
- package/dist/plugin.cjs +1 -1
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.cts +15 -9
- package/dist/plugin.d.ts +15 -9
- package/dist/plugin.js +1 -1
- package/dist/plugin.js.map +1 -1
- package/dist/plugins.cjs +1 -1
- package/dist/plugins.cjs.map +1 -1
- package/dist/plugins.d.cts +8 -2
- package/dist/plugins.d.ts +8 -2
- package/dist/plugins.js +1 -1
- package/dist/plugins.js.map +1 -1
- package/dist/{probe-D-IHg9dF.d.ts → probe-afwdYebU.d.ts} +6 -2
- package/dist/server.cjs +1 -1
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +19 -1
- package/dist/server.d.ts +19 -1
- package/dist/server.js +1 -1
- package/dist/server.js.map +1 -1
- package/dist/structural.d.cts +2 -0
- package/dist/structural.d.ts +2 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ One runtime serves every framework. The Astro, Next.js, SvelteKit and Nuxt adapt
|
|
|
18
18
|
|
|
19
19
|
## Highlights
|
|
20
20
|
|
|
21
|
-
- **One runtime, every frontend.** One TypeScript runtime compiled to a self-contained inline script of about
|
|
21
|
+
- **One runtime, every frontend.** One TypeScript runtime compiled to a self-contained inline script of about 48 KB gzip — 37 KB with the lean artifact, 48 to 50 KB once the route or fragment prelude is appended ([docs/options.md](docs/options.md)). The adapters for Astro, Next.js, SvelteKit and Nuxt deliver it; where they decide per request they also authorize the request, merge `frame-ancestors` into your CSP and mark the changed response `private, no-store`. They provide the fragment endpoint and, outside Astro, the route that serves the runtime asset.
|
|
22
22
|
- **Patch, fragment, route.** A binding is patched in place; a `data-payload-fragment` boundary is rendered again by your server from the unsaved form state; a patch that fell short, or a change nothing binds, goes to the fragment render or a route refresh when the page has one ([below](#patch-fragment-route)).
|
|
23
23
|
- **Delivery.** Inline, or a bootstrap that fetches the content-hashed, SRI-verified runtime only inside a preview (`delivery: 'asset'`; Astro's static equivalent is `mode: 'loader'`). Where something decides per request — Astro's middleware, `await LivePreviewScript(…)` in Next.js, the SvelteKit handle, the Nuxt Nitro plugin — a public visitor receives no script at all ([docs/deployment.md](docs/deployment.md#what-a-public-visitor-pays)).
|
|
24
24
|
- **Payload 3.x native.** `serverURL` re-fetches the populated document, like the official client, so relationship and upload fields render as content rather than as IDs — but only when an edit needs one: in the DOM runtime, typing into a text field costs no request, and a burst on a relationship costs two requests, at its start and its end, rather than one per keystroke.
|
|
@@ -31,37 +31,37 @@ One runtime serves every framework. The Astro, Next.js, SvelteKit and Nuxt adapt
|
|
|
31
31
|
|
|
32
32
|
## Compatibility
|
|
33
33
|
|
|
34
|
-
| Payload | Status | Checked by
|
|
35
|
-
| ------- | ------------------------------------------ |
|
|
36
|
-
| 2.x | supported in 2.x; ends with 3.0 | the 2.32.3 wire corpus replayed in CI; real-admin release checks of the DOM runtime and the React and Vue hooks ([docs/testing.md](docs/testing.md#local-release-checks))
|
|
37
|
-
| 3.x | supported | the real admin on every push (3.92.1, three engines); the 3.85, 3.88 and 3.89 wire corpora replayed in CI
|
|
38
|
-
| 4.x | pre-release, the direction of this package | the 4.0.0-beta.4 wire
|
|
34
|
+
| Payload | Status | Checked by |
|
|
35
|
+
| ------- | ------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
36
|
+
| 2.x | supported in 2.x; ends with 3.0 | the 2.32.3 wire corpus replayed in CI; real-admin release checks of the DOM runtime and the React and Vue hooks ([docs/testing.md](docs/testing.md#local-release-checks)) |
|
|
37
|
+
| 3.x | supported | the real admin on every push (3.92.1, three engines); the 3.85, 3.88 and 3.89 wire corpora replayed in CI |
|
|
38
|
+
| 4.x | pre-release, the direction of this package | the 4.0.0-beta.4 and 4.0.0-beta.6 wire corpora replayed in CI; the real-admin suite against `payload@beta` every day, as an early warning; the field-findings suite against 4.0.0-beta.6 in three engines, once, outside CI; a 2.2 release candidate on a site running 4.0.0-beta.4 with Astro 7.4.2 |
|
|
39
39
|
|
|
40
|
-
**Payload 4** is where this package is headed. Its pre-releases are followed as they appear, and support becomes official with the stable 4.0 release; until then the daily run against `payload@beta` warns early and does not gate a release. The Payload 4 pre-release captured so far passes the same protocol checks as the 3.x corpora. As of 4.0.0-beta.4, Payload 4 needs Node 24.22.1 or later, and its admin Next.js 16.4 or a later 16.x release. Payload 2.x support ends with the next major release of this package: 3.0 supports Payload 3.x and 4.x, and every 2.x release keeps supporting Payload 2 ([ADR 0007 ledger, entry 25](docs/architecture/0007-v2-defaults-and-renames-ledger.md#ledger), [Preparing for 3.0](docs/migration.md#preparing-for-30)). Payload 3.x stays supported. The manifest declares `payload` as an optional peer, `^2.0.0 || ^3.0.0 || ^4.0.0-0`: npm never installs it, and a project that has Payload outside that range gets npm's `ERESOLVE` error.
|
|
40
|
+
**Payload 4** is where this package is headed. Its pre-releases are followed as they appear, and support becomes official with the stable 4.0 release; until then the daily run against `payload@beta` warns early and does not gate a release. The Payload 4 pre-release captured so far passes the same protocol checks as the 3.x corpora. As of 4.0.0-beta.6, as since beta.4, Payload 4 needs Node 24.22.1 or later, and its admin Next.js 16.4 or a later 16.x release. Payload 2.x support ends with the next major release of this package: 3.0 supports Payload 3.x and 4.x, and every 2.x release keeps supporting Payload 2 ([ADR 0007 ledger, entry 25](docs/architecture/0007-v2-defaults-and-renames-ledger.md#ledger), [Preparing for 3.0](docs/migration.md#preparing-for-30)). 3.0 also needs Node 22 or newer and drops no framework major (entries 28 and 29). Payload 3.x stays supported. The manifest declares `payload` as an optional peer, `^2.0.0 || ^3.0.0 || ^4.0.0-0`: npm never installs it, and a project that has Payload outside that range gets npm's `ERESOLVE` error.
|
|
41
41
|
|
|
42
42
|
What differs between Payload 2, 3 and 4:
|
|
43
43
|
|
|
44
|
-
| | Payload 2.x | Payload 3.x | Payload 4.x (measured on 4.0.0-beta.4)
|
|
45
|
-
| ---------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
|
|
46
|
-
| Scalar field updates | ✅ | ✅ | ✅
|
|
47
|
-
| Rich text (Lexical) | ✅ | ✅ | ✅ through a fragment render
|
|
48
|
-
| Relationship / upload population | Collection GETs from the accepted schema with `serverURL` and matching depth (relationships measured against a real 2.32.3 admin, uploads by unit tests) | ✅ with `serverURL` (REST merge) | not measured yet
|
|
49
|
-
| Schema-driven field typing (`fieldSchemaJSON`) | ✅ | — (3.x removed it; DOM heuristics + Lexical auto-detection take over) | — (as in 3.x)
|
|
44
|
+
| | Payload 2.x | Payload 3.x | Payload 4.x (measured on 4.0.0-beta.4 and beta.6) |
|
|
45
|
+
| ---------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- | --------------------------------------------------------------------------- |
|
|
46
|
+
| Scalar field updates | ✅ | ✅ | ✅ |
|
|
47
|
+
| Rich text (Lexical) | ✅ | ✅ | ✅ through a fragment render (beta.4) and the client-side renderer (beta.6) |
|
|
48
|
+
| Relationship / upload population | Collection GETs from the accepted schema with `serverURL` and matching depth (relationships measured against a real 2.32.3 admin, uploads by unit tests) | ✅ with `serverURL` (REST merge) | uploads ✅ with `serverURL` (beta.6); relationships not measured yet |
|
|
49
|
+
| Schema-driven field typing (`fieldSchemaJSON`) | ✅ | — (3.x removed it; DOM heuristics + Lexical auto-detection take over) | — (as in 3.x) |
|
|
50
50
|
|
|
51
51
|
<!-- compat-matrix:start -->
|
|
52
52
|
|
|
53
|
-
| Framework | Supported
|
|
54
|
-
| --------- |
|
|
55
|
-
| Astro | >=4.0.0 <8.0.0
|
|
56
|
-
| Next.js | App Router, 15.5 and 16
|
|
57
|
-
| SvelteKit | 2.x
|
|
58
|
-
| Nuxt | 3.x (end of life since 31 July 2026: kept working, not officially supported) | 3.21.11 (chromium, firefox, webkit)
|
|
53
|
+
| Framework | Supported | Tested in CI on every push (version, browsers) |
|
|
54
|
+
| --------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- |
|
|
55
|
+
| Astro | >=4.0.0 <8.0.0 | 7.4.2 (chromium, firefox, webkit); 6.x (chromium); 5.x (chromium); 4.x (chromium) |
|
|
56
|
+
| Next.js | App Router, 15.5 and 16 | 16.4.3 (chromium, firefox, webkit); 15.x (chromium) |
|
|
57
|
+
| SvelteKit | 2.x and 3.x | 3.1.1 (chromium, firefox, webkit); 2.70.3 (chromium, firefox, webkit) |
|
|
58
|
+
| Nuxt | 4.x; 3.x (end of life since 31 July 2026: kept working, not officially supported) | 4.6.3 (chromium, firefox, webkit); 3.21.11 (chromium, firefox, webkit) |
|
|
59
59
|
|
|
60
60
|
Node >=20.19.0; the unit and integration suites run on Node 20, 22, 24, 26. Every version in the table is what the fixture lockfile or the matrix job installs, checked by `npm run compat:check`.
|
|
61
61
|
|
|
62
|
-
Of the
|
|
62
|
+
Of the 61 feature rows of `quality/compat-matrix.json`, 58 passed in the CI run the last Version PR recorded (commit `01129c7`, 2026-11-02, `quality/compat-results.json`); the other 3 have no recorded result.
|
|
63
63
|
|
|
64
|
-
Vite 5 through 8: that is what the supported framework majors install (Astro 7 → 8, Astro 6 → 7, Astro 5 → 6, Astro 4 → 5, SvelteKit 2 → 5/6/7/8, Nuxt 3 → 7), measured 2026-
|
|
64
|
+
Vite 5 through 8: that is what the supported framework majors install (Astro 7 → 8, Astro 6 → 7, Astro 5 → 6, Astro 4 → 5, SvelteKit 3 → 8, SvelteKit 2 → 5/6/7/8, Nuxt 4 → 8, Nuxt 3 → 7), measured 2026-10-31. `npm run compat:check` keeps the devDependency and the fixture lockfiles inside that span; `npm run compat:refresh` re-reads it from the registry.
|
|
65
65
|
|
|
66
66
|
The framework hooks and fragment renderers run twice on every push: at the floor of each peer range, as unit tests in jsdom that the `hook-matrix` job runs after installing the floors over the lockfile (React 18.0.0, Vue 3.3.0, Svelte 5.0.0), and at what the lockfile installs (React 19.3.1, Vue 3.5.44, Svelte 5.57.3), in the unit tests and the browser suites; the SvelteKit renderer is measured against a component compiled by `svelte/compiler` and rendered by the real `svelte/server`.
|
|
67
67
|
|
|
@@ -70,6 +70,8 @@ The framework hooks and fragment renderers run twice on every push: at the floor
|
|
|
70
70
|
- Payload 3.88.0: wire corpus captured from a real admin, replayed in tests/integration/wire-corpus.test.ts.
|
|
71
71
|
- Payload 3.89.0: wire corpus captured from a real admin, replayed in tests/integration/wire-corpus.test.ts.
|
|
72
72
|
- Payload 3.92.1: real admin E2E fixture (examples/payload-backend), run by CI on every push.
|
|
73
|
+
- Payload 4.0.0-beta.6: wire corpus captured on 2026-11-01 from a real Payload 4 admin (examples/payload-backend with payload@4.0.0-beta.6 installed over it, Node 24.22.1), replayed in tests/integration/wire-corpus.test.ts. The messages have the same top-level and field keys as the 4.0.0-beta.4 capture.
|
|
74
|
+
- Payload 4.0.0-beta.6 (pre-release): measured on 2026-11-02, outside CI, with tests/real-payload/surface-findings.spec.ts against examples/payload-backend with payload@4.0.0-beta.6 installed over it (Node 24.22.1): its 7 cases passed in Chromium, Firefox and WebKit. Among them an upload chosen in the admin reached an `<img>` inside a `<picture>` through the REST merge, and an edit in Lexical rich text was written by the client-side renderer, internal link included. Relationships were not part of the run.
|
|
73
75
|
- Payload 4.0.0-beta.4: wire corpus captured on 2026-10-26 from a real Payload 4 admin (examples/payload-backend with payload@4.0.0-beta.4 installed over it, Node 24.22.1), replayed in tests/integration/wire-corpus.test.ts; the fixture itself stays on 3.x.
|
|
74
76
|
- Payload 4.0.0-beta.4 (pre-release): measured once on 2026-10-24, outside CI, in a consumer project that runs 2.1.0 from npm (Next 16, Node 24, Postgres 18, the real admin driven by headless Chromium). The config plugin type-checks against Payload's declarations and passes its config sanitizing. For six collection documents in two locales, the admin's preview frame loads the URL a hand-written callback produced, apart from the order of the query parameters, with the same breakpoint menu and no page errors, and the locale reaches the path resolvers. Against an admin with a `csrf` list, the `payload-session` strategy authorizes once its `origin` option is set. That run did not cover globals, the create screen, drafts and autosave, other plugins that write a Live Preview URL, or replacing existing breakpoints. Since 2026-10-25 the daily protocol watch installs payload@beta into the admin fixture as a soft-fail early warning.
|
|
75
77
|
- Payload 4.0.0-beta.4 with Astro 7.4.2 (pre-release): measured on 2026-10-26, outside CI, with a 2.2 release candidate on a consumer site (the real admin driven by headless Chromium). Typing into a title and a text line patched the preview, typing into a rich-text field updated it through 7 fragment renders that answered 200, the frame never reloaded, and all 31 live-preview messages had the shape of the recorded capture. Relationship and upload population were not part of the run.
|
|
@@ -78,9 +80,9 @@ The framework hooks and fragment renderers run twice on every push: at the floor
|
|
|
78
80
|
|
|
79
81
|
<!-- compat-matrix:end -->
|
|
80
82
|
|
|
81
|
-
|
|
83
|
+
SvelteKit 3 and Nuxt 4 are supported. The `sveltekit3` job runs the SvelteKit example migrated to SvelteKit 3.1.1 with `npx sv migrate sveltekit-3`, and the `nuxt4` job runs the Nuxt example in Nuxt 4.6.3's `app/` layout. Both run on the development server against the mock admin in Chromium, Firefox and WebKit, and `real-payload-surfaces` drives both from the real admin in the same three engines. `real-payload-surfaces` also drives both production builds; the `production-lifecycle` job still builds SvelteKit 2 and Nuxt 3. The SvelteKit example needed the migration's changes ([docs/sveltekit.md](docs/sveltekit.md)); the package needed no change for either.
|
|
82
84
|
|
|
83
|
-
**A client-rendered app takes a hook.** `useLivePreviewDocument()` from `payload-live-preview/react` or `payload-live-preview/vue` returns the merged document and re-renders your tree. Payload 3 updates use the method-override merge request; Payload 2 scalar updates settle locally and raw relationships use schema-based collection GETs. A newer update aborts any request in flight; an HTTP error is refused instead of becoming the document; each hook keeps its own state, requests and errors, and
|
|
85
|
+
**A client-rendered app takes a hook.** `useLivePreviewDocument()` from `payload-live-preview/react` or `payload-live-preview/vue` returns the merged document and re-renders your tree. Payload 3 updates use the method-override merge request; Payload 2 scalar updates settle locally and raw relationships use schema-based collection GETs. A newer update aborts any request in flight; an HTTP error is refused instead of becoming the document; each hook keeps its own state, requests and errors, and a hook given a `document` merges only that document's updates; without one it follows the document the admin sends, whichever one it started from ([docs/react.md](docs/react.md), [docs/vue.md](docs/vue.md)). The official [`@payloadcms/live-preview-react`](https://payloadcms.com/docs/live-preview/client) / `-vue` hooks ship in lockstep with Payload and remain the safe default if that matters more to you; running either alongside the DOM runtime on one page: [docs/interop.md](docs/interop.md).
|
|
84
86
|
|
|
85
87
|
## Install
|
|
86
88
|
|
|
@@ -125,8 +127,10 @@ the mappings. Existing breakpoints stay when the option is omitted; supplying
|
|
|
125
127
|
it replaces the list. A competing root URL or a URL on a selected entity that
|
|
126
128
|
already exists when this transform runs is a configuration error. Make this
|
|
127
129
|
transform run after any plugin that may write a Live Preview URL in Payload's
|
|
128
|
-
effective execution order
|
|
129
|
-
|
|
130
|
+
effective execution order (Payload 3 and 4 sort by the `order` option), or
|
|
131
|
+
compose both routing policies explicitly. A resolver or the `fallback` may be
|
|
132
|
+
`null` for a document without a preview on Payload 3 and 4. The complete merge
|
|
133
|
+
and conflict rules are in [docs/payload.md](docs/payload.md).
|
|
130
134
|
|
|
131
135
|
In the Payload 3.92.1 admin, a collection document gets its native Live
|
|
132
136
|
Preview after its first save. The create screen has no preview toggle and no
|
|
@@ -137,10 +141,11 @@ Firefox and WebKit.
|
|
|
137
141
|
|
|
138
142
|
Payload 4 is still a pre-release ([Compatibility](#compatibility)). The plugin
|
|
139
143
|
was measured once against 4.0.0-beta.4, outside CI; the compatibility list says
|
|
140
|
-
what that run covered and what it left out.
|
|
144
|
+
what that run covered and what it left out. Its `order` option and `null`
|
|
145
|
+
resolvers were measured once against 4.0.0-beta.6, also outside CI
|
|
146
|
+
([ADR 0017](docs/architecture/0017-structural-payload-config-plugin.md)).
|
|
141
147
|
|
|
142
|
-
Use the lower-level callback when another plugin owns the surrounding config
|
|
143
|
-
when a document may have no preview route:
|
|
148
|
+
Use the lower-level callback when another plugin owns the surrounding config:
|
|
144
149
|
|
|
145
150
|
```ts
|
|
146
151
|
import { buildLivePreviewUrl } from 'payload-live-preview/payload';
|
|
@@ -171,7 +176,7 @@ export default buildConfig({
|
|
|
171
176
|
});
|
|
172
177
|
```
|
|
173
178
|
|
|
174
|
-
The helper appends `?preview=true`, one of the query parameters (`preview`, `draft`, `livePreview`) the adapters read as preview intent. The parameter is client-controlled: it selects delivery and never authorizes draft access. A hand-written `url: ({ data, locale, collectionConfig, globalConfig }) => string` callback works the same way; the [official docs](https://payloadcms.com/docs/live-preview/overview) have the full contract. The helper's nullable overload lets a resolver return `null` for a document without a route, and `fallback: null` declines every unmapped one; Payload 3 then shows no iframe. Payload 2.32.3's published callback result is string-only, so use the non-null overload and a string fallback there
|
|
179
|
+
The helper appends `?preview=true`, one of the query parameters (`preview`, `draft`, `livePreview`) the adapters read as preview intent. The parameter is client-controlled: it selects delivery and never authorizes draft access. A hand-written `url: ({ data, locale, collectionConfig, globalConfig }) => string` callback works the same way; the [official docs](https://payloadcms.com/docs/live-preview/overview) have the full contract. The helper's nullable overload lets a resolver return `null` for a document without a route, and `fallback: null` declines every unmapped one; Payload 3 then shows no iframe. Payload 2.32.3's published callback result is string-only, so use the non-null overload and a string fallback there, and keep the config plugin's resolvers to strings.
|
|
175
180
|
|
|
176
181
|
The config plugin accepts no signing secret or token option. Where no session
|
|
177
182
|
cookie crosses origins, the manual `signed-token` URL callback is a Payload 3
|
|
@@ -351,7 +356,7 @@ That is it: the runtime detects the admin's iframe and starts patching. Rich tex
|
|
|
351
356
|
| Rich text and empty fields on the server | the `RichText` and `PreviewBoundary` components | `lexicalToHtml()` and a `data-payload-boundary` element | `lexicalToHtml()` and a `data-payload-boundary` element | `lexicalToHtml()` and a `data-payload-boundary` element |
|
|
352
357
|
| `pll-codegen annotate` reads | `.astro`, also as a Vite plugin | `.jsx`, `.tsx` | `.svelte` | not `.vue` files |
|
|
353
358
|
|
|
354
|
-
Astro also writes the runtime into a static build (`inline`, `loader`). Its `RichText` and `PreviewBoundary` components write the same markup the other frameworks write by hand with `lexicalToHtml()` and a `data-payload-boundary` element ([docs/bindings.md](docs/bindings.md)). The test depth differs: CI installs Astro 4 to 7
|
|
359
|
+
Astro also writes the runtime into a static build (`inline`, `loader`). Its `RichText` and `PreviewBoundary` components write the same markup the other frameworks write by hand with `lexicalToHtml()` and a `data-payload-boundary` element ([docs/bindings.md](docs/bindings.md)). The test depth differs: CI installs Astro 4 to 7, Next.js 15.5 and 16, SvelteKit 2 and 3, and Nuxt 3 and 4. Nuxt 3 reached its end of life on 31 July 2026.
|
|
355
360
|
|
|
356
361
|
## Patch, fragment, route
|
|
357
362
|
|
|
@@ -24,6 +24,9 @@
|
|
|
24
24
|
* `data-payload-strategy="patch"` is written explicitly: the wrapper is a
|
|
25
25
|
* patch target; markup a server renders instead lives in a
|
|
26
26
|
* `data-payload-fragment` boundary (docs/hybrid.md).
|
|
27
|
+
*
|
|
28
|
+
* Where `authorizePreview` decides, a response it did not authorize keeps the
|
|
29
|
+
* wrapper and carries no `data-payload-*`, as the gated helpers do (ADR 0006).
|
|
27
30
|
*/
|
|
28
31
|
|
|
29
32
|
interface Props {
|
|
@@ -50,14 +53,24 @@ function isEmpty(candidate: unknown): boolean {
|
|
|
50
53
|
|
|
51
54
|
const Tag = as;
|
|
52
55
|
const empty = isEmpty(value);
|
|
56
|
+
const locals = Astro.locals as {
|
|
57
|
+
livePreviewRequiresAuthorization?: boolean;
|
|
58
|
+
livePreviewAuthorization?: unknown;
|
|
59
|
+
};
|
|
60
|
+
const binding =
|
|
61
|
+
locals.livePreviewRequiresAuthorization === true && locals.livePreviewAuthorization === undefined
|
|
62
|
+
? {}
|
|
63
|
+
: {
|
|
64
|
+
'data-payload-field': field,
|
|
65
|
+
'data-payload-type': type,
|
|
66
|
+
'data-payload-boundary': '',
|
|
67
|
+
'data-payload-strategy': 'patch',
|
|
68
|
+
};
|
|
53
69
|
---
|
|
54
70
|
|
|
55
71
|
<Tag
|
|
56
72
|
{...rest}
|
|
57
|
-
|
|
58
|
-
data-payload-type={type}
|
|
59
|
-
data-payload-boundary=""
|
|
60
|
-
data-payload-strategy="patch"
|
|
73
|
+
{...binding}
|
|
61
74
|
hidden={empty ? true : undefined}
|
|
62
75
|
>
|
|
63
76
|
<slot />
|
|
@@ -70,6 +70,17 @@ const {
|
|
|
70
70
|
requireDocument,
|
|
71
71
|
} = Astro.props;
|
|
72
72
|
const Tag = tag;
|
|
73
|
+
const locals = Astro.locals as {
|
|
74
|
+
livePreviewRequiresAuthorization?: boolean;
|
|
75
|
+
livePreviewAuthorization?: unknown;
|
|
76
|
+
};
|
|
77
|
+
// Where `authorizePreview` decides, a response it did not authorize carries no binding (ADR 0006).
|
|
78
|
+
const bound =
|
|
79
|
+
field !== undefined &&
|
|
80
|
+
!(
|
|
81
|
+
locals.livePreviewRequiresAuthorization === true &&
|
|
82
|
+
locals.livePreviewAuthorization === undefined
|
|
83
|
+
);
|
|
73
84
|
const html = isLexicalContent(value)
|
|
74
85
|
? lexicalToHtml(value, {
|
|
75
86
|
...(sanitizerDocument === undefined ? {} : { document: sanitizerDocument }),
|
|
@@ -80,7 +91,7 @@ const html = isLexicalContent(value)
|
|
|
80
91
|
|
|
81
92
|
<Tag
|
|
82
93
|
class={className}
|
|
83
|
-
data-payload-field={field}
|
|
84
|
-
data-payload-richtext={
|
|
94
|
+
data-payload-field={bound ? field : undefined}
|
|
95
|
+
data-payload-richtext={bound ? '' : undefined}
|
|
85
96
|
set:html={html}
|
|
86
97
|
/>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { L as LivePreviewAstroOptions } from '../../middleware-
|
|
2
|
-
export { a as LivePreviewMiddleware, c as createLivePreviewMiddleware } from '../../middleware-
|
|
3
|
-
import { h as hasPreviewIntent } from '../../options-
|
|
4
|
-
export { P as PreviewAdapterOptions, a as PreviewRequestLike, b as PreviewRequestOptions, c as PreviewSignal } from '../../options-
|
|
5
|
-
import { F as FragmentEndpointOptions$1, a as FragmentRegistry$1, b as FragmentRegistryEntry$1, c as FragmentRenderer$1 } from '../../fragment-endpoint-
|
|
6
|
-
export { d as FragmentRenderInput } from '../../fragment-endpoint-
|
|
7
|
-
export { A as AUTHORIZATION_LOCALS_KEY, a as AUTHORIZATION_OUTCOME_LOCALS_KEY, L as LivePreviewLocals, N as NONCE_LOCALS_KEY } from '../../locals-
|
|
1
|
+
import { L as LivePreviewAstroOptions } from '../../middleware-Dnt6u4nF.js';
|
|
2
|
+
export { a as LivePreviewMiddleware, c as createLivePreviewMiddleware } from '../../middleware-Dnt6u4nF.js';
|
|
3
|
+
import { h as hasPreviewIntent } from '../../options-DTzhFVJ4.js';
|
|
4
|
+
export { P as PreviewAdapterOptions, a as PreviewRequestLike, b as PreviewRequestOptions, c as PreviewSignal } from '../../options-DTzhFVJ4.js';
|
|
5
|
+
import { F as FragmentEndpointOptions$1, a as FragmentRegistry$1, b as FragmentRegistryEntry$1, c as FragmentRenderer$1 } from '../../fragment-endpoint-CQE_7MKi.js';
|
|
6
|
+
export { d as FragmentRenderInput } from '../../fragment-endpoint-CQE_7MKi.js';
|
|
7
|
+
export { A as AUTHORIZATION_LOCALS_KEY, a as AUTHORIZATION_OUTCOME_LOCALS_KEY, L as LivePreviewLocals, N as NONCE_LOCALS_KEY } from '../../locals-CyzDKfKU.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* The Astro integration for `astro.config.mjs`: `livePreview({ ... })`.
|