I noticed that when using JSON serialization in the workspace, the backpack now includes its state as part of the workspace serialization. For example it looks like this:
{
"blocks": [],
"backpack": [/* backpack state */]
}
In my use case, the backpack follows the user, while the blockly workspaces are attached to documents that are shared by many people. So in other words, the backpack and workspace do not live together. So I'm finding myself doing this when serializing the workspace:
const state = Blockly.serialization.workspaces.save(workspace);
delete state['backpack'];
// Now save JSON.stringify(state) to the database
It also seems like Blockly doesn't like it when it gets hydrated with an empty JSON object, so I'm finding myself doing this:
if (!Object.keys(state).length) return;
Blockly.serialization.workspaces.load(state, workspace);
What was the rationale for storing backpack state with workspace serialization? Is there a way to opt out of this?
Thanks,
Johnny