payload-live-preview 1.8.0 → 2.0.0-beta.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.
- package/README.md +301 -93
- package/dist/adapters/astro/PreviewBoundary.astro +66 -0
- package/dist/adapters/astro/RichText.astro +6 -0
- package/dist/adapters/astro/index.d.ts +165 -134
- 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 +4 -9
- 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 +13 -80
- package/dist/adapters/nextjs/index.js +1 -1
- package/dist/adapters/nextjs/index.js.map +1 -1
- package/dist/adapters/nuxt/index.d.ts +46 -106
- package/dist/adapters/nuxt/index.js +1 -1
- package/dist/adapters/nuxt/index.js.map +1 -1
- package/dist/adapters/sveltekit/index.d.ts +10 -75
- package/dist/adapters/sveltekit/index.js +1 -1
- package/dist/adapters/sveltekit/index.js.map +1 -1
- package/dist/client.cjs +2 -0
- package/dist/client.cjs.map +1 -0
- package/dist/client.d.cts +747 -0
- package/dist/client.d.ts +747 -0
- package/dist/client.js +2 -0
- package/dist/client.js.map +1 -0
- package/dist/codegen-astro.d.ts +5 -27
- package/dist/codegen-astro.js +1 -1
- package/dist/codegen-astro.js.map +1 -1
- package/dist/codegen-cli.d.ts +3 -16
- 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.d.cts +37 -124
- package/dist/codegen.d.ts +37 -124
- 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 +647 -1100
- package/dist/core.d.ts +647 -1100
- package/dist/core.js +1 -1
- package/dist/core.js.map +1 -1
- package/dist/doctor-cli.d.ts +3 -28
- package/dist/doctor-cli.js +1 -1
- package/dist/doctor-cli.js.map +1 -1
- package/dist/doctor.d.ts +16 -32
- package/dist/doctor.js +1 -1
- package/dist/doctor.js.map +1 -1
- package/dist/fragment.cjs +2 -0
- package/dist/fragment.cjs.map +1 -0
- package/dist/fragment.d.cts +333 -0
- package/dist/fragment.d.ts +333 -0
- package/dist/fragment.js +2 -0
- package/dist/fragment.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +885 -1531
- package/dist/index.d.ts +885 -1531
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lexical.cjs +2 -0
- package/dist/lexical.cjs.map +1 -0
- package/dist/lexical.d.cts +90 -0
- package/dist/lexical.d.ts +90 -0
- package/dist/lexical.js +2 -0
- package/dist/lexical.js.map +1 -0
- package/dist/middleware-CEPsY1P7.d.ts +40 -0
- package/dist/migrate.d.ts +73 -0
- package/dist/migrate.js +2 -0
- package/dist/migrate.js.map +1 -0
- package/dist/options-CEzzfHJu.d.ts +197 -0
- package/dist/payload.cjs +1 -1
- package/dist/payload.cjs.map +1 -1
- package/dist/payload.d.cts +11 -80
- package/dist/payload.d.ts +11 -80
- package/dist/payload.js +1 -1
- package/dist/payload.js.map +1 -1
- package/dist/plugins.cjs +2 -0
- package/dist/plugins.cjs.map +1 -0
- package/dist/plugins.d.cts +509 -0
- package/dist/plugins.d.ts +509 -0
- package/dist/plugins.js +2 -0
- package/dist/plugins.js.map +1 -0
- package/dist/{probe-tMHdim5y.d.ts → probe-CYtvj_Lm.d.ts} +43 -77
- package/dist/server.cjs +2 -0
- package/dist/server.cjs.map +1 -0
- package/dist/server.d.cts +435 -0
- package/dist/server.d.ts +435 -0
- package/dist/server.js +2 -0
- package/dist/server.js.map +1 -0
- package/dist/structural.cjs +3 -0
- package/dist/structural.cjs.map +1 -0
- package/dist/structural.d.cts +243 -0
- package/dist/structural.d.ts +243 -0
- package/dist/structural.js +3 -0
- package/dist/structural.js.map +1 -0
- package/package.json +86 -7
- package/dist/middleware-DD4Hwomt.d.ts +0 -189
|
@@ -1,89 +1,22 @@
|
|
|
1
|
+
import { b as PreviewAdapterOptions } from '../../options-CEzzfHJu.js';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
|
-
* Next.js adapter
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* client-rendered React trees prefer the official
|
|
6
|
-
* `@payloadcms/live-preview-react` (`useLivePreview`) — React
|
|
7
|
-
* re-renders can revert DOM patches made here.
|
|
8
|
-
*
|
|
9
|
-
* Provides:
|
|
10
|
-
*
|
|
11
|
-
* - `renderLivePreviewScript(options)` / `generateInlineScript` —
|
|
12
|
-
* embed the script in your root layout via
|
|
13
|
-
* `<script dangerouslySetInnerHTML>`. This is the PRIMARY wiring
|
|
14
|
-
* for Next.js: standard middleware cannot inject into the HTML
|
|
15
|
-
* body because `NextResponse.next()` carries no body.
|
|
16
|
-
*
|
|
17
|
-
* - `createLivePreviewMiddleware(options)` — merges CSP headers
|
|
18
|
-
* (`frame-ancestors`) onto responses carrying preview intent. Its
|
|
19
|
-
* script-injection path only activates when you pass it a
|
|
20
|
-
* `Response` that actually carries an HTML body (custom servers,
|
|
21
|
-
* route handlers returning HTML) — in standard `middleware.ts`
|
|
22
|
-
* use `autoInject: false`.
|
|
23
|
-
*
|
|
24
|
-
* Preview intent is not authorization. Run application-owned server
|
|
25
|
-
* authentication first and use its result to gate draft data, cache
|
|
26
|
-
* policy, privileged headers, CSP changes, and script rendering.
|
|
27
|
-
*
|
|
28
|
-
* @module @adapters/nextjs
|
|
4
|
+
* Next.js adapter. `renderLivePreviewScript()` in the root layout is the
|
|
5
|
+
* primary wiring: `NextResponse.next()` carries no body, so the middleware
|
|
6
|
+
* only injects into responses that actually carry HTML.
|
|
29
7
|
*/
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
/** Payload server origin for REST data merging (Payload 3.x). */
|
|
33
|
-
readonly serverURL?: string;
|
|
34
|
-
/** REST API route prefix used with `serverURL`. Defaults to `/api`. */
|
|
35
|
-
readonly apiRoute?: string;
|
|
36
|
-
/** Population depth used with `serverURL`. Defaults to `1`. */
|
|
37
|
-
readonly mergeDepth?: number;
|
|
38
|
-
readonly autoInject?: boolean;
|
|
39
|
-
/**
|
|
40
|
-
* `'preview-only'` (default) — inject only into responses carrying
|
|
41
|
-
* preview intent. The signals are client-controlled and do not
|
|
42
|
-
* authorize access. `'always'` — every HTML response.
|
|
43
|
-
*/
|
|
44
|
-
readonly inject?: 'preview-only' | 'always';
|
|
45
|
-
/** Query params that signal preview intent. Default `['preview', 'draft', 'livePreview']`. */
|
|
46
|
-
readonly previewQueryParams?: readonly string[];
|
|
47
|
-
/** Which signals count as preview intent. Default: query, fetch-dest, referer. */
|
|
48
|
-
readonly previewSignals?: readonly ('query' | 'fetch-dest' | 'referer')[];
|
|
49
|
-
/**
|
|
50
|
-
* Synchronous route/content filter for script injection only. It is
|
|
51
|
-
* not authentication and does not suppress CSP handling.
|
|
52
|
-
*/
|
|
53
|
-
readonly shouldInject?: (request: Request) => boolean;
|
|
54
|
-
/**
|
|
55
|
-
* CSP management: `'frame-ancestors'` (default) merges only the
|
|
56
|
-
* embed permission; `'full'` also manages a nonce'd `script-src`;
|
|
57
|
-
* `false` never touches CSP. `true` is a legacy alias for
|
|
58
|
-
* `'frame-ancestors'`.
|
|
59
|
-
*/
|
|
60
|
-
readonly manageCsp?: boolean | 'frame-ancestors' | 'full';
|
|
61
|
-
/** Add `'strict-dynamic'` to the managed `script-src`. Default `false`. */
|
|
62
|
-
readonly strictDynamic?: boolean;
|
|
63
|
-
readonly frameAncestorsExtra?: readonly string[];
|
|
64
|
-
readonly scriptSrcExtra?: readonly string[];
|
|
65
|
-
readonly debug?: boolean;
|
|
66
|
-
readonly debounceMs?: number;
|
|
67
|
-
/** Heartbeat timeout in ms. Default `0` (disabled). */
|
|
68
|
-
readonly heartbeatMs?: number;
|
|
69
|
-
}
|
|
70
|
-
type NextMiddleware = (request: Request) => Promise<Response | undefined>;
|
|
8
|
+
|
|
9
|
+
type LivePreviewNextOptions = PreviewAdapterOptions;
|
|
71
10
|
/**
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* are privileged.
|
|
11
|
+
* Middleware over the standard `Request`/`Response` pair: on preview intent it
|
|
12
|
+
* authorizes, injects, merges CSP and marks the response uncacheable. Next.js
|
|
13
|
+
* middleware has no `locals`, so the verdict is not published — call
|
|
14
|
+
* `authorizePreviewRequest()` in the route when a page needs it.
|
|
77
15
|
*/
|
|
78
16
|
declare function createLivePreviewMiddleware(options?: LivePreviewNextOptions): (request: Request, response: Response) => Promise<Response>;
|
|
79
|
-
/**
|
|
80
|
-
* Render the live-preview `<script>` tag — for embedding manually in
|
|
81
|
-
* App Router or Pages Router layouts. Rendering must be gated by the
|
|
82
|
-
* application's verified preview authorization, not merely an intent
|
|
83
|
-
* query parameter.
|
|
84
|
-
*/
|
|
17
|
+
/** The `<script>` tag for `app/layout.tsx`; pass the nonce your CSP uses. */
|
|
85
18
|
declare function renderLivePreviewScript(options?: LivePreviewNextOptions & {
|
|
86
19
|
readonly nonce?: string;
|
|
87
20
|
}): string;
|
|
88
21
|
|
|
89
|
-
export { type LivePreviewNextOptions,
|
|
22
|
+
export { type LivePreviewNextOptions, PreviewAdapterOptions, createLivePreviewMiddleware, renderLivePreviewScript };
|