@turbowarp/sb3fix 0.3.2 → 0.3.3
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 +3 -3
- package/src/sb3fix.js +22 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turbowarp/sb3fix",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "Fix corrupted Scratch projects",
|
|
5
5
|
"main": "src/sb3fix.js",
|
|
6
6
|
"scripts": {
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
},
|
|
22
22
|
"homepage": "https://github.com/TurboWarp/sb3fix#readme",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@turbowarp/jszip": "^3.11.
|
|
24
|
+
"@turbowarp/jszip": "^3.11.1"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"copy-webpack-plugin": "^12.0.2",
|
|
28
|
-
"webpack": "^5.
|
|
28
|
+
"webpack": "^5.96.1",
|
|
29
29
|
"webpack-cli": "^5.1.4"
|
|
30
30
|
}
|
|
31
31
|
}
|
package/src/sb3fix.js
CHANGED
|
@@ -351,11 +351,10 @@ const fixJSON = (data, options = {}) => {
|
|
|
351
351
|
fixTargetInPlace(target);
|
|
352
352
|
}
|
|
353
353
|
|
|
354
|
-
let stage;
|
|
355
354
|
const allStages = targets.filter((target) => target.isStage);
|
|
356
355
|
if (allStages.length === 0) {
|
|
357
356
|
log('stage is missing; adding an empty one');
|
|
358
|
-
|
|
357
|
+
targets.unshift({
|
|
359
358
|
isStage: true,
|
|
360
359
|
name: 'Stage',
|
|
361
360
|
variables: {},
|
|
@@ -380,22 +379,31 @@ const fixJSON = (data, options = {}) => {
|
|
|
380
379
|
videoTransparency: 50,
|
|
381
380
|
videoState: "on",
|
|
382
381
|
textToSpeechLanguage: null
|
|
383
|
-
};
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
const
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
targets.splice(
|
|
382
|
+
});
|
|
383
|
+
} else {
|
|
384
|
+
// We will accept the first stage in targets as the real stage
|
|
385
|
+
const firstStageIndex = targets.findIndex((target) => target.isStage);
|
|
386
|
+
|
|
387
|
+
// Stage must be the first target
|
|
388
|
+
if (firstStageIndex !== 0) {
|
|
389
|
+
log(`stage was at wrong index: ${firstStageIndex}`);
|
|
390
|
+
const stage = targets[firstStageIndex];
|
|
391
|
+
targets.splice(firstStageIndex, 1);
|
|
393
392
|
targets.unshift(stage);
|
|
394
393
|
}
|
|
395
|
-
|
|
396
|
-
|
|
394
|
+
|
|
395
|
+
// Remove all the other stages
|
|
396
|
+
for (let i = targets.length - 1; i > 0; i--) {
|
|
397
|
+
if (targets[i].isStage) {
|
|
398
|
+
log(`removing extra stage at index ${i}`);
|
|
399
|
+
targets.splice(i, 1);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
397
402
|
}
|
|
398
403
|
|
|
404
|
+
// Above checks ensure this invariant holds
|
|
405
|
+
const stage = targets[0];
|
|
406
|
+
|
|
399
407
|
// stage's name must match exactly
|
|
400
408
|
if (stage.name !== 'Stage') {
|
|
401
409
|
log(`stage had wrong name: ${stage.name}`);
|