@turbowarp/sb3fix 0.2.2 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/sb3fix.js +15 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turbowarp/sb3fix",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Fix corrupted Scratch projects",
|
|
5
5
|
"main": "src/sb3fix.js",
|
|
6
6
|
"scripts": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"homepage": "https://github.com/TurboWarp/sb3fix#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"jszip": "^3.
|
|
23
|
+
"@turbowarp/jszip": "^3.11.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"copy-webpack-plugin": "^12.0.2",
|
package/src/sb3fix.js
CHANGED
|
@@ -218,6 +218,20 @@ const fixJSON = (data, options = {}) => {
|
|
|
218
218
|
costume.name = String(costume.name);
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
+
// https://github.com/scratchfoundation/scratch-parser/blob/665f05d739a202d565a4af70a201909393d456b2/lib/sb3_definitions.json#L51
|
|
222
|
+
const knownDataFormats = ['png', 'svg', 'jpeg', 'jpg', 'bmp', 'gif'];
|
|
223
|
+
if (!knownDataFormats.includes(costume.dataFormat)) {
|
|
224
|
+
if (typeof costume.md5ext === 'string' && costume.md5ext.endsWith('.svg')) {
|
|
225
|
+
log(`costume ${i} is vector, had invalid dataFormat ${costume.dataFormat}`);
|
|
226
|
+
costume.dataFormat = 'svg';
|
|
227
|
+
} else {
|
|
228
|
+
log(`costume ${i} is bitmap, had invalid dataFormat ${costume.dataFormat}`);
|
|
229
|
+
// dataFormat is only really used to detect vector or bitmap, so we don't
|
|
230
|
+
// need to set this to the real format
|
|
231
|
+
costume.dataFormat = 'png';
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
221
235
|
if (!('assetId' in costume)) {
|
|
222
236
|
log(`costume ${i} was missing assetId, deleted`);
|
|
223
237
|
costumes.splice(i, 1);
|
|
@@ -421,7 +435,7 @@ const fixJSON = (data, options = {}) => {
|
|
|
421
435
|
*/
|
|
422
436
|
const fixZip = async (data, options = {}) => {
|
|
423
437
|
// JSZip is not a small library, so we'll load it somewhat lazily.
|
|
424
|
-
const JSZip = require('jszip');
|
|
438
|
+
const JSZip = require('@turbowarp/jszip');
|
|
425
439
|
|
|
426
440
|
const zip = await JSZip.loadAsync(data);
|
|
427
441
|
|