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,85 +1,42 @@
|
|
|
1
|
+
import { b as PreviewAdapterOptions, c as PreviewRequestLike } from '../../options-CEzzfHJu.js';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
|
-
* Nuxt 3 adapter
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* - `livePreviewNitroPlugin(options)` — the recommended wiring: a
|
|
7
|
-
* Nitro plugin body that hooks `render:html`, injects the inline
|
|
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
|
-
*
|
|
11
|
-
* ```ts
|
|
12
|
-
* import { livePreviewNitroPlugin } from 'payload-live-preview/nuxt';
|
|
13
|
-
* export default defineNitroPlugin(
|
|
14
|
-
* livePreviewNitroPlugin({ allowedOrigins: ['https://admin.example.com'] }),
|
|
15
|
-
* );
|
|
16
|
-
* ```
|
|
17
|
-
*
|
|
18
|
-
* - `renderLivePreviewScript(options)` — a script-tag string for
|
|
19
|
-
* manual embedding in a Nuxt layout via `useHead`.
|
|
20
|
-
*
|
|
21
|
-
* - `buildLivePreviewCsp(options, nonce, existing?)` — the merged
|
|
22
|
-
* CSP header value, for consumers managing headers themselves.
|
|
23
|
-
*
|
|
24
|
-
* - `defineLivePreviewServerHandler(options)` — a minimal Nitro
|
|
25
|
-
* server middleware that ONLY stashes a per-request nonce on
|
|
26
|
-
* `event.context.livePreviewNonce`. It does not inject anything;
|
|
27
|
-
* prefer the Nitro plugin above.
|
|
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
|
-
*
|
|
35
|
-
* @module @adapters/nuxt
|
|
4
|
+
* Nuxt 3 / Nitro adapter: the server handler decides before the Vue app
|
|
5
|
+
* renders so pages can read the verdict, and the `render:html` plugin applies
|
|
6
|
+
* it. Nitro and H3 are duck-typed so this compiles without the peers.
|
|
36
7
|
*/
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
readonly
|
|
46
|
-
|
|
47
|
-
* `'preview-only'` (default) — inject only into responses carrying
|
|
48
|
-
* preview intent. The signals are not authorization. `'always'` —
|
|
49
|
-
* every HTML response.
|
|
50
|
-
*/
|
|
51
|
-
readonly inject?: 'preview-only' | 'always';
|
|
52
|
-
/** Query params that signal preview intent. Default `['preview', 'draft', 'livePreview']`. */
|
|
53
|
-
readonly previewQueryParams?: readonly string[];
|
|
54
|
-
/** Which signals count as preview intent. Default: query, fetch-dest, referer. */
|
|
55
|
-
readonly previewSignals?: readonly ('query' | 'fetch-dest' | 'referer')[];
|
|
56
|
-
/**
|
|
57
|
-
* CSP management: `'frame-ancestors'` (default) merges only the
|
|
58
|
-
* embed permission; `'full'` also manages a nonce'd `script-src`;
|
|
59
|
-
* `false` never touches CSP. `true` is a legacy alias for
|
|
60
|
-
* `'frame-ancestors'`.
|
|
61
|
-
*/
|
|
62
|
-
readonly manageCsp?: boolean | 'frame-ancestors' | 'full';
|
|
63
|
-
/** Add `'strict-dynamic'` to the managed `script-src`. Default `false`. */
|
|
64
|
-
readonly strictDynamic?: boolean;
|
|
65
|
-
readonly frameAncestorsExtra?: readonly string[];
|
|
66
|
-
readonly scriptSrcExtra?: readonly string[];
|
|
67
|
-
readonly debug?: boolean;
|
|
68
|
-
readonly debounceMs?: number;
|
|
69
|
-
/** Heartbeat timeout in ms. Default `0` (disabled). */
|
|
70
|
-
readonly heartbeatMs?: number;
|
|
8
|
+
|
|
9
|
+
type LivePreviewNuxtOptions = PreviewAdapterOptions<PreviewRequestLike>;
|
|
10
|
+
interface HeadersLike {
|
|
11
|
+
get(name: string): string | null;
|
|
12
|
+
set?(name: string, value: string): void;
|
|
13
|
+
}
|
|
14
|
+
type NodeHeaderValue = string | number | string[] | undefined;
|
|
15
|
+
interface NodeRequestLike {
|
|
16
|
+
readonly url?: string;
|
|
17
|
+
readonly headers?: Record<string, string | string[] | undefined>;
|
|
71
18
|
}
|
|
19
|
+
interface NodeResponseLike {
|
|
20
|
+
getHeader?: (name: string) => NodeHeaderValue;
|
|
21
|
+
setHeader?: (name: string, value: string) => void;
|
|
22
|
+
}
|
|
23
|
+
/** An H3 event as v1 (`node.req`/`node.res`) or v2 (`req: Request`, `res.headers`) shapes it. */
|
|
72
24
|
interface H3EventLike {
|
|
73
25
|
readonly path?: string;
|
|
26
|
+
readonly url?: {
|
|
27
|
+
readonly href: string;
|
|
28
|
+
} | string;
|
|
29
|
+
readonly headers?: HeadersLike;
|
|
30
|
+
readonly req?: NodeRequestLike | {
|
|
31
|
+
readonly headers?: HeadersLike;
|
|
32
|
+
readonly url?: string;
|
|
33
|
+
};
|
|
34
|
+
readonly res?: NodeResponseLike | {
|
|
35
|
+
readonly headers?: HeadersLike;
|
|
36
|
+
};
|
|
74
37
|
readonly node?: {
|
|
75
|
-
readonly req?:
|
|
76
|
-
|
|
77
|
-
readonly headers?: Record<string, string | string[] | undefined>;
|
|
78
|
-
};
|
|
79
|
-
readonly res?: {
|
|
80
|
-
getHeader?: (name: string) => string | number | string[] | undefined;
|
|
81
|
-
setHeader?: (name: string, value: string) => void;
|
|
82
|
-
};
|
|
38
|
+
readonly req?: NodeRequestLike;
|
|
39
|
+
readonly res?: NodeResponseLike;
|
|
83
40
|
};
|
|
84
41
|
readonly context?: Record<string, unknown>;
|
|
85
42
|
}
|
|
@@ -91,46 +48,29 @@ interface NitroAppLike {
|
|
|
91
48
|
readonly hooks: {
|
|
92
49
|
hook(name: 'render:html', fn: (html: RenderHtmlContextLike, context: {
|
|
93
50
|
event: H3EventLike;
|
|
94
|
-
}) => void): void;
|
|
51
|
+
}) => void | Promise<void>): void;
|
|
95
52
|
};
|
|
96
53
|
}
|
|
97
54
|
type NitroHandler = (event: H3EventLike) => Promise<Response | undefined>;
|
|
55
|
+
/** Where the server handler leaves its decision for the plugin, on `event.context`. */
|
|
56
|
+
declare const DECISION_CONTEXT_KEY = "livePreviewDecision";
|
|
98
57
|
/**
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
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.
|
|
58
|
+
* Nitro plugin body (`defineNitroPlugin(livePreviewNitroPlugin(...))`): on
|
|
59
|
+
* `render:html` it reuses the server handler's stashed decision, or decides
|
|
60
|
+
* itself, then appends the runtime and sets the CSP and cache headers.
|
|
105
61
|
*/
|
|
106
62
|
declare function livePreviewNitroPlugin(options?: LivePreviewNuxtOptions): (nitroApp: NitroAppLike) => void;
|
|
107
63
|
/**
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
* `livePreviewNitroPlugin` for automatic injection.
|
|
112
|
-
*/
|
|
113
|
-
declare function defineLivePreviewServerHandler(_options?: LivePreviewNuxtOptions): NitroHandler;
|
|
114
|
-
/**
|
|
115
|
-
* Render the live-preview `<script>` tag for embedding in a Nuxt
|
|
116
|
-
* layout via `useHead`. Call this only after the application's verified
|
|
117
|
-
* preview authorization when script delivery is restricted:
|
|
118
|
-
*
|
|
119
|
-
* ```ts
|
|
120
|
-
* useHead({
|
|
121
|
-
* script: [
|
|
122
|
-
* { innerHTML: renderLivePreviewScript({ nonce: useNonce() }) },
|
|
123
|
-
* ],
|
|
124
|
-
* });
|
|
125
|
-
* ```
|
|
64
|
+
* Server middleware (`defineEventHandler(defineLivePreviewServerHandler(o))`)
|
|
65
|
+
* that decides before the app renders and publishes the verdict on
|
|
66
|
+
* `event.context`. Give it the plugin's options; the plugin reuses its verdict.
|
|
126
67
|
*/
|
|
68
|
+
declare function defineLivePreviewServerHandler(options?: LivePreviewNuxtOptions): NitroHandler;
|
|
69
|
+
/** The `<script>` tag for manual insertion (`useHead()`) when `autoInject` is off. */
|
|
127
70
|
declare function renderLivePreviewScript(options?: LivePreviewNuxtOptions & {
|
|
128
71
|
readonly nonce?: string;
|
|
129
72
|
}): string;
|
|
130
|
-
/**
|
|
131
|
-
* Build the merged CSP header value for a Nuxt response. Useful when
|
|
132
|
-
* the consumer manages CSP themselves via `useResponseHeader`.
|
|
133
|
-
*/
|
|
73
|
+
/** The CSP header value for consumers that set the header themselves; it builds and never gates, so `manageCsp: false` still yields frame-ancestors. */
|
|
134
74
|
declare function buildLivePreviewCsp(options: LivePreviewNuxtOptions, nonce: string, existing?: string, mode?: 'frame-ancestors' | 'full'): string;
|
|
135
75
|
|
|
136
|
-
export { type LivePreviewNuxtOptions, type NitroHandler, buildLivePreviewCsp, defineLivePreviewServerHandler, livePreviewNitroPlugin, renderLivePreviewScript };
|
|
76
|
+
export { DECISION_CONTEXT_KEY, type LivePreviewNuxtOptions, type NitroHandler, PreviewAdapterOptions, buildLivePreviewCsp, defineLivePreviewServerHandler, livePreviewNitroPlugin, renderLivePreviewScript };
|