payload-live-preview 1.2.2 → 1.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.
- package/dist/adapters/astro/index.js +1 -1
- package/dist/adapters/astro/index.js.map +1 -1
- package/dist/adapters/astro/middleware-entry.js +1 -1
- package/dist/adapters/astro/middleware-entry.js.map +1 -1
- package/dist/adapters/nextjs/index.js +1 -1
- package/dist/adapters/nextjs/index.js.map +1 -1
- package/dist/adapters/nuxt/index.js +1 -1
- package/dist/adapters/nuxt/index.js.map +1 -1
- package/dist/adapters/sveltekit/index.js +1 -1
- package/dist/adapters/sveltekit/index.js.map +1 -1
- package/dist/codegen-astro.js +1 -1
- package/dist/codegen-astro.js.map +1 -1
- 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 +84 -1
- package/dist/codegen.d.ts +84 -1
- 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 +19 -0
- package/dist/core.d.ts +19 -0
- package/dist/core.js +1 -1
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +72 -1
- package/dist/index.d.ts +72 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -634,6 +634,25 @@ declare class LivePreviewClient {
|
|
|
634
634
|
* roll back, and be retried by a later call.
|
|
635
635
|
*/
|
|
636
636
|
start(): boolean;
|
|
637
|
+
/**
|
|
638
|
+
* Release the message ingress while keeping this client usable.
|
|
639
|
+
*
|
|
640
|
+
* For the document lifecycle, not for teardown: a back/forward-cache restore
|
|
641
|
+
* does not re-run module scripts, so a client that stays attached across
|
|
642
|
+
* `pagehide` returns bound to a frozen page and silently stops updating.
|
|
643
|
+
* Plugins, renderers and transforms survive; `resume()` brings the same
|
|
644
|
+
* client back. Returns `false` when there was nothing running to suspend.
|
|
645
|
+
*/
|
|
646
|
+
suspend(): boolean;
|
|
647
|
+
/**
|
|
648
|
+
* Reacquire after `suspend()`.
|
|
649
|
+
*
|
|
650
|
+
* Deliberately the same path as `start()`: a restored document needs the
|
|
651
|
+
* cache rebuilt, the observers rebound and the handshake rebroadcast, which
|
|
652
|
+
* is exactly what starting does. Returns `false` for a destroyed client or
|
|
653
|
+
* one that was never started.
|
|
654
|
+
*/
|
|
655
|
+
resume(): boolean;
|
|
637
656
|
/**
|
|
638
657
|
* Stop the runtime and tear down every plugin. Idempotent.
|
|
639
658
|
*/
|
|
@@ -664,6 +683,58 @@ declare class LivePreviewClient {
|
|
|
664
683
|
*/
|
|
665
684
|
declare function initLivePreview(config?: LivePreviewClientConfig): LivePreviewClient | null;
|
|
666
685
|
|
|
686
|
+
/**
|
|
687
|
+
* Document-lifecycle owner for the live-preview client.
|
|
688
|
+
*
|
|
689
|
+
* The runtime learns about messages, not about navigation. Two browser
|
|
690
|
+
* behaviours make that gap visible, and both are silent:
|
|
691
|
+
*
|
|
692
|
+
* - A **back/forward-cache restore** does not re-run module scripts. A client
|
|
693
|
+
* that stays attached across `pagehide` comes back bound to a document the
|
|
694
|
+
* browser froze and thawed, and simply stops updating.
|
|
695
|
+
* - A **soft navigation** replaces page content without a new document. The
|
|
696
|
+
* bindings the cache holds are gone, and nothing tells the runtime.
|
|
697
|
+
*
|
|
698
|
+
* This binds both to `suspend()`/`resume()`/`refreshCache()` in one place, so a
|
|
699
|
+
* consumer that uses no framework adapter can own the lifecycle with one call
|
|
700
|
+
* instead of re-deriving it — which is what every integration has had to do so
|
|
701
|
+
* far.
|
|
702
|
+
*
|
|
703
|
+
* @module @client/navigation-lifecycle
|
|
704
|
+
*/
|
|
705
|
+
/** The part of the client this owner drives. */
|
|
706
|
+
interface NavigationLifecycleTarget {
|
|
707
|
+
suspend(): boolean;
|
|
708
|
+
resume(): boolean;
|
|
709
|
+
refreshCache(): void;
|
|
710
|
+
}
|
|
711
|
+
interface NavigationLifecycleOptions {
|
|
712
|
+
/**
|
|
713
|
+
* Event target for `pagehide`/`pageshow`. Defaults to `window`.
|
|
714
|
+
*
|
|
715
|
+
* These fire on the window, not the document, and only there — binding them
|
|
716
|
+
* anywhere else silently never fires.
|
|
717
|
+
*/
|
|
718
|
+
readonly windowTarget?: EventTarget;
|
|
719
|
+
/**
|
|
720
|
+
* Event target for soft-navigation events. Defaults to `document`.
|
|
721
|
+
*/
|
|
722
|
+
readonly documentTarget?: EventTarget;
|
|
723
|
+
/**
|
|
724
|
+
* Soft-navigation events after which the DOM has been replaced and the
|
|
725
|
+
* binding cache has to be rebuilt — for example `astro:page-load`.
|
|
726
|
+
*
|
|
727
|
+
* Empty by default: the package cannot know which framework is present, and
|
|
728
|
+
* guessing would either miss the event or rebuild on an unrelated one.
|
|
729
|
+
*/
|
|
730
|
+
readonly softNavigationEvents?: readonly string[];
|
|
731
|
+
}
|
|
732
|
+
/**
|
|
733
|
+
* Bind the document lifecycle. Returns an unbind function; calling it twice is
|
|
734
|
+
* harmless.
|
|
735
|
+
*/
|
|
736
|
+
declare function bindNavigationLifecycle(target: NavigationLifecycleTarget, options?: NavigationLifecycleOptions): () => void;
|
|
737
|
+
|
|
667
738
|
interface RuntimeBuildInfo {
|
|
668
739
|
readonly generatedAt: string;
|
|
669
740
|
readonly size: number;
|
|
@@ -1925,4 +1996,4 @@ interface PreviewBindings {
|
|
|
1925
1996
|
*/
|
|
1926
1997
|
declare function createPreviewBindings(options: PreviewBindingsOptions): PreviewBindings;
|
|
1927
1998
|
|
|
1928
|
-
export { type AnalyticsSnapshot, type BindOptions, type BlockRenderContext, type BlockRenderer, type CachedElement, type CspDirectiveMerge, type DocumentSaveHandler, type DocumentSavePluginOptions, type DocumentSaveStrategy, EventEmitter, type EventHandler, type FetchPreviewDocumentOptions, type FetchPreviewGlobalOptions, type FieldBindingAttributes, type FieldName, type FieldPath, type FieldRenderer, type FieldTransform, type FieldType, type FrameAncestorsOptions, type InlineScriptConfig, LIBRARY_PROTOCOL_VERSION, type LexicalNode, type LexicalRoot, LivePreviewClient, type LivePreviewClientConfig, type LivePreviewEventMap, type LivePreviewPlugin, OriginDetector, type OwnerBindingAttributes, type PayloadFieldSchema, type PayloadFieldType, type PayloadLivePreviewData, type PayloadLivePreviewMessage, type PayloadMedia, type PayloadRelationship, type PluginContext, type PluginDisposer, type PluginEvents, type PreviewBindings, type PreviewBindingsOptions, type PreviewFetchBaseOptions, type PreviewRequestLike, type PreviewRequestOptions, type PreviewWhere, type ProtocolCapability, type ProtocolNegotiation, type RenderContext, type SanitizerDocument, type SuppressedBinding, type Unsubscribe, VERSION, type ValueAt, bind, bindByPath, buildBuiltinRenderers, buildFrameAncestors, buildScriptSrcWithNonce, createAnalyticsPlugin, createPreviewBindings, debugPlugin, detectInitialLocale, documentSavePlugin, escapeHtml, escapeHtmlAttribute, fetchPreviewDocument, fetchPreviewGlobal, generateCspNonce, generateInlineScript, hasCapability, highlightPlugin, initLivePreview, isDevMode, isExternalHttpUrl, isInIframe, isInPopup, isInPreviewContext, isLexicalContent, isPreviewRequest, isSafeUrl, lexicalToHtml, lexicalToPlainText, mergeCspHeader, negotiateProtocol, registerBlockRenderer, registerBuiltinRenderer, runtimeBuildInfo, sanitizeHtml, setCspCrypto, setSanitizerDocument, wrapWithScriptTag };
|
|
1999
|
+
export { type AnalyticsSnapshot, type BindOptions, type BlockRenderContext, type BlockRenderer, type CachedElement, type CspDirectiveMerge, type DocumentSaveHandler, type DocumentSavePluginOptions, type DocumentSaveStrategy, EventEmitter, type EventHandler, type FetchPreviewDocumentOptions, type FetchPreviewGlobalOptions, type FieldBindingAttributes, type FieldName, type FieldPath, type FieldRenderer, type FieldTransform, type FieldType, type FrameAncestorsOptions, type InlineScriptConfig, LIBRARY_PROTOCOL_VERSION, type LexicalNode, type LexicalRoot, LivePreviewClient, type LivePreviewClientConfig, type LivePreviewEventMap, type LivePreviewPlugin, type NavigationLifecycleOptions, type NavigationLifecycleTarget, OriginDetector, type OwnerBindingAttributes, type PayloadFieldSchema, type PayloadFieldType, type PayloadLivePreviewData, type PayloadLivePreviewMessage, type PayloadMedia, type PayloadRelationship, type PluginContext, type PluginDisposer, type PluginEvents, type PreviewBindings, type PreviewBindingsOptions, type PreviewFetchBaseOptions, type PreviewRequestLike, type PreviewRequestOptions, type PreviewWhere, type ProtocolCapability, type ProtocolNegotiation, type RenderContext, type SanitizerDocument, type SuppressedBinding, type Unsubscribe, VERSION, type ValueAt, bind, bindByPath, bindNavigationLifecycle, buildBuiltinRenderers, buildFrameAncestors, buildScriptSrcWithNonce, createAnalyticsPlugin, createPreviewBindings, debugPlugin, detectInitialLocale, documentSavePlugin, escapeHtml, escapeHtmlAttribute, fetchPreviewDocument, fetchPreviewGlobal, generateCspNonce, generateInlineScript, hasCapability, highlightPlugin, initLivePreview, isDevMode, isExternalHttpUrl, isInIframe, isInPopup, isInPreviewContext, isLexicalContent, isPreviewRequest, isSafeUrl, lexicalToHtml, lexicalToPlainText, mergeCspHeader, negotiateProtocol, registerBlockRenderer, registerBuiltinRenderer, runtimeBuildInfo, sanitizeHtml, setCspCrypto, setSanitizerDocument, wrapWithScriptTag };
|
package/dist/index.d.ts
CHANGED
|
@@ -634,6 +634,25 @@ declare class LivePreviewClient {
|
|
|
634
634
|
* roll back, and be retried by a later call.
|
|
635
635
|
*/
|
|
636
636
|
start(): boolean;
|
|
637
|
+
/**
|
|
638
|
+
* Release the message ingress while keeping this client usable.
|
|
639
|
+
*
|
|
640
|
+
* For the document lifecycle, not for teardown: a back/forward-cache restore
|
|
641
|
+
* does not re-run module scripts, so a client that stays attached across
|
|
642
|
+
* `pagehide` returns bound to a frozen page and silently stops updating.
|
|
643
|
+
* Plugins, renderers and transforms survive; `resume()` brings the same
|
|
644
|
+
* client back. Returns `false` when there was nothing running to suspend.
|
|
645
|
+
*/
|
|
646
|
+
suspend(): boolean;
|
|
647
|
+
/**
|
|
648
|
+
* Reacquire after `suspend()`.
|
|
649
|
+
*
|
|
650
|
+
* Deliberately the same path as `start()`: a restored document needs the
|
|
651
|
+
* cache rebuilt, the observers rebound and the handshake rebroadcast, which
|
|
652
|
+
* is exactly what starting does. Returns `false` for a destroyed client or
|
|
653
|
+
* one that was never started.
|
|
654
|
+
*/
|
|
655
|
+
resume(): boolean;
|
|
637
656
|
/**
|
|
638
657
|
* Stop the runtime and tear down every plugin. Idempotent.
|
|
639
658
|
*/
|
|
@@ -664,6 +683,58 @@ declare class LivePreviewClient {
|
|
|
664
683
|
*/
|
|
665
684
|
declare function initLivePreview(config?: LivePreviewClientConfig): LivePreviewClient | null;
|
|
666
685
|
|
|
686
|
+
/**
|
|
687
|
+
* Document-lifecycle owner for the live-preview client.
|
|
688
|
+
*
|
|
689
|
+
* The runtime learns about messages, not about navigation. Two browser
|
|
690
|
+
* behaviours make that gap visible, and both are silent:
|
|
691
|
+
*
|
|
692
|
+
* - A **back/forward-cache restore** does not re-run module scripts. A client
|
|
693
|
+
* that stays attached across `pagehide` comes back bound to a document the
|
|
694
|
+
* browser froze and thawed, and simply stops updating.
|
|
695
|
+
* - A **soft navigation** replaces page content without a new document. The
|
|
696
|
+
* bindings the cache holds are gone, and nothing tells the runtime.
|
|
697
|
+
*
|
|
698
|
+
* This binds both to `suspend()`/`resume()`/`refreshCache()` in one place, so a
|
|
699
|
+
* consumer that uses no framework adapter can own the lifecycle with one call
|
|
700
|
+
* instead of re-deriving it — which is what every integration has had to do so
|
|
701
|
+
* far.
|
|
702
|
+
*
|
|
703
|
+
* @module @client/navigation-lifecycle
|
|
704
|
+
*/
|
|
705
|
+
/** The part of the client this owner drives. */
|
|
706
|
+
interface NavigationLifecycleTarget {
|
|
707
|
+
suspend(): boolean;
|
|
708
|
+
resume(): boolean;
|
|
709
|
+
refreshCache(): void;
|
|
710
|
+
}
|
|
711
|
+
interface NavigationLifecycleOptions {
|
|
712
|
+
/**
|
|
713
|
+
* Event target for `pagehide`/`pageshow`. Defaults to `window`.
|
|
714
|
+
*
|
|
715
|
+
* These fire on the window, not the document, and only there — binding them
|
|
716
|
+
* anywhere else silently never fires.
|
|
717
|
+
*/
|
|
718
|
+
readonly windowTarget?: EventTarget;
|
|
719
|
+
/**
|
|
720
|
+
* Event target for soft-navigation events. Defaults to `document`.
|
|
721
|
+
*/
|
|
722
|
+
readonly documentTarget?: EventTarget;
|
|
723
|
+
/**
|
|
724
|
+
* Soft-navigation events after which the DOM has been replaced and the
|
|
725
|
+
* binding cache has to be rebuilt — for example `astro:page-load`.
|
|
726
|
+
*
|
|
727
|
+
* Empty by default: the package cannot know which framework is present, and
|
|
728
|
+
* guessing would either miss the event or rebuild on an unrelated one.
|
|
729
|
+
*/
|
|
730
|
+
readonly softNavigationEvents?: readonly string[];
|
|
731
|
+
}
|
|
732
|
+
/**
|
|
733
|
+
* Bind the document lifecycle. Returns an unbind function; calling it twice is
|
|
734
|
+
* harmless.
|
|
735
|
+
*/
|
|
736
|
+
declare function bindNavigationLifecycle(target: NavigationLifecycleTarget, options?: NavigationLifecycleOptions): () => void;
|
|
737
|
+
|
|
667
738
|
interface RuntimeBuildInfo {
|
|
668
739
|
readonly generatedAt: string;
|
|
669
740
|
readonly size: number;
|
|
@@ -1925,4 +1996,4 @@ interface PreviewBindings {
|
|
|
1925
1996
|
*/
|
|
1926
1997
|
declare function createPreviewBindings(options: PreviewBindingsOptions): PreviewBindings;
|
|
1927
1998
|
|
|
1928
|
-
export { type AnalyticsSnapshot, type BindOptions, type BlockRenderContext, type BlockRenderer, type CachedElement, type CspDirectiveMerge, type DocumentSaveHandler, type DocumentSavePluginOptions, type DocumentSaveStrategy, EventEmitter, type EventHandler, type FetchPreviewDocumentOptions, type FetchPreviewGlobalOptions, type FieldBindingAttributes, type FieldName, type FieldPath, type FieldRenderer, type FieldTransform, type FieldType, type FrameAncestorsOptions, type InlineScriptConfig, LIBRARY_PROTOCOL_VERSION, type LexicalNode, type LexicalRoot, LivePreviewClient, type LivePreviewClientConfig, type LivePreviewEventMap, type LivePreviewPlugin, OriginDetector, type OwnerBindingAttributes, type PayloadFieldSchema, type PayloadFieldType, type PayloadLivePreviewData, type PayloadLivePreviewMessage, type PayloadMedia, type PayloadRelationship, type PluginContext, type PluginDisposer, type PluginEvents, type PreviewBindings, type PreviewBindingsOptions, type PreviewFetchBaseOptions, type PreviewRequestLike, type PreviewRequestOptions, type PreviewWhere, type ProtocolCapability, type ProtocolNegotiation, type RenderContext, type SanitizerDocument, type SuppressedBinding, type Unsubscribe, VERSION, type ValueAt, bind, bindByPath, buildBuiltinRenderers, buildFrameAncestors, buildScriptSrcWithNonce, createAnalyticsPlugin, createPreviewBindings, debugPlugin, detectInitialLocale, documentSavePlugin, escapeHtml, escapeHtmlAttribute, fetchPreviewDocument, fetchPreviewGlobal, generateCspNonce, generateInlineScript, hasCapability, highlightPlugin, initLivePreview, isDevMode, isExternalHttpUrl, isInIframe, isInPopup, isInPreviewContext, isLexicalContent, isPreviewRequest, isSafeUrl, lexicalToHtml, lexicalToPlainText, mergeCspHeader, negotiateProtocol, registerBlockRenderer, registerBuiltinRenderer, runtimeBuildInfo, sanitizeHtml, setCspCrypto, setSanitizerDocument, wrapWithScriptTag };
|
|
1999
|
+
export { type AnalyticsSnapshot, type BindOptions, type BlockRenderContext, type BlockRenderer, type CachedElement, type CspDirectiveMerge, type DocumentSaveHandler, type DocumentSavePluginOptions, type DocumentSaveStrategy, EventEmitter, type EventHandler, type FetchPreviewDocumentOptions, type FetchPreviewGlobalOptions, type FieldBindingAttributes, type FieldName, type FieldPath, type FieldRenderer, type FieldTransform, type FieldType, type FrameAncestorsOptions, type InlineScriptConfig, LIBRARY_PROTOCOL_VERSION, type LexicalNode, type LexicalRoot, LivePreviewClient, type LivePreviewClientConfig, type LivePreviewEventMap, type LivePreviewPlugin, type NavigationLifecycleOptions, type NavigationLifecycleTarget, OriginDetector, type OwnerBindingAttributes, type PayloadFieldSchema, type PayloadFieldType, type PayloadLivePreviewData, type PayloadLivePreviewMessage, type PayloadMedia, type PayloadRelationship, type PluginContext, type PluginDisposer, type PluginEvents, type PreviewBindings, type PreviewBindingsOptions, type PreviewFetchBaseOptions, type PreviewRequestLike, type PreviewRequestOptions, type PreviewWhere, type ProtocolCapability, type ProtocolNegotiation, type RenderContext, type SanitizerDocument, type SuppressedBinding, type Unsubscribe, VERSION, type ValueAt, bind, bindByPath, bindNavigationLifecycle, buildBuiltinRenderers, buildFrameAncestors, buildScriptSrcWithNonce, createAnalyticsPlugin, createPreviewBindings, debugPlugin, detectInitialLocale, documentSavePlugin, escapeHtml, escapeHtmlAttribute, fetchPreviewDocument, fetchPreviewGlobal, generateCspNonce, generateInlineScript, hasCapability, highlightPlugin, initLivePreview, isDevMode, isExternalHttpUrl, isInIframe, isInPopup, isInPreviewContext, isLexicalContent, isPreviewRequest, isSafeUrl, lexicalToHtml, lexicalToPlainText, mergeCspHeader, negotiateProtocol, registerBlockRenderer, registerBuiltinRenderer, runtimeBuildInfo, sanitizeHtml, setCspCrypto, setSanitizerDocument, wrapWithScriptTag };
|