import type { NavigationBridge, NavigationBridgeConfig, NavigateOptions, NavigationStore, ResolvedSegment } from "./types.js"; import type { EventController, NavigationHandle } from "./event-controller.js"; /** * Options for committing a navigation transaction */ interface CommitOptions { url: string; segmentIds: string[]; segments: ResolvedSegment[]; replace?: boolean; scroll?: boolean; /** User-provided state to store in history.state */ state?: unknown; /** If true, only update store without changing URL/history (for server actions) */ storeOnly?: boolean; /** If true, this is an intercept route - store in history.state for popstate handling */ intercept?: boolean; /** Source URL where the intercept was triggered from (stored in history.state) */ interceptSourceUrl?: string; /** If true, only update cache without touching store or history (for background stale revalidation) */ cacheOnly?: boolean; } /** * Options that can override the pre-configured commit settings */ interface BoundCommitOverrides { /** Override scroll behavior (e.g., disable for intercepts) */ scroll?: boolean; /** Override replace behavior (e.g., force replace for intercepts) */ replace?: boolean; /** Override user-provided state */ state?: unknown; /** Mark this as an intercept route */ intercept?: boolean; /** Source URL where intercept was triggered from */ interceptSourceUrl?: string; /** If true, only update cache (for stale revalidation) */ cacheOnly?: boolean; } /** * Token for tracking an active stream - call end() when stream completes */ export interface StreamingToken { end(): void; } /** * Bound transaction with pre-configured commit options (without segmentIds/segments) */ export interface BoundTransaction { readonly currentUrl: string; /** Start streaming and get a token to end it when the stream completes */ startStreaming(): StreamingToken; commit(segmentIds: string[], segments: ResolvedSegment[], overrides?: BoundCommitOverrides): void; } /** * Navigation transaction for managing state during navigation * Uses the event controller handle for lifecycle management */ interface NavigationTransaction extends Disposable { /** Optimistically commit from cache - instant render before revalidation */ optimisticCommit(options: CommitOptions): void; /** Final commit with server data (or reconciliation after optimistic) */ commit(options: CommitOptions): void; with(options: Omit): BoundTransaction; /** The navigation handle from the event controller */ handle: NavigationHandle; } /** * Creates a navigation transaction that coordinates with the event controller. * Handles loading state transitions and cleanup on completion/abort. * * Supports optimistic navigation: render from cache immediately, * then revalidate in background and reconcile if data changed. */ declare function createNavigationTransaction(store: NavigationStore, eventController: EventController, url: string, options?: NavigateOptions & { skipLoadingState?: boolean; }): NavigationTransaction; export { createNavigationTransaction }; /** * Extended configuration for navigation bridge with event controller */ export interface NavigationBridgeConfigWithController extends NavigationBridgeConfig { eventController: EventController; /** RSC version from initial payload metadata */ version?: string; } /** * Create a navigation bridge for handling client-side navigation * * The bridge coordinates all navigation operations: * - Link click interception * - Browser back/forward (popstate) * - Programmatic navigation * * Uses the event controller for reactive state management. * * @param config - Bridge configuration * @returns NavigationBridge instance */ export declare function createNavigationBridge(config: NavigationBridgeConfigWithController): NavigationBridge; export { createNavigationBridge as default }; //# sourceMappingURL=navigation-bridge.d.ts.map