mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-06-04 09:33:57 -04:00
Tests and cleanup of addSprite3 so that .sprite3 format does not need to be nested inside an extra {targets: ...}
This commit is contained in:
parent
9cc34d7406
commit
55352e88b1
7 changed files with 105 additions and 14 deletions
src/serialization
|
@ -871,15 +871,17 @@ const parseScratchObject = function (object, runtime, extensions, zip) {
|
|||
* @param {object} json - JSON representation of a VM runtime.
|
||||
* @param {Runtime} runtime - Runtime instance
|
||||
* @param {JSZip} zip - Sb3 file describing this project (to load assets from)
|
||||
* @param {boolean} isSingleSprite - If true treat as single sprite, else treat as whole project
|
||||
* @returns {Promise.<ImportedProject>} Promise that resolves to the list of targets after the project is deserialized
|
||||
*/
|
||||
const deserialize = function (json, runtime, zip) {
|
||||
const deserialize = function (json, runtime, zip, isSingleSprite) {
|
||||
const extensions = {
|
||||
extensionIDs: new Set(),
|
||||
extensionURLs: new Map()
|
||||
};
|
||||
return Promise.all(
|
||||
(json.targets || []).map(target => parseScratchObject(target, runtime, extensions, zip))
|
||||
((isSingleSprite ? [json] : json.targets) || []).map(target =>
|
||||
parseScratchObject(target, runtime, extensions, zip))
|
||||
).then(targets => ({
|
||||
targets,
|
||||
extensions
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue