{"id":27440315,"url":"https://github.com/leopard-js/sb-edit","last_synced_at":"2025-04-14T22:39:59.662Z","repository":{"id":44044801,"uuid":"221310114","full_name":"leopard-js/sb-edit","owner":"leopard-js","description":"Javascript library for manipulating Scratch project files","archived":false,"fork":false,"pushed_at":"2024-07-15T20:16:04.000Z","size":1122,"stargazers_count":56,"open_issues_count":34,"forks_count":15,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-12T18:13:14.064Z","etag":null,"topics":["javascript","scratch"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leopard-js.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-11-12T20:54:56.000Z","updated_at":"2025-01-26T21:54:49.000Z","dependencies_parsed_at":"2023-12-16T22:38:32.275Z","dependency_job_id":"c8a350f2-fcb6-4ee3-960d-4db777f24bdb","html_url":"https://github.com/leopard-js/sb-edit","commit_stats":null,"previous_names":[],"tags_count":43,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leopard-js%2Fsb-edit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leopard-js%2Fsb-edit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leopard-js%2Fsb-edit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leopard-js%2Fsb-edit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leopard-js","download_url":"https://codeload.github.com/leopard-js/sb-edit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248975308,"owners_count":21192198,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","scratch"],"created_at":"2025-04-14T22:39:59.015Z","updated_at":"2025-04-14T22:39:59.628Z","avatar_url":"https://github.com/leopard-js.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sb-edit\n\nsb-edit is a javascript library for manipulating Scratch project files.\n\n\u003e #### 🚧 Warning!\n\u003e\n\u003e sb-edit is still a work-in-progress. Not everything will work, and the API will probably change drastically. Don't get too comfortable the way things are. ;)\n\n## Importing and exporting\n\nsb-edit allows importing and exporting a variety of Scratch project file types:\n\n| File Format                                            | Import     | Export         |\n| ------------------------------------------------------ | ---------- | -------------- |\n| Scratch 3.0 (**.sb3**)                                 | ✅ Yes     | ✅ Yes         |\n| Scratch 2.0 (**.sb2**)                                 | 🕒 Planned | 🕒 Planned     |\n| [Leopard](https://github.com/PullJosh/leopard)         | ❌ No      | ✅ Yes         |\n| [scratchblocks](https://github.com/tjvr/scratchblocks) | 👻 Maybe!  | 🚧 In progress |\n\n## Editing\n\nsb-edit can also be used to modify Scratch projects. A few things you can/will be able to do with sb-edit:\n\n|                     | Add        | Edit       | Delete     |\n| ------------------- | ---------- | ---------- | ---------- |\n| Sprites             | 🕒 Planned | ✅ Yes     | ✅ Yes     |\n| Stage               | ❌ No      | ✅ Yes     | ❌ No      |\n| Scripts             | 🕒 Planned | 🕒 Planned | 🕒 Planned |\n| Costumes and sounds | 🕒 Planned | 🕒 Planned | 🕒 Planned |\n\n## CLI Examples\n\nTo use the sb-edit CLI, first install it globally using the following command:\n\n```\n$ npm i -g sb-edit\n```\n\n### Convert .sb3 project to Leopard\n\n```\n$ sb-edit --input path/to/project.sb3 --output path/to/output-folder\n```\n\n### Convert .sb3 project to Leopard .zip\n\n```\n$ sb-edit --input path/to/project.sb3 --output path/to/output-folder.zip\n```\n\n## Code Examples\n\n### Import an .sb3 file in Node\n\n```js\nconst { Project } = require(\"sb-edit\");\nconst fs = require(\"fs\");\nconst path = require(\"path\");\n\nconst file = fs.readFileSync(path.join(__dirname, \"myProject.sb3\"));\nconst project = await Project.fromSb3(file);\n\nconsole.log(project);\n```\n\n### Export an .sb3 file in Node\n\n```js\nconst { Project } = require(\"sb-edit\");\nconst fs = require(\"fs\");\nconst path = require(\"path\");\n\nconst project = /* Get yourself a `Project`... */;\n\nconst saveLocation = path.join(__dirname, \"myProject.sb3\");\nfs.writeFileSync(saveLocation, Buffer.from(await project.toSb3()));\n\n// `project` is now saved at ./myProject.sb3\n```\n\n### Get Leopard code for project\n\n```js\nconst project = /* Get yourself a `Project`... */;\n\nconsole.log(project.toLeopard({ printWidth: 100 })); // Optionally pass a Prettier config object!\n```\n\n## Development\n\nIf you want to help develop the sb-edit package, you'll need to follow these steps:\n\n### Step 1: Download sb-edit and prepare to use\n\n```shell\n\u003e git clone https://github.com/PullJosh/sb-edit.git\n\u003e cd sb-edit\n\u003e npm link # Allow using sb-edit in another local project\n```\n\n### Step 2: Add sb-edit as dependency in another project\n\n```shell\n\u003e cd my-cool-project\n\u003e npm init # This should be a node project\n\u003e npm link sb-edit # Similar to `npm install` but uses local version\n```\n\n### Step 3: Modify sb-edit\n\nIf you make any changes to the sb-edit source code, you'll have to rebuild the package. Here's how:\n\n```shell\n\u003e cd sb-edit # Cloned from Github and then edited\n\u003e npm run build # Build the new version!\n\u003e npm run watch # Watch files and rebuild automatically when code is changed\n```\n\nYou can also run the [Jest](https://jestjs.io/) tests to make sure you didn't break anything:\n\n```shell\n\u003e cd sb-edit # You're probably already here ;)\n\u003e npm test # Run Jest tests\n\u003e npm run lint # Check code for style problems\n```\n\nAnd finally, make sure everything is pretty:\n\n```shell\n\u003e cd sb-edit\n\u003e npm run format # Format code to look nice with Prettier\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleopard-js%2Fsb-edit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleopard-js%2Fsb-edit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleopard-js%2Fsb-edit/lists"}