payload-live-preview 2.2.2 → 2.3.1

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 (100) hide show
  1. package/README.md +35 -30
  2. package/dist/adapters/astro/PreviewBoundary.astro +17 -4
  3. package/dist/adapters/astro/RichText.astro +13 -2
  4. package/dist/adapters/astro/index.d.ts +7 -7
  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 +3 -3
  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 +2 -2
  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 +4 -4
  14. package/dist/adapters/nuxt/index.js +1 -1
  15. package/dist/adapters/nuxt/index.js.map +1 -1
  16. package/dist/adapters/nuxt/module.d.ts +1 -1
  17. package/dist/adapters/react/index.d.ts +2 -2
  18. package/dist/adapters/react/index.js +1 -1
  19. package/dist/adapters/react/index.js.map +1 -1
  20. package/dist/adapters/sveltekit/index.d.ts +5 -5
  21. package/dist/adapters/sveltekit/index.js +1 -1
  22. package/dist/adapters/sveltekit/index.js.map +1 -1
  23. package/dist/adapters/vue/index.d.ts +2 -2
  24. package/dist/adapters/vue/index.js +1 -1
  25. package/dist/adapters/vue/index.js.map +1 -1
  26. package/dist/client.cjs +1 -1
  27. package/dist/client.cjs.map +1 -1
  28. package/dist/client.d.cts +15 -3
  29. package/dist/client.d.ts +15 -3
  30. package/dist/client.js +1 -1
  31. package/dist/client.js.map +1 -1
  32. package/dist/codegen-astro.js +1 -1
  33. package/dist/codegen-astro.js.map +1 -1
  34. package/dist/codegen-cli.js +1 -1
  35. package/dist/codegen-cli.js.map +1 -1
  36. package/dist/codegen.cjs +1 -1
  37. package/dist/codegen.cjs.map +1 -1
  38. package/dist/codegen.js +1 -1
  39. package/dist/codegen.js.map +1 -1
  40. package/dist/core.cjs +1 -1
  41. package/dist/core.cjs.map +1 -1
  42. package/dist/core.d.cts +139 -4
  43. package/dist/core.d.ts +139 -4
  44. package/dist/core.js +1 -1
  45. package/dist/core.js.map +1 -1
  46. package/dist/doctor-cli.d.ts +1 -1
  47. package/dist/doctor-cli.js +1 -1
  48. package/dist/doctor-cli.js.map +1 -1
  49. package/dist/doctor.d.ts +2 -2
  50. package/dist/doctor.js +1 -1
  51. package/dist/doctor.js.map +1 -1
  52. package/dist/{document-session-Bkd181PV.d.ts → document-session-BuYuO3ae.d.ts} +27 -2
  53. package/dist/{fragment-endpoint-CLRpNQ3n.d.ts → fragment-endpoint-CQE_7MKi.d.ts} +1 -1
  54. package/dist/fragment.cjs +1 -1
  55. package/dist/fragment.cjs.map +1 -1
  56. package/dist/fragment.d.cts +6 -2
  57. package/dist/fragment.d.ts +6 -2
  58. package/dist/fragment.js +1 -1
  59. package/dist/fragment.js.map +1 -1
  60. package/dist/index.cjs +1 -1
  61. package/dist/index.cjs.map +1 -1
  62. package/dist/index.d.cts +73 -12
  63. package/dist/index.d.ts +73 -12
  64. package/dist/index.js +1 -1
  65. package/dist/index.js.map +1 -1
  66. package/dist/lean.cjs +1 -1
  67. package/dist/lean.cjs.map +1 -1
  68. package/dist/lean.js +1 -1
  69. package/dist/lean.js.map +1 -1
  70. package/dist/lexical.cjs +1 -1
  71. package/dist/lexical.cjs.map +1 -1
  72. package/dist/lexical.d.cts +16 -4
  73. package/dist/lexical.d.ts +16 -4
  74. package/dist/lexical.js +1 -1
  75. package/dist/lexical.js.map +1 -1
  76. package/dist/{locals-zz2gi9dj.d.ts → locals-CyzDKfKU.d.ts} +7 -1
  77. package/dist/{middleware-CI-UTf6R.d.ts → middleware-Dnt6u4nF.d.ts} +2 -2
  78. package/dist/{options-CnYybG51.d.ts → options-DTzhFVJ4.d.ts} +13 -1
  79. package/dist/plugin.cjs +1 -1
  80. package/dist/plugin.cjs.map +1 -1
  81. package/dist/plugin.d.cts +15 -9
  82. package/dist/plugin.d.ts +15 -9
  83. package/dist/plugin.js +1 -1
  84. package/dist/plugin.js.map +1 -1
  85. package/dist/plugins.cjs +1 -1
  86. package/dist/plugins.cjs.map +1 -1
  87. package/dist/plugins.d.cts +8 -2
  88. package/dist/plugins.d.ts +8 -2
  89. package/dist/plugins.js +1 -1
  90. package/dist/plugins.js.map +1 -1
  91. package/dist/{probe-D-IHg9dF.d.ts → probe-afwdYebU.d.ts} +6 -2
  92. package/dist/server.cjs +1 -1
  93. package/dist/server.cjs.map +1 -1
  94. package/dist/server.d.cts +19 -1
  95. package/dist/server.d.ts +19 -1
  96. package/dist/server.js +1 -1
  97. package/dist/server.js.map +1 -1
  98. package/dist/structural.d.cts +2 -0
  99. package/dist/structural.d.ts +2 -0
  100. package/package.json +2 -1
package/dist/core.d.cts CHANGED
@@ -37,6 +37,8 @@ declare const DIAGNOSTIC_CODES: Readonly<{
37
37
  readonly UnattributableUpdate: "LP0202";
38
38
  /** An update carried a value for a field the page binds nowhere; editing it changes nothing on this page. */
39
39
  readonly UnboundField: "LP0203";
40
+ /** In development: a bound path covers its group under the `descendant` default, which 3.0 changes. */
41
+ readonly CoverageDefaultChanges: "LP0204";
40
42
  /** The visibility gate held offscreen writes back until they scroll into view. */
41
43
  readonly VisibilityGateDeferred: "LP0301";
42
44
  /** A value was refused because the attribute or the value itself is unsafe. */
@@ -61,7 +63,7 @@ declare const DIAGNOSTIC_CODES: Readonly<{
61
63
  readonly UnrenderedBlockKept: "LP0410";
62
64
  /** A patch cannot reach what the server would have drawn; `onUnfaithfulPatch` decided what happens next. */
63
65
  readonly UnfaithfulPatch: "LP0411";
64
- /** The first write to a date, number or checkbox binding replaced a different reading of the same value. */
66
+ /** The first write to a date, number, checkbox, select or radio binding replaced a different reading of the same value. */
65
67
  readonly ServerFormatReplaced: "LP0412";
66
68
  /** A Lexical block has no renderer, and the write could not keep the markup the server rendered for it; it is gone. */
67
69
  readonly UnrenderedBlockLost: "LP0413";
@@ -81,7 +83,7 @@ declare const DIAGNOSTIC_CODES: Readonly<{
81
83
  readonly StartupFailed: "LP0605";
82
84
  /** Sending the ready handshake failed. */
83
85
  readonly ReadyFailed: "LP0606";
84
- /** The page declared hydration, but no React commit, Vue mount or SvelteKit mount came within the cap; the runtime started without waiting. */
86
+ /** The page declared hydration, but no React commit, Vue mount, SvelteKit mount or `markHydrated()` call came within the cap; the runtime started without waiting. */
85
87
  readonly HydrationWaitTimedOut: "LP0607";
86
88
  /** The audit found no runtime in a response that carried preview intent. */
87
89
  readonly AuditRuntimeMissing: "LP0701";
@@ -123,6 +125,8 @@ declare const DIAGNOSTIC_CODES: Readonly<{
123
125
  readonly V2ReadinessGap: "LP0709";
124
126
  /** The preview runtime is served to anonymous visitors, not only inside the admin frame. */
125
127
  readonly RuntimeOnPublicPage: "LP0710";
128
+ /** An element carries attributes that only mean something beside `data-payload-field`, and has none. */
129
+ readonly AuditModifierWithoutField: "LP0711";
126
130
  }>;
127
131
  /** A diagnostic code, as it appears in log output and on the `error` event. */
128
132
  type DiagnosticCode = (typeof DIAGNOSTIC_CODES)[keyof typeof DIAGNOSTIC_CODES];
@@ -345,6 +349,8 @@ interface RenderContext {
345
349
  * completes the sentence 'field "x" …' in LP0411.
346
350
  */
347
351
  readonly reportUnfaithful?: (target: CachedElement, reason: string) => void;
352
+ /** The route of a Lexical internal link, as `internalLinkPattern` gives it. */
353
+ readonly internalLinkPattern?: string;
348
354
  }
349
355
  /**
350
356
  * A renderer writes one value into its element. It must not throw: one bad
@@ -851,7 +857,7 @@ interface LivePreviewInspection {
851
857
  * SvelteKit page is not connected yet; `timed-out` is LP0607.
852
858
  */
853
859
  readonly hydration: {
854
- readonly mode: 'off' | 'react' | 'vue' | 'sveltekit';
860
+ readonly mode: 'off' | 'react' | 'vue' | 'sveltekit' | 'manual';
855
861
  readonly state: 'idle' | 'waiting' | 'committed' | 'timed-out';
856
862
  };
857
863
  }
@@ -1004,6 +1010,12 @@ interface LivePreviewClientConfig {
1004
1010
  readonly apiRoute?: string;
1005
1011
  /** Population depth used with `serverURL`. Required with it; `defaults: 'v1'` falls back to `1`. */
1006
1012
  readonly mergeDepth?: number;
1013
+ /** Milliseconds the `serverURL` merge may wait before the update shows its raw values. Off by default. */
1014
+ readonly mergeTimeoutMs?: number;
1015
+ /** The route of a Lexical internal link with no `url` of its own, as `/{locale}/{slug}/`. */
1016
+ readonly internalLinkPattern?: string;
1017
+ /** Hold a route render until Payload reports the save: the route shows what is saved. */
1018
+ readonly routeAfterSave?: boolean;
1007
1019
  /** Custom fetch for the `serverURL` merge request: attach auth headers or route through a proxy. */
1008
1020
  readonly mergeFetch?: typeof fetch;
1009
1021
  /** Verbose console output. Defaults to dev-mode detection. */
@@ -1411,6 +1423,11 @@ interface FieldBindingAttributes {
1411
1423
  readonly 'data-payload-alt'?: string;
1412
1424
  readonly 'data-payload-href'?: string;
1413
1425
  readonly 'data-payload-array-template'?: string;
1426
+ readonly 'data-payload-format'?: string;
1427
+ readonly 'data-payload-text'?: string;
1428
+ readonly 'data-payload-strategy'?: string;
1429
+ readonly 'data-payload-depends'?: string;
1430
+ readonly 'data-payload-boundary'?: string;
1414
1431
  }
1415
1432
  interface BindOptions {
1416
1433
  /** Attribute to write instead of the text content, e.g. `'src'` for `<img>`. */
@@ -1429,6 +1446,19 @@ interface BindOptions {
1429
1446
  readonly href?: string;
1430
1447
  /** Markup per array item with `{{value}}` placeholders. */
1431
1448
  readonly arrayTemplate?: string;
1449
+ /** How a date or number is written, from `data-payload-format`'s vocabulary. */
1450
+ readonly format?: string;
1451
+ /** Let a text write replace the element's children. */
1452
+ readonly text?: boolean;
1453
+ /** Who shows this field: the patch (default), a server-rendered fragment, or the route. */
1454
+ readonly strategy?: 'patch' | 'fragment' | 'route';
1455
+ /** Fields whose change re-applies this binding under `skipUnchanged`. */
1456
+ readonly dependsOn?: readonly string[];
1457
+ /**
1458
+ * An anchor for a field that may be empty, so an edit that fills it has somewhere to
1459
+ * land. Set `hidden` yourself while the value is empty; the runtime keeps it right after that.
1460
+ */
1461
+ readonly anchor?: boolean;
1432
1462
  }
1433
1463
  /** `bind<Homepage>('heroTitle')`; without `T` any string is accepted. */
1434
1464
  declare function bind<T = Record<string, unknown>>(field: FieldName<T>, options?: BindOptions): FieldBindingAttributes;
@@ -1514,6 +1544,111 @@ interface IslandUpdateDetail {
1514
1544
  /** Whether `element` (or an ancestor) is an island that did not opt into patching. @internal */
1515
1545
  declare function isInsideIsland(element: Element): boolean;
1516
1546
 
1547
+ /**
1548
+ * The document a framework hook exposes, kept outside any framework: the
1549
+ * message bus decides which windows may speak, `DataMerger` turns the admin's
1550
+ * raw form values back into a populated document, and this class holds the one
1551
+ * snapshot a `useSyncExternalStore`-shaped API reads.
1552
+ *
1553
+ * It touches no DOM. A hook that re-renders a component tree needs the data,
1554
+ * not the bindings — everything about elements lives in the runtime instead.
1555
+ *
1556
+ * The session is per instance (ADR 0002): two hooks on one page have two
1557
+ * mergers, two revisions and two snapshots, so a request or an error in one
1558
+ * never reaches the other. A session given a `document` merges only the
1559
+ * messages for that document; without one it follows the document the admin
1560
+ * sends, whichever document it started from.
1561
+ */
1562
+ /**
1563
+ * `idle` — connected, nothing received yet. `live` — the newest update was
1564
+ * merged and is in `data`. `unavailable` — it could not be, and `data` is the
1565
+ * last good document rather than a half-merged one.
1566
+ */
1567
+ type DocumentStatus = 'idle' | 'live' | 'unavailable';
1568
+ interface DocumentSnapshot<T> {
1569
+ /** The newest document that merged; never a partially applied one. */
1570
+ readonly data: T;
1571
+ /** No update has settled yet, or a merge is in flight. */
1572
+ readonly isLoading: boolean;
1573
+ readonly status: DocumentStatus;
1574
+ /** Why the last update did not merge; `undefined` while `status` is not `unavailable`. */
1575
+ readonly error: Error | undefined;
1576
+ /**
1577
+ * Which of this session's messages `data` came from: `0` for the initial
1578
+ * data, and unchanged when a merge fails. The framework paints `data` in its
1579
+ * own commit; a component that must know it was painted compares this in an
1580
+ * effect (ADR 0023).
1581
+ */
1582
+ readonly revision: number;
1583
+ }
1584
+ /**
1585
+ * The document a session previews: a collection document by its id, or a global by its slug.
1586
+ * `locale` narrows it to the updates the admin sends for that locale.
1587
+ */
1588
+ type PreviewDocument = {
1589
+ readonly collection: string;
1590
+ readonly id: string | number;
1591
+ readonly locale?: string;
1592
+ } | {
1593
+ readonly global: string;
1594
+ readonly locale?: string;
1595
+ };
1596
+ interface DocumentSessionOptions {
1597
+ /** Payload server origin the update is re-fetched from. */
1598
+ readonly serverURL: string;
1599
+ /** REST route prefix. Default `/api`. */
1600
+ readonly apiRoute?: string;
1601
+ /** Population depth for the merge. Default `1`, as Payload's own hook. */
1602
+ readonly depth?: number;
1603
+ /**
1604
+ * Milliseconds a merge may wait for the server; after that the update is `unavailable`
1605
+ * and `data` stays the last good document. Off by default: a merge waits as long as the
1606
+ * server takes.
1607
+ */
1608
+ readonly timeoutMs?: number;
1609
+ /**
1610
+ * Admin origins allowed to post updates. Without one the session falls back
1611
+ * to the localhost matcher in development and trusts nothing in production.
1612
+ */
1613
+ readonly allowedOrigins?: readonly string[];
1614
+ /** `'parent-or-opener'` (default) refuses every window but the framing or opening one. */
1615
+ readonly eventSourcePolicy?: 'any' | 'parent-or-opener';
1616
+ /** Trust `document.referrer` as an origin source. Default `false`. */
1617
+ readonly enableReferrerDetection?: boolean;
1618
+ /** Match `localhost` origins in development. Default `true`. */
1619
+ readonly enableLocalhostMatching?: boolean;
1620
+ /**
1621
+ * The document this session previews. An update for another document is ignored, and so is
1622
+ * one that does not say which document it is for: Payload 2 sends no collection or global
1623
+ * slug, and a create screen has no id yet. Without it the session merges every update.
1624
+ */
1625
+ readonly document?: PreviewDocument;
1626
+ /** Injected for tests. */
1627
+ readonly fetchFn?: typeof fetch;
1628
+ /** Window to listen on. Default the global one. */
1629
+ readonly target?: Window;
1630
+ }
1631
+ type Listener = () => void;
1632
+ declare class DocumentSession<T> {
1633
+ #private;
1634
+ constructor(initialData: T, options: DocumentSessionOptions);
1635
+ /**
1636
+ * Attach on the first subscriber and detach with the last, so a component
1637
+ * that mounts twice (React's strict mode) listens once and a page that
1638
+ * unmounts the hook stops listening at all.
1639
+ */
1640
+ subscribe: (listener: Listener) => (() => void);
1641
+ getSnapshot: () => DocumentSnapshot<T>;
1642
+ /** Server rendering has no window and no messages: the initial snapshot a client render starts from. */
1643
+ getServerSnapshot: () => DocumentSnapshot<T>;
1644
+ }
1645
+ /**
1646
+ * One preview document, with no framework around it: `subscribe` and `getSnapshot`
1647
+ * fit a `useSyncExternalStore` or a Svelte store.
1648
+ * @beta
1649
+ */
1650
+ declare function createDocumentSession<T>(initialData: T, options: DocumentSessionOptions): DocumentSession<T>;
1651
+
1517
1652
  /**
1518
1653
  * Narrow public entry — the minimum API for sites that only need to
1519
1654
  * receive postMessage updates and apply them to the DOM.
@@ -1536,4 +1671,4 @@ declare function isInsideIsland(element: Element): boolean;
1536
1671
  /** @internal */
1537
1672
  declare const CORE_ENTRY = true;
1538
1673
 
1539
- export { AUTHORIZED_PREVIEW_BRAND_KEY, type AuthorizedPreviewContext, type AuthorizedPreviewDocument, type AuthorizedPreviewPayloadScope, type AuthorizedPreviewScope, type BindOptions, CAPABILITY_DECLARATIONS, CAPABILITY_DOCUMENTATION, CORE_ENTRY, type CachedElement, type CapabilityDeclaration, type CapabilityDocumentation, type CapabilitySource, type ConnectionStatus, type CustomRendererKey, DIAGNOSTIC_CODES, type DefaultsProfile, type DiagnosticCode, EventEmitter, type EventHandler, type EventSourcePolicy, type FieldBindingAttributes, type FieldName, type FieldPath, type FieldRenderer, type FieldType, type FragmentBoundaryAttributes, type FragmentBoundaryOptions, type FragmentContext, type FragmentReport, type FragmentStrategy, type FrameAncestorsOptions, ISLAND_EVENT, type InspectionBindings, type InspectionFidelity, type InspectionFragments, type InspectionOrigins, type InspectionProtocol, type InspectionRevisions, type InspectionRoute, type InspectionScheduler, type IslandUpdateDetail, LIBRARY_PROTOCOL_VERSION, LivePreviewClient, type LivePreviewClientConfig, type LivePreviewEventMap, type LivePreviewInspection, OriginDetector, type OwnerBindingAttributes, PROTOCOL_CAPABILITIES, type PayloadDocumentEventDetail, type PayloadFieldCondition, type PayloadFieldSchema, type PayloadFieldType, type PayloadLivePreviewData, type PayloadLivePreviewMessage, type PluginCompatibility, type PluginInspection, type PreviewAuthorizationStrategyName, type PreviewBindings, type PreviewBindingsOptions, type ProtocolCapability, type ProtocolNegotiation, type ProtocolProfile, type ProtocolProfileName, type RenderContext, type RendererKey, type RevisionDisplay, type RevisionDisplayState, type RevisionShortfall, type RichTextRenderer, type RouteContext, type RouteOutcome, type RoutePlanContext, type RouteRefresh, type RouteStrategy, type SanitizerDocument, type SanitizerPolicyMode, type StrategyHandlers, type SuppressedBinding, type Unsubscribe, type UpdateSource, VERSION, type ValueAt, bind, bindByPath, buildFrameAncestors, buildScriptSrcWithNonce, createPreviewBindings, detectInitialLocale, detectProtocolProfile, escapeHtml, escapeHtmlAttribute, generateCspNonce, hasCapability, initLivePreview, isAuthorizedPreviewContext, isDevMode, isExternalHttpUrl, isInIframe, isInPopup, isInPreviewContext, isInsideIsland, isSafeUrl, negotiateProtocol, registerRouteRefresh, sanitizeHtml, setCspCrypto, setSanitizerDocument };
1674
+ export { AUTHORIZED_PREVIEW_BRAND_KEY, type AuthorizedPreviewContext, type AuthorizedPreviewDocument, type AuthorizedPreviewPayloadScope, type AuthorizedPreviewScope, type BindOptions, CAPABILITY_DECLARATIONS, CAPABILITY_DOCUMENTATION, CORE_ENTRY, type CachedElement, type CapabilityDeclaration, type CapabilityDocumentation, type CapabilitySource, type ConnectionStatus, type CustomRendererKey, DIAGNOSTIC_CODES, type DefaultsProfile, type DiagnosticCode, DocumentSession, type DocumentSessionOptions, type DocumentSnapshot, type DocumentStatus, EventEmitter, type EventHandler, type EventSourcePolicy, type FieldBindingAttributes, type FieldName, type FieldPath, type FieldRenderer, type FieldType, type FragmentBoundaryAttributes, type FragmentBoundaryOptions, type FragmentContext, type FragmentReport, type FragmentStrategy, type FrameAncestorsOptions, ISLAND_EVENT, type InspectionBindings, type InspectionFidelity, type InspectionFragments, type InspectionOrigins, type InspectionProtocol, type InspectionRevisions, type InspectionRoute, type InspectionScheduler, type IslandUpdateDetail, LIBRARY_PROTOCOL_VERSION, LivePreviewClient, type LivePreviewClientConfig, type LivePreviewEventMap, type LivePreviewInspection, OriginDetector, type OwnerBindingAttributes, PROTOCOL_CAPABILITIES, type PayloadDocumentEventDetail, type PayloadFieldCondition, type PayloadFieldSchema, type PayloadFieldType, type PayloadLivePreviewData, type PayloadLivePreviewMessage, type PluginCompatibility, type PluginInspection, type PreviewAuthorizationStrategyName, type PreviewBindings, type PreviewBindingsOptions, type PreviewDocument, type ProtocolCapability, type ProtocolNegotiation, type ProtocolProfile, type ProtocolProfileName, type RenderContext, type RendererKey, type RevisionDisplay, type RevisionDisplayState, type RevisionShortfall, type RichTextRenderer, type RouteContext, type RouteOutcome, type RoutePlanContext, type RouteRefresh, type RouteStrategy, type SanitizerDocument, type SanitizerPolicyMode, type StrategyHandlers, type SuppressedBinding, type Unsubscribe, type UpdateSource, VERSION, type ValueAt, bind, bindByPath, buildFrameAncestors, buildScriptSrcWithNonce, createDocumentSession, createPreviewBindings, detectInitialLocale, detectProtocolProfile, escapeHtml, escapeHtmlAttribute, generateCspNonce, hasCapability, initLivePreview, isAuthorizedPreviewContext, isDevMode, isExternalHttpUrl, isInIframe, isInPopup, isInPreviewContext, isInsideIsland, isSafeUrl, negotiateProtocol, registerRouteRefresh, sanitizeHtml, setCspCrypto, setSanitizerDocument };
package/dist/core.d.ts CHANGED
@@ -37,6 +37,8 @@ declare const DIAGNOSTIC_CODES: Readonly<{
37
37
  readonly UnattributableUpdate: "LP0202";
38
38
  /** An update carried a value for a field the page binds nowhere; editing it changes nothing on this page. */
39
39
  readonly UnboundField: "LP0203";
40
+ /** In development: a bound path covers its group under the `descendant` default, which 3.0 changes. */
41
+ readonly CoverageDefaultChanges: "LP0204";
40
42
  /** The visibility gate held offscreen writes back until they scroll into view. */
41
43
  readonly VisibilityGateDeferred: "LP0301";
42
44
  /** A value was refused because the attribute or the value itself is unsafe. */
@@ -61,7 +63,7 @@ declare const DIAGNOSTIC_CODES: Readonly<{
61
63
  readonly UnrenderedBlockKept: "LP0410";
62
64
  /** A patch cannot reach what the server would have drawn; `onUnfaithfulPatch` decided what happens next. */
63
65
  readonly UnfaithfulPatch: "LP0411";
64
- /** The first write to a date, number or checkbox binding replaced a different reading of the same value. */
66
+ /** The first write to a date, number, checkbox, select or radio binding replaced a different reading of the same value. */
65
67
  readonly ServerFormatReplaced: "LP0412";
66
68
  /** A Lexical block has no renderer, and the write could not keep the markup the server rendered for it; it is gone. */
67
69
  readonly UnrenderedBlockLost: "LP0413";
@@ -81,7 +83,7 @@ declare const DIAGNOSTIC_CODES: Readonly<{
81
83
  readonly StartupFailed: "LP0605";
82
84
  /** Sending the ready handshake failed. */
83
85
  readonly ReadyFailed: "LP0606";
84
- /** The page declared hydration, but no React commit, Vue mount or SvelteKit mount came within the cap; the runtime started without waiting. */
86
+ /** The page declared hydration, but no React commit, Vue mount, SvelteKit mount or `markHydrated()` call came within the cap; the runtime started without waiting. */
85
87
  readonly HydrationWaitTimedOut: "LP0607";
86
88
  /** The audit found no runtime in a response that carried preview intent. */
87
89
  readonly AuditRuntimeMissing: "LP0701";
@@ -123,6 +125,8 @@ declare const DIAGNOSTIC_CODES: Readonly<{
123
125
  readonly V2ReadinessGap: "LP0709";
124
126
  /** The preview runtime is served to anonymous visitors, not only inside the admin frame. */
125
127
  readonly RuntimeOnPublicPage: "LP0710";
128
+ /** An element carries attributes that only mean something beside `data-payload-field`, and has none. */
129
+ readonly AuditModifierWithoutField: "LP0711";
126
130
  }>;
127
131
  /** A diagnostic code, as it appears in log output and on the `error` event. */
128
132
  type DiagnosticCode = (typeof DIAGNOSTIC_CODES)[keyof typeof DIAGNOSTIC_CODES];
@@ -345,6 +349,8 @@ interface RenderContext {
345
349
  * completes the sentence 'field "x" …' in LP0411.
346
350
  */
347
351
  readonly reportUnfaithful?: (target: CachedElement, reason: string) => void;
352
+ /** The route of a Lexical internal link, as `internalLinkPattern` gives it. */
353
+ readonly internalLinkPattern?: string;
348
354
  }
349
355
  /**
350
356
  * A renderer writes one value into its element. It must not throw: one bad
@@ -851,7 +857,7 @@ interface LivePreviewInspection {
851
857
  * SvelteKit page is not connected yet; `timed-out` is LP0607.
852
858
  */
853
859
  readonly hydration: {
854
- readonly mode: 'off' | 'react' | 'vue' | 'sveltekit';
860
+ readonly mode: 'off' | 'react' | 'vue' | 'sveltekit' | 'manual';
855
861
  readonly state: 'idle' | 'waiting' | 'committed' | 'timed-out';
856
862
  };
857
863
  }
@@ -1004,6 +1010,12 @@ interface LivePreviewClientConfig {
1004
1010
  readonly apiRoute?: string;
1005
1011
  /** Population depth used with `serverURL`. Required with it; `defaults: 'v1'` falls back to `1`. */
1006
1012
  readonly mergeDepth?: number;
1013
+ /** Milliseconds the `serverURL` merge may wait before the update shows its raw values. Off by default. */
1014
+ readonly mergeTimeoutMs?: number;
1015
+ /** The route of a Lexical internal link with no `url` of its own, as `/{locale}/{slug}/`. */
1016
+ readonly internalLinkPattern?: string;
1017
+ /** Hold a route render until Payload reports the save: the route shows what is saved. */
1018
+ readonly routeAfterSave?: boolean;
1007
1019
  /** Custom fetch for the `serverURL` merge request: attach auth headers or route through a proxy. */
1008
1020
  readonly mergeFetch?: typeof fetch;
1009
1021
  /** Verbose console output. Defaults to dev-mode detection. */
@@ -1411,6 +1423,11 @@ interface FieldBindingAttributes {
1411
1423
  readonly 'data-payload-alt'?: string;
1412
1424
  readonly 'data-payload-href'?: string;
1413
1425
  readonly 'data-payload-array-template'?: string;
1426
+ readonly 'data-payload-format'?: string;
1427
+ readonly 'data-payload-text'?: string;
1428
+ readonly 'data-payload-strategy'?: string;
1429
+ readonly 'data-payload-depends'?: string;
1430
+ readonly 'data-payload-boundary'?: string;
1414
1431
  }
1415
1432
  interface BindOptions {
1416
1433
  /** Attribute to write instead of the text content, e.g. `'src'` for `<img>`. */
@@ -1429,6 +1446,19 @@ interface BindOptions {
1429
1446
  readonly href?: string;
1430
1447
  /** Markup per array item with `{{value}}` placeholders. */
1431
1448
  readonly arrayTemplate?: string;
1449
+ /** How a date or number is written, from `data-payload-format`'s vocabulary. */
1450
+ readonly format?: string;
1451
+ /** Let a text write replace the element's children. */
1452
+ readonly text?: boolean;
1453
+ /** Who shows this field: the patch (default), a server-rendered fragment, or the route. */
1454
+ readonly strategy?: 'patch' | 'fragment' | 'route';
1455
+ /** Fields whose change re-applies this binding under `skipUnchanged`. */
1456
+ readonly dependsOn?: readonly string[];
1457
+ /**
1458
+ * An anchor for a field that may be empty, so an edit that fills it has somewhere to
1459
+ * land. Set `hidden` yourself while the value is empty; the runtime keeps it right after that.
1460
+ */
1461
+ readonly anchor?: boolean;
1432
1462
  }
1433
1463
  /** `bind<Homepage>('heroTitle')`; without `T` any string is accepted. */
1434
1464
  declare function bind<T = Record<string, unknown>>(field: FieldName<T>, options?: BindOptions): FieldBindingAttributes;
@@ -1514,6 +1544,111 @@ interface IslandUpdateDetail {
1514
1544
  /** Whether `element` (or an ancestor) is an island that did not opt into patching. @internal */
1515
1545
  declare function isInsideIsland(element: Element): boolean;
1516
1546
 
1547
+ /**
1548
+ * The document a framework hook exposes, kept outside any framework: the
1549
+ * message bus decides which windows may speak, `DataMerger` turns the admin's
1550
+ * raw form values back into a populated document, and this class holds the one
1551
+ * snapshot a `useSyncExternalStore`-shaped API reads.
1552
+ *
1553
+ * It touches no DOM. A hook that re-renders a component tree needs the data,
1554
+ * not the bindings — everything about elements lives in the runtime instead.
1555
+ *
1556
+ * The session is per instance (ADR 0002): two hooks on one page have two
1557
+ * mergers, two revisions and two snapshots, so a request or an error in one
1558
+ * never reaches the other. A session given a `document` merges only the
1559
+ * messages for that document; without one it follows the document the admin
1560
+ * sends, whichever document it started from.
1561
+ */
1562
+ /**
1563
+ * `idle` — connected, nothing received yet. `live` — the newest update was
1564
+ * merged and is in `data`. `unavailable` — it could not be, and `data` is the
1565
+ * last good document rather than a half-merged one.
1566
+ */
1567
+ type DocumentStatus = 'idle' | 'live' | 'unavailable';
1568
+ interface DocumentSnapshot<T> {
1569
+ /** The newest document that merged; never a partially applied one. */
1570
+ readonly data: T;
1571
+ /** No update has settled yet, or a merge is in flight. */
1572
+ readonly isLoading: boolean;
1573
+ readonly status: DocumentStatus;
1574
+ /** Why the last update did not merge; `undefined` while `status` is not `unavailable`. */
1575
+ readonly error: Error | undefined;
1576
+ /**
1577
+ * Which of this session's messages `data` came from: `0` for the initial
1578
+ * data, and unchanged when a merge fails. The framework paints `data` in its
1579
+ * own commit; a component that must know it was painted compares this in an
1580
+ * effect (ADR 0023).
1581
+ */
1582
+ readonly revision: number;
1583
+ }
1584
+ /**
1585
+ * The document a session previews: a collection document by its id, or a global by its slug.
1586
+ * `locale` narrows it to the updates the admin sends for that locale.
1587
+ */
1588
+ type PreviewDocument = {
1589
+ readonly collection: string;
1590
+ readonly id: string | number;
1591
+ readonly locale?: string;
1592
+ } | {
1593
+ readonly global: string;
1594
+ readonly locale?: string;
1595
+ };
1596
+ interface DocumentSessionOptions {
1597
+ /** Payload server origin the update is re-fetched from. */
1598
+ readonly serverURL: string;
1599
+ /** REST route prefix. Default `/api`. */
1600
+ readonly apiRoute?: string;
1601
+ /** Population depth for the merge. Default `1`, as Payload's own hook. */
1602
+ readonly depth?: number;
1603
+ /**
1604
+ * Milliseconds a merge may wait for the server; after that the update is `unavailable`
1605
+ * and `data` stays the last good document. Off by default: a merge waits as long as the
1606
+ * server takes.
1607
+ */
1608
+ readonly timeoutMs?: number;
1609
+ /**
1610
+ * Admin origins allowed to post updates. Without one the session falls back
1611
+ * to the localhost matcher in development and trusts nothing in production.
1612
+ */
1613
+ readonly allowedOrigins?: readonly string[];
1614
+ /** `'parent-or-opener'` (default) refuses every window but the framing or opening one. */
1615
+ readonly eventSourcePolicy?: 'any' | 'parent-or-opener';
1616
+ /** Trust `document.referrer` as an origin source. Default `false`. */
1617
+ readonly enableReferrerDetection?: boolean;
1618
+ /** Match `localhost` origins in development. Default `true`. */
1619
+ readonly enableLocalhostMatching?: boolean;
1620
+ /**
1621
+ * The document this session previews. An update for another document is ignored, and so is
1622
+ * one that does not say which document it is for: Payload 2 sends no collection or global
1623
+ * slug, and a create screen has no id yet. Without it the session merges every update.
1624
+ */
1625
+ readonly document?: PreviewDocument;
1626
+ /** Injected for tests. */
1627
+ readonly fetchFn?: typeof fetch;
1628
+ /** Window to listen on. Default the global one. */
1629
+ readonly target?: Window;
1630
+ }
1631
+ type Listener = () => void;
1632
+ declare class DocumentSession<T> {
1633
+ #private;
1634
+ constructor(initialData: T, options: DocumentSessionOptions);
1635
+ /**
1636
+ * Attach on the first subscriber and detach with the last, so a component
1637
+ * that mounts twice (React's strict mode) listens once and a page that
1638
+ * unmounts the hook stops listening at all.
1639
+ */
1640
+ subscribe: (listener: Listener) => (() => void);
1641
+ getSnapshot: () => DocumentSnapshot<T>;
1642
+ /** Server rendering has no window and no messages: the initial snapshot a client render starts from. */
1643
+ getServerSnapshot: () => DocumentSnapshot<T>;
1644
+ }
1645
+ /**
1646
+ * One preview document, with no framework around it: `subscribe` and `getSnapshot`
1647
+ * fit a `useSyncExternalStore` or a Svelte store.
1648
+ * @beta
1649
+ */
1650
+ declare function createDocumentSession<T>(initialData: T, options: DocumentSessionOptions): DocumentSession<T>;
1651
+
1517
1652
  /**
1518
1653
  * Narrow public entry — the minimum API for sites that only need to
1519
1654
  * receive postMessage updates and apply them to the DOM.
@@ -1536,4 +1671,4 @@ declare function isInsideIsland(element: Element): boolean;
1536
1671
  /** @internal */
1537
1672
  declare const CORE_ENTRY = true;
1538
1673
 
1539
- export { AUTHORIZED_PREVIEW_BRAND_KEY, type AuthorizedPreviewContext, type AuthorizedPreviewDocument, type AuthorizedPreviewPayloadScope, type AuthorizedPreviewScope, type BindOptions, CAPABILITY_DECLARATIONS, CAPABILITY_DOCUMENTATION, CORE_ENTRY, type CachedElement, type CapabilityDeclaration, type CapabilityDocumentation, type CapabilitySource, type ConnectionStatus, type CustomRendererKey, DIAGNOSTIC_CODES, type DefaultsProfile, type DiagnosticCode, EventEmitter, type EventHandler, type EventSourcePolicy, type FieldBindingAttributes, type FieldName, type FieldPath, type FieldRenderer, type FieldType, type FragmentBoundaryAttributes, type FragmentBoundaryOptions, type FragmentContext, type FragmentReport, type FragmentStrategy, type FrameAncestorsOptions, ISLAND_EVENT, type InspectionBindings, type InspectionFidelity, type InspectionFragments, type InspectionOrigins, type InspectionProtocol, type InspectionRevisions, type InspectionRoute, type InspectionScheduler, type IslandUpdateDetail, LIBRARY_PROTOCOL_VERSION, LivePreviewClient, type LivePreviewClientConfig, type LivePreviewEventMap, type LivePreviewInspection, OriginDetector, type OwnerBindingAttributes, PROTOCOL_CAPABILITIES, type PayloadDocumentEventDetail, type PayloadFieldCondition, type PayloadFieldSchema, type PayloadFieldType, type PayloadLivePreviewData, type PayloadLivePreviewMessage, type PluginCompatibility, type PluginInspection, type PreviewAuthorizationStrategyName, type PreviewBindings, type PreviewBindingsOptions, type ProtocolCapability, type ProtocolNegotiation, type ProtocolProfile, type ProtocolProfileName, type RenderContext, type RendererKey, type RevisionDisplay, type RevisionDisplayState, type RevisionShortfall, type RichTextRenderer, type RouteContext, type RouteOutcome, type RoutePlanContext, type RouteRefresh, type RouteStrategy, type SanitizerDocument, type SanitizerPolicyMode, type StrategyHandlers, type SuppressedBinding, type Unsubscribe, type UpdateSource, VERSION, type ValueAt, bind, bindByPath, buildFrameAncestors, buildScriptSrcWithNonce, createPreviewBindings, detectInitialLocale, detectProtocolProfile, escapeHtml, escapeHtmlAttribute, generateCspNonce, hasCapability, initLivePreview, isAuthorizedPreviewContext, isDevMode, isExternalHttpUrl, isInIframe, isInPopup, isInPreviewContext, isInsideIsland, isSafeUrl, negotiateProtocol, registerRouteRefresh, sanitizeHtml, setCspCrypto, setSanitizerDocument };
1674
+ export { AUTHORIZED_PREVIEW_BRAND_KEY, type AuthorizedPreviewContext, type AuthorizedPreviewDocument, type AuthorizedPreviewPayloadScope, type AuthorizedPreviewScope, type BindOptions, CAPABILITY_DECLARATIONS, CAPABILITY_DOCUMENTATION, CORE_ENTRY, type CachedElement, type CapabilityDeclaration, type CapabilityDocumentation, type CapabilitySource, type ConnectionStatus, type CustomRendererKey, DIAGNOSTIC_CODES, type DefaultsProfile, type DiagnosticCode, DocumentSession, type DocumentSessionOptions, type DocumentSnapshot, type DocumentStatus, EventEmitter, type EventHandler, type EventSourcePolicy, type FieldBindingAttributes, type FieldName, type FieldPath, type FieldRenderer, type FieldType, type FragmentBoundaryAttributes, type FragmentBoundaryOptions, type FragmentContext, type FragmentReport, type FragmentStrategy, type FrameAncestorsOptions, ISLAND_EVENT, type InspectionBindings, type InspectionFidelity, type InspectionFragments, type InspectionOrigins, type InspectionProtocol, type InspectionRevisions, type InspectionRoute, type InspectionScheduler, type IslandUpdateDetail, LIBRARY_PROTOCOL_VERSION, LivePreviewClient, type LivePreviewClientConfig, type LivePreviewEventMap, type LivePreviewInspection, OriginDetector, type OwnerBindingAttributes, PROTOCOL_CAPABILITIES, type PayloadDocumentEventDetail, type PayloadFieldCondition, type PayloadFieldSchema, type PayloadFieldType, type PayloadLivePreviewData, type PayloadLivePreviewMessage, type PluginCompatibility, type PluginInspection, type PreviewAuthorizationStrategyName, type PreviewBindings, type PreviewBindingsOptions, type PreviewDocument, type ProtocolCapability, type ProtocolNegotiation, type ProtocolProfile, type ProtocolProfileName, type RenderContext, type RendererKey, type RevisionDisplay, type RevisionDisplayState, type RevisionShortfall, type RichTextRenderer, type RouteContext, type RouteOutcome, type RoutePlanContext, type RouteRefresh, type RouteStrategy, type SanitizerDocument, type SanitizerPolicyMode, type StrategyHandlers, type SuppressedBinding, type Unsubscribe, type UpdateSource, VERSION, type ValueAt, bind, bindByPath, buildFrameAncestors, buildScriptSrcWithNonce, createDocumentSession, createPreviewBindings, detectInitialLocale, detectProtocolProfile, escapeHtml, escapeHtmlAttribute, generateCspNonce, hasCapability, initLivePreview, isAuthorizedPreviewContext, isDevMode, isExternalHttpUrl, isInIframe, isInPopup, isInPreviewContext, isInsideIsland, isSafeUrl, negotiateProtocol, registerRouteRefresh, sanitizeHtml, setCspCrypto, setSanitizerDocument };