Commit graph

50 commits

Author SHA1 Message Date
Andy O'Neill
41d1119728
Merge branch 'master' into backspace 2022-12-12 11:13:11 -05:00
Eric Rosenbaum
6dadf4c32a feat(sb3_schema.json): add origin field to meta info 2021-04-29 11:52:35 -04:00
apple502j
ca764efb0f
fix(parse): do not remove backslashes followed by b 2021-02-07 15:44:00 +09:00
Karishma Chadha
da7c3d12c1 refactor(unzip): remove support for gzip files
remove gzip dependency and support for gzip files as that was an unused code path

BREAKING CHANGE: Gzipped files are no longer supported as input to the parser.
2019-03-15 12:23:40 -04:00
Karishma Chadha
f73ef51038 fix(parse): remove backspace control characters from input to be parsed 2019-02-25 17:02:30 -05:00
chrisgarrity
750e866444 fix(unzip): handle sb2 files zipped with a folder
Uses a pattern to find the sprite or project json in a zipped folder or flat list of files.

Added tests for
* loading a sprite or project with a nested folder
* loading a file without a json

Fixes 
2019-02-07 11:24:33 +01:00
Karishma Chadha
bea66d6c2d fix(sb3_definitions): prevent sprites from being named _stage_
add test fixture and unit test for this change
2018-12-19 11:09:06 -05:00
Karishma Chadha
f8f8c33c64 fix(sb3_definitions): allow sprites to be named 'stage' or 'Stage'
2018-12-18 18:19:59 -05:00
Karishma Chadha
5a9d618a62 fix(sb3_definitions): fix comment position validation
A comment's x and y can be null. This will occur if a project is imported from 2.0, a sprite that is
not currently selected has comments, and that project is immediately saved in 3.0 without switching
to the other sprite that has comments.
2018-08-13 14:28:13 -04:00
Karishma Chadha
8eb3c30108 fix(sb3_definitions): fix validation error
fix a validation error where projects with certain custom procedure blocks were failing to load
2018-08-09 15:17:00 -04:00
Karishma Chadha
d2fe285a8c feat: add layerOrder informaiton to stage and sprites
Validates the new layerOrder property for the stage and the sprites, adds tests for validation.
2018-07-24 17:00:38 -04:00
Karishma Chadha
328b5a32da fix(sb3_definitions): add comment text character limit 2018-06-15 17:48:53 -04:00
Karishma Chadha
1f8a651ac8 feat(sb3_schema): add comment validation for sb3 2018-06-15 10:53:14 -04:00
Karishma Chadha
af53ae2ef2 fix(sprite2): sprite2 validation should allow sprites without sounds 2018-05-07 10:24:12 -04:00
Karishma Chadha
62b96fa49f refactor(sprite3_schema): clean up sprite3 representation 2018-05-03 16:20:54 -04:00
Karishma Chadha
78ce54e69f test: add new sprite2 test fixtures and integration tests
provide test coverage for sprite2 validation, and update sprite2_schema
2018-05-02 23:46:26 -04:00
Karishma Chadha
b0d1e46cd8 test(tests): fix up tests to accommodate new apis 2018-05-02 23:46:26 -04:00
Karishma Chadha
b808e7447f 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
2018-05-02 23:46:26 -04:00
Karishma Chadha
705d806e9c fix(schema): escape '.' in regex patterns 2018-04-11 19:03:56 -04:00
Karishma Chadha
61a0694c70 style($schema): Remove extra new line 2018-04-11 09:12:43 -04:00
Karishma Chadha
06352bb11e refactor($schema): Account for mp3 sounds when considering pattern for 'md5ext' property. 2018-04-10 17:02:50 -04:00
Karishma Chadha
6b002ec49a refactor($schema): Uhdoing validation workaround for orphan shadow issue in scratch-blocks and scrat
Variables and lists are the only primitives that should exist at the top level.
2018-04-10 16:46:37 -04:00
Karishma Chadha
6427bb242b refactor($schema): Replace underscore with hyphen in video state enum. 2018-04-10 16:41:28 -04:00
Karishma Chadha
cc8ca6181b refactor($schema): Fix minor issues with schema
Only accept lowercase file extensions (serialization should ensure that these are saved lowercase),
add description for some constants.
2018-04-10 16:39:12 -04:00
Karishma Chadha
4918c08049 refactor($schema): Update video state enum replacing hyphen with underscore. 2018-04-06 16:53:12 -04:00
Karishma Chadha
4ced34a70f refactor($schema): Update validation of variables now that default project has been updated to use n 2018-04-06 14:53:56 -04:00
Karishma Chadha
ede7cc8864 refactor($schema): Add tempo, volume, and video related state to sb3 schema. 2018-04-06 14:53:56 -04:00
Karishma Chadha
3e9a4cd788 refactor($schema): Fix some validation issues. 2018-04-06 14:53:56 -04:00
Karishma Chadha
7bd778d6b5 refactor($schema): Handle new block serialization compression of primitives.
Update validation of sb3 projects to account for new block serialization that includes
precompression of primitives like the math_number or text blocks.
2018-04-06 14:53:56 -04:00
Karishma Chadha
efbe1e4550 fix($schema): Fix another validation error with 2.0 projects. 'videoAlpha' is not always available b
2018-04-06 14:41:58 -04:00
Karishma Chadha
77b9bec8f8 fix($schema): Fix . 'penLayerMd5' can be null, and 'swfVersion' is not always provided in the inf
fix 
2018-04-06 13:50:33 -04:00
Karishma Chadha
9cf4d13ba8 feat($lib): Add support for gzipped inputs.
BREAKING CHANGE: Changes to the unzip library function. It takes an extra argument describing
whether the given input should be unpacked as a gzip file. Otherwise unpacks as a zip file.
2018-04-05 13:32:06 -04:00
Andrew Sliwinski
0fe264a05b refactor: Merge changes from upstream and resolve issues with interface and test coverage
Merges in changes from upstream and resolves issues with both the removal of the analysis library as
well as issues with lint rules and integration tests.
2018-03-24 11:36:17 -04:00
Andrew Sliwinski
f7cb29dff6 refactor: Extricates analysis from the scope of this project
Removes the ./lib/analysis module from the scope of this project along with all related
documentation and test coverage.

BREAKING CHANGE: Module no longer provides a _meta object with returned project object.
2018-03-24 11:19:01 -04:00
Andrew Sliwinski
e8369be7f5 refactor: Refactor library to use latest scratch eslint rules and update all dependencies
Refactors library to use latest scratch eslint rules. Updates all dependencies to latest versions
which requires minor changes to the JSON schema, tests, and supported engine (8+)

BREAKING CHANGE: Module no longer supports less than Node 8
2018-03-24 11:09:43 -04:00
Karishma Chadha
f9e47d2e29 fix($lib): Fix validator issues related to sb2 to sb3 conversion. 2018-03-23 17:48:29 -04:00
Karishma Chadha
a9c809ea4c fix($lib): Fix recorded sounds not being validated properly in sb3.
Recorded sounds were not being validated properly in sb3 because they were missing previously
required properties like 'rate' and 'sampleCount'. Removing these requirements.
2018-03-23 11:42:48 -04:00
Karishma Chadha
7dbc23c118 refactor($lib): Replace 'md5' property name with 'md5ext' in sb3 schema to reflect the ac 2018-03-23 09:38:57 -04:00
Karishma Chadha
faa0cdd30c refactor($lib): Remove runtime properties from sb3 schema that aren't ne 2018-03-23 09:38:34 -04:00
Karishma Chadha
663d6ee8e6 test($test): Rename zip to unzip for clarity. Add descriptive error message to
Added unit tests for unzip and added a user-friendly error message for unzip being unable to perform
its duties of extracting a project.json from the given input (zip).
2018-03-23 09:38:14 -04:00
Karishma Chadha
1501c957c7 refactor($sb3_schema): Fix up schema to be more permissive.
Field and input values can be strings or numbers. TopLevel property is not required of blocks. VM
version property should be more permissive and follow semantic release convention.
2018-03-23 09:38:14 -04:00
Karishma Chadha
e577e1caa3 refactor($sb3_schema): Allow capital letters in asset id ane md5 2018-03-23 09:38:14 -04:00
Karishma Chadha
7f8672dfbc refactor($lib): Add callback wrapper around JSZip promise-based interface. Refactor m
Refactor unpack and main exported function to return optional zip, if originally provided, in
addition to the validated project.

BREAKING CHANGE: Change to main api to return originally provided zip (or null if string was
provided) along with validated project, in a 2-element array.
2018-03-23 09:37:48 -04:00
Karishma Chadha
a74a97a906 feat($lib): Add sb3 schema for validation of Scratch 3.0 projects.
Added sb3 schema, renamed sb2 schema, and updated validate to check given input against both sb2 and
sb3 schemas. Validate appends a projectVersion to the given project with 2 or 3 if the given project
is valid against the corresponding schema. Validate now returns an object containing an error
message and both the sb2 and sb3 validation errors upon failure to validate against both schemas.

BREAKING CHANGE: Changes to validate API and what it returns (namely, error returned by validate is
no longer a string, but is now an object which contains an error message string as well as the sb2
errors and the sb3 errors). Users of this library function should expect to parse the given error to
figure out why validation failed.
2018-03-23 09:37:24 -04:00
Karishma Chadha
7e6cb8327a feat(unpack): Unpacker can now take string as input.
Allow unpacker to properly handle string as input, so that project json string (loaded from
scratch-storage) can be fed into scratch-parser.
2018-02-26 15:42:12 -05:00
Karishma Chadha
103db490a3 build(unpack): Swap out 3rd party zip library
Swapping out adm-zip dependency with jszip for use with the browser.
2018-02-25 21:19:51 -05:00
Andrew Sliwinski
9322967b5c fix($schema): Removes 'sounds' from required array in JSON schema
Removes 'sounds' from required array in JSON schema as to resolve edge case discovered in GH-13

GH-13
2017-09-01 19:53:17 -03:00
Andrew Sliwinski
bf56efd280 fix(analyze): Resolve issues with block and sprite counts
Resolves issue where sprite counts were inflated due to global variables and lists as well as an
issue where block counts were deflated due to improper handling of nested block structures

GH-10
2017-05-12 16:31:33 -04:00
Andrew Sliwinski
a0a03ef679 Initial functioning parser 2016-03-18 19:51:40 -04:00
Andrew Sliwinski
4642c66e08 Initial WIP commit with streaming parser 2016-03-15 10:31:35 -04:00