UNPKG

saltfish

Version:

An interactive video-guided tour system for web applications

143 lines 5.53 kB
import type { Step, ResettableManager } from '../types'; import type { TriggerManager } from './TriggerManager'; /** * Manages transitions between steps in the Saltfish playlist Player * Serves as a single source of truth for determining when to move to the next step */ export declare class TransitionManager implements ResettableManager { private activeTransitions; private waitingForInteraction; private isStateMachineValidating; private triggerManager; private beforeUnloadHandler; constructor(); /** * Sets the TriggerManager reference for coordinating playlist triggers * @param triggerManager - The TriggerManager instance */ setTriggerManager(triggerManager: TriggerManager): void; /** * Monitors history pushState and replaceState methods to detect SPA navigation */ private monitorHistoryChanges; /** * Handles URL changes by checking active URL path transitions and playlist triggers */ private handleURLChange; /** * Sets up transitions for a step * @param step - The step to set up transitions for * @param triggerImmediately - Whether to immediately trigger non-interaction transitions * @param skipTimeouts - Whether to skip setting up timeout transitions (useful for manual policy steps) */ setupTransitions(step: Step, triggerImmediately?: boolean, skipTimeouts?: boolean): void; /** * Sets up DOM click transitions * @param transition - The transition configuration */ private setupDOMClickTransition; /** * Sets up timeout transitions * @param transition - The transition configuration * @param triggerImmediately - Whether to trigger immediately */ private setupTimeoutTransition; /** * Sets up URL path transitions * @param transition - The transition configuration */ private setupURLPathTransition; /** * Saves pending navigation data for cross-page URL transitions * This enables resuming from the correct step after a hard page refresh * @param urlPattern - The URL pattern to match * @param nextStepId - The step ID to navigate to */ private savePendingNavigation; /** * Sets up beforeunload handler as backup for cross-page URL transitions * This ensures pending navigation is saved even if the page unloads unexpectedly * @param urlPattern - The URL pattern to match * @param nextStepId - The step ID to navigate to */ private setupBeforeUnloadHandler; /** * Removes the beforeunload handler if it exists */ private removeBeforeUnloadHandler; /** * Checks if the current URL path matches a pattern */ private isURLPathMatch; /** * Handles URL requirement validation failure by exiting and closing the playlist * @param stepId - The step ID that failed validation * @param urlRequirement - The URL requirement that was not met */ private handleUrlRequirementFailure; /** * Validates the URL requirement for the current step (immediate, no retries) * Used for external navigation detection - should close immediately if URL doesn't match * @returns boolean - true if validation passes or no requirement exists, false if validation fails */ validateCurrentStepUrl(): boolean; /** * Triggers a transition to a new step * @param nextStepId - The ID of the step to transition to */ triggerTransition(nextStepId: string): void; /** * Triggers a transition with progress coordination to ensure state is saved before page navigation * @param nextStepId - The ID of the step to transition to * @returns Promise<boolean> - True if transition was successful, false otherwise */ private triggerTransitionWithProgress; /** * Cleans up all active transitions */ cleanupTransitions(): void; /** * Sets the waiting for interaction state * @param isWaiting - Whether the player is waiting for interaction */ setWaitingForInteraction(isWaiting: boolean): void; /** * Checks if the player is waiting for interaction * @returns Whether the player is waiting for interaction */ isWaitingForInteraction(): boolean; /** * Resets the transition manager to initial state for reuse */ reset(): void; /** * Marks the start of StateMachineActionHandler validation to prevent race conditions * TransitionManager will skip validation while this flag is set */ startStateMachineValidation(): void; /** * Marks the end of StateMachineActionHandler validation */ endStateMachineValidation(): void; /** * Destroys the transition manager and cleans up resources */ destroy(): void; /** * Sets up DOM element visible transitions * @param transition - The transition configuration */ private setupDOMElementVisibleTransition; /** * Re-dispatches a click event to allow original page behavior after our transition logic completes * @param originalEvent - The original click event that was intercepted */ private reDispatchClick; /** * Determines if clicking an element will likely cause a hard page refresh * @param element - The target element that was clicked * @returns true if the click will likely cause a hard refresh, false otherwise */ private willCauseHardRefresh; } //# sourceMappingURL=TransitionManager.d.ts.map