wave-roll
Version:
JavaScript Library for Comparative MIDI Piano-Roll Visualization
137 lines • 4.42 kB
TypeScript
import { AppState, StateManagerConfig } from "./types";
import type { OnsetMarkerStyle } from "@/types";
export declare class StateManager {
private state;
private config;
private readonly listeners;
private readonly fileVisibilityManager;
private readonly panHandlersManager;
constructor(config?: Partial<StateManagerConfig>);
private createInitialState;
getUIState(): AppState["ui"];
getState(): AppState;
getConfig(): StateManagerConfig;
getFilePanValuesRef(): Record<string, number>;
getFilePanStateHandlersRef(): Record<string, (pan: number | null) => void>;
getFileMuteStatesRef(): Record<string, boolean>;
/**
* Update UI state
*/
updateUIState(updates: Partial<AppState["ui"]>): void;
/**
* Update playback state
*/
updatePlaybackState(updates: Partial<AppState["playback"]>): void;
/**
* Update file visibility state
*/
updateFileVisibilityState(updates: Partial<AppState["fileVisibility"]>): void;
/**
* Update loop points state
*/
updateLoopPointsState(updates: Partial<AppState["loopPoints"]>): void;
/**
* Update pan/volume state
*/
updatePanVolumeState(updates: Partial<AppState["panVolume"]>): void;
/**
* Update visual state
*/
updateVisualState(updates: Partial<AppState["visual"]>): void;
/**
* Update evaluation state
*/
updateEvaluationState(updates: Partial<AppState["evaluation"]>): void;
/** Assign or update the onset marker style for a file. */
setOnsetMarkerForFile(fileId: string, style: OnsetMarkerStyle): void;
/** Get the onset marker style for a file, if any. */
getOnsetMarkerForFile(fileId: string): OnsetMarkerStyle | undefined;
/** Ensure a unique onset marker is assigned to the file if missing. */
ensureOnsetMarkerForFile(fileId: string): OnsetMarkerStyle;
/**
* Assign the next available unique onset marker to the file, even if it already has one.
* Cycles shapes (filled first, then outlined) and skips the current style when possible.
*/
assignNextUniqueOnsetMarker(fileId: string): OnsetMarkerStyle;
/**
* Preserve state during updates (batch operations)
*/
preserveStateForBatch<T>(operation: () => T): T;
/**
* Synchronize file visibility with a set of file IDs
*/
syncFileVisibility(fileIds: string[]): void;
/**
* Add file to visibility tracking
*/
addFileToVisibility(fileId: string): void;
/**
* Remove file from visibility tracking
*/
removeFileFromVisibility(fileId: string): void;
/**
* Toggle file visibility
*/
toggleFileVisibility(fileId: string): boolean;
/**
* Set pan value for a file
*/
setFilePanValue(fileId: string, panValue: number): void;
/**
* Register pan state handler for a file
*/
registerFilePanHandler(fileId: string, handler: (pan: number | null) => void): void;
/**
* Unregister pan state handler for a file
*/
unregisterFilePanHandler(fileId: string): void;
/**
* Synchronize pan values across all files
*/
syncPanValues(panValue: number | null): void;
/**
* Set mute state for a file
*/
setFileMuteState(fileId: string, muted: boolean): void;
/**
* Get mute state for a file
*/
getFileMuteState(fileId: string): boolean;
/**
* Set loop points with validation
*/
setLoopPoints(a: number | null, b: number | null): void;
/**
* Clear loop points
*/
clearLoopPoints(): void;
/**
* Set loop points from percentages
*/
setLoopPointsFromPercentages(aPercent: number | null, bPercent: number | null): void;
/**
* Update configuration
*/
updateConfig(updates: Partial<StateManagerConfig>): void;
/**
* Reset state to initial values
*/
resetState(): void;
/**
* Register state change callback
*/
onStateChange(callback: () => void): void;
/**
* Unregister state change callback
*/
offStateChange(callback: () => void): void;
/**
* Notify all registered callbacks of state change
*/
private notify;
}
/**
* Create a new state manager instance
*/
export declare function createStateManager(config?: Partial<StateManagerConfig>): StateManager;
//# sourceMappingURL=state-manager.d.ts.map