payload-live-preview 1.0.2 → 1.0.4
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 +150 -84
- package/dist/adapters/astro/RichText.astro +8 -4
- package/dist/adapters/astro/index.d.ts +84 -9
- package/dist/adapters/astro/index.js +1 -363
- package/dist/adapters/astro/index.js.map +1 -1
- package/dist/adapters/astro/middleware-entry.d.ts +1 -1
- package/dist/adapters/astro/middleware-entry.js +1 -296
- package/dist/adapters/astro/middleware-entry.js.map +1 -1
- package/dist/adapters/nextjs/index.d.ts +24 -10
- package/dist/adapters/nextjs/index.js +1 -305
- package/dist/adapters/nextjs/index.js.map +1 -1
- package/dist/adapters/nuxt/index.d.ts +20 -10
- package/dist/adapters/nuxt/index.js +1 -293
- package/dist/adapters/nuxt/index.js.map +1 -1
- package/dist/adapters/sveltekit/index.d.ts +22 -6
- package/dist/adapters/sveltekit/index.js +1 -272
- package/dist/adapters/sveltekit/index.js.map +1 -1
- package/dist/codegen-astro.js +1 -609
- package/dist/codegen-astro.js.map +1 -1
- package/dist/codegen-cli.js +1 -665
- package/dist/codegen-cli.js.map +1 -1
- package/dist/codegen.cjs +1 -550
- package/dist/codegen.cjs.map +1 -1
- package/dist/codegen.js +1 -546
- package/dist/codegen.js.map +1 -1
- package/dist/core.cjs +1 -3719
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +1210 -7
- package/dist/core.d.ts +1210 -7
- package/dist/core.js +1 -3692
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +1 -4118
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1359 -34
- package/dist/index.d.ts +1359 -34
- package/dist/index.js +1 -4075
- package/dist/index.js.map +1 -1
- package/dist/{middleware-BwIlf0jW.d.cts → middleware-CkSeLZ-9.d.ts} +35 -19
- package/dist/payload.cjs +1 -30
- package/dist/payload.cjs.map +1 -1
- package/dist/payload.d.cts +4 -3
- package/dist/payload.d.ts +4 -3
- package/dist/payload.js +1 -28
- package/dist/payload.js.map +1 -1
- package/package.json +55 -16
- package/dist/adapters/astro/index.cjs +0 -370
- package/dist/adapters/astro/index.cjs.map +0 -1
- package/dist/adapters/astro/index.d.cts +0 -105
- package/dist/adapters/astro/middleware-entry.cjs +0 -303
- package/dist/adapters/astro/middleware-entry.cjs.map +0 -1
- package/dist/adapters/astro/middleware-entry.d.cts +0 -15
- package/dist/adapters/nextjs/index.cjs +0 -309
- package/dist/adapters/nextjs/index.cjs.map +0 -1
- package/dist/adapters/nextjs/index.d.cts +0 -75
- package/dist/adapters/nuxt/index.cjs +0 -299
- package/dist/adapters/nuxt/index.cjs.map +0 -1
- package/dist/adapters/nuxt/index.d.cts +0 -126
- package/dist/adapters/sveltekit/index.cjs +0 -275
- package/dist/adapters/sveltekit/index.cjs.map +0 -1
- package/dist/adapters/sveltekit/index.d.cts +0 -80
- package/dist/bind-BSgxoQhN.d.cts +0 -1137
- package/dist/bind-BSgxoQhN.d.ts +0 -1137
- package/dist/codegen-astro.cjs +0 -612
- package/dist/codegen-astro.cjs.map +0 -1
- package/dist/codegen-astro.d.cts +0 -54
- package/dist/codegen-cli.cjs +0 -669
- package/dist/codegen-cli.cjs.map +0 -1
- package/dist/codegen-cli.d.cts +0 -19
- package/dist/middleware-BwIlf0jW.d.ts +0 -168
- package/dist/preview-request-DAvxm18T.d.cts +0 -68
- package/dist/preview-request-DAvxm18T.d.ts +0 -68
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
*
|
|
6
6
|
* - `livePreviewNitroPlugin(options)` — the recommended wiring: a
|
|
7
7
|
* Nitro plugin body that hooks `render:html`, injects the inline
|
|
8
|
-
* script into the head of preview
|
|
9
|
-
* header. Drop it in `server/plugins/live-preview.ts`:
|
|
8
|
+
* script into the head of responses carrying preview intent, and
|
|
9
|
+
* merges the CSP header. Drop it in `server/plugins/live-preview.ts`:
|
|
10
10
|
*
|
|
11
11
|
* ```ts
|
|
12
12
|
* import { livePreviewNitroPlugin } from 'payload-live-preview/nuxt';
|
|
@@ -26,6 +26,12 @@
|
|
|
26
26
|
* `event.context.livePreviewNonce`. It does not inject anything;
|
|
27
27
|
* prefer the Nitro plugin above.
|
|
28
28
|
*
|
|
29
|
+
* Preview-intent signals are client-controlled and do not authenticate
|
|
30
|
+
* a request. This convenience plugin has no authorization hook. When
|
|
31
|
+
* response changes are protected, use an application-owned render hook
|
|
32
|
+
* and call `renderLivePreviewScript()` / `buildLivePreviewCsp()` only
|
|
33
|
+
* after the same verified decision that gates draft data and caching.
|
|
34
|
+
*
|
|
29
35
|
* @module @adapters/nuxt
|
|
30
36
|
*/
|
|
31
37
|
interface LivePreviewNuxtOptions {
|
|
@@ -38,13 +44,14 @@ interface LivePreviewNuxtOptions {
|
|
|
38
44
|
readonly mergeDepth?: number;
|
|
39
45
|
readonly autoInject?: boolean;
|
|
40
46
|
/**
|
|
41
|
-
* `'preview-only'` (default) — inject only into responses
|
|
42
|
-
*
|
|
47
|
+
* `'preview-only'` (default) — inject only into responses carrying
|
|
48
|
+
* preview intent. The signals are not authorization. `'always'` —
|
|
49
|
+
* every HTML response.
|
|
43
50
|
*/
|
|
44
51
|
readonly inject?: 'preview-only' | 'always';
|
|
45
|
-
/** Query params that
|
|
52
|
+
/** Query params that signal preview intent. Default `['preview', 'draft', 'livePreview']`. */
|
|
46
53
|
readonly previewQueryParams?: readonly string[];
|
|
47
|
-
/** Which signals count as
|
|
54
|
+
/** Which signals count as preview intent. Default: query, fetch-dest, referer. */
|
|
48
55
|
readonly previewSignals?: readonly ('query' | 'fetch-dest' | 'referer')[];
|
|
49
56
|
/**
|
|
50
57
|
* CSP management: `'frame-ancestors'` (default) merges only the
|
|
@@ -90,9 +97,11 @@ interface NitroAppLike {
|
|
|
90
97
|
type NitroHandler = (event: H3EventLike) => Promise<Response | undefined>;
|
|
91
98
|
/**
|
|
92
99
|
* Body for a Nitro plugin (`defineNitroPlugin(livePreviewNitroPlugin(...))`).
|
|
93
|
-
* Hooks `render:html`: on preview
|
|
94
|
-
* runtime to the document head and merges the CSP header
|
|
95
|
-
* response.
|
|
100
|
+
* Hooks `render:html`: on requests carrying preview intent it appends
|
|
101
|
+
* the inline runtime to the document head and merges the CSP header
|
|
102
|
+
* onto the response. This convenience path detects intent only; use a
|
|
103
|
+
* custom application-owned hook with the manual helpers when these
|
|
104
|
+
* response changes require authorization.
|
|
96
105
|
*/
|
|
97
106
|
declare function livePreviewNitroPlugin(options?: LivePreviewNuxtOptions): (nitroApp: NitroAppLike) => void;
|
|
98
107
|
/**
|
|
@@ -104,7 +113,8 @@ declare function livePreviewNitroPlugin(options?: LivePreviewNuxtOptions): (nitr
|
|
|
104
113
|
declare function defineLivePreviewServerHandler(_options?: LivePreviewNuxtOptions): NitroHandler;
|
|
105
114
|
/**
|
|
106
115
|
* Render the live-preview `<script>` tag for embedding in a Nuxt
|
|
107
|
-
* layout via `useHead
|
|
116
|
+
* layout via `useHead`. Call this only after the application's verified
|
|
117
|
+
* preview authorization when script delivery is restricted:
|
|
108
118
|
*
|
|
109
119
|
* ```ts
|
|
110
120
|
* useHead({
|