Load and store project and asset files for Scratch 3.0
npm install scratch-storage


In your own Node.js environment/application:
``bash`
npm install https://github.com/scratchfoundation/scratch-storage.git
If you want to edit/play yourself (requires Git):
`bash`
git clone https://github.com/scratchfoundation/scratch-storage.git
cd scratch-storage
npm install
`html`
`js`
var storage = require('scratch-storage');
// continue to "Storage API Quick Start" section below
Once you have an instance of scratch-storage, add some web sources. For each source you'll need to provide a function`
to generate a URL for a supported type of asset:js`
/**
* @param {Asset} asset - calculate a URL for this asset.
* @returns {string} a URL to download a project asset (PNG, WAV, etc.)
*/
var getAssetUrl = function (asset) {
var assetUrlParts = [
'https://assets.example.com/path/to/assets/',
asset.assetId,
'.',
asset.dataFormat,
'/get/'
];
return assetUrlParts.join('');
};
Then, let the storage module know about your source:
`js`
storage.addWebStore(
[AssetType.ImageVector, AssetType.ImageBitmap, AssetType.Sound],
getAssetUrl);
If you're using ES6 you may be able to simplify all of the above quite a bit:
`jshttps://assets.example.com/path/to/assets/${asset.assetId}.${asset.dataFormat}/get/
storage.addWebStore(
[AssetType.ImageVector, AssetType.ImageBitmap, AssetType.Sound],
asset => );`
Once the storage module is aware of the sources you need, you can start loading assets:
`jssoundAsset
storage.load(AssetType.Sound, soundId).then(function (soundAsset) {
// is an Asset object. File contents are stored in soundAsset.data.`
});
If you'd like to use scratch-storage with scratch-vm you must "attach" the storage module to the VM:`js`
vm.attachStorage(storage);
To run all tests:
`bash`
npm test
To show test coverage:
`bash`
npm run coverage
In order to automatically determine the type of version bump necessary, semantic
release expects commit messages to be formatted following
conventional-changelog.
``
subject and body are your familiar commit subject and body. footer isBREAKING CHANGE
where you would include and ISSUES FIXED sections if
applicable.
type is one of:fix
* : A bug fix Causes a patch release (0.0.x)feat
* : A new feature Causes a minor release (0.x.0)docs
* : Documentation only changesstyle
* : Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)refactor
* : A code change that neither fixes a bug nor adds a featureperf
* : A code change that improves performance May or may not cause a minor release. It's not clear.test
* : Adding missing tests or correcting existing testsci
* : Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)chore
* : Other changes that don't modify src or test filesrevert
* : Reverts a previous commit
Use the commitizen CLI to make commits
formatted in this way:
`bash`
npm install -g commitizen
npm install
Now you're ready to make commits using git cz`.