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
|
* Convert tracks to serialized format
|
||||||
*/
|
*/
|
||||||
function serializeTracks(tracks: Track[]): SerializedTrack[] {
|
function serializeTracks(tracks: Track[]): SerializedTrack[] {
|
||||||
return tracks.map(track => ({
|
return tracks.map(track => {
|
||||||
id: track.id,
|
// Serialize automation by deep cloning to remove any functions
|
||||||
name: track.name,
|
const automation = track.automation ? JSON.parse(JSON.stringify(track.automation)) : { lanes: [], showAutomation: false };
|
||||||
color: track.color,
|
|
||||||
volume: track.volume,
|
return {
|
||||||
pan: track.pan,
|
id: track.id,
|
||||||
muted: track.mute,
|
name: track.name,
|
||||||
soloed: track.solo,
|
color: track.color,
|
||||||
collapsed: track.collapsed,
|
volume: track.volume,
|
||||||
height: track.height,
|
pan: track.pan,
|
||||||
audioBuffer: track.audioBuffer ? serializeAudioBuffer(track.audioBuffer) : null,
|
muted: track.mute,
|
||||||
effects: serializeEffects(track.effectChain?.effects || []),
|
soloed: track.solo,
|
||||||
automation: track.automation,
|
collapsed: track.collapsed,
|
||||||
recordEnabled: track.recordEnabled,
|
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