/** * Shared document navigation lifecycle events for browser runtimes. * * @remarks * `eco:before-swap`, `eco:after-swap`, and `eco:page-load` are the public * contract consumed by dev tooling, global injectors, and layout scripts. * Dispatch helpers live here so browser-router and react-router stay aligned. * * @module */ import type { EcoNavigationDirection } from './navigation-coordinator.js'; export declare const ECO_NAVIGATION_LIFECYCLE_EVENTS: { readonly BEFORE_SWAP: "eco:before-swap"; readonly AFTER_SWAP: "eco:after-swap"; readonly PAGE_LOAD: "eco:page-load"; }; /** Base detail shared by navigation lifecycle events. */ export interface EcoNavigationEvent { url: URL; direction: EcoNavigationDirection; } /** Detail for the pre-commit lifecycle event. */ export interface EcoBeforeSwapEvent extends EcoNavigationEvent { newDocument: Document; reload: () => void; } /** Detail for the post-commit lifecycle event. */ export interface EcoAfterSwapEvent extends EcoNavigationEvent { } /** Typed document event map for navigation lifecycle listeners. */ export interface EcoNavigationLifecycleEventMap { 'eco:before-swap': CustomEvent; 'eco:after-swap': CustomEvent; 'eco:page-load': CustomEvent; } export type DispatchBeforeSwapResult = { requestedReload: boolean; }; export type SchedulePageLoadOptions = { isStale?: () => boolean; schedule?: (callback: FrameRequestCallback) => number; }; /** * Dispatches `eco:before-swap` and reports whether a listener requested reload. */ export declare function dispatchBeforeSwap(doc: Document, input: Omit): DispatchBeforeSwapResult; /** Dispatches `eco:after-swap`. */ export declare function dispatchAfterSwap(doc: Document, detail: EcoAfterSwapEvent): void; export type CompleteNavigationLifecycleOptions = SchedulePageLoadOptions; /** Dispatches `eco:after-swap` and schedules `eco:page-load`. */ export declare function completeNavigationLifecycle(doc: Document, detail: EcoNavigationEvent, options?: CompleteNavigationLifecycleOptions): void; /** * Schedules `eco:page-load` on the next animation frame unless navigation is stale. */ export declare function schedulePageLoad(doc: Document, detail: EcoNavigationEvent, options?: SchedulePageLoadOptions): void;