payload-live-preview 2.3.1 → 2.4.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 (60) hide show
  1. package/README.md +13 -46
  2. package/dist/adapters/astro/index.js +1 -1
  3. package/dist/adapters/astro/index.js.map +1 -1
  4. package/dist/adapters/astro/middleware-entry.js +1 -1
  5. package/dist/adapters/astro/middleware-entry.js.map +1 -1
  6. package/dist/adapters/nextjs/client.d.ts +28 -0
  7. package/dist/adapters/nextjs/client.js +3 -0
  8. package/dist/adapters/nextjs/client.js.map +1 -0
  9. package/dist/adapters/nextjs/index.d.ts +34 -12
  10. package/dist/adapters/nextjs/index.js +1 -1
  11. package/dist/adapters/nextjs/index.js.map +1 -1
  12. package/dist/adapters/nuxt/client.d.ts +29 -0
  13. package/dist/adapters/nuxt/client.js +2 -0
  14. package/dist/adapters/nuxt/client.js.map +1 -0
  15. package/dist/adapters/nuxt/index.js +1 -1
  16. package/dist/adapters/nuxt/index.js.map +1 -1
  17. package/dist/adapters/nuxt/module.d.ts +23 -3
  18. package/dist/adapters/nuxt/module.js +1 -1
  19. package/dist/adapters/nuxt/module.js.map +1 -1
  20. package/dist/adapters/react/index.d.ts +2 -2
  21. package/dist/adapters/react/index.js +1 -1
  22. package/dist/adapters/react/index.js.map +1 -1
  23. package/dist/adapters/sveltekit/client.d.ts +37 -0
  24. package/dist/adapters/sveltekit/client.js +2 -0
  25. package/dist/adapters/sveltekit/client.js.map +1 -0
  26. package/dist/adapters/sveltekit/index.js +1 -1
  27. package/dist/adapters/sveltekit/index.js.map +1 -1
  28. package/dist/adapters/vue/index.d.ts +2 -2
  29. package/dist/adapters/vue/index.js +1 -1
  30. package/dist/adapters/vue/index.js.map +1 -1
  31. package/dist/client.cjs +1 -1
  32. package/dist/client.cjs.map +1 -1
  33. package/dist/client.js +1 -1
  34. package/dist/client.js.map +1 -1
  35. package/dist/core.cjs +1 -1
  36. package/dist/core.cjs.map +1 -1
  37. package/dist/core.d.cts +22 -14
  38. package/dist/core.d.ts +22 -14
  39. package/dist/core.js +1 -1
  40. package/dist/core.js.map +1 -1
  41. package/dist/{document-session-BuYuO3ae.d.ts → document-session-oK92QjES.d.ts} +7 -1
  42. package/dist/index.cjs +1 -1
  43. package/dist/index.cjs.map +1 -1
  44. package/dist/index.js +1 -1
  45. package/dist/index.js.map +1 -1
  46. package/dist/lean.cjs +1 -1
  47. package/dist/lean.cjs.map +1 -1
  48. package/dist/lean.js +1 -1
  49. package/dist/lean.js.map +1 -1
  50. package/dist/lexical.cjs.map +1 -1
  51. package/dist/lexical.js.map +1 -1
  52. package/dist/plugins.cjs +1 -1
  53. package/dist/plugins.cjs.map +1 -1
  54. package/dist/plugins.js +1 -1
  55. package/dist/plugins.js.map +1 -1
  56. package/dist/server.cjs.map +1 -1
  57. package/dist/server.js.map +1 -1
  58. package/dist/structural.cjs.map +1 -1
  59. package/dist/structural.js.map +1 -1
  60. package/package.json +23 -1
package/dist/core.d.cts CHANGED
@@ -1603,7 +1603,7 @@ interface DocumentSessionOptions {
1603
1603
  /**
1604
1604
  * Milliseconds a merge may wait for the server; after that the update is `unavailable`
1605
1605
  * and `data` stays the last good document. Off by default: a merge waits as long as the
1606
- * server takes.
1606
+ * server takes. `0` keeps it off when 3.0 gives it a default (ADR 0007, row 27).
1607
1607
  */
1608
1608
  readonly timeoutMs?: number;
1609
1609
  /**
@@ -1623,28 +1623,36 @@ interface DocumentSessionOptions {
1623
1623
  * slug, and a create screen has no id yet. Without it the session merges every update.
1624
1624
  */
1625
1625
  readonly document?: PreviewDocument;
1626
+ /**
1627
+ * With a `locale` in `document`, also leave alone an update that names no locale, as 3.0
1628
+ * does for every hook with a `locale` (ADR 0007, row 31). Off by default: such an update is
1629
+ * merged.
1630
+ */
1631
+ readonly requireLocale?: boolean;
1626
1632
  /** Injected for tests. */
1627
1633
  readonly fetchFn?: typeof fetch;
1628
1634
  /** Window to listen on. Default the global one. */
1629
1635
  readonly target?: Window;
1630
1636
  }
1631
- type Listener = () => void;
1632
- declare class DocumentSession<T> {
1633
- #private;
1634
- constructor(initialData: T, options: DocumentSessionOptions);
1637
+ /**
1638
+ * One preview document, with no framework around it: `subscribe` and `getSnapshot`
1639
+ * fit a `useSyncExternalStore` or a Svelte store. `createDocumentSession()` makes
1640
+ * one; no entry exports the class behind it.
1641
+ * @beta
1642
+ */
1643
+ interface DocumentSession<T> {
1635
1644
  /**
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.
1645
+ * Called with every new snapshot. The first listener starts listening for the
1646
+ * admin's messages, and the last one to unsubscribe stops it.
1639
1647
  */
1640
- subscribe: (listener: Listener) => (() => void);
1641
- getSnapshot: () => DocumentSnapshot<T>;
1648
+ readonly subscribe: (listener: () => void) => () => void;
1649
+ /** The current snapshot; a new object only when something in it changed. */
1650
+ readonly getSnapshot: () => DocumentSnapshot<T>;
1642
1651
  /** Server rendering has no window and no messages: the initial snapshot a client render starts from. */
1643
- getServerSnapshot: () => DocumentSnapshot<T>;
1652
+ readonly getServerSnapshot: () => DocumentSnapshot<T>;
1644
1653
  }
1645
1654
  /**
1646
- * One preview document, with no framework around it: `subscribe` and `getSnapshot`
1647
- * fit a `useSyncExternalStore` or a Svelte store.
1655
+ * A session for one preview document. Nothing listens before the first `subscribe`.
1648
1656
  * @beta
1649
1657
  */
1650
1658
  declare function createDocumentSession<T>(initialData: T, options: DocumentSessionOptions): DocumentSession<T>;
@@ -1671,4 +1679,4 @@ declare function createDocumentSession<T>(initialData: T, options: DocumentSessi
1671
1679
  /** @internal */
1672
1680
  declare const CORE_ENTRY = true;
1673
1681
 
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 };
1682
+ 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, type 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
@@ -1603,7 +1603,7 @@ interface DocumentSessionOptions {
1603
1603
  /**
1604
1604
  * Milliseconds a merge may wait for the server; after that the update is `unavailable`
1605
1605
  * and `data` stays the last good document. Off by default: a merge waits as long as the
1606
- * server takes.
1606
+ * server takes. `0` keeps it off when 3.0 gives it a default (ADR 0007, row 27).
1607
1607
  */
1608
1608
  readonly timeoutMs?: number;
1609
1609
  /**
@@ -1623,28 +1623,36 @@ interface DocumentSessionOptions {
1623
1623
  * slug, and a create screen has no id yet. Without it the session merges every update.
1624
1624
  */
1625
1625
  readonly document?: PreviewDocument;
1626
+ /**
1627
+ * With a `locale` in `document`, also leave alone an update that names no locale, as 3.0
1628
+ * does for every hook with a `locale` (ADR 0007, row 31). Off by default: such an update is
1629
+ * merged.
1630
+ */
1631
+ readonly requireLocale?: boolean;
1626
1632
  /** Injected for tests. */
1627
1633
  readonly fetchFn?: typeof fetch;
1628
1634
  /** Window to listen on. Default the global one. */
1629
1635
  readonly target?: Window;
1630
1636
  }
1631
- type Listener = () => void;
1632
- declare class DocumentSession<T> {
1633
- #private;
1634
- constructor(initialData: T, options: DocumentSessionOptions);
1637
+ /**
1638
+ * One preview document, with no framework around it: `subscribe` and `getSnapshot`
1639
+ * fit a `useSyncExternalStore` or a Svelte store. `createDocumentSession()` makes
1640
+ * one; no entry exports the class behind it.
1641
+ * @beta
1642
+ */
1643
+ interface DocumentSession<T> {
1635
1644
  /**
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.
1645
+ * Called with every new snapshot. The first listener starts listening for the
1646
+ * admin's messages, and the last one to unsubscribe stops it.
1639
1647
  */
1640
- subscribe: (listener: Listener) => (() => void);
1641
- getSnapshot: () => DocumentSnapshot<T>;
1648
+ readonly subscribe: (listener: () => void) => () => void;
1649
+ /** The current snapshot; a new object only when something in it changed. */
1650
+ readonly getSnapshot: () => DocumentSnapshot<T>;
1642
1651
  /** Server rendering has no window and no messages: the initial snapshot a client render starts from. */
1643
- getServerSnapshot: () => DocumentSnapshot<T>;
1652
+ readonly getServerSnapshot: () => DocumentSnapshot<T>;
1644
1653
  }
1645
1654
  /**
1646
- * One preview document, with no framework around it: `subscribe` and `getSnapshot`
1647
- * fit a `useSyncExternalStore` or a Svelte store.
1655
+ * A session for one preview document. Nothing listens before the first `subscribe`.
1648
1656
  * @beta
1649
1657
  */
1650
1658
  declare function createDocumentSession<T>(initialData: T, options: DocumentSessionOptions): DocumentSession<T>;
@@ -1671,4 +1679,4 @@ declare function createDocumentSession<T>(initialData: T, options: DocumentSessi
1671
1679
  /** @internal */
1672
1680
  declare const CORE_ENTRY = true;
1673
1681
 
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 };
1682
+ 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, type 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 };