payload-live-preview 2.0.1 → 2.0.2

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 (76) hide show
  1. package/README.md +36 -31
  2. package/dist/adapters/astro/RichText.astro +1 -1
  3. package/dist/adapters/astro/index.js +1 -1
  4. package/dist/adapters/astro/index.js.map +1 -1
  5. package/dist/adapters/astro/middleware-entry.js +1 -1
  6. package/dist/adapters/astro/middleware-entry.js.map +1 -1
  7. package/dist/adapters/nextjs/index.js +1 -1
  8. package/dist/adapters/nextjs/index.js.map +1 -1
  9. package/dist/adapters/nuxt/index.js +1 -1
  10. package/dist/adapters/nuxt/index.js.map +1 -1
  11. package/dist/adapters/nuxt/module.d.ts +12 -4
  12. package/dist/adapters/nuxt/module.js.map +1 -1
  13. package/dist/adapters/react/index.d.ts +6 -5
  14. package/dist/adapters/react/index.js.map +1 -1
  15. package/dist/adapters/sveltekit/index.js +1 -1
  16. package/dist/adapters/sveltekit/index.js.map +1 -1
  17. package/dist/adapters/vue/index.d.ts +3 -3
  18. package/dist/adapters/vue/index.js.map +1 -1
  19. package/dist/annotate.js +1 -1
  20. package/dist/annotate.js.map +1 -1
  21. package/dist/client.cjs +1 -1
  22. package/dist/client.cjs.map +1 -1
  23. package/dist/client.js +1 -1
  24. package/dist/client.js.map +1 -1
  25. package/dist/codegen-astro.d.ts +4 -1
  26. package/dist/codegen-astro.js.map +1 -1
  27. package/dist/codegen-cli.js +1 -1
  28. package/dist/codegen-cli.js.map +1 -1
  29. package/dist/codegen.cjs +1 -1
  30. package/dist/codegen.cjs.map +1 -1
  31. package/dist/codegen.js +1 -1
  32. package/dist/codegen.js.map +1 -1
  33. package/dist/core.cjs +1 -1
  34. package/dist/core.cjs.map +1 -1
  35. package/dist/core.d.cts +1 -1
  36. package/dist/core.d.ts +1 -1
  37. package/dist/core.js +1 -1
  38. package/dist/core.js.map +1 -1
  39. package/dist/doctor-cli.d.ts +1 -1
  40. package/dist/doctor-cli.js +1 -1
  41. package/dist/doctor-cli.js.map +1 -1
  42. package/dist/doctor.d.ts +2 -2
  43. package/dist/doctor.js +1 -1
  44. package/dist/doctor.js.map +1 -1
  45. package/dist/fragment.cjs.map +1 -1
  46. package/dist/fragment.d.cts +6 -3
  47. package/dist/fragment.d.ts +6 -3
  48. package/dist/fragment.js.map +1 -1
  49. package/dist/index.cjs +1 -1
  50. package/dist/index.cjs.map +1 -1
  51. package/dist/index.d.cts +8 -8
  52. package/dist/index.d.ts +8 -8
  53. package/dist/index.js +1 -1
  54. package/dist/index.js.map +1 -1
  55. package/dist/lean.cjs +1 -1
  56. package/dist/lean.cjs.map +1 -1
  57. package/dist/lean.d.cts +3 -3
  58. package/dist/lean.d.ts +3 -3
  59. package/dist/lean.js +1 -1
  60. package/dist/lean.js.map +1 -1
  61. package/dist/lexical.cjs +1 -1
  62. package/dist/lexical.cjs.map +1 -1
  63. package/dist/lexical.d.cts +11 -1
  64. package/dist/lexical.d.ts +11 -1
  65. package/dist/lexical.js +1 -1
  66. package/dist/lexical.js.map +1 -1
  67. package/dist/plugins.cjs +1 -1
  68. package/dist/plugins.cjs.map +1 -1
  69. package/dist/plugins.js +1 -1
  70. package/dist/plugins.js.map +1 -1
  71. package/dist/{probe-wmvfVEsI.d.ts → probe-DqaItcwX.d.ts} +2 -1
  72. package/dist/structural.cjs +2 -2
  73. package/dist/structural.cjs.map +1 -1
  74. package/dist/structural.js +2 -2
  75. package/dist/structural.js.map +1 -1
  76. package/package.json +2 -3
package/README.md CHANGED
@@ -6,45 +6,49 @@
6
6
  [![Payload 2.x / 3.x](https://img.shields.io/badge/Payload-2.x%20%2F%203.x-black)](https://payloadcms.com)
7
7
  [![npm](https://img.shields.io/npm/v/payload-live-preview?color=cb3837&logo=npm)](https://www.npmjs.com/package/payload-live-preview)
8
8
 
9
- > **Live preview for Payload CMS in Astro** — and any other server-rendered or static frontend (SvelteKit, Nuxt, Next.js, plain HTML).
9
+ > **Live preview for Payload CMS on server-rendered and static sites** — Astro, Next.js, SvelteKit, Nuxt and plain HTML.
10
10
 
11
- **The missing piece for Astro + Payload.** The official live-preview packages are React and Vue hooks: they re-render a hydrated component tree, so they cannot touch server-produced Astro markup. This package makes the admin's real-time preview work where no client framework owns the page. Add one line to `astro.config.mjs`, mark what should update — one attribute per component on a server-rendered page with a fragment endpoint, per field on a static one — and edits stream into the preview iframe as the editor types. No rebuild, no reload, no React.
11
+ The official live-preview packages are React and Vue hooks: they re-render a hydrated component tree, so they cannot touch markup a server produced. This package makes the admin's real-time preview work where no client framework owns the page. Mark what should update — one attribute per component on a server-rendered page with a fragment endpoint, per field on a static one — and edits reach the preview iframe as the editor types: bound elements are patched in place, fragment boundaries are rendered again by your server. No rebuild, no reload. A client-rendered app gets React and Vue hooks with the same merge underneath. Strict by default, zero runtime dependencies.
12
12
 
13
- The runtime is framework-agnostic: one script drives Astro, SvelteKit, Nuxt, Next.js and plain HTML. Astro is the first-class, end-to-end-tested path.
13
+ One runtime serves every framework, and every framework adapter's example app runs end to end in Chromium, Firefox and WebKit on every push to `main` and on pull requests. Astro has the most coverage: the widest version matrix (4.x to 7.x), the only end-to-end tests against a real Payload admin, the `RichText` and `PreviewBoundary` components, and the build-time annotator.
14
14
 
15
15
  **New here? Start with the [Astro guide](docs/astro.md), or pick your framework in the [documentation index](docs/README.md).**
16
16
 
17
17
  ## Highlights
18
18
 
19
- - **One runtime, every frontend.** One TypeScript runtime compiled to a self-contained inline script of about 35 KB gzip — 28 KB with the lean artifact ([docs/options.md](docs/options.md)); the adapters for Astro, Next.js, SvelteKit and Nuxt only decide when to deliver it.
20
- - **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: typing into a text field costs no request, and a burst on a relationship costs two rather than one per keystroke.
21
- - **Complete Lexical renderer.** 20 node types including `upload`, `relationship`, `block`, `autolink`, tabs, indent and RTL, with automatic rich-text detection: `data-payload-field` alone is enough.
22
- - **Authorization before anything privileged.** Wherever the runtime is injected at request time, draft reads, runtime injection, CSP changes and binding attributes follow one verified decision per request; Astro's default `inline` and `loader` modes inject at build time into every page, where the runtime does not start outside a preview frame. The client-controlled intent signals never unlock anything.
19
+ - **One runtime, every frontend.** One TypeScript runtime compiled to a self-contained inline script of about 35 KB gzip — 28 KB with the lean artifact ([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.
20
+ - **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 binding in `<head>`, or one marked `data-payload-strategy="route"`, can refresh the whole route. A patch the runtime knows fell short, or a change nothing binds, is handed to the fragment render or a route refresh when the page has one ([below](#patch-fragment-route)).
21
+ - **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, `<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)).
22
+ - **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 rather than one per keystroke.
23
+ - **Lexical renderer.** 20 node types including `upload`, `relationship`, `block`, `autolink`, tabs, indent and RTL, with automatic rich-text detection: `data-payload-field` alone is enough. An unknown node renders only its children; a block with no registered renderer becomes an empty placeholder, and the live write keeps the markup your server rendered in its place when the two trees line up. The prebuilt inline runtime cannot register block renderers.
24
+ - **Hooks for client-rendered apps.** `useLivePreviewDocument()` from `payload-live-preview/react` or `/vue` hands the merged document to your component tree ([docs/react.md](docs/react.md), [docs/vue.md](docs/vue.md)).
25
+ - **Tooling.** `pll doctor <url>` requests a page as a visitor and as the admin's iframe and reports the difference; `pll migrate` rewrites 1.x APIs to their 2.0 names; `pll-codegen` generates types from the Payload config, and `pll-codegen annotate` finds the bindings a template can take unambiguously.
26
+ - **Authorization before anything privileged.** Where an adapter decides per request with `authorizePreview`, draft reads, runtime injection, CSP changes and binding attributes follow one verified decision, and the client-controlled intent signals unlock nothing. The setups that deliver at build time, render the script for every request or inject on intent alone are named under [Security model](#security-model).
23
27
  - **Strict by default.** Escape-by-default sanitizer, URL and `srcset` validation, policed attribute writes, prototype-pollution guards, per-instance clients, typed bindings with `pll-codegen`.
24
28
 
25
29
  ## Compatibility
26
30
 
27
- | | Payload 2.x | Payload 3.x |
28
- | ---------------------------------------------- | ----------------------------- | --------------------------------------------------------------------- |
29
- | Scalar field updates | ✅ | ✅ |
30
- | Rich text (Lexical) | ✅ | ✅ |
31
- | Relationship / upload population | ✅ (admin merges client-side) | ✅ with `serverURL` (REST merge) |
32
- | Schema-driven field typing (`fieldSchemaJSON`) | ✅ | — (3.x removed it; DOM heuristics + Lexical auto-detection take over) |
31
+ | | Payload 2.x | Payload 3.x |
32
+ | ---------------------------------------------- | ------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
33
+ | Scalar field updates | ✅ | ✅ |
34
+ | Rich text (Lexical) | ✅ | ✅ |
35
+ | Relationship / upload population | The admin's populated data, used as sent; not verified against a real 2.x admin | ✅ with `serverURL` (REST merge) |
36
+ | Schema-driven field typing (`fieldSchemaJSON`) | ✅ | — (3.x removed it; DOM heuristics + Lexical auto-detection take over) |
33
37
 
34
38
  <!-- compat-matrix:start -->
35
39
 
36
- | Framework | Supported | Tested in CI on every push (version, browsers) |
37
- | --------- | --------------------- | --------------------------------------------------------------------------------- |
38
- | Astro | >=4.0.0 <8.0.0 | 7.3.2 (chromium, firefox, webkit); 6.x (chromium); 5.x (chromium); 4.x (chromium) |
39
- | Next.js | App Router, 15 and 16 | 16.3.4 (chromium, firefox, webkit) |
40
- | SvelteKit | 2.x | 2.70.2 (chromium, firefox, webkit) |
41
- | Nuxt | 3.x | 3.21.11 (chromium, firefox, webkit) |
40
+ | Framework | Supported | Tested in CI on every push (version, browsers) |
41
+ | --------- | -------------- | --------------------------------------------------------------------------------- |
42
+ | Astro | >=4.0.0 <8.0.0 | 7.3.2 (chromium, firefox, webkit); 6.x (chromium); 5.x (chromium); 4.x (chromium) |
43
+ | Next.js | App Router, 16 | 16.3.4 (chromium, firefox, webkit) |
44
+ | SvelteKit | 2.x | 2.70.2 (chromium, firefox, webkit) |
45
+ | Nuxt | 3.x | 3.21.11 (chromium, firefox, webkit) |
42
46
 
43
47
  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`.
44
48
 
45
49
  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-09-06. `npm run compat:check` keeps the devDependency and the fixture lockfiles inside that span; `npm run compat:refresh` re-reads it from the registry.
46
50
 
47
- - Payload 2.x: captured-message integration tests and fieldSchemaJSON typing.
51
+ - Payload 2.32.3: wire corpus captured from a real admin in a one-off round (examples/ has no Payload 2 fixture), replayed in tests/integration/wire-corpus.test.ts, plus fieldSchemaJSON typing in tests/integration/schema-driven.test.ts; relationship and upload population is not verified against a real 2.x admin.
48
52
  - Payload 3.85.0: wire corpus captured from a real admin, replayed in tests/integration/wire-corpus.test.ts.
49
53
  - Payload 3.88.0: wire corpus captured from a real admin, replayed in tests/integration/wire-corpus.test.ts.
50
54
  - Payload 3.89.0: real admin E2E (examples/payload-backend) on every push, plus a wire corpus captured from it.
@@ -54,7 +58,7 @@ Vite 5 through 8: that is what the supported framework majors install (Astro 7
54
58
 
55
59
  <!-- compat-matrix:end -->
56
60
 
57
- **A client-rendered app wants a hook.** `payload-live-preview/react` and `payload-live-preview/vue` are ones: `useLivePreviewDocument()` returns the merged document and re-renders your tree, with this package's merge underneath — one request at a time, the newer answer winning, an HTTP error refused instead of becoming the document, and a cache per call ([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).
61
+ **A client-rendered app wants a hook.** `payload-live-preview/react` and `payload-live-preview/vue` are ones: `useLivePreviewDocument()` returns the merged document and re-renders your tree, with this package's merge underneath: every accepted update, a text edit too, sends one merge request, and a newer one aborts the request in flight; an HTTP error is refused instead of becoming the document; and each hook has a session of its own, so two previews on one page keep their own documents ([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).
58
62
 
59
63
  ## Install
60
64
 
@@ -62,7 +66,7 @@ Vite 5 through 8: that is what the supported framework majors install (Astro 7
62
66
  npm install payload-live-preview
63
67
  ```
64
68
 
65
- Three entries cover most projects. The root `payload-live-preview` carries the client, the inline script generator, the renderers and the plugins. `payload-live-preview/astro`, `/nextjs`, `/sveltekit` and `/nuxt` hold one framework adapter each; `/nuxt-module` registers the Nuxt one from `nuxt.config.ts`. `payload-live-preview/server` is the privileged surface for server code: `definePreview()`, `authorizePreviewRequest()`, `issuePreviewToken()` and `createPreviewBindings()`. The focused entries (`core`, `client`, `lexical`, `structural`, `plugins`, `fragment`, `lean`, `payload`, `codegen`, `codegen/astro`, `annotate`, `doctor`, `migrate`) are listed in [docs/options.md](docs/options.md).
69
+ Three entries cover most projects. The root `payload-live-preview` carries the client, the inline script generator, the renderers and four of the five built-in plugins; the unbound-fields overlay and `PluginManager` are on `payload-live-preview/plugins`. `payload-live-preview/astro`, `/nextjs`, `/sveltekit` and `/nuxt` hold one framework adapter each; `/nuxt-module` registers the Nuxt one from `nuxt.config.ts`, and since it cannot carry `authorizePreview` it runs with `defaults: 'v1'` ([docs/nuxt.md](docs/nuxt.md)). `payload-live-preview/server` is the privileged surface for server code: `definePreview()`, `authorizePreviewRequest()`, `issuePreviewToken()` and `createPreviewBindings()`. The focused entries (`core`, `client`, `lexical`, `structural`, `plugins`, `fragment`, `lean`, `payload`, `codegen`, `codegen/astro`, `annotate`, `doctor`, `migrate`) are listed in [docs/options.md](docs/options.md).
66
70
 
67
71
  ## Configure Payload
68
72
 
@@ -112,9 +116,10 @@ import { livePreview } from 'payload-live-preview/astro';
112
116
  export default defineConfig({
113
117
  integrations: [
114
118
  livePreview({
115
- allowedOrigins: [import.meta.env.PUBLIC_PAYLOAD_ADMIN_ORIGIN],
119
+ // process.env: import.meta.env carries no PUBLIC_ variables in this file.
120
+ allowedOrigins: [process.env.PUBLIC_PAYLOAD_ADMIN_ORIGIN],
116
121
  // Payload 3.x: populate relationship/upload fields via REST merge
117
- serverURL: import.meta.env.PUBLIC_PAYLOAD_ADMIN_ORIGIN,
122
+ serverURL: process.env.PUBLIC_PAYLOAD_ADMIN_ORIGIN,
118
123
  // Required alongside serverURL: the population depth, 0 for none.
119
124
  mergeDepth: 1,
120
125
  }),
@@ -140,20 +145,20 @@ On a static build there is no server to render it, so the fields are bound indiv
140
145
  <img data-payload-field="hero" alt={alt} src={url} />
141
146
  ```
142
147
 
143
- Which to reach for, and what each costs: [docs/bindings.md](docs/bindings.md#how-much-markup-this-actually-needs). `pll-codegen annotate` writes the unambiguous bindings for you and reports the rest.
148
+ Which to reach for, and what each costs: [docs/bindings.md](docs/bindings.md#how-much-markup-this-actually-needs). `pll-codegen annotate` adds the unambiguous bindings and names each one it refuses, with the reason; without `--write` it only reports, and exits with `3` when it found work.
144
149
 
145
150
  That is it: the inline script detects the admin's iframe and starts patching. Rich text is detected from the value shape; `data-payload-richtext` only forces it. Payload 3.x posts raw form values, so relationship and upload fields arrive as IDs until `serverURL` with `mergeDepth` re-fetches the populated document ([docs/options.md](docs/options.md)). Injection modes, request-time middleware, authorization and the initial draft read: [docs/astro.md](docs/astro.md).
146
151
 
147
152
  ### Other frameworks
148
153
 
149
- - **Next.js (App Router)** — the script in `app/layout.tsx`, the adapter middleware for headers: [docs/nextjs.md](docs/nextjs.md).
154
+ - **Next.js (App Router)** — `<LivePreviewScript />` in `app/layout.tsx`, the adapter middleware for headers: [docs/nextjs.md](docs/nextjs.md).
150
155
  - **SvelteKit** — `livePreviewHandle()` in `hooks.server.ts`: [docs/sveltekit.md](docs/sveltekit.md).
151
156
  - **Nuxt** — a Nitro plugin plus a server handler: [docs/nuxt.md](docs/nuxt.md).
152
157
  - **Plain HTML** — `generateInlineScript()` at build time: [docs/html.md](docs/html.md).
153
158
 
154
159
  ## Patch, fragment, route
155
160
 
156
- A binding is patched in place by default. A `data-payload-fragment` boundary is rendered by your server from the unsaved form state instead — conditional sections, derived values, custom blocks, the component's own logic — and morphed in with focus and visitor state intact; the runtime posts the fields to the same-origin endpoint named in `fragments: { endpoint }`, built with `createFragmentEndpoint()`, which every adapter entry exports — Astro renders through its container API, Next.js through `react-dom/server`, SvelteKit through `svelte/server`, Nuxt through `vue/server-renderer` — and patches the boundary's own bindings when the server cannot render. With `routeStrategy: true` or `fragments` set, a binding in `<head>`, or one marked `data-payload-strategy="route"`, refreshes the whole route once per revision with scroll and focus kept; without either it is patched like any other. Markup, endpoint, deployment requirements and the abuse model: [docs/hybrid.md](docs/hybrid.md).
161
+ A binding is patched in place by default. A `data-payload-fragment` boundary is rendered by your server from the unsaved form state instead — conditional sections, derived values, custom blocks, the component's own logic — and morphed in with focus and visitor state intact; the runtime posts the fields to the same-origin endpoint named in `fragments: { endpoint }`, built with `createFragmentEndpoint()`, which every adapter entry exports — Astro renders through its container API, Next.js through `react-dom/server`, SvelteKit through `svelte/server`, Nuxt through `vue/server-renderer` — and patches the boundary's own bindings when the server cannot render. With `routeStrategy: true` or `fragments` set, a binding in `<head>`, or one marked `data-payload-strategy="route"`, refreshes the whole route once per revision with scroll and focus kept; without either it is patched like any other. The route is matched by top-level field name, so a dotted binding such as `meta.title` refreshes it only with `data-payload-depends="meta"`. Markup, endpoint, deployment requirements and the abuse model: [docs/hybrid.md](docs/hybrid.md).
157
162
 
158
163
  ## Events and plugins
159
164
 
@@ -171,8 +176,8 @@ Every event, transforms, custom field renderers, the built-in plugins and the pl
171
176
 
172
177
  ## Security model
173
178
 
174
- - **Preview intent is not authorization.** The query parameter, the iframe destination and the referer are client-controlled; the adapters count the query alone by default. `allowedOrigins` governs browser `postMessage` senders and `shouldInject` filters routes; neither authenticates the request. `authorizePreviewRequest()` does, and wherever injection happens at request time that one result controls draft reads, `private, no-store` caching, CSP changes and runtime injection. Astro's build-time `inline` and `loader` modes decide nothing per request: every page carries the runtime or its bootstrap.
175
- - **Origin validation.** Every incoming message is checked against `allowedOrigins`; `document.referrer` is ignored by default, and after the first accepted update the runtime locks to that origin. The adapters merge a `frame-ancestors` policy for the admin origins without clobbering the rest of your CSP.
179
+ - **Preview intent is not authorization.** The query parameter, the iframe destination and the referer are client-controlled; the adapters count the query alone by default. `allowedOrigins` governs browser `postMessage` senders and `shouldInject` filters routes; neither authenticates the request. `authorizePreviewRequest()` does, and where an adapter decides per request with `authorizePreview` — `createLivePreviewMiddleware()`, `livePreviewHandle()`, `livePreviewNitroPlugin()`, `defineLivePreviewServerHandler()` — that one result controls draft reads, `private, no-store` caching, CSP changes and runtime injection, and `<LivePreviewScript />` gates the Next.js script on the same verdict. Other setups decide less. Astro's build-time `inline` and `loader` modes and the synchronous `livePreviewScriptProps()` and `renderLivePreviewScript()` put the runtime or its bootstrap into every page that renders them, where it does not start outside a preview frame. Astro's `mode: 'middleware'` and the Nuxt module cannot carry `authorizePreview`, so they need `defaults: 'v1'` (or `strict: false`) and inject on intent alone.
180
+ - **Origin validation.** Every incoming message is checked against `allowedOrigins`; `document.referrer` is ignored by default, and after the first accepted update the inline runtime and `LivePreviewClient` lock to that origin (the React and Vue hooks do not). The adapters merge a `frame-ancestors` policy for the admin origins without clobbering the rest of your CSP.
176
181
  - **Sanitization and URL validation.** Lexical and HTML writes pass a DOM sanitizer with a curated allow-list — `<script>`, `<form>`, `<iframe>`, `<svg>`, event handlers and `style` are rejected — and every `href`, `src`, `srcset` and `poster` must be `http(s)`, `mailto:`, `tel:` or relative; external links get `rel="noopener noreferrer"`.
177
182
  - **Binding attributes are disclosure.** `data-payload-field` names a CMS field and `data-payload-owner` a document. `createPreviewBindings({ authorization })` suppresses them, companions included, on public responses. Never key CSS off `data-payload-*`.
178
183
  - **Policed writes, no prototype pollution.** `data-payload-attribute` refuses event handlers, `style`, `srcdoc`, `formaction`, `id` and `name`; nested lookups refuse `__proto__`, `prototype` and `constructor`, and incoming data is never merged into existing objects.
@@ -181,12 +186,12 @@ Full details in [docs/security.md](docs/security.md). Report vulnerabilities per
181
186
 
182
187
  ## Troubleshooting
183
188
 
184
- - **Nothing updates.** Run `__livePreview.inspect()` in the preview iframe's console first; it names the cause in most cases. The common ones: the admin origin is missing from `allowedOrigins`, the page is not inside an iframe, the bound element does not exist (an empty field needs an anchor).
189
+ - **Nothing updates.** Run `__livePreview.inspect()` in the preview iframe's console first — the handle exists once the injected runtime has started inside a preview frame; a page that starts `LivePreviewClient` itself calls `client.inspect()`. It names the cause in most cases. The common ones: the admin origin is missing from `allowedOrigins`, the page is not inside an iframe, the bound element does not exist (an empty field needs an anchor).
185
190
  - **Relationship fields show IDs.** Set `serverURL` with `mergeDepth`; Payload 3.x posts unpopulated form values.
186
191
  - **The preview iframe refuses to load.** The host sets `X-Frame-Options` or a restrictive `frame-ancestors`. The adapters merge `frame-ancestors` on authorized preview responses; an `X-Frame-Options: DENY` from a proxy must go.
187
192
  - **The adapter refuses to start.** The strict default needs `authorizePreview`, a non-empty `allowedOrigins` (`https:` in production) and no referer trust; `defaults: 'v1'` stages a migration one row at a time.
188
193
 
189
- `inspect()` readings, `pll doctor` and every diagnostic code: [docs/troubleshooting.md](docs/troubleshooting.md). `pll doctor` sends its preview request with `?preview=true`; a preview behind `authorizePreview` is audited with an editor's credential, such as `--header "x-preview-token: …"`.
194
+ `inspect()` readings, `pll doctor` and every diagnostic code: [docs/troubleshooting.md](docs/troubleshooting.md). `pll doctor` sends its preview request with `?preview=true`; a preview behind `authorizePreview` is audited with an editor's credential. A signed token goes in the URL as `?previewToken=…`, which the visitor request drops; `--header "x-preview-token: …"` works only where the token strategy sets `transport: { kind: 'header' }`; a Payload session is `--header "Cookie: payload-token=…"`.
190
195
 
191
196
  ## Documentation
192
197
 
@@ -33,7 +33,7 @@
33
33
  * every value they interpolate, but the sanitizer that would catch a
34
34
  * custom renderer's mistake needs a DOM, and there is none during SSR
35
35
  * unless the project supplied one with `setSanitizerDocument()`. See
36
- * docs/security.md §3.
36
+ * "HTML sanitization" in docs/security.md.
37
37
  */
38
38
  // Self-referencing import so the shipped copy in dist/ resolves
39
39
  // through the package exports map in consumer projects.