fix: serialize automation data to prevent DataCloneError

Deep clone automation data using JSON.parse(JSON.stringify()) to remove
any functions before saving to IndexedDB. This prevents DataCloneError
when trying to store non-serializable data.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-19 10:02:37 +01:00
parent 67abbb20cb
commit 1b41fca393

View File

@@ -45,7 +45,11 @@ function serializeEffects(effects: any[]): any[] {
* Convert tracks to serialized format * Convert tracks to serialized format
*/ */
function serializeTracks(tracks: Track[]): SerializedTrack[] { function serializeTracks(tracks: Track[]): SerializedTrack[] {
return tracks.map(track => ({ return tracks.map(track => {
// Serialize automation by deep cloning to remove any functions
const automation = track.automation ? JSON.parse(JSON.stringify(track.automation)) : { lanes: [], showAutomation: false };
return {
id: track.id, id: track.id,
name: track.name, name: track.name,
color: track.color, color: track.color,
@@ -57,9 +61,10 @@ function serializeTracks(tracks: Track[]): SerializedTrack[] {
height: track.height, height: track.height,
audioBuffer: track.audioBuffer ? serializeAudioBuffer(track.audioBuffer) : null, audioBuffer: track.audioBuffer ? serializeAudioBuffer(track.audioBuffer) : null,
effects: serializeEffects(track.effectChain?.effects || []), effects: serializeEffects(track.effectChain?.effects || []),
automation: track.automation, automation,
recordEnabled: track.recordEnabled, recordEnabled: track.recordEnabled,
})); };
});
} }
/** /**