Implement API to be used by autosaving

This method serializes the project
This commit is contained in:
Thomas Weber committed 2021-01-02 20:13:54 -06:00
1 parent 145014e5a7
commit ae615fe51e
1 file changed
+19
+19
View File
@@ -451,6 +451,25 @@ class VirtualMachine extends EventEmitter {
});
}
/**
* Serailize the project into a map of files without actually zipping the project.
* @returns {Record<string | Uint8Array>} Files of the project.
*/
saveProjectSb3DontZip () {
const soundDescs = serializeSounds(this.runtime);
const costumeDescs = serializeCostumes(this.runtime);
const projectJson = this.toJSON();
const files = {
'project.json': projectJson
};
for (const fileDesc of soundDescs.concat(costumeDescs)) {
files[fileDesc.fileName] = fileDesc.fileContent;
}
return files;
}
/*
* @type {Array<object>} Array of all costumes and sounds currently in the runtime
*/