src/virtual-machine.js
/**
     * @returns {string} Project in a Scratch 3.0 JSON representation.
     */
@returns {string} Project in a Scratch 3.0 JSON representation.
@returns { string } Project in a Scratch 3 . 0 JSON representation .
saveProjectSb3 () {
        const soundDescs = serializeSounds(this.runtime);
        const costumeDescs = serializeCostumes(this.runtime);
        const projectJson = this.toJSON();
        const zip = new JSZip();
        zip.file('project.json', projectJson);
        for (let i = 0; i < soundDescs.length; i++) {
            const currSound = soundDescs[i];
            zip.file(currSound.fileName, currSound.fileContent);
        }
        for (let i = 0; i < costumeDescs.length; i++) {
            const currCostume = costumeDescs[i];
            zip.file(currCostume.fileName, currCostume.fileContent);
        }
        return zip.generateAsync({type: 'blob'});
    }
saveProjectSb3 ( ) { const soundDescs = serializeSounds ( this . runtime ) ; const costumeDescs = serializeCostumes ( this . runtime ) ; const projectJson = this . toJSON ( ) ; const zip = new JSZip ( ) ; zip . file ( 'project.json' , projectJson ) ; for ( let i = 0 ; i < soundDescs . length ; i ++ ) { const currSound = soundDescs [ i ] ; zip . file ( currSound . fileName , currSound . fileContent ) ; } for ( let i = 0 ; i < costumeDescs . length ; i ++ ) { const currCostume = costumeDescs [ i ] ; zip . file ( currCostume . fileName , currCostume . fileContent ) ; } return zip . generateAsync ( { type : 'blob' } ) ; }
@returns {string} Project in a Scratch 3.0 JSON representation.
@returns { string } Project in a Scratch 3 . 0 JSON representation .
// Put everything in a zip file // TODO compression?