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.
Files changed (98) hide show
  1. package/README.md +301 -93
  2. package/dist/adapters/astro/PreviewBoundary.astro +66 -0
  3. package/dist/adapters/astro/RichText.astro +6 -0
  4. package/dist/adapters/astro/index.d.ts +165 -134
  5. package/dist/adapters/astro/index.js +1 -1
  6. package/dist/adapters/astro/index.js.map +1 -1
  7. package/dist/adapters/astro/middleware-entry.d.ts +4 -9
  8. package/dist/adapters/astro/middleware-entry.js +1 -1
  9. package/dist/adapters/astro/middleware-entry.js.map +1 -1
  10. package/dist/adapters/nextjs/index.d.ts +13 -80
  11. package/dist/adapters/nextjs/index.js +1 -1
  12. package/dist/adapters/nextjs/index.js.map +1 -1
  13. package/dist/adapters/nuxt/index.d.ts +46 -106
  14. package/dist/adapters/nuxt/index.js +1 -1
  15. package/dist/adapters/nuxt/index.js.map +1 -1
  16. package/dist/adapters/sveltekit/index.d.ts +10 -75
  17. package/dist/adapters/sveltekit/index.js +1 -1
  18. package/dist/adapters/sveltekit/index.js.map +1 -1
  19. package/dist/client.cjs +2 -0
  20. package/dist/client.cjs.map +1 -0
  21. package/dist/client.d.cts +747 -0
  22. package/dist/client.d.ts +747 -0
  23. package/dist/client.js +2 -0
  24. package/dist/client.js.map +1 -0
  25. package/dist/codegen-astro.d.ts +5 -27
  26. package/dist/codegen-astro.js +1 -1
  27. package/dist/codegen-astro.js.map +1 -1
  28. package/dist/codegen-cli.d.ts +3 -16
  29. package/dist/codegen-cli.js +1 -1
  30. package/dist/codegen-cli.js.map +1 -1
  31. package/dist/codegen.cjs +1 -1
  32. package/dist/codegen.cjs.map +1 -1
  33. package/dist/codegen.d.cts +37 -124
  34. package/dist/codegen.d.ts +37 -124
  35. package/dist/codegen.js +1 -1
  36. package/dist/codegen.js.map +1 -1
  37. package/dist/core.cjs +1 -1
  38. package/dist/core.cjs.map +1 -1
  39. package/dist/core.d.cts +647 -1100
  40. package/dist/core.d.ts +647 -1100
  41. package/dist/core.js +1 -1
  42. package/dist/core.js.map +1 -1
  43. package/dist/doctor-cli.d.ts +3 -28
  44. package/dist/doctor-cli.js +1 -1
  45. package/dist/doctor-cli.js.map +1 -1
  46. package/dist/doctor.d.ts +16 -32
  47. package/dist/doctor.js +1 -1
  48. package/dist/doctor.js.map +1 -1
  49. package/dist/fragment.cjs +2 -0
  50. package/dist/fragment.cjs.map +1 -0
  51. package/dist/fragment.d.cts +333 -0
  52. package/dist/fragment.d.ts +333 -0
  53. package/dist/fragment.js +2 -0
  54. package/dist/fragment.js.map +1 -0
  55. package/dist/index.cjs +1 -1
  56. package/dist/index.cjs.map +1 -1
  57. package/dist/index.d.cts +885 -1531
  58. package/dist/index.d.ts +885 -1531
  59. package/dist/index.js +1 -1
  60. package/dist/index.js.map +1 -1
  61. package/dist/lexical.cjs +2 -0
  62. package/dist/lexical.cjs.map +1 -0
  63. package/dist/lexical.d.cts +90 -0
  64. package/dist/lexical.d.ts +90 -0
  65. package/dist/lexical.js +2 -0
  66. package/dist/lexical.js.map +1 -0
  67. package/dist/middleware-CEPsY1P7.d.ts +40 -0
  68. package/dist/migrate.d.ts +73 -0
  69. package/dist/migrate.js +2 -0
  70. package/dist/migrate.js.map +1 -0
  71. package/dist/options-CEzzfHJu.d.ts +197 -0
  72. package/dist/payload.cjs +1 -1
  73. package/dist/payload.cjs.map +1 -1
  74. package/dist/payload.d.cts +11 -80
  75. package/dist/payload.d.ts +11 -80
  76. package/dist/payload.js +1 -1
  77. package/dist/payload.js.map +1 -1
  78. package/dist/plugins.cjs +2 -0
  79. package/dist/plugins.cjs.map +1 -0
  80. package/dist/plugins.d.cts +509 -0
  81. package/dist/plugins.d.ts +509 -0
  82. package/dist/plugins.js +2 -0
  83. package/dist/plugins.js.map +1 -0
  84. package/dist/{probe-tMHdim5y.d.ts → probe-CYtvj_Lm.d.ts} +43 -77
  85. package/dist/server.cjs +2 -0
  86. package/dist/server.cjs.map +1 -0
  87. package/dist/server.d.cts +435 -0
  88. package/dist/server.d.ts +435 -0
  89. package/dist/server.js +2 -0
  90. package/dist/server.js.map +1 -0
  91. package/dist/structural.cjs +3 -0
  92. package/dist/structural.cjs.map +1 -0
  93. package/dist/structural.d.cts +243 -0
  94. package/dist/structural.d.ts +243 -0
  95. package/dist/structural.js +3 -0
  96. package/dist/structural.js.map +1 -0
  97. package/package.json +86 -7
  98. package/dist/middleware-DD4Hwomt.d.ts +0 -189
@@ -1,67 +1,11 @@
1
+ import { b as PreviewAdapterOptions } from '../../options-CEzzfHJu.js';
2
+
1
3
  /**
2
- * SvelteKit adapter for Payload Live Preview.
3
- *
4
- * Exposes a `handle` hook compatible with SvelteKit's `hooks.server.ts`:
5
- *
6
- * ```ts
7
- * import { livePreviewHandle } from 'payload-live-preview/sveltekit';
8
- *
9
- * export const handle = livePreviewHandle({
10
- * allowedOrigins: ['https://admin.example.com'],
11
- * });
12
- * ```
13
- *
14
- * For projects that already use `sequence(...)`, compose the returned
15
- * handle with the others; it never short-circuits the chain.
16
- *
17
- * The built-in signals detect preview intent only. They do not
18
- * authenticate the request. Place application-owned server
19
- * authorization around this handle and invoke it only after success
20
- * when draft data, credentials, private cache policy, CSP changes, or
21
- * runtime injection are gated.
22
- *
23
- * @module @adapters/sveltekit
4
+ * SvelteKit adapter: a `handle` hook for `hooks.server.ts`. Composes with
5
+ * `sequence()` and never short-circuits the chain.
24
6
  */
25
- interface LivePreviewSvelteKitOptions {
26
- readonly allowedOrigins?: readonly string[];
27
- /** Payload server origin for REST data merging (Payload 3.x). */
28
- readonly serverURL?: string;
29
- /** REST API route prefix used with `serverURL`. Defaults to `/api`. */
30
- readonly apiRoute?: string;
31
- /** Population depth used with `serverURL`. Defaults to `1`. */
32
- readonly mergeDepth?: number;
33
- readonly autoInject?: boolean;
34
- /**
35
- * `'preview-only'` (default) — inject only into responses carrying
36
- * preview intent. The signals are client-controlled and do not
37
- * authorize access. `'always'` — every HTML response.
38
- */
39
- readonly inject?: 'preview-only' | 'always';
40
- /** Query params that signal preview intent. Default `['preview', 'draft', 'livePreview']`. */
41
- readonly previewQueryParams?: readonly string[];
42
- /** Which signals count as preview intent. Default: query, fetch-dest, referer. */
43
- readonly previewSignals?: readonly ('query' | 'fetch-dest' | 'referer')[];
44
- /**
45
- * Synchronous route/content filter for script injection only. It is
46
- * not authentication and does not suppress CSP handling.
47
- */
48
- readonly shouldInject?: (request: Request) => boolean;
49
- /**
50
- * CSP management: `'frame-ancestors'` (default) merges only the
51
- * embed permission; `'full'` also manages a nonce'd `script-src`;
52
- * `false` never touches CSP. `true` is a legacy alias for
53
- * `'frame-ancestors'`.
54
- */
55
- readonly manageCsp?: boolean | 'frame-ancestors' | 'full';
56
- /** Add `'strict-dynamic'` to the managed `script-src`. Default `false`. */
57
- readonly strictDynamic?: boolean;
58
- readonly frameAncestorsExtra?: readonly string[];
59
- readonly scriptSrcExtra?: readonly string[];
60
- readonly debug?: boolean;
61
- readonly debounceMs?: number;
62
- /** Heartbeat timeout in ms. Default `0` (disabled). */
63
- readonly heartbeatMs?: number;
64
- }
7
+
8
+ type LivePreviewSvelteKitOptions = PreviewAdapterOptions;
65
9
  interface SvelteKitRequestEvent {
66
10
  readonly request: Request;
67
11
  readonly locals: Record<string, unknown>;
@@ -78,19 +22,10 @@ type SvelteKitHandle = (input: {
78
22
  readonly resolve: SvelteKitResolve;
79
23
  }) => Promise<Response>;
80
24
  /**
81
- * Build a SvelteKit `handle` hook. The hook:
82
- *
83
- * 1. Generates a CSP nonce and writes it to `event.locals.livePreviewNonce`
84
- * so consumer-rendered scripts can read it from the load function.
85
- * 2. On requests carrying preview intent, uses
86
- * `resolve(..., { transformPageChunk })`
87
- * to inject the script into the `<head>` of the HTML response.
88
- * 3. Merges the `Content-Security-Policy` header on those responses.
89
- *
90
- * Call this handle only after application-owned authorization when
91
- * those response mutations are privileged. `shouldInject` is not an
92
- * authorization boundary and does not disable CSP handling.
25
+ * The `handle` hook: it decides before rendering and publishes the verdict on
26
+ * `event.locals`, rewrites the `<head>` chunk through `transformPageChunk`,
27
+ * then merges CSP and marks the response uncacheable.
93
28
  */
94
29
  declare function livePreviewHandle(options?: LivePreviewSvelteKitOptions): SvelteKitHandle;
95
30
 
96
- export { type LivePreviewSvelteKitOptions, type SvelteKitHandle, livePreviewHandle };
31
+ export { type LivePreviewSvelteKitOptions, PreviewAdapterOptions, type SvelteKitHandle, livePreviewHandle };