Skip to content

Commit

Permalink
introduced a setupFunctions array to group all the setup function cal…
Browse files Browse the repository at this point in the history
…l, add uses export statements for BACKWARDCOMPATIBILIYDICT and initBasicProtoBlocks, instead of comments to indicate exports (#3994)
  • Loading branch information
retrogtx authored Sep 8, 2024
1 parent 011678d commit a6f3514
Showing 1 changed file with 32 additions and 32 deletions.
64 changes: 32 additions & 32 deletions js/basicblocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* Dictionary mapping old block names to their corresponding new block names for backward compatibility.
* @constant {Object<string, string>}
*/
const BACKWARDCOMPATIBILIYDICT = {
export const BACKWARDCOMPATIBILIYDICT = {
fullscreen: "vspace",
fillscreen2: "fillscreen",
sandwichclampcollapsed: "clamp",
Expand Down Expand Up @@ -72,41 +72,41 @@ const BACKWARDCOMPATIBILIYDICT = {
shell: "turtleshell"
};

// Define blocks here. Note: The blocks are placed on the palettes
// from bottom to top, i.e., the block at the top of a palette will be
// the last block added to a palette.
const setupFunctions = [
setupRhythmBlockPaletteBlocks,
setupRhythmBlocks,
setupMeterBlocks,
setupPitchBlocks,
setupIntervalsBlocks,
setupToneBlocks,
setupOrnamentBlocks,
setupVolumeBlocks,
setupDrumBlocks,
setupWidgetBlocks,
setupFlowBlocks,
setupNumberBlocks,
setupActionBlocks,
setupBoxesBlocks,
setupBooleanBlocks,
setupHeapBlocks,
setupDictBlocks,
setupExtrasBlocks,
setupProgramBlocks,
setupGraphicsBlocks,
setupPenBlocks,
setupMediaBlocks,
setupSensorsBlocks,
setupEnsembleBlocks
];

/**
* @public
* @param {Object} palettes
* @param {Object} blocks
* @param {Object} activity
* @returns {void}
*/
const initBasicProtoBlocks = (activity) => {
export const initBasicProtoBlocks = (activity) => {
activity.blocks.palettes = activity.palettes;
setupRhythmBlockPaletteBlocks(activity);
setupRhythmBlocks(activity);
setupMeterBlocks(activity);
setupPitchBlocks(activity);
setupIntervalsBlocks(activity);
setupToneBlocks(activity);
setupOrnamentBlocks(activity);
setupVolumeBlocks(activity);
setupDrumBlocks(activity);
setupWidgetBlocks(activity);
setupFlowBlocks(activity);
setupNumberBlocks(activity);
setupActionBlocks(activity);
setupBoxesBlocks(activity);
setupBooleanBlocks(activity);
setupHeapBlocks(activity);
setupDictBlocks(activity);
setupExtrasBlocks(activity);
setupProgramBlocks(activity);
setupGraphicsBlocks(activity);
setupPenBlocks(activity);
setupMediaBlocks(activity);
setupSensorsBlocks(activity);
setupEnsembleBlocks(activity);
setupFunctions.forEach(setup => setup(activity));

// Push protoblocks onto their palettes.
for (const protoblock in activity.blocks.protoBlockDict) {
Expand All @@ -116,4 +116,4 @@ const initBasicProtoBlocks = (activity) => {
);
}
}
};
};

0 comments on commit a6f3514

Please sign in to comment.