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:
@@ -45,21 +45,26 @@ function serializeEffects(effects: any[]): any[] {
|
||||
* Convert tracks to serialized format
|
||||
*/
|
||||
function serializeTracks(tracks: Track[]): SerializedTrack[] {
|
||||
return tracks.map(track => ({
|
||||
id: track.id,
|
||||
name: track.name,
|
||||
color: track.color,
|
||||
volume: track.volume,
|
||||
pan: track.pan,
|
||||
muted: track.mute,
|
||||
soloed: track.solo,
|
||||
collapsed: track.collapsed,
|
||||
height: track.height,
|
||||
audioBuffer: track.audioBuffer ? serializeAudioBuffer(track.audioBuffer) : null,
|
||||
effects: serializeEffects(track.effectChain?.effects || []),
|
||||
automation: track.automation,
|
||||
recordEnabled: track.recordEnabled,
|
||||
}));
|
||||
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,
|
||||
name: track.name,
|
||||
color: track.color,
|
||||
volume: track.volume,
|
||||
pan: track.pan,
|
||||
muted: track.mute,
|
||||
soloed: track.solo,
|
||||
collapsed: track.collapsed,
|
||||
height: track.height,
|
||||
audioBuffer: track.audioBuffer ? serializeAudioBuffer(track.audioBuffer) : null,
|
||||
effects: serializeEffects(track.effectChain?.effects || []),
|
||||
automation,
|
||||
recordEnabled: track.recordEnabled,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user