{"id":16157458,"url":"https://github.com/apple502j/parse-sb3-blocks","last_synced_at":"2025-03-18T20:30:53.621Z","repository":{"id":48412358,"uuid":"277599778","full_name":"apple502j/parse-sb3-blocks","owner":"apple502j","description":"Parse sb3 blocks, and generate scratchblocks formatted code.","archived":false,"fork":false,"pushed_at":"2022-11-08T09:27:39.000Z","size":3626,"stargazers_count":19,"open_issues_count":4,"forks_count":6,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-28T12:20:21.824Z","etag":null,"topics":["hacktoberfest","parser","sb3","scratch"],"latest_commit_sha":null,"homepage":"https://apple502j.github.io/parse-sb3-blocks/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/apple502j.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null}},"created_at":"2020-07-06T16:57:02.000Z","updated_at":"2024-11-26T04:06:23.000Z","dependencies_parsed_at":"2023-01-21T05:42:33.266Z","dependency_job_id":null,"html_url":"https://github.com/apple502j/parse-sb3-blocks","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apple502j%2Fparse-sb3-blocks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apple502j%2Fparse-sb3-blocks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apple502j%2Fparse-sb3-blocks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apple502j%2Fparse-sb3-blocks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apple502j","download_url":"https://codeload.github.com/apple502j/parse-sb3-blocks/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243950792,"owners_count":20373664,"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":["hacktoberfest","parser","sb3","scratch"],"created_at":"2024-10-10T01:49:34.580Z","updated_at":"2025-03-18T20:30:53.006Z","avatar_url":"https://github.com/apple502j.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# parse-sb3-blocks\n**parse-sb3-blocks** parses Scratch 3.0 block formats, and convert it to [scratchblocks](https://github.com/scratchblocks/scratchblocks) format.\n\n## Usage\n### Example\n```js\nimport {toScratchblocks} from 'parse-sb3-blocks';\n\nconst sb3blocks = {\n    'ND,(]G?KLIy(IZrd2sl.': {\n        opcode: 'event_whenflagclicked',\n        ...\n    }\n};\n\nconsole.log(toScratchblocks('ND,(]G?KLIy(IZrd2sl.', sb3blocks, 'en', {tabs: ' '.repeat(4)}));\n```\n\n### toScratchblocks\n**toScratchblocks** is a function. This can take three to four arguments:\n\n- scriptStart: The block ID to start parsing from. **This must be a block ID of Connectable** (which includes hat blocks.)\n- blocks: serialized SB3 format (project.json format) of blocks.\n- locale: Locale to use. `en` should always be available.\n- opts: Optional. It can be an object (see below)\n\n#### Options\n`opts` can have these properties.\n\n- tabs: Tab characters used by C/E blocks for indenting. **Note that while parse-sb3-blocks can use non-space/tab indent, scratchblocks only accepts tab or spaces.** Pass empty string to remove indents. Defaults to four spaces.\n- variableStyle: If set to `none` (default), variables will never have `::variables` at the end. If set to `always`, it will always have `::variables`. If set to `as-needed`, it will have `::variables` if block name conflicts.\n\n### Internal Functions and Parsers\nIt also exports several classes used internally by the parsers. These are not APIs and is subject to changes at any time.\n\n#### Inputtable and Connectable\nConnectable is an instance that can be connected to a stack block via next-parent, including:\n- Block (stack, hat, cap)\n- CBlock\n- EBlock (if-else)\n- Definition\n- ProcedureCall\n\nInputtable can be used as an argument. Note that `Icon` is not technically an argument, but is Inputtable.\n- Stack (for arguments to C/E blocks)\n- Menu (includes fields menu and menu block)\n- Variable (variable reporters and custom block arguments)\n- Icon (greenFlag, turnLeft, turnRight icon)\n- BooleanBlock\n- ReporterBlock\n- Input and its subclasses NumberInput, StringInput, ColorPickerInput, BroadcastMenuInput, EmptyBooleanInput\n\nBoth Connectable and Inputtable implement `toScratchblocks` method. It accepts `locale` and `opts`, similar to the exported `toScratchblocks`.\n\nInstances with class name ending with \"Block\" have these attributes:\n- `id` for block ID\n- `opcode` for block opcode\n- `inputtables` for object of input key to Inputtable\n\n### Block Mapping\n`block-enum.js` provides an enum for block types.\n\n`translations.js` is an auto-generated file which includes all translations. `options.js` is also auto-generated, and contains which block needs options (because of conflicting names).\n\n**Only blocks and menu items in all-blocks.js are supported.**\n\n#### all-blocks.js\nall-blocks.js default-exports allBlocks, which is an object with opcode as key and the object (see below) as value.\n\nThe object has these keys and values:\n- noTranslation: If set to `true`, it will be ignored from the translation generator.\n- defaultMessage: Message in default language (English).\n- type: The block type. Defaults to `BlockEnum.BLOCK`.\n- defaultOptions: The block option for the block when using defaultMessage, in case duplicates exist. It can have category key and the category as a value.\n- translationKey: Translation key for scratch-l10n. Defaults to the block opcode, upper-cased.\n- boolArg: Array of arguments which must be boolean. Used to fill empty arguments with `EmptyBooleanInput`. If omitted, empty array is used.\n\n## Building\nNode 16+ is required for building. Type `npm run build`, which generates locale files.\n\n### env\n- `mode`: Unless set to `dev`, the result is minified. Add `docs` to update the JS file used in demo.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapple502j%2Fparse-sb3-blocks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapple502j%2Fparse-sb3-blocks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapple502j%2Fparse-sb3-blocks/lists"}