mirror of
https://github.com/scratchfoundation/scratch-parser.git
synced 2025-08-28 22:18:45 -04:00
feat(schemas): add support for sprite files for 2.0 and 3.0
refactor schemas to support sprite2 and sprite3 files, while reusing rules in common with sb2 and sb3 files BREAKING CHANGE: Change to main API which now takes an additional boolean argument indicating whether a sprite or project is being validated
This commit is contained in:
parent
5daad968a4
commit
b808e7447f
11 changed files with 759 additions and 616 deletions
|
@ -4,11 +4,13 @@ var unzip = require('./unzip');
|
|||
* If input a buffer, transforms buffer into a UTF-8 string.
|
||||
* If input is encoded in zip or gzip format, the input will be extracted and decoded.
|
||||
* If input is a string, passes that string along to the given callback.
|
||||
* @param {boolean} isSprite Whether the input should be treated as
|
||||
* a sprite (true) or a whole project (false)
|
||||
* @param {Buffer | string} input Project data
|
||||
* @param {Function} callback Error or stringified project data
|
||||
* @return {void}
|
||||
*/
|
||||
module.exports = function (input, callback) {
|
||||
module.exports = function (isSprite, input, callback) {
|
||||
if (typeof input === 'string') {
|
||||
// Pass string to callback
|
||||
return callback(null, [input, null]);
|
||||
|
@ -46,5 +48,5 @@ module.exports = function (input, callback) {
|
|||
// Return error if legacy encoding detected
|
||||
if (isLegacy) return callback('Parser only supports Scratch 2.X and above');
|
||||
|
||||
unzip(input, isGZip, callback);
|
||||
unzip(isSprite, input, isGZip, callback);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue