mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-06-14 06:21:14 -04:00
Modify serializeTarget function to take an extension set as an argument
This allows the serialize function to build a list of all extensions used
This commit is contained in:
parent
17679340f9
commit
026dd96491
1 changed files with 9 additions and 2 deletions
|
@ -419,17 +419,19 @@ const serializeComments = function (comments) {
|
|||
* Serialize the given target. Only serialize properties that are necessary
|
||||
* for saving and loading this target.
|
||||
* @param {object} target The target to be serialized.
|
||||
* @param {Set} extensions A set of extensions to add extension IDs to
|
||||
* @return {object} A serialized representation of the given target.
|
||||
*/
|
||||
const serializeTarget = function (target) {
|
||||
const serializeTarget = function (target, extensions) {
|
||||
const obj = Object.create(null);
|
||||
let targetExtensions = [];
|
||||
obj.isStage = target.isStage;
|
||||
obj.name = obj.isStage ? 'Stage' : target.name;
|
||||
const vars = serializeVariables(target.variables);
|
||||
obj.variables = vars.variables;
|
||||
obj.lists = vars.lists;
|
||||
obj.broadcasts = vars.broadcasts;
|
||||
[obj.blocks, obj.extensions] = serializeBlocks(target.blocks);
|
||||
[obj.blocks, targetExtensions] = serializeBlocks(target.blocks);
|
||||
obj.comments = serializeComments(target.comments);
|
||||
obj.currentCostume = target.currentCostume;
|
||||
obj.costumes = target.costumes.map(serializeCostume);
|
||||
|
@ -448,6 +450,11 @@ const serializeTarget = function (target) {
|
|||
obj.draggable = target.draggable;
|
||||
obj.rotationStyle = target.rotationStyle;
|
||||
}
|
||||
|
||||
// Add found extensions to the extensions object
|
||||
targetExtensions.forEach(extensionId => {
|
||||
extensions.add(extensionId);
|
||||
});
|
||||
return obj;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue