Skip to content

Save and Load sb3 projects #1564

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 9, 2018
Merged

Conversation

kchadha
Copy link
Contributor

@kchadha kchadha commented Mar 5, 2018

Proposed Changes

Save button (when manually enabled) downloads a zip containing:

  • the project's JSON
  • serialized sounds
  • serialized costumes

For sounds and costumes, this should include any edits made in the sound/costume editor respectively.

Load button (when manually enabled) should take in a zip that was previously downloaded via the save button, and the project should load and sounds and costumes should be up to date.

These changes depend on scratchfoundation/scratch-vm#964, and should not be merged until after that PR has been merged.

Reason for Changes

Towards a working SB3 Save and Load implementation.

Test Coverage

Existing tests pass, but integration tests for saving and loading need to be added in the near future.

Changes to come

  • Projects should save as '.sb3'
  • Compress downloaded projects
  • Remove unnecessary calls to storage caching (this includes implementing an indication that an asset is dirty, checking if loading locally vs. from server as a way of pre-emptively deciding whether assets should be cached to storage from imported file or if we should lookup the asset in the webstore)
  • Remove duplication of asset metadata between vm and storage (this includes duplication of information in 'assetId' and 'md5' properties. Tracking these in two different ways causes bugs and confusion.
  • Allowing 'load' to load .sb2 and .sb files (filter out all other file extensions from the file system browser).
  • scratch-vm#194 & validation of project json based on sb3 spec

Copy link
Contributor

@cwillisf cwillisf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to my comments on scratchfoundation/scratch-vm#964, I think the jszip dependency should be in scratch-storage. Is that your plan in the long run?

The code looks good to me, other than that concern.

@kchadha
Copy link
Contributor Author

kchadha commented Mar 8, 2018

@cwillisf, I agree with removing the JSZip dependency from scratch-gui, as it's not strictly necessary. In regards to moving the JSZip dependency out of scratch-vm and into scratch-storage, I think that means that scratch-storage will have to keep the unpacked zip assets around until vm is done deserializing the project (and vm will subsequently make requests to scratch-storage to fetch the assets it needs). When the VM is done deserializing, it can tell storage to get rid of the zip. I think this way, we can make sure that storage is not doing unnecessary work of decoding extraneous files, and is also not storing large files forever. How does this sound?

…s functionality gets moved to scratch-storage).
@kchadha
Copy link
Contributor Author

kchadha commented Mar 8, 2018

@cwillisf, I removed the JSZip dependency out of here. VM now unpacks the zip for the short term. I will eventually move this functionality into scratch-storage if my above comment sounds like a good plan. =]

Copy link
Contributor

@cwillisf cwillisf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. Thanks!

Copy link
Contributor

@rschamp rschamp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, thanks @kchadha!

@kchadha kchadha merged commit d9f1333 into scratchfoundation:develop Mar 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants