mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 23:12:24 -05:00
Return extension ids from serializeBlocks instead of modifying Set passed to it
This commit is contained in:
parent
15de2eaa68
commit
17679340f9
1 changed files with 7 additions and 8 deletions
|
@ -272,12 +272,13 @@ const compressInputTree = function (block, blocks) {
|
||||||
* Serialize the given blocks object (representing all the blocks for the target
|
* Serialize the given blocks object (representing all the blocks for the target
|
||||||
* currently being serialized.)
|
* currently being serialized.)
|
||||||
* @param {object} blocks The blocks to be serialized
|
* @param {object} blocks The blocks to be serialized
|
||||||
* @param {Set} extensionIDs Set of extension ids
|
* @return {Array} An array of the serialized blocks with compressed inputs and
|
||||||
* @return {object} The serialized blocks with compressed inputs and compressed
|
* compressed primitives and the list of all extension IDs present
|
||||||
* primitives.
|
* in the serialized blocks.
|
||||||
*/
|
*/
|
||||||
const serializeBlocks = function (blocks, extensionIDs) {
|
const serializeBlocks = function (blocks) {
|
||||||
const obj = Object.create(null);
|
const obj = Object.create(null);
|
||||||
|
const extensionIDs = new Set();
|
||||||
for (const blockID in blocks) {
|
for (const blockID in blocks) {
|
||||||
if (!blocks.hasOwnProperty(blockID)) continue;
|
if (!blocks.hasOwnProperty(blockID)) continue;
|
||||||
obj[blockID] = serializeBlock(blocks[blockID], blocks);
|
obj[blockID] = serializeBlock(blocks[blockID], blocks);
|
||||||
|
@ -314,7 +315,7 @@ const serializeBlocks = function (blocks, extensionIDs) {
|
||||||
delete obj[blockID];
|
delete obj[blockID];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return obj;
|
return [obj, Array.from(extensionIDs)];
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -422,15 +423,13 @@ const serializeComments = function (comments) {
|
||||||
*/
|
*/
|
||||||
const serializeTarget = function (target) {
|
const serializeTarget = function (target) {
|
||||||
const obj = Object.create(null);
|
const obj = Object.create(null);
|
||||||
const extensionIDs = new Set();
|
|
||||||
obj.isStage = target.isStage;
|
obj.isStage = target.isStage;
|
||||||
obj.name = obj.isStage ? 'Stage' : target.name;
|
obj.name = obj.isStage ? 'Stage' : target.name;
|
||||||
const vars = serializeVariables(target.variables);
|
const vars = serializeVariables(target.variables);
|
||||||
obj.variables = vars.variables;
|
obj.variables = vars.variables;
|
||||||
obj.lists = vars.lists;
|
obj.lists = vars.lists;
|
||||||
obj.broadcasts = vars.broadcasts;
|
obj.broadcasts = vars.broadcasts;
|
||||||
obj.blocks = serializeBlocks(target.blocks, extensionIDs);
|
[obj.blocks, obj.extensions] = serializeBlocks(target.blocks);
|
||||||
obj.extensions = Array.from(extensionIDs);
|
|
||||||
obj.comments = serializeComments(target.comments);
|
obj.comments = serializeComments(target.comments);
|
||||||
obj.currentCostume = target.currentCostume;
|
obj.currentCostume = target.currentCostume;
|
||||||
obj.costumes = target.costumes.map(serializeCostume);
|
obj.costumes = target.costumes.map(serializeCostume);
|
||||||
|
|
Loading…
Reference in a new issue