@@ -26,17 +26,17 @@ import { GeneratorContext } from './generator_context';
2626import * as commonStorage from '../storage/common_storage' ;
2727import * as mechanismComponentHolder from '../blocks/mrc_mechanism_component_holder' ;
2828//import { testAllBlocksInToolbox } from '../toolbox/toolbox_tests';
29- import { MethodsCategory } from '../toolbox/methods_category' ;
30- import { EventsCategory } from '../toolbox/event_category' ;
29+ import { MethodsCategory } from '../toolbox/methods_category' ;
30+ import { EventsCategory } from '../toolbox/event_category' ;
3131import { getToolboxJSON } from '../toolbox/toolbox' ;
3232
3333const EMPTY_TOOLBOX : Blockly . utils . toolbox . ToolboxDefinition = {
34- kind : 'categoryToolbox' ,
35- contents : [ ] ,
34+ kind : 'categoryToolbox' ,
35+ contents : [ ] ,
3636} ;
3737
3838export class Editor {
39- private static workspaceIdToEditor : { [ key : string ] : Editor } = { } ;
39+ private static workspaceIdToEditor : { [ key : string ] : Editor } = { } ;
4040
4141 private blocklyWorkspace : Blockly . WorkspaceSvg ;
4242 private generatorContext : GeneratorContext ;
@@ -136,14 +136,14 @@ export class Editor {
136136 if ( currentModule ) {
137137 // Fetch the content for the current module and the robot.
138138 // TODO: Also fetch the content for the mechanisms?
139- const promises : { [ key : string ] : Promise < string > } = { } ; // key is module path, value is promise of module content.
139+ const promises : { [ key : string ] : Promise < string > } = { } ; // key is module path, value is promise of module content.
140140 promises [ this . modulePath ] = this . storage . fetchModuleContent ( this . modulePath ) ;
141141 if ( this . robotPath !== this . modulePath ) {
142142 // Also fetch the robot module content. It contains components, etc, that can be used.
143143 promises [ this . robotPath ] = this . storage . fetchModuleContent ( this . robotPath )
144144 }
145145
146- const moduleContents : { [ key : string ] : string } = { } ; // key is module path, value is module content
146+ const moduleContents : { [ key : string ] : string } = { } ; // key is module path, value is module content
147147 await Promise . all (
148148 Object . entries ( promises ) . map ( async ( [ modulePath , promise ] ) => {
149149 moduleContents [ modulePath ] = await promise ;
@@ -173,7 +173,7 @@ export class Editor {
173173 if ( toolbox != this . toolbox ) {
174174 this . toolbox = toolbox ;
175175 this . blocklyWorkspace . updateToolbox ( toolbox ) ;
176- // testAllBlocksInToolbox(toolbox);
176+ // testAllBlocksInToolbox(toolbox);
177177 }
178178 }
179179
@@ -220,23 +220,24 @@ export class Editor {
220220 throw new Error ( 'getModuleContent: this.currentModule is null.' ) ;
221221 }
222222 const pythonCode = extendedPythonGenerator . mrcWorkspaceToCode (
223- this . blocklyWorkspace , this . generatorContext ) ;
223+ this . blocklyWorkspace , this . generatorContext ) ;
224224 const exportedBlocks = JSON . stringify ( this . generatorContext . getExportedBlocks ( ) ) ;
225225 const blocksContent = JSON . stringify (
226- Blockly . serialization . workspaces . save ( this . blocklyWorkspace ) ) ;
226+ Blockly . serialization . workspaces . save ( this . blocklyWorkspace ) ) ;
227227 const componentsContent = JSON . stringify ( this . getComponents ( ) ) ;
228228 return commonStorage . makeModuleContent (
229- this . currentModule , pythonCode , blocksContent , exportedBlocks , componentsContent ) ;
229+ this . currentModule , pythonCode , blocksContent , exportedBlocks , componentsContent ) ;
230230 }
231231
232232 private getComponents ( ) : commonStorage . Component [ ] {
233233 const components : commonStorage . Component [ ] = [ ] ;
234234 if ( this . currentModule ?. moduleType === commonStorage . MODULE_TYPE_ROBOT ||
235- this . currentModule ?. moduleType === commonStorage . MODULE_TYPE_MECHANISM ) {
235+ this . currentModule ?. moduleType === commonStorage . MODULE_TYPE_MECHANISM ) {
236236 // Get the holder block and ask it for the components.
237237 const holderBlocks = this . blocklyWorkspace . getBlocksByType ( mechanismComponentHolder . BLOCK_NAME ) ;
238238 holderBlocks . forEach ( holderBlock => {
239- const componentsFromHolder : commonStorage . Component [ ] = holderBlock . getComponents ( ) ;
239+ const componentsFromHolder : commonStorage . Component [ ] =
240+ ( holderBlock as mechanismComponentHolder . MechanismComponentHolderBlock ) . getComponents ( ) ;
240241 componentsFromHolder . forEach ( component => {
241242 components . push ( component ) ;
242243 } ) ;
0 commit comments