saltfish
Version:
An interactive video-guided tour system for web applications
160 lines • 5.64 kB
TypeScript
import { VideoManager } from '../managers/VideoManager';
import { SaltfishEventName, EventHandler } from '../managers/EventManager';
import type { SaltfishConfig, PlaylistOptions } from '../types';
/**
* Main class for the Saltfish playlist Player
*/
export declare class SaltfishPlayer {
private static instance;
private shadowDOMManager;
videoManager: VideoManager;
private cursorManager;
private interactionManager;
private analyticsManager;
private sessionRecordingManager;
private sessionManager;
private buttonManager;
private transitionManager;
private triggerManager;
private eventManager;
private playlistManager;
private stepTimeoutManager;
private uiManager;
private playerView;
private dragManager;
private uiUpdaterUnsubscribe;
private eventUpdaterUnsubscribe;
private isInitialized;
private static prevState;
private static destroyTimeoutId;
private lastConfig;
private lastUserIdentification;
/**
* Creates a new Saltfish playlist Player instance
* @private Constructor is private to enforce singleton pattern
*/
private constructor();
/**
* Gets the singleton instance of the Saltfish playlist Player
*/
static getInstance(): SaltfishPlayer;
/**
* Gets the current sessionId (persistent across 30 minutes)
* @returns The current sessionId
*/
getSessionId(): string;
/**
* Gets the current runId (unique per playlist execution)
* @returns The current runId or null if no playlist is running
*/
getRunId(): string | null;
/**
* Initializes the Saltfish playlist Player
* @param config - Configuration options
*/
initialize(config: SaltfishConfig): Promise<void>;
/**
* Identifies the current user
* @param userId - User ID
* @param userData - Additional user data
*/
identifyUser(userId: string, userData?: any): void;
/**
* Identifies the current user anonymously (localStorage only, no backend communication)
* Automatically generates a persistent anonymous user ID stored in localStorage
* @param userData - Optional additional user data
*/
identifyAnonymous(userData?: any): void;
/**
* Fetches user data from the backend
* @param userId - User ID
* @param userData - Additional user data
*/
private fetchUserData;
/**
* Loads user data from localStorage for anonymous identification
* @param userId - User ID
* @param userData - Additional user data
*/
private loadAnonymousUserData;
/**
* Gets or creates a persistent anonymous user ID
* @returns A persistent anonymous user ID
*/
private getOrCreateAnonymousUserId;
/**
* Starts a new playlist
* @param playlistId - ID of the playlist to start
* @param options - Optional playback options including position, drag behavior, and starting step
* @param options.position - Position of the player on screen
* @param options.allowDrag - Whether the player can be dragged
* @param options.startNodeId - Optional step ID to start from instead of the manifest's default startStep
*
* If the player has been destroyed, it will automatically reinitialize using the last configuration
* before starting the playlist.
*/
startPlaylist(playlistId: string, options?: PlaylistOptions): Promise<void>;
/**
* Registers action handlers with the state machine
*/
private registerStateMachineActions;
/**
* Finds the URL of the next video in the playlist
* @param currentStep - The current step being played
* @returns The URL of the next video or null if no next video exists
*/
private findNextVideoUrl;
/**
* Gets the appropriate video URL for a step, preferring compressedVideoUrl if available
* @param step - The step to get the video URL for
* @returns The video URL to use (compressed if available, otherwise regular)
*/
private getVideoUrl;
/**
* Setup UI and Event updaters that subscribe to store changes
*/
private setupUpdaters;
/**
* Handles store state changes
*/
private handleStoreChanges;
/**
* Destroys the Saltfish playlist Player instance
*/
destroy(): void;
/**
* Handles completed state
*/
private handleCompletedState;
/**
* Registers an event listener to be called when the given eventName is triggered
* @param eventName - Name of event to listen for
* @param listener - Function to call when the event is triggered
*/
on<T extends SaltfishEventName>(eventName: T, listener: EventHandler<T>): void;
/**
* Removes an event listener for the given eventName
* @param eventName - Name of event to stop listening for
* @param listener - Function to remove
* @returns true if the listener was removed, false if it wasn't found
*/
off<T extends SaltfishEventName>(eventName: T, listener: EventHandler<T>): boolean;
/**
* Resets the current playlist to its initial state
*/
resetPlaylist(): void;
/**
* Cleans up the current playlist state
*/
private cleanupCurrentPlaylist;
/**
* Cleans up playlist-specific resources while keeping trigger monitoring active
*/
private cleanupPlaylist;
/**
* Updates the visibility of player controls based on the current state
* @param state - The current player state
*/
private updateControlsVisibility;
}
//# sourceMappingURL=SaltfishPlayer.d.ts.map