Skip to content

Commit

Permalink
✨ feat: scratch-block extension support
Browse files Browse the repository at this point in the history
Signed-off-by: SimonShiki <[email protected]>
  • Loading branch information
SimonShiki committed Feb 4, 2024
1 parent 2a9d95a commit 0413e22
Show file tree
Hide file tree
Showing 5 changed files with 183 additions and 160 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"eslint": "^8.49.0",
"html-webpack-plugin": "^5.5.3",
"mini-svg-data-uri": "^1.4.4",
"typescript": "^5.2.2",
"typescript": "^5.3.0",
"webpack": "^5.88.2",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^4.15.1",
Expand Down
13 changes: 12 additions & 1 deletion src/loader/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -604,8 +604,19 @@ class EurekaLoader {
info: blockInfo,
xml: blockInfo.xml
};
default:
default: {
if ('extensions' in blockInfo) {
const converted = origConvertFunc.call(this, blockInfo, categoryInfo, ...args);
for (const extension of blockInfo.extensions!) {
if (!('extensions' in converted.json)) converted.json = [/*'scratch_extension'*/];
if (!converted.json.extensions.includes(extension)) {
converted.json.extensions.push(extension);
}
}
return converted;
}
return origConvertFunc.call(this, blockInfo, categoryInfo, ...args);
}
}
}
return origConvertFunc.call(this, blockInfo, categoryInfo, ...args);
Expand Down
2 changes: 2 additions & 0 deletions src/typings/block-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ enum BlockType {
HAT = 'hat',
/**
* A text label (not an actual block) for adding comments or labling blocks
* (TurboWarp specific)
*/
LABEL = 'label',
/**
Expand All @@ -44,6 +45,7 @@ enum BlockType {
REPORTER = 'reporter',
/**
* Arbitrary scratch-blocks XML.
* (TurboWarp specific)
*/
XML = 'xml'
}
Expand Down
6 changes: 6 additions & 0 deletions src/typings/extension-metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,14 @@ export interface ExtensionBlockMetadata {
filter?: TargetType[];
/**
* Arbitrary scratch-blocks XML string.
* (TurboWarp specific)
*/
xml?: string;
/**
* List of scratch-blocks extensions to use.
* (TurboWarp specific)
*/
extensions?: string[];
}

export interface ExtensionArgumentMetadata {
Expand Down
Loading

0 comments on commit 0413e22

Please sign in to comment.