@turbowarp/sb3fix 0.3.5 → 0.3.7

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.
Files changed (4) hide show
  1. package/LICENSE +373 -373
  2. package/README.md +100 -100
  3. package/package.json +31 -31
  4. package/src/sb3fix.js +606 -552
package/README.md CHANGED
@@ -1,100 +1,100 @@
1
- # sb3fix
2
-
3
- https://turbowarp.github.io/sb3fix/
4
-
5
- Fix corrupted Scratch 3 projects.
6
-
7
- ## API
8
-
9
- Install with:
10
-
11
- ```bash
12
- npm install @turbowarp/sb3fix
13
- ```
14
-
15
- Then use from Node.js:
16
-
17
- ```js
18
- const sb3fix = require('@turbowarp/sb3fix');
19
- const fs = require('fs');
20
-
21
- const run = async () => {
22
- // Fix a .sb3 or .sprite3 with sb3fix.fixZip()
23
- // Input can be an ArrayBuffer, Uint8Array, Blob, File, or Node.js Buffer.
24
- // Output will be Uint8Array.
25
- // This method returns a Promise. If there is an error, that promise will reject.
26
- const brokenZip = fs.readFileSync('your-broken-project.sb3');
27
- const fixedZip = await sb3fix.fixZip(brokenZip);
28
- console.log(fixedZip);
29
-
30
- // Fix just a project.json or sprite.json with sb3fix.fixJSON()
31
- // Input can be a parsed project.json object or a parsed sprite.json object or a string.
32
- // If the input is an object, that object will be modified in-place instead of being copied.
33
- // Output will be a parsed project.json object or a parsed sprite.json object depending on input.
34
- // This method is NOT async. If there is an error, a plain JavaScript error will be thrown.
35
- const brokenJSON = fs.readFileSync('your-broken-project.json', 'utf-8');
36
- const fixedJSON = sb3fix.fixJSON(brokenJSON);
37
- console.log(fixedJSON);
38
-
39
- // sb3fix is deterministic. The same input will always give the same output, bit-for-bit.
40
-
41
- // Both sb3fix methods take in an optional options object.
42
- const options = {
43
- // While sb3fix runs, it'll log what it's doing and what it fixed. You can monitor those
44
- // using this callback. These messages are primarily a debugging tool, so the exact output
45
- // is not stable and may change without warning.
46
- logCallback: (message) => {
47
- console.log(message);
48
- }
49
- };
50
- // To use the above options, just supply as the second argument when you call sb3fix:
51
- await sb3fix.fixZip(brokenZip, options);
52
- sb3fix.fixJSON(brokenJSON, options);
53
- };
54
-
55
- run();
56
- ```
57
-
58
- ## Development
59
-
60
- Install things:
61
-
62
- ```bash
63
- git clone https://github.com/TurboWarp/sb3fix.git
64
- cd sb3fix
65
- npm ci
66
- ```
67
-
68
- Source code is in the src folder. During development do:
69
-
70
- ```bash
71
- npm start
72
- ```
73
-
74
- Then open dist/index.html in your favorite browser (there isn't a localhost development server).
75
-
76
- For the final build:
77
-
78
- ```bash
79
- npm run build
80
- ```
81
-
82
- All changes should have a corresponding test. Add test sb3 files in tests/samples, then run:
83
-
84
- ```bash
85
- npm run update
86
- ```
87
-
88
- Then check that the changes in tests/expected-output match what you expect. No unexpected changes! You can check if all the tests still pass with:
89
-
90
- ```bash
91
- npm run test
92
- ```
93
-
94
- ## License
95
-
96
- Copyright (C) 2023-2024 Thomas Weber
97
-
98
- This Source Code Form is subject to the terms of the Mozilla Public
99
- License, v. 2.0. If a copy of the MPL was not distributed with this
100
- file, You can obtain one at https://mozilla.org/MPL/2.0/.
1
+ # sb3fix
2
+
3
+ https://turbowarp.github.io/sb3fix/
4
+
5
+ Fix corrupted Scratch 3 projects.
6
+
7
+ ## API
8
+
9
+ Install with:
10
+
11
+ ```bash
12
+ npm install @turbowarp/sb3fix
13
+ ```
14
+
15
+ Then use from Node.js:
16
+
17
+ ```js
18
+ const sb3fix = require('@turbowarp/sb3fix');
19
+ const fs = require('fs');
20
+
21
+ const run = async () => {
22
+ // Fix a .sb3 or .sprite3 with sb3fix.fixZip()
23
+ // Input can be an ArrayBuffer, Uint8Array, Blob, File, or Node.js Buffer.
24
+ // Output will be Uint8Array.
25
+ // This method returns a Promise. If there is an error, that promise will reject.
26
+ const brokenZip = fs.readFileSync('your-broken-project.sb3');
27
+ const fixedZip = await sb3fix.fixZip(brokenZip);
28
+ console.log(fixedZip);
29
+
30
+ // Fix just a project.json or sprite.json with sb3fix.fixJSON()
31
+ // Input can be a parsed project.json object or a parsed sprite.json object or a string.
32
+ // If the input is an object, that object will be modified in-place instead of being copied.
33
+ // Output will be a parsed project.json object or a parsed sprite.json object depending on input.
34
+ // This method is NOT async. If there is an error, a plain JavaScript error will be thrown.
35
+ const brokenJSON = fs.readFileSync('your-broken-project.json', 'utf-8');
36
+ const fixedJSON = sb3fix.fixJSON(brokenJSON);
37
+ console.log(fixedJSON);
38
+
39
+ // sb3fix is deterministic. The same input will always give the same output, bit-for-bit.
40
+
41
+ // Both sb3fix methods take in an optional options object.
42
+ const options = {
43
+ // While sb3fix runs, it'll log what it's doing and what it fixed. You can monitor those
44
+ // using this callback. These messages are primarily a debugging tool, so the exact output
45
+ // is not stable and may change without warning.
46
+ logCallback: (message) => {
47
+ console.log(message);
48
+ }
49
+ };
50
+ // To use the above options, just supply as the second argument when you call sb3fix:
51
+ await sb3fix.fixZip(brokenZip, options);
52
+ sb3fix.fixJSON(brokenJSON, options);
53
+ };
54
+
55
+ run();
56
+ ```
57
+
58
+ ## Development
59
+
60
+ Install things:
61
+
62
+ ```bash
63
+ git clone https://github.com/TurboWarp/sb3fix.git
64
+ cd sb3fix
65
+ npm ci
66
+ ```
67
+
68
+ Source code is in the src folder. During development do:
69
+
70
+ ```bash
71
+ npm start
72
+ ```
73
+
74
+ Then open dist/index.html in your favorite browser (there isn't a localhost development server).
75
+
76
+ For the final build:
77
+
78
+ ```bash
79
+ npm run build
80
+ ```
81
+
82
+ All changes should have a corresponding test. Add test sb3 files in tests/samples, then run:
83
+
84
+ ```bash
85
+ npm run update
86
+ ```
87
+
88
+ Then check that the changes in tests/expected-output match what you expect. No unexpected changes! You can check if all the tests still pass with:
89
+
90
+ ```bash
91
+ npm run test
92
+ ```
93
+
94
+ ## License
95
+
96
+ Copyright (C) 2023-2025 Thomas Weber
97
+
98
+ This Source Code Form is subject to the terms of the Mozilla Public
99
+ License, v. 2.0. If a copy of the MPL was not distributed with this
100
+ file, You can obtain one at https://mozilla.org/MPL/2.0/.
package/package.json CHANGED
@@ -1,31 +1,31 @@
1
- {
2
- "name": "@turbowarp/sb3fix",
3
- "version": "0.3.5",
4
- "description": "Fix corrupted Scratch projects",
5
- "main": "src/sb3fix.js",
6
- "scripts": {
7
- "build": "webpack -c webpack.config.js",
8
- "watch": "webpack --watch -c webpack.config.js",
9
- "start": "webpack --watch -c webpack.config.js",
10
- "update": "node tests/snapshots --update",
11
- "test": "node tests/snapshots --validate"
12
- },
13
- "repository": {
14
- "type": "git",
15
- "url": "git+https://github.com/TurboWarp/sb3fix.git"
16
- },
17
- "author": "GarboMuffin",
18
- "license": "MPL-2.0",
19
- "bugs": {
20
- "url": "https://github.com/TurboWarp/sb3fix/issues"
21
- },
22
- "homepage": "https://github.com/TurboWarp/sb3fix#readme",
23
- "dependencies": {
24
- "@turbowarp/jszip": "^3.11.1"
25
- },
26
- "devDependencies": {
27
- "copy-webpack-plugin": "^13.0.0",
28
- "webpack": "^5.98.0",
29
- "webpack-cli": "^6.0.1"
30
- }
31
- }
1
+ {
2
+ "name": "@turbowarp/sb3fix",
3
+ "version": "0.3.7",
4
+ "description": "Fix corrupted Scratch projects",
5
+ "main": "src/sb3fix.js",
6
+ "scripts": {
7
+ "build": "webpack -c webpack.config.js",
8
+ "watch": "webpack --watch -c webpack.config.js",
9
+ "start": "webpack --watch -c webpack.config.js",
10
+ "update": "node tests/snapshots --update",
11
+ "test": "node tests/snapshots --validate"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/TurboWarp/sb3fix.git"
16
+ },
17
+ "author": "GarboMuffin",
18
+ "license": "MPL-2.0",
19
+ "bugs": {
20
+ "url": "https://github.com/TurboWarp/sb3fix/issues"
21
+ },
22
+ "homepage": "https://github.com/TurboWarp/sb3fix#readme",
23
+ "dependencies": {
24
+ "@turbowarp/jszip": "^3.11.1"
25
+ },
26
+ "devDependencies": {
27
+ "copy-webpack-plugin": "^13.0.0",
28
+ "webpack": "^5.98.0",
29
+ "webpack-cli": "^6.0.1"
30
+ }
31
+ }