namespace pxt . blocks { const THIS_NAME = "this" ; export const MATH_FUNCTIONS = { unary : [ "sqrt" , "sin" , "cos" , "tan" ] , binary : [ "atan2" ] , infix : [ "idiv" , "imul" ] } ; export const ROUNDING_FUNCTIONS = [ "round" , "ceil" , "floor" , "trunc" ] ; export interface BlockParameter { actualName : string ; type ? : string ; definitionName : string ; shadowBlockId ? : string ; defaultValue ? : string ; isOptional ? : boolean ; fieldEditor ? : string ; fieldOptions ? : Map < string > ; shadowOptions ? : Map < string > ; range ? : { min : number ; max : number ; } ; } export interface BlockCompileInfo { parameters : ReadonlyArray < BlockParameter > ; actualNameToParam : Map < BlockParameter > ; definitionNameToParam : Map < BlockParameter > ; handlerArgs ? : HandlerArg [ ] ; thisParameter ? : BlockParameter ; } export interface HandlerArg { name : string ; type : string ; inBlockDef : boolean ; } export const builtinFunctionInfo = { "Math.abs" : { blockId : "math_op3" , params : [ "x" ] } , "Math.min" : { blockId : "math_op2" , params : [ "x" , "y" ] } , "Math.max" : { blockId : "math_op2" , params : [ "x" , "y" ] } } ; export function normalizeBlock ( b , err = pxt . log ) { if ( ! b ) return b ; let nb = b . replace ( /(?:^|[^\\])([%$])\s+/g , '$1' ) ; if ( nb != b ) { err ( `block has extra spaces: ${ b }` ) ; b = nb ; } b = nb ; nb = b . replace ( /([%$]\w+)\s*=\s*(\w+)/ , '$1=$2' ) ; if ( nb != b ) { err ( `block has space between %name and = : ${ b }` ) ; b = nb ; } nb = nb . replace ( /\s*\|\s*/g , '|' ) ; return nb ; } export function compileInfo ( fn ) { const res = { parameters : [ ] , actualNameToParam : { } , definitionNameToParam : { } , handlerArgs : [ ] } ; const instance = ( fn . kind == ts . pxtc . SymbolKind . Method || fn . kind == ts . pxtc . SymbolKind . Property ) && ! fn . attributes . defaultInstance ; const hasBlockDef = ! ! fn . attributes . _def ; const defParameters = hasBlockDef ? fn . attributes . _def . parameters . slice ( 0 ) : undefined ; const optionalStart = hasBlockDef ? defParameters . length : ( fn . parameters ? fn . parameters . length : 0 ) ; const bInfo = builtinFunctionInfo [ fn . qName ] ; if ( hasBlockDef && fn . attributes . _expandedDef ) { defParameters . push ( ... fn . attributes . _expandedDef . parameters ) ; } const refMap = { } ; const definitionsWithoutRefs = defParameters ? defParameters . filter ( p => { if ( p . ref ) { refMap [ p . name ] = p ; return false ; } return true ; } ) : [ ] ; if ( instance && hasBlockDef && defParameters . length ) { const def = refMap [ THIS_NAME ] || defParameters [ 0 ] ; const defName = def . name ; const isVar = ! def . shadowBlockId || def . shadowBlockId === "variables_get" ; let defaultValue ; if ( isVar ) { defaultValue = def . varName || fn . attributes . paramDefl [ defName ] || fn . attributes . paramDefl [ "this" ] ; } res . thisParameter = { actualName : THIS_NAME , definitionName : defName , shadowBlockId : def . shadowBlockId , type : fn . namespace , defaultValue : defaultValue , fieldEditor : fieldEditor ( defName , THIS_NAME ) , fieldOptions : fieldOptions ( defName , THIS_NAME ) , shadowOptions : shadowOptions ( defName , THIS_NAME ) , } ; } if ( fn . parameters ) { let defIndex = ( instance && ! refMap [ THIS_NAME ] ) ? 1 : 0 ; fn . parameters . forEach ( ( p , i ) => { let def ; if ( refMap [ p . name ] ) { def = refMap [ p . name ] ; } else if ( defIndex < definitionsWithoutRefs . length ) { def = definitionsWithoutRefs [ defIndex ] ; ++ defIndex ; } if ( def || ! hasBlockDef ) { let range = undefined ; if ( p . options && p . options [ "min" ] && p . options [ "max" ] ) { range = { min : p . options [ "min" ] . value , max : p . options [ "max" ] . value } ; } const defName = def ? def . name : ( bInfo ? bInfo . params [ defIndex ++ ] : p . name ) ; const isVarOrArray = def && ( def . shadowBlockId === "variables_get" || def . shadowBlockId == "lists_create_with" ) ; ( res . parameters as BlockParameter [ ] ) . push ( { actualName : p . name , type : p . type , defaultValue : isVarOrArray ? ( def . varName || p . default ) : p . default , definitionName : defName , shadowBlockId : def && def . shadowBlockId , isOptional : defParameters ? defParameters . indexOf ( def ) >= optionalStart : false , fieldEditor : fieldEditor ( defName , p . name ) , fieldOptions : fieldOptions ( defName , p . name ) , shadowOptions : shadowOptions ( defName , p . name ) , range } ) ; } if ( p . handlerParameters ) { p . handlerParameters . forEach ( arg => { res . handlerArgs . push ( { name : arg . name , type : arg . type , inBlockDef : defParameters ? defParameters . some ( def => def . ref && def . name === arg . name ) : false } ) ; } ) ; } } ) ; } res . parameters . forEach ( p => { res . actualNameToParam [ p . actualName ] = p ; res . definitionNameToParam [ p . definitionName ] = p ; } ) ; return res ; function fieldEditor ( defName , actualName ) { return fn . attributes . paramFieldEditor && ( fn . attributes . paramFieldEditor [ defName ] || fn . attributes . paramFieldEditor [ actualName ] ) ; } function fieldOptions ( defName , actualName ) { return fn . attributes . paramFieldEditorOptions && ( fn . attributes . paramFieldEditorOptions [ defName ] || fn . attributes . paramFieldEditorOptions [ actualName ] ) ; } function shadowOptions ( defName , actualName ) { return fn . attributes . paramShadowOptions && ( fn . attributes . paramShadowOptions [ defName ] || fn . attributes . paramShadowOptions [ actualName ] ) ; } } export function hasHandler ( fn ) { return fn . parameters && fn . parameters . some ( p => ( p . type == "() => void" || p . type == "Action" || ! ! p . properties ?. length || ! ! p . handlerParameters ?. length ) ) ; } param varType return export function reporterTypeForArgType ( varType ) { let reporterType = "argument_reporter_custom" ; if ( varType === "boolean" || varType === "number" || varType === "string" ) { reporterType = `argument_reporter_${ varType }` ; } return reporterType ; } export function defaultIconForArgType ( typeName = "" ) { switch ( typeName ) { case "number" : return "calculator" ; case "string" : return "text width" ; case "boolean" : return "random" ; case "Array" : return "list" ; default : return "align justify" ; } } export interface FieldDescription { n : string ; pre ? : string ; p ? : string ; ni : number ; } export function parseFields ( b ) { return b . split ( '|' ) . map ( ( n , ni ) => { let m = /([^%]*)\s*%([a-zA-Z0-9_]+)/ . exec ( n ) ; if ( ! m ) return { n , ni } ; let pre = m [ 1 ] ; if ( pre ) pre = pre . trim ( ) ; let p = m [ 2 ] ; return { n , ni , pre , p } ; } ) ; } export interface BlockDefinition { name : string ; category : string ; url : string ; tooltip ? : string | Map < string > ; operators ? : Map < string [ ] > ; block ? : Map < string > ; blockTextSearch ? : string ; tooltipSearch ? : string ; translationIds ? : string [ ] ; } let _blockDefinitions ; export function blockDefinitions ( ) { if ( ! _blockDefinitions ) cacheBlockDefinitions ( ) ; return _blockDefinitions ; } export function getBlockDefinition ( blockId ) { if ( ! _blockDefinitions ) cacheBlockDefinitions ( ) ; return _blockDefinitions [ blockId ] ; } function cacheBlockDefinitions ( ) { _blockDefinitions = { 'device_while' : { name : Util . lf ( "a loop that repeats while the condition is true" ) , tooltip : Util . lf ( "Run the same sequence of actions while the condition is met." ) , url : '/blocks/loops/while' , category : 'loops' , block : { message0 : Util . lf ( "while %1" ) , appendField : Util . lf ( "{id:while}do" ) } } , 'pxt_controls_for' : { name : Util . lf ( "a loop that repeats the number of times you say" ) , tooltip : Util . lf ( "Have the variable '{0}' take on the values from 0 to the end number, counting by 1, and do the specified blocks." ) , url : '/blocks/loops/for' , category : 'loops' , block : { message0 : Util . lf ( "for %1 from 0 to %2" ) , variable : Util . lf ( "{id:var}index" ) , appendField : Util . lf ( "{id:for}do" ) } } , 'controls_simple_for' : { name : Util . lf ( "a loop that repeats the number of times you say" ) , tooltip : Util . lf ( "Have the variable '{0}' take on the values from 0 to the end number, counting by 1, and do the specified blocks." ) , url : '/blocks/loops/for' , category : 'loops' , block : { message0 : Util . lf ( "for %1 from 0 to %2" ) , variable : Util . lf ( "{id:var}index" ) , appendField : Util . lf ( "{id:for}do" ) } } , 'pxt_controls_for_of' : { name : Util . lf ( "a loop that repeats for each value in an array" ) , tooltip : Util . lf ( "Have the variable '{0}' take the value of each item in the array one by one, and do the specified blocks." ) , url : '/blocks/loops/for-of' , category : 'loops' , block : { message0 : Util . lf ( "for element %1 of %2" ) , variable : Util . lf ( "{id:var}value" ) , appendField : Util . lf ( "{id:for_of}do" ) } } , 'controls_for_of' : { name : Util . lf ( "a loop that repeats for each value in an array" ) , tooltip : Util . lf ( "Have the variable '{0}' take the value of each item in the array one by one, and do the specified blocks." ) , url : '/blocks/loops/for-of' , category : 'loops' , block : { message0 : Util . lf ( "for element %1 of %2" ) , variable : Util . lf ( "{id:var}value" ) , appendField : Util . lf ( "{id:for_of}do" ) } } , 'math_op2' : { name : Util . lf ( "minimum or maximum of 2 numbers" ) , tooltip : { "min" : Util . lf ( "smaller value of 2 numbers" ) , "max" : Util . lf ( "larger value of 2 numbers" ) } , url : '/blocks/math' , operators : { 'op' : [ "min" , "max" ] } , category : 'math' } , 'math_op3' : { name : Util . lf ( "absolute number" ) , tooltip : Util . lf ( "absolute value of a number" ) , url : '/reference/math' , category : 'math' , block : { message0 : Util . lf ( "absolute of %1" ) } } , 'math_number' : { name : Util . lf ( "{id:block}number" ) , url : '/blocks/math/random' , category : 'math' , tooltip : ( pxt . appTarget && pxt . appTarget . compile ) ? Util . lf ( "a decimal number" ) : Util . lf ( "an integer number" ) } , 'math_integer' : { name : Util . lf ( "{id:block}number" ) , url : '/blocks/math/random' , category : 'math' , tooltip : Util . lf ( "an integer number" ) } , 'math_whole_number' : { name : Util . lf ( "{id:block}number" ) , url : '/blocks/math/random' , category : 'math' , tooltip : Util . lf ( "a whole number" ) } , 'math_number_minmax' : { name : Util . lf ( "{id:block}number" ) , url : '/blocks/math/random' , category : 'math' } , 'math_arithmetic' : { name : Util . lf ( "arithmetic operation" ) , url : '/blocks/math' , tooltip : { ADD : Util . lf ( "Return the sum of the two numbers." ) , MINUS : Util . lf ( "Return the difference of the two numbers." ) , MULTIPLY : Util . lf ( "Return the product of the two numbers." ) , DIVIDE : Util . lf ( "Return the quotient of the two numbers." ) , POWER : Util . lf ( "Return the first number raised to the power of the second number." ) , } , operators : { 'OP' : [ "ADD" , "MINUS" , "MULTIPLY" , "DIVIDE" , "POWER" ] } , category : 'math' , block : { MATH_ADDITION_SYMBOL : Util . lf ( "{id:op}+" ) , MATH_SUBTRACTION_SYMBOL : Util . lf ( "{id:op}-" ) , MATH_MULTIPLICATION_SYMBOL : Util . lf ( "{id:op}×" ) , MATH_DIVISION_SYMBOL : Util . lf ( "{id:op}÷" ) , MATH_POWER_SYMBOL : Util . lf ( "{id:op}**" ) } } , 'math_modulo' : { name : Util . lf ( "division remainder" ) , tooltip : Util . lf ( "Return the remainder from dividing the two numbers." ) , url : '/blocks/math' , category : 'math' , block : { MATH_MODULO_TITLE : Util . lf ( "remainder of %1 ÷ %2" ) } } , 'math_js_op' : { name : Util . lf ( "math function" ) , tooltip : { "sqrt" : Util . lf ( "Returns the square root of the argument" ) , "sin" : Util . lf ( "Returns the sine of the argument" ) , "cos" : Util . lf ( "Returns the cosine of the argument" ) , "tan" : Util . lf ( "Returns the tangent of the argument" ) , "atan2" : Util . lf ( "Returns the arctangent of the quotient of the two arguments" ) , "idiv" : Util . lf ( "Returns the integer portion of the division operation on the two arguments" ) , "imul" : Util . lf ( "Returns the integer portion of the multiplication operation on the two arguments" ) } , url : '/blocks/math' , operators : { 'OP' : [ "sqrt" , "sin" , "cos" , "tan" , "atan2" , "idiv" , "imul" ] } , category : 'math' , block : { "sqrt" : Util . lf ( "{id:op}square root" ) , "sin" : Util . lf ( "{id:op}sin" ) , "cos" : Util . lf ( "{id:op}cos" ) , "tan" : Util . lf ( "{id:op}tan" ) , "atan2" : Util . lf ( "{id:op}atan2" ) , "idiv" : Util . lf ( "{id:op}integer ÷" ) , "imul" : Util . lf ( "{id:op}integer ×" ) , } } , "math_js_round" : { name : Util . lf ( "rounding functions" ) , tooltip : { "round" : Util . lf ( "Increases the argument to the next higher whole number if its fractional part is more than one half" ) , "ceil" : Util . lf ( "Increases the argument to the next higher whole number" ) , "floor" : Util . lf ( "Decreases the argument to the next lower whole number" ) , "trunc" : Util . lf ( "Removes the fractional part of the argument" ) } , url : '/blocks/math' , operators : { "OP" : [ "round" , "ceil" , "floor" , "trunc" ] } , category : 'math' , block : { "round" : Util . lf ( "{id:op}round" ) , "ceil" : Util . lf ( "{id:op}ceiling" ) , "floor" : Util . lf ( "{id:op}floor" ) , "trunc" : Util . lf ( "{id:op}truncate" ) , } } , 'variables_change' : { name : Util . lf ( "update the value of a number variable" ) , tooltip : Util . lf ( "Changes the value of the variable by this amount" ) , url : '/blocks/variables/change' , category : 'variables' , block : { message0 : Util . lf ( "change %1 by %2" ) } } , 'controls_repeat_ext' : { name : Util . lf ( "a loop that repeats and increments an index" ) , tooltip : Util . lf ( "Do some statements several times." ) , url : '/blocks/loops/repeat' , category : 'loops' , block : { CONTROLS_REPEAT_TITLE : Util . lf ( "repeat %1 times" ) , CONTROLS_REPEAT_INPUT_DO : Util . lf ( "{id:repeat}do" ) } } , 'variables_get' : { name : Util . lf ( "get the value of a variable" ) , tooltip : Util . lf ( "Returns the value of this variable." ) , url : '/blocks/variables' , category : 'variables' , block : { VARIABLES_GET_CREATE_SET : Util . lf ( "Create 'set %1'" ) } } , 'variables_get_reporter' : { name : Util . lf ( "get the value of a variable" ) , tooltip : Util . lf ( "Returns the value of this variable." ) , url : '/blocks/variables' , category : 'variables' , block : { VARIABLES_GET_CREATE_SET : Util . lf ( "Create 'set %1'" ) } } , 'variables_set' : { name : Util . lf ( "assign the value of a variable" ) , tooltip : Util . lf ( "Sets this variable to be equal to the input." ) , url : '/blocks/variables/assign' , category : 'variables' , block : { VARIABLES_SET : Util . lf ( "set %1 to %2" ) } } , 'controls_if' : { name : Util . lf ( "a conditional statement" ) , tooltip : { CONTROLS_IF_TOOLTIP_1 : Util . lf ( "If a value is true, then do some statements." ) , CONTROLS_IF_TOOLTIP_2 : Util . lf ( "If a value is true, then do the first block of statements. Otherwise, do the second block of statements." ) , CONTROLS_IF_TOOLTIP_3 : Util . lf ( "If the first value is true, then do the first block of statements. Otherwise, if the second value is true, do the second block of statements." ) , CONTROLS_IF_TOOLTIP_4 : Util . lf ( "If the first value is true, then do the first block of statements. Otherwise, if the second value is true, do the second block of statements. If none of the values are true, do the last block of statements." ) } , tooltipSearch : "CONTROLS_IF_TOOLTIP_2" , url : '/blocks/logic/if' , category : 'logic' , block : { CONTROLS_IF_MSG_IF : Util . lf ( "{id:logic}if" ) , CONTROLS_IF_MSG_THEN : Util . lf ( "{id:logic}then" ) , CONTROLS_IF_MSG_ELSE : Util . lf ( "{id:logic}else" ) , CONTROLS_IF_MSG_ELSEIF : Util . lf ( "{id:logic}else if" ) } } , 'lists_create_with' : { name : Util . lf ( "create an array" ) , tooltip : Util . lf ( "Creates a new array." ) , url : '/reference/arrays/create' , category : 'arrays' , blockTextSearch : "LISTS_CREATE_WITH_INPUT_WITH" , block : { LISTS_CREATE_EMPTY_TITLE : Util . lf ( "empty array" ) , LISTS_CREATE_WITH_INPUT_WITH : Util . lf ( "array of" ) , LISTS_CREATE_WITH_CONTAINER_TITLE_ADD : Util . lf ( "array" ) , LISTS_CREATE_WITH_ITEM_TITLE : Util . lf ( "value" ) } } , 'lists_length' : { name : Util . lf ( "array length" ) , tooltip : Util . lf ( "Returns the number of items in an array." ) , url : '/reference/arrays/length' , category : 'arrays' , block : { LISTS_LENGTH_TITLE : Util . lf ( "length of array %1" ) } } , 'lists_index_get' : { name : Util . lf ( "get a value in an array" ) , tooltip : Util . lf ( "Returns the value at the given index in an array." ) , url : '/reference/arrays/get' , category : 'arrays' , block : { message0 : Util . lf ( "%1 get value at %2" ) } } , 'lists_index_set' : { name : Util . lf ( "set a value in an array" ) , tooltip : Util . lf ( "Sets the value at the given index in an array" ) , url : '/reference/arrays/set' , category : 'arrays' , block : { message0 : Util . lf ( "%1 set value at %2 to %3" ) } } , 'logic_compare' : { name : Util . lf ( "comparing two numbers" ) , tooltip : { LOGIC_COMPARE_TOOLTIP_EQ : Util . lf ( "Return true if both inputs equal each other." ) , LOGIC_COMPARE_TOOLTIP_NEQ : Util . lf ( "Return true if both inputs are not equal to each other." ) , LOGIC_COMPARE_TOOLTIP_LT : Util . lf ( "Return true if the first input is smaller than the second input." ) , LOGIC_COMPARE_TOOLTIP_LTE : Util . lf ( "Return true if the first input is smaller than or equal to the second input." ) , LOGIC_COMPARE_TOOLTIP_GT : Util . lf ( "Return true if the first input is greater than the second input." ) , LOGIC_COMPARE_TOOLTIP_GTE : Util . lf ( "Return true if the first input is greater than or equal to the second input." ) } , url : '/blocks/logic/boolean' , category : 'logic' , block : { search : "= ≠ < ≤ > ≥" } } , 'logic_operation' : { name : Util . lf ( "boolean operation" ) , tooltip : { LOGIC_OPERATION_TOOLTIP_AND : Util . lf ( "Return true if both inputs are true." ) , LOGIC_OPERATION_TOOLTIP_OR : Util . lf ( "Return true if at least one of the inputs is true." ) } , url : '/blocks/logic/boolean' , category : 'logic' , block : { LOGIC_OPERATION_AND : Util . lf ( "{id:op}and" ) , LOGIC_OPERATION_OR : Util . lf ( "{id:op}or" ) } } , 'logic_negate' : { name : Util . lf ( "logical negation" ) , tooltip : Util . lf ( "Returns true if the input is false. Returns false if the input is true." ) , url : '/blocks/logic/boolean' , category : 'logic' , block : { LOGIC_NEGATE_TITLE : Util . lf ( "not %1" ) } } , 'logic_boolean' : { name : Util . lf ( "a `true` or `false` value" ) , tooltip : Util . lf ( "Returns either true or false." ) , url : '/blocks/logic/boolean' , category : 'logic' , block : { LOGIC_BOOLEAN_TRUE : Util . lf ( "{id:boolean}true" ) , LOGIC_BOOLEAN_FALSE : Util . lf ( "{id:boolean}false" ) } } , 'text' : { name : Util . lf ( "a piece of text" ) , tooltip : Util . lf ( "A letter, word, or line of text." ) , url : '/types/string' , category : 'text' , block : { search : Util . lf ( "a piece of text" ) } } , 'text_length' : { name : Util . lf ( "number of characters in the string" ) , tooltip : Util . lf ( "Returns the number of letters (including spaces) in the provided text." ) , url : '/reference/text/length' , category : 'text' , block : { TEXT_LENGTH_TITLE : Util . lf ( "length of %1" ) } } , 'text_join' : { name : Util . lf ( "join items to create text" ) , tooltip : Util . lf ( "Create a piece of text by joining together any number of items." ) , url : '/reference/text/join' , category : 'text' , block : { TEXT_JOIN_TITLE_CREATEWITH : Util . lf ( "join" ) } } , 'procedures_defnoreturn' : { name : Util . lf ( "define the function" ) , tooltip : Util . lf ( "Create a function." ) , url : '/types/function/define' , category : 'functions' , block : { PROCEDURES_DEFNORETURN_TITLE : Util . lf ( "function" ) , PROCEDURE_ALREADY_EXISTS : Util . lf ( "A function named '%1' already exists." ) } } , 'procedures_callnoreturn' : { name : Util . lf ( "call the function" ) , tooltip : Util . lf ( "Call the user-defined function." ) , url : '/types/function/call' , category : 'functions' , block : { PROCEDURES_CALLNORETURN_TITLE : Util . lf ( "call function" ) } } , 'function_return' : { name : Util . lf ( "return a value from within a function" ) , tooltip : Util . lf ( "Return a value from within a user-defined function." ) , url : '/types/function/return' , category : 'functions' , block : { message_with_value : Util . lf ( "return %1" ) , message_no_value : Util . lf ( "return" ) } } , 'function_definition' : { name : Util . lf ( "define the function" ) , tooltip : Util . lf ( "Create a function." ) , url : '/types/function/define' , category : 'functions' , block : { FUNCTIONS_EDIT_OPTION : Util . lf ( "Edit Function" ) } } , 'function_call' : { name : Util . lf ( "call the function" ) , tooltip : Util . lf ( "Call the user-defined function." ) , url : '/types/function/call' , category : 'functions' , block : { FUNCTIONS_CALL_TITLE : Util . lf ( "call" ) , FUNCTIONS_GO_TO_DEFINITION_OPTION : Util . lf ( "Go to Definition" ) } } , 'function_call_output' : { name : Util . lf ( "call the function with a return value" ) , tooltip : Util . lf ( "Call the user-defined function with a return value." ) , url : '/types/function/call' , category : 'functions' , block : { } } } ; _blockDefinitions [ pxtc . ON_START_TYPE ] = { name : Util . lf ( "on start event" ) , tooltip : Util . lf ( "Run code when the program starts" ) , url : '/blocks/on-start' , category : "loops" , block : { message0 : Util . lf ( "on start %1 %2" ) } } ; _blockDefinitions [ pxtc . PAUSE_UNTIL_TYPE ] = { name : Util . lf ( "pause until" ) , tooltip : Util . lf ( "Pause execution of code until the given boolean expression is true" ) , url : '/blocks/pause-until' , category : "loops" , block : { message0 : Util . lf ( "pause until %1" ) } } ; _blockDefinitions [ pxtc . TS_BREAK_TYPE ] = { name : Util . lf ( "break" ) , tooltip : Util . lf ( "Break out of the current loop or switch" ) , url : '/blocks/loops/break' , category : 'loops' , block : { message0 : Util . lf ( "break" ) } } ; _blockDefinitions [ pxtc . TS_CONTINUE_TYPE ] = { name : Util . lf ( "continue" ) , tooltip : Util . lf ( "Skip current iteration and continues with the next iteration in the loop" ) , url : '/blocks/loops/continue' , category : 'loops' , block : { message0 : Util . lf ( "continue" ) } } ; if ( pxt . Util . isTranslationMode ( ) ) { const msg = Blockly . Msg as any ; Util . values ( _blockDefinitions ) . filter ( b => b . block ) . forEach ( b => { const keys = Object . keys ( b . block ) ; b . translationIds = Util . values ( b . block ) ; keys . forEach ( k => pxt . crowdin . inContextLoadAsync ( b . block [ k ] ) . then ( r => { b . block [ k ] = r ; if ( /^[A-Z_]+$/ . test ( k ) ) msg [ k ] = r ; } ) ) ; } ) ; } } }