Skip to content

Commit

Permalink
Add a return type to installCustomBlocks()
Browse files Browse the repository at this point in the history
  • Loading branch information
snickell committed May 16, 2024
1 parent d02dbc1 commit 063e790
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 6 deletions.
36 changes: 31 additions & 5 deletions libprotolab/blockly/define-blocks-in-pool-style.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { installCustomBlocks } from "./from-cdo/block_utils";
import type { InputTypes, BlockDefinition } from "./from-cdo/block_utils";
import type { InputTypes, BlockDefinition, BlockNamesByCategory } from "./from-cdo/block_utils";

import Blockly from "blockly";

Expand Down Expand Up @@ -32,16 +32,42 @@ const customInputTypes: InputTypes = {
};

const blockDefinitions: BlockDefinition[] = [

Check failure on line 34 in libprotolab/blockly/define-blocks-in-pool-style.ts

View workflow job for this annotation

GitHub Actions / deploy

'blockDefinitions' is declared but its value is never read.

{
func: "makeBurst",
inline: true,
blockText: "create {EFFECT} effect with {NUM} {ANIMATION_NAME} sprites",
style: "sprite_blocks",
args: [
{
name: "NUM",
type: "Number",
},
{
name: "ANIMATION_NAME",
customInput: "costumePicker",
},
{
name: "EFFECT",
options: [
["burst", '"burst"'],
["pop", '"pop"'],
["rain", '"rain"'],
["spiral", '"spiral"'],
],
},
],
},
];

export function defineBlocksInPoolStyle() {
const blocksByCategory = installCustomBlocks({
export function defineBlocksInPoolStyle({blockDefinitions, customInputTypes}: {
blockDefinitions: BlockDefinition[];
customInputTypes: InputTypes;
}) : BlockNamesByCategory {
return installCustomBlocks({
blockly: Blockly,
blockDefinitions,
customInputTypes,
});
return blocksByCategory;
}

// FIXME: remove debug code
Expand Down
7 changes: 6 additions & 1 deletion libprotolab/blockly/from-cdo/block_utils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,13 @@ type BlockDefinition = {
style?: string;
};

type BlockName = string;
type BlockNamesByCategory = {
[category: string]: BlockName[];
};

export function installCustomBlocks(args: {
blockly: typeof Blockly;
blockDefinitions: BlockDefinition[];
customInputTypes: InputTypes;
}): any;
}): BlockNamesByCategory;

0 comments on commit 063e790

Please sign in to comment.