mirror of
https://github.com/google/blockly.git
synced 2026-05-03 02:20:12 +02:00
chore(build): Rebuild blockly for v9.0.0 release (#6479)
This commit is contained in:
committed by
GitHub
parent
c836645235
commit
b06576c8d1
+1515
-1993
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+189
-171
@@ -12,100 +12,113 @@
|
||||
}
|
||||
}(this, function(__parent__) {
|
||||
var $=__parent__.__namespace__;
|
||||
var module$exports$Blockly$libraryBlocks$variablesDynamic={};
|
||||
module$exports$Blockly$libraryBlocks$variablesDynamic.blocks=(0,$.module$exports$Blockly$common.createBlockDefinitionsFromJsonArray)([{type:"variables_get_dynamic",message0:"%1",args0:[{type:"field_variable",name:"VAR",variable:"%{BKY_VARIABLES_DEFAULT_NAME}"}],output:null,style:"variable_dynamic_blocks",helpUrl:"%{BKY_VARIABLES_GET_HELPURL}",tooltip:"%{BKY_VARIABLES_GET_TOOLTIP}",extensions:["contextMenu_variableDynamicSetterGetter"]},{type:"variables_set_dynamic",message0:"%{BKY_VARIABLES_SET}",
|
||||
var module$exports$Blockly$libraryBlocks$variablesDynamic={},module$contents$Blockly$libraryBlocks$variablesDynamic_ContextMenu=$.module$build$src$core$contextmenu,module$contents$Blockly$libraryBlocks$variablesDynamic_Extensions=$.module$build$src$core$extensions,module$contents$Blockly$libraryBlocks$variablesDynamic_Variables=$.module$build$src$core$variables,module$contents$Blockly$libraryBlocks$variablesDynamic_xml=$.module$build$src$core$utils$xml,module$contents$Blockly$libraryBlocks$variablesDynamic_BlockDefinition=
|
||||
Object,module$contents$Blockly$libraryBlocks$variablesDynamic_Msg=$.module$build$src$core$msg.Msg,module$contents$Blockly$libraryBlocks$variablesDynamic_createBlockDefinitionsFromJsonArray=$.module$build$src$core$common.createBlockDefinitionsFromJsonArray,module$contents$Blockly$libraryBlocks$variablesDynamic_defineBlocks=$.module$build$src$core$common.defineBlocks;
|
||||
module$exports$Blockly$libraryBlocks$variablesDynamic.blocks=module$contents$Blockly$libraryBlocks$variablesDynamic_createBlockDefinitionsFromJsonArray([{type:"variables_get_dynamic",message0:"%1",args0:[{type:"field_variable",name:"VAR",variable:"%{BKY_VARIABLES_DEFAULT_NAME}"}],output:null,style:"variable_dynamic_blocks",helpUrl:"%{BKY_VARIABLES_GET_HELPURL}",tooltip:"%{BKY_VARIABLES_GET_TOOLTIP}",extensions:["contextMenu_variableDynamicSetterGetter"]},{type:"variables_set_dynamic",message0:"%{BKY_VARIABLES_SET}",
|
||||
args0:[{type:"field_variable",name:"VAR",variable:"%{BKY_VARIABLES_DEFAULT_NAME}"},{type:"input_value",name:"VALUE"}],previousStatement:null,nextStatement:null,style:"variable_dynamic_blocks",tooltip:"%{BKY_VARIABLES_SET_TOOLTIP}",helpUrl:"%{BKY_VARIABLES_SET_HELPURL}",extensions:["contextMenu_variableDynamicSetterGetter"]}]);
|
||||
var module$contents$Blockly$libraryBlocks$variablesDynamic_CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MIXIN={customContextMenu:function(a){if(!this.isInFlyout){var b=this.getFieldValue("VAR");var c=this.workspace.getVariableById(b).type;if("variables_get_dynamic"===this.type){b="variables_set_dynamic";var d=$.module$exports$Blockly$Msg.Msg.VARIABLES_GET_CREATE_SET}else b="variables_get_dynamic",d=$.module$exports$Blockly$Msg.Msg.VARIABLES_SET_CREATE_GET;var e={enabled:0<this.workspace.remainingCapacity()},
|
||||
f=this.getField("VAR").getText();e.text=d.replace("%1",f);d=(0,$.module$exports$Blockly$utils$xml.createElement)("field");d.setAttribute("name","VAR");d.setAttribute("variabletype",c);d.appendChild((0,$.module$exports$Blockly$utils$xml.createTextNode)(f));c=(0,$.module$exports$Blockly$utils$xml.createElement)("block");c.setAttribute("type",b);c.appendChild(d);e.callback=(0,$.module$exports$Blockly$ContextMenu.callbackFactory)(this,c);a.push(e)}else if("variables_get_dynamic"===this.type||"variables_get_reporter_dynamic"===
|
||||
this.type)b={text:$.module$exports$Blockly$Msg.Msg.RENAME_VARIABLE,enabled:!0,callback:module$contents$Blockly$libraryBlocks$variablesDynamic_renameOptionCallbackFactory(this)},e=this.getField("VAR").getText(),e={text:$.module$exports$Blockly$Msg.Msg.DELETE_VARIABLE.replace("%1",e),enabled:!0,callback:module$contents$Blockly$libraryBlocks$variablesDynamic_deleteOptionCallbackFactory(this)},a.unshift(b),a.unshift(e)},onchange:function(a){a=this.getFieldValue("VAR");a=(0,$.module$exports$Blockly$Variables.getVariable)(this.workspace,
|
||||
a);"variables_get_dynamic"===this.type?this.outputConnection.setCheck(a.type):this.getInput("VALUE").connection.setCheck(a.type)}},module$contents$Blockly$libraryBlocks$variablesDynamic_renameOptionCallbackFactory=function(a){return function(){var b=a.workspace,c=a.getField("VAR").getVariable();(0,$.module$exports$Blockly$Variables.renameVariable)(b,c)}},module$contents$Blockly$libraryBlocks$variablesDynamic_deleteOptionCallbackFactory=function(a){return function(){var b=a.workspace,c=a.getField("VAR").getVariable();
|
||||
b.deleteVariableById(c.getId());b.refreshToolboxSelection()}};(0,$.module$exports$Blockly$Extensions.registerMixin)("contextMenu_variableDynamicSetterGetter",module$contents$Blockly$libraryBlocks$variablesDynamic_CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MIXIN);(0,$.module$exports$Blockly$common.defineBlocks)(module$exports$Blockly$libraryBlocks$variablesDynamic.blocks);var module$exports$Blockly$libraryBlocks$variables={};
|
||||
module$exports$Blockly$libraryBlocks$variables.blocks=(0,$.module$exports$Blockly$common.createBlockDefinitionsFromJsonArray)([{type:"variables_get",message0:"%1",args0:[{type:"field_variable",name:"VAR",variable:"%{BKY_VARIABLES_DEFAULT_NAME}"}],output:null,style:"variable_blocks",helpUrl:"%{BKY_VARIABLES_GET_HELPURL}",tooltip:"%{BKY_VARIABLES_GET_TOOLTIP}",extensions:["contextMenu_variableSetterGetter"]},{type:"variables_set",message0:"%{BKY_VARIABLES_SET}",args0:[{type:"field_variable",name:"VAR",
|
||||
variable:"%{BKY_VARIABLES_DEFAULT_NAME}"},{type:"input_value",name:"VALUE"}],previousStatement:null,nextStatement:null,style:"variable_blocks",tooltip:"%{BKY_VARIABLES_SET_TOOLTIP}",helpUrl:"%{BKY_VARIABLES_SET_HELPURL}",extensions:["contextMenu_variableSetterGetter"]}]);
|
||||
var module$contents$Blockly$libraryBlocks$variables_CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MIXIN={customContextMenu:function(a){if(!this.isInFlyout){if("variables_get"===this.type){var b="variables_set";var c=$.module$exports$Blockly$Msg.Msg.VARIABLES_GET_CREATE_SET}else b="variables_get",c=$.module$exports$Blockly$Msg.Msg.VARIABLES_SET_CREATE_GET;var d={enabled:0<this.workspace.remainingCapacity()},e=this.getField("VAR").getText();d.text=c.replace("%1",e);c=(0,$.module$exports$Blockly$utils$xml.createElement)("field");
|
||||
c.setAttribute("name","VAR");c.appendChild((0,$.module$exports$Blockly$utils$xml.createTextNode)(e));e=(0,$.module$exports$Blockly$utils$xml.createElement)("block");e.setAttribute("type",b);e.appendChild(c);d.callback=(0,$.module$exports$Blockly$ContextMenu.callbackFactory)(this,e);a.push(d)}else if("variables_get"===this.type||"variables_get_reporter"===this.type)b={text:$.module$exports$Blockly$Msg.Msg.RENAME_VARIABLE,enabled:!0,callback:module$contents$Blockly$libraryBlocks$variables_renameOptionCallbackFactory(this)},
|
||||
d=this.getField("VAR").getText(),d={text:$.module$exports$Blockly$Msg.Msg.DELETE_VARIABLE.replace("%1",d),enabled:!0,callback:module$contents$Blockly$libraryBlocks$variables_deleteOptionCallbackFactory(this)},a.unshift(b),a.unshift(d)}},module$contents$Blockly$libraryBlocks$variables_renameOptionCallbackFactory=function(a){return function(){var b=a.workspace,c=a.getField("VAR").getVariable();(0,$.module$exports$Blockly$Variables.renameVariable)(b,c)}},module$contents$Blockly$libraryBlocks$variables_deleteOptionCallbackFactory=
|
||||
function(a){return function(){var b=a.workspace,c=a.getField("VAR").getVariable();b.deleteVariableById(c.getId());b.refreshToolboxSelection()}};(0,$.module$exports$Blockly$Extensions.registerMixin)("contextMenu_variableSetterGetter",module$contents$Blockly$libraryBlocks$variables_CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MIXIN);(0,$.module$exports$Blockly$common.defineBlocks)(module$exports$Blockly$libraryBlocks$variables.blocks);var module$exports$Blockly$libraryBlocks$texts={};
|
||||
module$exports$Blockly$libraryBlocks$texts.blocks=(0,$.module$exports$Blockly$common.createBlockDefinitionsFromJsonArray)([{type:"text",message0:"%1",args0:[{type:"field_input",name:"TEXT",text:""}],output:"String",style:"text_blocks",helpUrl:"%{BKY_TEXT_TEXT_HELPURL}",tooltip:"%{BKY_TEXT_TEXT_TOOLTIP}",extensions:["text_quotes","parent_tooltip_when_inline"]},{type:"text_multiline",message0:"%1 %2",args0:[{type:"field_image",src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAARCAYAAADpPU2iAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAdhgAAHYYBXaITgQAAABh0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMS42/U4J6AAAAP1JREFUOE+Vks0KQUEYhjmRIja4ABtZ2dm5A3t3Ia6AUm7CylYuQRaUhZSlLZJiQbFAyRnPN33y01HOW08z8873zpwzM4F3GWOCruvGIE4/rLaV+Nq1hVGMBqzhqlxgCys4wJA65xnogMHsQ5lujnYHTejBBCK2mE4abjCgMGhNxHgDFWjDSG07kdfVa2pZMf4ZyMAdWmpZMfYOsLiDMYMjlMB+K613QISRhTnITnsYg5yUd0DETmEoMlkFOeIT/A58iyK5E18BuTBfgYXfwNJv4P9/oEBerLylOnRhygmGdPpTTBZAPkde61lbQe4moWUvYUZYLfUNftIY4zwA5X2Z9AYnQrEAAAAASUVORK5CYII=",width:12,
|
||||
height:17,alt:"\u00b6"},{type:"field_multilinetext",name:"TEXT",text:""}],output:"String",style:"text_blocks",helpUrl:"%{BKY_TEXT_TEXT_HELPURL}",tooltip:"%{BKY_TEXT_TEXT_TOOLTIP}",extensions:["parent_tooltip_when_inline"]},{type:"text_join",message0:"",output:"String",style:"text_blocks",helpUrl:"%{BKY_TEXT_JOIN_HELPURL}",tooltip:"%{BKY_TEXT_JOIN_TOOLTIP}",mutator:"text_join_mutator"},{type:"text_create_join_container",message0:"%{BKY_TEXT_CREATE_JOIN_TITLE_JOIN} %1 %2",args0:[{type:"input_dummy"},
|
||||
var module$contents$Blockly$libraryBlocks$variablesDynamic_CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MIXIN={customContextMenu:function(a){if(!this.isInFlyout){var b=this.getFieldValue("VAR");var c=this.workspace.getVariableById(b).type;if("variables_get_dynamic"===this.type){b="variables_set_dynamic";var d=module$contents$Blockly$libraryBlocks$variablesDynamic_Msg.VARIABLES_GET_CREATE_SET}else b="variables_get_dynamic",d=module$contents$Blockly$libraryBlocks$variablesDynamic_Msg.VARIABLES_SET_CREATE_GET;
|
||||
var e={enabled:0<this.workspace.remainingCapacity()};const f=this.getField("VAR").getText();e.text=d.replace("%1",f);d=$.module$build$src$core$utils$xml.createElement("field");d.setAttribute("name","VAR");d.setAttribute("variabletype",c);d.appendChild($.module$build$src$core$utils$xml.createTextNode(f));c=$.module$build$src$core$utils$xml.createElement("block");c.setAttribute("type",b);c.appendChild(d);e.callback=$.module$build$src$core$contextmenu.callbackFactory(this,c);a.push(e)}else if("variables_get_dynamic"===
|
||||
this.type||"variables_get_reporter_dynamic"===this.type)b={text:module$contents$Blockly$libraryBlocks$variablesDynamic_Msg.RENAME_VARIABLE,enabled:!0,callback:module$contents$Blockly$libraryBlocks$variablesDynamic_renameOptionCallbackFactory(this)},e=this.getField("VAR").getText(),e={text:module$contents$Blockly$libraryBlocks$variablesDynamic_Msg.DELETE_VARIABLE.replace("%1",e),enabled:!0,callback:module$contents$Blockly$libraryBlocks$variablesDynamic_deleteOptionCallbackFactory(this)},a.unshift(b),
|
||||
a.unshift(e)},onchange:function(a){a=this.getFieldValue("VAR");a=$.module$build$src$core$variables.getVariable(this.workspace,a);"variables_get_dynamic"===this.type?this.outputConnection.setCheck(a.type):this.getInput("VALUE").connection.setCheck(a.type)}},module$contents$Blockly$libraryBlocks$variablesDynamic_renameOptionCallbackFactory=function(a){return function(){const b=a.workspace,c=a.getField("VAR").getVariable();$.module$build$src$core$variables.renameVariable(b,c)}},module$contents$Blockly$libraryBlocks$variablesDynamic_deleteOptionCallbackFactory=
|
||||
function(a){return function(){const b=a.workspace,c=a.getField("VAR").getVariable();b.deleteVariableById(c.getId());b.refreshToolboxSelection()}};$.module$build$src$core$extensions.registerMixin("contextMenu_variableDynamicSetterGetter",module$contents$Blockly$libraryBlocks$variablesDynamic_CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MIXIN);module$contents$Blockly$libraryBlocks$variablesDynamic_defineBlocks(module$exports$Blockly$libraryBlocks$variablesDynamic.blocks);var module$exports$Blockly$libraryBlocks$variables={},module$contents$Blockly$libraryBlocks$variables_ContextMenu=$.module$build$src$core$contextmenu,module$contents$Blockly$libraryBlocks$variables_Extensions=$.module$build$src$core$extensions,module$contents$Blockly$libraryBlocks$variables_Variables=$.module$build$src$core$variables,module$contents$Blockly$libraryBlocks$variables_xmlUtils=$.module$build$src$core$utils$xml,module$contents$Blockly$libraryBlocks$variables_BlockDefinition=Object,module$contents$Blockly$libraryBlocks$variables_Msg=
|
||||
$.module$build$src$core$msg.Msg,module$contents$Blockly$libraryBlocks$variables_createBlockDefinitionsFromJsonArray=$.module$build$src$core$common.createBlockDefinitionsFromJsonArray,module$contents$Blockly$libraryBlocks$variables_defineBlocks=$.module$build$src$core$common.defineBlocks;
|
||||
module$exports$Blockly$libraryBlocks$variables.blocks=module$contents$Blockly$libraryBlocks$variables_createBlockDefinitionsFromJsonArray([{type:"variables_get",message0:"%1",args0:[{type:"field_variable",name:"VAR",variable:"%{BKY_VARIABLES_DEFAULT_NAME}"}],output:null,style:"variable_blocks",helpUrl:"%{BKY_VARIABLES_GET_HELPURL}",tooltip:"%{BKY_VARIABLES_GET_TOOLTIP}",extensions:["contextMenu_variableSetterGetter"]},{type:"variables_set",message0:"%{BKY_VARIABLES_SET}",args0:[{type:"field_variable",
|
||||
name:"VAR",variable:"%{BKY_VARIABLES_DEFAULT_NAME}"},{type:"input_value",name:"VALUE"}],previousStatement:null,nextStatement:null,style:"variable_blocks",tooltip:"%{BKY_VARIABLES_SET_TOOLTIP}",helpUrl:"%{BKY_VARIABLES_SET_HELPURL}",extensions:["contextMenu_variableSetterGetter"]}]);
|
||||
var module$contents$Blockly$libraryBlocks$variables_CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MIXIN={customContextMenu:function(a){if(!this.isInFlyout){if("variables_get"===this.type){var b="variables_set";var c=module$contents$Blockly$libraryBlocks$variables_Msg.VARIABLES_GET_CREATE_SET}else b="variables_get",c=module$contents$Blockly$libraryBlocks$variables_Msg.VARIABLES_SET_CREATE_GET;var d={enabled:0<this.workspace.remainingCapacity()},e=this.getField("VAR").getText();d.text=c.replace("%1",e);
|
||||
c=$.module$build$src$core$utils$xml.createElement("field");c.setAttribute("name","VAR");c.appendChild($.module$build$src$core$utils$xml.createTextNode(e));e=$.module$build$src$core$utils$xml.createElement("block");e.setAttribute("type",b);e.appendChild(c);d.callback=$.module$build$src$core$contextmenu.callbackFactory(this,e);a.push(d)}else if("variables_get"===this.type||"variables_get_reporter"===this.type)b={text:module$contents$Blockly$libraryBlocks$variables_Msg.RENAME_VARIABLE,enabled:!0,callback:module$contents$Blockly$libraryBlocks$variables_renameOptionCallbackFactory(this)},
|
||||
d=this.getField("VAR").getText(),d={text:module$contents$Blockly$libraryBlocks$variables_Msg.DELETE_VARIABLE.replace("%1",d),enabled:!0,callback:module$contents$Blockly$libraryBlocks$variables_deleteOptionCallbackFactory(this)},a.unshift(b),a.unshift(d)}},module$contents$Blockly$libraryBlocks$variables_renameOptionCallbackFactory=function(a){return function(){const b=a.workspace,c=a.getField("VAR").getVariable();$.module$build$src$core$variables.renameVariable(b,c)}},module$contents$Blockly$libraryBlocks$variables_deleteOptionCallbackFactory=
|
||||
function(a){return function(){const b=a.workspace,c=a.getField("VAR").getVariable();b.deleteVariableById(c.getId());b.refreshToolboxSelection()}};$.module$build$src$core$extensions.registerMixin("contextMenu_variableSetterGetter",module$contents$Blockly$libraryBlocks$variables_CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MIXIN);module$contents$Blockly$libraryBlocks$variables_defineBlocks(module$exports$Blockly$libraryBlocks$variables.blocks);var module$exports$Blockly$libraryBlocks$texts={},module$contents$Blockly$libraryBlocks$texts_Extensions=$.module$build$src$core$extensions,module$contents$Blockly$libraryBlocks$texts_Msg=$.module$build$src$core$msg.Msg,module$contents$Blockly$libraryBlocks$texts_xmlUtils=$.module$build$src$core$utils$xml,module$contents$Blockly$libraryBlocks$texts_Align=$.Align$$module$build$src$core$input,module$contents$Blockly$libraryBlocks$texts_BlockDefinition=Object,module$contents$Blockly$libraryBlocks$texts_ConnectionType=
|
||||
$.module$build$src$core$connection_type.ConnectionType,module$contents$Blockly$libraryBlocks$texts_FieldDropdown=$.module$build$src$core$field_dropdown.FieldDropdown,module$contents$Blockly$libraryBlocks$texts_FieldImage=$.FieldImage$$module$build$src$core$field_image,module$contents$Blockly$libraryBlocks$texts_FieldTextInput=$.FieldTextInput$$module$build$src$core$field_textinput,module$contents$Blockly$libraryBlocks$texts_Mutator=$.Mutator$$module$build$src$core$mutator,module$contents$Blockly$libraryBlocks$texts_createBlockDefinitionsFromJsonArray=
|
||||
$.module$build$src$core$common.createBlockDefinitionsFromJsonArray,module$contents$Blockly$libraryBlocks$texts_defineBlocks=$.module$build$src$core$common.defineBlocks;
|
||||
module$exports$Blockly$libraryBlocks$texts.blocks=module$contents$Blockly$libraryBlocks$texts_createBlockDefinitionsFromJsonArray([{type:"text",message0:"%1",args0:[{type:"field_input",name:"TEXT",text:""}],output:"String",style:"text_blocks",helpUrl:"%{BKY_TEXT_TEXT_HELPURL}",tooltip:"%{BKY_TEXT_TEXT_TOOLTIP}",extensions:["text_quotes","parent_tooltip_when_inline"]},{type:"text_multiline",message0:"%1 %2",args0:[{type:"field_image",src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAARCAYAAADpPU2iAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAdhgAAHYYBXaITgQAAABh0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMS42/U4J6AAAAP1JREFUOE+Vks0KQUEYhjmRIja4ABtZ2dm5A3t3Ia6AUm7CylYuQRaUhZSlLZJiQbFAyRnPN33y01HOW08z8873zpwzM4F3GWOCruvGIE4/rLaV+Nq1hVGMBqzhqlxgCys4wJA65xnogMHsQ5lujnYHTejBBCK2mE4abjCgMGhNxHgDFWjDSG07kdfVa2pZMf4ZyMAdWmpZMfYOsLiDMYMjlMB+K613QISRhTnITnsYg5yUd0DETmEoMlkFOeIT/A58iyK5E18BuTBfgYXfwNJv4P9/oEBerLylOnRhygmGdPpTTBZAPkde61lbQe4moWUvYUZYLfUNftIY4zwA5X2Z9AYnQrEAAAAASUVORK5CYII=",
|
||||
width:12,height:17,alt:"\u00b6"},{type:"field_multilinetext",name:"TEXT",text:""}],output:"String",style:"text_blocks",helpUrl:"%{BKY_TEXT_TEXT_HELPURL}",tooltip:"%{BKY_TEXT_TEXT_TOOLTIP}",extensions:["parent_tooltip_when_inline"]},{type:"text_join",message0:"",output:"String",style:"text_blocks",helpUrl:"%{BKY_TEXT_JOIN_HELPURL}",tooltip:"%{BKY_TEXT_JOIN_TOOLTIP}",mutator:"text_join_mutator"},{type:"text_create_join_container",message0:"%{BKY_TEXT_CREATE_JOIN_TITLE_JOIN} %1 %2",args0:[{type:"input_dummy"},
|
||||
{type:"input_statement",name:"STACK"}],style:"text_blocks",tooltip:"%{BKY_TEXT_CREATE_JOIN_TOOLTIP}",enableContextMenu:!1},{type:"text_create_join_item",message0:"%{BKY_TEXT_CREATE_JOIN_ITEM_TITLE_ITEM}",previousStatement:null,nextStatement:null,style:"text_blocks",tooltip:"%{BKY_TEXT_CREATE_JOIN_ITEM_TOOLTIP}",enableContextMenu:!1},{type:"text_append",message0:"%{BKY_TEXT_APPEND_TITLE}",args0:[{type:"field_variable",name:"VAR",variable:"%{BKY_TEXT_APPEND_VARIABLE}"},{type:"input_value",name:"TEXT"}],
|
||||
previousStatement:null,nextStatement:null,style:"text_blocks",extensions:["text_append_tooltip"]},{type:"text_length",message0:"%{BKY_TEXT_LENGTH_TITLE}",args0:[{type:"input_value",name:"VALUE",check:["String","Array"]}],output:"Number",style:"text_blocks",tooltip:"%{BKY_TEXT_LENGTH_TOOLTIP}",helpUrl:"%{BKY_TEXT_LENGTH_HELPURL}"},{type:"text_isEmpty",message0:"%{BKY_TEXT_ISEMPTY_TITLE}",args0:[{type:"input_value",name:"VALUE",check:["String","Array"]}],output:"Boolean",style:"text_blocks",tooltip:"%{BKY_TEXT_ISEMPTY_TOOLTIP}",
|
||||
helpUrl:"%{BKY_TEXT_ISEMPTY_HELPURL}"},{type:"text_indexOf",message0:"%{BKY_TEXT_INDEXOF_TITLE}",args0:[{type:"input_value",name:"VALUE",check:"String"},{type:"field_dropdown",name:"END",options:[["%{BKY_TEXT_INDEXOF_OPERATOR_FIRST}","FIRST"],["%{BKY_TEXT_INDEXOF_OPERATOR_LAST}","LAST"]]},{type:"input_value",name:"FIND",check:"String"}],output:"Number",style:"text_blocks",helpUrl:"%{BKY_TEXT_INDEXOF_HELPURL}",inputsInline:!0,extensions:["text_indexOf_tooltip"]},{type:"text_charAt",message0:"%{BKY_TEXT_CHARAT_TITLE}",
|
||||
args0:[{type:"input_value",name:"VALUE",check:"String"},{type:"field_dropdown",name:"WHERE",options:[["%{BKY_TEXT_CHARAT_FROM_START}","FROM_START"],["%{BKY_TEXT_CHARAT_FROM_END}","FROM_END"],["%{BKY_TEXT_CHARAT_FIRST}","FIRST"],["%{BKY_TEXT_CHARAT_LAST}","LAST"],["%{BKY_TEXT_CHARAT_RANDOM}","RANDOM"]]}],output:"String",style:"text_blocks",helpUrl:"%{BKY_TEXT_CHARAT_HELPURL}",inputsInline:!0,mutator:"text_charAt_mutator"}]);
|
||||
module$exports$Blockly$libraryBlocks$texts.blocks.text_getSubstring={init:function(){this.WHERE_OPTIONS_1=[[$.module$exports$Blockly$Msg.Msg.TEXT_GET_SUBSTRING_START_FROM_START,"FROM_START"],[$.module$exports$Blockly$Msg.Msg.TEXT_GET_SUBSTRING_START_FROM_END,"FROM_END"],[$.module$exports$Blockly$Msg.Msg.TEXT_GET_SUBSTRING_START_FIRST,"FIRST"]];this.WHERE_OPTIONS_2=[[$.module$exports$Blockly$Msg.Msg.TEXT_GET_SUBSTRING_END_FROM_START,"FROM_START"],[$.module$exports$Blockly$Msg.Msg.TEXT_GET_SUBSTRING_END_FROM_END,
|
||||
"FROM_END"],[$.module$exports$Blockly$Msg.Msg.TEXT_GET_SUBSTRING_END_LAST,"LAST"]];this.setHelpUrl($.module$exports$Blockly$Msg.Msg.TEXT_GET_SUBSTRING_HELPURL);this.setStyle("text_blocks");this.appendValueInput("STRING").setCheck("String").appendField($.module$exports$Blockly$Msg.Msg.TEXT_GET_SUBSTRING_INPUT_IN_TEXT);this.appendDummyInput("AT1");this.appendDummyInput("AT2");$.module$exports$Blockly$Msg.Msg.TEXT_GET_SUBSTRING_TAIL&&this.appendDummyInput("TAIL").appendField($.module$exports$Blockly$Msg.Msg.TEXT_GET_SUBSTRING_TAIL);
|
||||
this.setInputsInline(!0);this.setOutput(!0,"String");this.updateAt_(1,!0);this.updateAt_(2,!0);this.setTooltip($.module$exports$Blockly$Msg.Msg.TEXT_GET_SUBSTRING_TOOLTIP)},mutationToDom:function(){var a=(0,$.module$exports$Blockly$utils$xml.createElement)("mutation"),b=this.getInput("AT1").type===$.module$exports$Blockly$ConnectionType.ConnectionType.INPUT_VALUE;a.setAttribute("at1",b);b=this.getInput("AT2").type===$.module$exports$Blockly$ConnectionType.ConnectionType.INPUT_VALUE;a.setAttribute("at2",
|
||||
b);return a},domToMutation:function(a){var b="true"===a.getAttribute("at1");a="true"===a.getAttribute("at2");this.updateAt_(1,b);this.updateAt_(2,a)},updateAt_:function(a,b){this.removeInput("AT"+a);this.removeInput("ORDINAL"+a,!0);b?(this.appendValueInput("AT"+a).setCheck("Number"),$.module$exports$Blockly$Msg.Msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL"+a).appendField($.module$exports$Blockly$Msg.Msg.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT"+a);2===a&&$.module$exports$Blockly$Msg.Msg.TEXT_GET_SUBSTRING_TAIL&&
|
||||
(this.removeInput("TAIL",!0),this.appendDummyInput("TAIL").appendField($.module$exports$Blockly$Msg.Msg.TEXT_GET_SUBSTRING_TAIL));var c=new $.module$exports$Blockly$FieldDropdown.FieldDropdown(this["WHERE_OPTIONS_"+a],function(d){var e="FROM_START"===d||"FROM_END"===d;if(e!==b){var f=this.getSourceBlock();f.updateAt_(a,e);f.setFieldValue(d,"WHERE"+a);return null}});this.getInput("AT"+a).appendField(c,"WHERE"+a);1===a&&(this.moveInputBefore("AT1","AT2"),this.getInput("ORDINAL1")&&this.moveInputBefore("ORDINAL1",
|
||||
"AT2"))}};
|
||||
module$exports$Blockly$libraryBlocks$texts.blocks.text_changeCase={init:function(){var a=[[$.module$exports$Blockly$Msg.Msg.TEXT_CHANGECASE_OPERATOR_UPPERCASE,"UPPERCASE"],[$.module$exports$Blockly$Msg.Msg.TEXT_CHANGECASE_OPERATOR_LOWERCASE,"LOWERCASE"],[$.module$exports$Blockly$Msg.Msg.TEXT_CHANGECASE_OPERATOR_TITLECASE,"TITLECASE"]];this.setHelpUrl($.module$exports$Blockly$Msg.Msg.TEXT_CHANGECASE_HELPURL);this.setStyle("text_blocks");this.appendValueInput("TEXT").setCheck("String").appendField(new $.module$exports$Blockly$FieldDropdown.FieldDropdown(a),"CASE");
|
||||
this.setOutput(!0,"String");this.setTooltip($.module$exports$Blockly$Msg.Msg.TEXT_CHANGECASE_TOOLTIP)}};
|
||||
module$exports$Blockly$libraryBlocks$texts.blocks.text_trim={init:function(){var a=[[$.module$exports$Blockly$Msg.Msg.TEXT_TRIM_OPERATOR_BOTH,"BOTH"],[$.module$exports$Blockly$Msg.Msg.TEXT_TRIM_OPERATOR_LEFT,"LEFT"],[$.module$exports$Blockly$Msg.Msg.TEXT_TRIM_OPERATOR_RIGHT,"RIGHT"]];this.setHelpUrl($.module$exports$Blockly$Msg.Msg.TEXT_TRIM_HELPURL);this.setStyle("text_blocks");this.appendValueInput("TEXT").setCheck("String").appendField(new $.module$exports$Blockly$FieldDropdown.FieldDropdown(a),"MODE");
|
||||
this.setOutput(!0,"String");this.setTooltip($.module$exports$Blockly$Msg.Msg.TEXT_TRIM_TOOLTIP)}};module$exports$Blockly$libraryBlocks$texts.blocks.text_print={init:function(){this.jsonInit({message0:$.module$exports$Blockly$Msg.Msg.TEXT_PRINT_TITLE,args0:[{type:"input_value",name:"TEXT"}],previousStatement:null,nextStatement:null,style:"text_blocks",tooltip:$.module$exports$Blockly$Msg.Msg.TEXT_PRINT_TOOLTIP,helpUrl:$.module$exports$Blockly$Msg.Msg.TEXT_PRINT_HELPURL})}};
|
||||
var module$contents$Blockly$libraryBlocks$texts_TEXT_PROMPT_COMMON={updateType_:function(a){this.outputConnection.setCheck("NUMBER"===a?"Number":"String")},mutationToDom:function(){var a=(0,$.module$exports$Blockly$utils$xml.createElement)("mutation");a.setAttribute("type",this.getFieldValue("TYPE"));return a},domToMutation:function(a){this.updateType_(a.getAttribute("type"))}};
|
||||
module$exports$Blockly$libraryBlocks$texts.blocks.text_prompt_ext=Object.assign({},module$contents$Blockly$libraryBlocks$texts_TEXT_PROMPT_COMMON,{init:function(){var a=[[$.module$exports$Blockly$Msg.Msg.TEXT_PROMPT_TYPE_TEXT,"TEXT"],[$.module$exports$Blockly$Msg.Msg.TEXT_PROMPT_TYPE_NUMBER,"NUMBER"]];this.setHelpUrl($.module$exports$Blockly$Msg.Msg.TEXT_PROMPT_HELPURL);this.setStyle("text_blocks");var b=this;a=new $.module$exports$Blockly$FieldDropdown.FieldDropdown(a,function(c){b.updateType_(c)});
|
||||
this.appendValueInput("TEXT").appendField(a,"TYPE");this.setOutput(!0,"String");this.setTooltip(function(){return"TEXT"===b.getFieldValue("TYPE")?$.module$exports$Blockly$Msg.Msg.TEXT_PROMPT_TOOLTIP_TEXT:$.module$exports$Blockly$Msg.Msg.TEXT_PROMPT_TOOLTIP_NUMBER})}});
|
||||
module$exports$Blockly$libraryBlocks$texts.blocks.text_prompt=Object.assign({},module$contents$Blockly$libraryBlocks$texts_TEXT_PROMPT_COMMON,{init:function(){this.mixin(module$contents$Blockly$libraryBlocks$texts_QUOTE_IMAGE_MIXIN);var a=[[$.module$exports$Blockly$Msg.Msg.TEXT_PROMPT_TYPE_TEXT,"TEXT"],[$.module$exports$Blockly$Msg.Msg.TEXT_PROMPT_TYPE_NUMBER,"NUMBER"]],b=this;this.setHelpUrl($.module$exports$Blockly$Msg.Msg.TEXT_PROMPT_HELPURL);this.setStyle("text_blocks");a=new $.module$exports$Blockly$FieldDropdown.FieldDropdown(a,
|
||||
function(c){b.updateType_(c)});this.appendDummyInput().appendField(a,"TYPE").appendField(this.newQuote_(!0)).appendField(new $.module$exports$Blockly$FieldTextInput.FieldTextInput(""),"TEXT").appendField(this.newQuote_(!1));this.setOutput(!0,"String");this.setTooltip(function(){return"TEXT"===b.getFieldValue("TYPE")?$.module$exports$Blockly$Msg.Msg.TEXT_PROMPT_TOOLTIP_TEXT:$.module$exports$Blockly$Msg.Msg.TEXT_PROMPT_TOOLTIP_NUMBER})}});
|
||||
module$exports$Blockly$libraryBlocks$texts.blocks.text_count={init:function(){this.jsonInit({message0:$.module$exports$Blockly$Msg.Msg.TEXT_COUNT_MESSAGE0,args0:[{type:"input_value",name:"SUB",check:"String"},{type:"input_value",name:"TEXT",check:"String"}],output:"Number",inputsInline:!0,style:"text_blocks",tooltip:$.module$exports$Blockly$Msg.Msg.TEXT_COUNT_TOOLTIP,helpUrl:$.module$exports$Blockly$Msg.Msg.TEXT_COUNT_HELPURL})}};
|
||||
module$exports$Blockly$libraryBlocks$texts.blocks.text_replace={init:function(){this.jsonInit({message0:$.module$exports$Blockly$Msg.Msg.TEXT_REPLACE_MESSAGE0,args0:[{type:"input_value",name:"FROM",check:"String"},{type:"input_value",name:"TO",check:"String"},{type:"input_value",name:"TEXT",check:"String"}],output:"String",inputsInline:!0,style:"text_blocks",tooltip:$.module$exports$Blockly$Msg.Msg.TEXT_REPLACE_TOOLTIP,helpUrl:$.module$exports$Blockly$Msg.Msg.TEXT_REPLACE_HELPURL})}};
|
||||
module$exports$Blockly$libraryBlocks$texts.blocks.text_reverse={init:function(){this.jsonInit({message0:$.module$exports$Blockly$Msg.Msg.TEXT_REVERSE_MESSAGE0,args0:[{type:"input_value",name:"TEXT",check:"String"}],output:"String",inputsInline:!0,style:"text_blocks",tooltip:$.module$exports$Blockly$Msg.Msg.TEXT_REVERSE_TOOLTIP,helpUrl:$.module$exports$Blockly$Msg.Msg.TEXT_REVERSE_HELPURL})}};
|
||||
module$exports$Blockly$libraryBlocks$texts.blocks.text_getSubstring={init:function(){this.WHERE_OPTIONS_1=[[module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_GET_SUBSTRING_START_FROM_START,"FROM_START"],[module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_GET_SUBSTRING_START_FROM_END,"FROM_END"],[module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_GET_SUBSTRING_START_FIRST,"FIRST"]];this.WHERE_OPTIONS_2=[[module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_GET_SUBSTRING_END_FROM_START,"FROM_START"],
|
||||
[module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_GET_SUBSTRING_END_FROM_END,"FROM_END"],[module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_GET_SUBSTRING_END_LAST,"LAST"]];this.setHelpUrl(module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_GET_SUBSTRING_HELPURL);this.setStyle("text_blocks");this.appendValueInput("STRING").setCheck("String").appendField(module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_GET_SUBSTRING_INPUT_IN_TEXT);this.appendDummyInput("AT1");this.appendDummyInput("AT2");
|
||||
module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_GET_SUBSTRING_TAIL&&this.appendDummyInput("TAIL").appendField(module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_GET_SUBSTRING_TAIL);this.setInputsInline(!0);this.setOutput(!0,"String");this.updateAt_(1,!0);this.updateAt_(2,!0);this.setTooltip(module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_GET_SUBSTRING_TOOLTIP)},mutationToDom:function(){const a=$.module$build$src$core$utils$xml.createElement("mutation");var b=this.getInput("AT1").type===
|
||||
$.module$build$src$core$connection_type.ConnectionType.INPUT_VALUE;a.setAttribute("at1",b);b=this.getInput("AT2").type===$.module$build$src$core$connection_type.ConnectionType.INPUT_VALUE;a.setAttribute("at2",b);return a},domToMutation:function(a){const b="true"===a.getAttribute("at1");a="true"===a.getAttribute("at2");this.updateAt_(1,b);this.updateAt_(2,a)},updateAt_:function(a,b){this.removeInput("AT"+a);this.removeInput("ORDINAL"+a,!0);b?(this.appendValueInput("AT"+a).setCheck("Number"),module$contents$Blockly$libraryBlocks$texts_Msg.ORDINAL_NUMBER_SUFFIX&&
|
||||
this.appendDummyInput("ORDINAL"+a).appendField(module$contents$Blockly$libraryBlocks$texts_Msg.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT"+a);2===a&&module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_GET_SUBSTRING_TAIL&&(this.removeInput("TAIL",!0),this.appendDummyInput("TAIL").appendField(module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_GET_SUBSTRING_TAIL));const c=new module$contents$Blockly$libraryBlocks$texts_FieldDropdown(this["WHERE_OPTIONS_"+a],function(d){const e="FROM_START"===
|
||||
d||"FROM_END"===d;if(e!==b){const f=this.getSourceBlock();f.updateAt_(a,e);f.setFieldValue(d,"WHERE"+a);return null}});this.getInput("AT"+a).appendField(c,"WHERE"+a);1===a&&(this.moveInputBefore("AT1","AT2"),this.getInput("ORDINAL1")&&this.moveInputBefore("ORDINAL1","AT2"))}};
|
||||
module$exports$Blockly$libraryBlocks$texts.blocks.text_changeCase={init:function(){const a=[[module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_CHANGECASE_OPERATOR_UPPERCASE,"UPPERCASE"],[module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_CHANGECASE_OPERATOR_LOWERCASE,"LOWERCASE"],[module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_CHANGECASE_OPERATOR_TITLECASE,"TITLECASE"]];this.setHelpUrl(module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_CHANGECASE_HELPURL);this.setStyle("text_blocks");
|
||||
this.appendValueInput("TEXT").setCheck("String").appendField(new module$contents$Blockly$libraryBlocks$texts_FieldDropdown(a),"CASE");this.setOutput(!0,"String");this.setTooltip(module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_CHANGECASE_TOOLTIP)}};
|
||||
module$exports$Blockly$libraryBlocks$texts.blocks.text_trim={init:function(){const a=[[module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_TRIM_OPERATOR_BOTH,"BOTH"],[module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_TRIM_OPERATOR_LEFT,"LEFT"],[module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_TRIM_OPERATOR_RIGHT,"RIGHT"]];this.setHelpUrl(module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_TRIM_HELPURL);this.setStyle("text_blocks");this.appendValueInput("TEXT").setCheck("String").appendField(new module$contents$Blockly$libraryBlocks$texts_FieldDropdown(a),
|
||||
"MODE");this.setOutput(!0,"String");this.setTooltip(module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_TRIM_TOOLTIP)}};module$exports$Blockly$libraryBlocks$texts.blocks.text_print={init:function(){this.jsonInit({message0:module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_PRINT_TITLE,args0:[{type:"input_value",name:"TEXT"}],previousStatement:null,nextStatement:null,style:"text_blocks",tooltip:module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_PRINT_TOOLTIP,helpUrl:module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_PRINT_HELPURL})}};
|
||||
var module$contents$Blockly$libraryBlocks$texts_TEXT_PROMPT_COMMON={updateType_:function(a){this.outputConnection.setCheck("NUMBER"===a?"Number":"String")},mutationToDom:function(){const a=$.module$build$src$core$utils$xml.createElement("mutation");a.setAttribute("type",this.getFieldValue("TYPE"));return a},domToMutation:function(a){this.updateType_(a.getAttribute("type"))}};
|
||||
module$exports$Blockly$libraryBlocks$texts.blocks.text_prompt_ext=Object.assign({},module$contents$Blockly$libraryBlocks$texts_TEXT_PROMPT_COMMON,{init:function(){var a=[[module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_PROMPT_TYPE_TEXT,"TEXT"],[module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_PROMPT_TYPE_NUMBER,"NUMBER"]];this.setHelpUrl(module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_PROMPT_HELPURL);this.setStyle("text_blocks");const b=this;a=new module$contents$Blockly$libraryBlocks$texts_FieldDropdown(a,
|
||||
function(c){b.updateType_(c)});this.appendValueInput("TEXT").appendField(a,"TYPE");this.setOutput(!0,"String");this.setTooltip(function(){return"TEXT"===b.getFieldValue("TYPE")?module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_PROMPT_TOOLTIP_TEXT:module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_PROMPT_TOOLTIP_NUMBER})}});
|
||||
module$exports$Blockly$libraryBlocks$texts.blocks.text_prompt=Object.assign({},module$contents$Blockly$libraryBlocks$texts_TEXT_PROMPT_COMMON,{init:function(){this.mixin(module$contents$Blockly$libraryBlocks$texts_QUOTE_IMAGE_MIXIN);var a=[[module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_PROMPT_TYPE_TEXT,"TEXT"],[module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_PROMPT_TYPE_NUMBER,"NUMBER"]];const b=this;this.setHelpUrl(module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_PROMPT_HELPURL);
|
||||
this.setStyle("text_blocks");a=new module$contents$Blockly$libraryBlocks$texts_FieldDropdown(a,function(c){b.updateType_(c)});this.appendDummyInput().appendField(a,"TYPE").appendField(this.newQuote_(!0)).appendField(new $.FieldTextInput$$module$build$src$core$field_textinput(""),"TEXT").appendField(this.newQuote_(!1));this.setOutput(!0,"String");this.setTooltip(function(){return"TEXT"===b.getFieldValue("TYPE")?module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_PROMPT_TOOLTIP_TEXT:module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_PROMPT_TOOLTIP_NUMBER})}});
|
||||
module$exports$Blockly$libraryBlocks$texts.blocks.text_count={init:function(){this.jsonInit({message0:module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_COUNT_MESSAGE0,args0:[{type:"input_value",name:"SUB",check:"String"},{type:"input_value",name:"TEXT",check:"String"}],output:"Number",inputsInline:!0,style:"text_blocks",tooltip:module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_COUNT_TOOLTIP,helpUrl:module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_COUNT_HELPURL})}};
|
||||
module$exports$Blockly$libraryBlocks$texts.blocks.text_replace={init:function(){this.jsonInit({message0:module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_REPLACE_MESSAGE0,args0:[{type:"input_value",name:"FROM",check:"String"},{type:"input_value",name:"TO",check:"String"},{type:"input_value",name:"TEXT",check:"String"}],output:"String",inputsInline:!0,style:"text_blocks",tooltip:module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_REPLACE_TOOLTIP,helpUrl:module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_REPLACE_HELPURL})}};
|
||||
module$exports$Blockly$libraryBlocks$texts.blocks.text_reverse={init:function(){this.jsonInit({message0:module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_REVERSE_MESSAGE0,args0:[{type:"input_value",name:"TEXT",check:"String"}],output:"String",inputsInline:!0,style:"text_blocks",tooltip:module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_REVERSE_TOOLTIP,helpUrl:module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_REVERSE_HELPURL})}};
|
||||
var module$contents$Blockly$libraryBlocks$texts_QUOTE_IMAGE_MIXIN={QUOTE_IMAGE_LEFT_DATAURI:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAQAAAAqJXdxAAAAn0lEQVQI1z3OMa5BURSF4f/cQhAKjUQhuQmFNwGJEUi0RKN5rU7FHKhpjEH3TEMtkdBSCY1EIv8r7nFX9e29V7EBAOvu7RPjwmWGH/VuF8CyN9/OAdvqIXYLvtRaNjx9mMTDyo+NjAN1HNcl9ZQ5oQMM3dgDUqDo1l8DzvwmtZN7mnD+PkmLa+4mhrxVA9fRowBWmVBhFy5gYEjKMfz9AylsaRRgGzvZAAAAAElFTkSuQmCC",QUOTE_IMAGE_RIGHT_DATAURI:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAQAAAAqJXdxAAAAqUlEQVQI1z3KvUpCcRiA8ef9E4JNHhI0aFEacm1o0BsI0Slx8wa8gLauoDnoBhq7DcfWhggONDmJJgqCPA7neJ7p934EOOKOnM8Q7PDElo/4x4lFb2DmuUjcUzS3URnGib9qaPNbuXvBO3sGPHJDRG6fGVdMSeWDP2q99FQdFrz26Gu5Tq7dFMzUvbXy8KXeAj57cOklgA+u1B5AoslLtGIHQMaCVnwDnADZIFIrXsoXrgAAAABJRU5ErkJggg==",
|
||||
QUOTE_IMAGE_WIDTH:12,QUOTE_IMAGE_HEIGHT:12,quoteField_:function(a){for(var b=0,c;c=this.inputList[b];b++)for(var d=0,e;e=c.fieldRow[d];d++)if(a===e.name){c.insertFieldAt(d,this.newQuote_(!0));c.insertFieldAt(d+2,this.newQuote_(!1));return}console.warn('field named "'+a+'" not found in '+this.toDevString())},newQuote_:function(a){a=this.RTL?!a:a;return new $.module$exports$Blockly$FieldImage.FieldImage(a?this.QUOTE_IMAGE_LEFT_DATAURI:this.QUOTE_IMAGE_RIGHT_DATAURI,this.QUOTE_IMAGE_WIDTH,this.QUOTE_IMAGE_HEIGHT,
|
||||
a?"\u201c":"\u201d")}},module$contents$Blockly$libraryBlocks$texts_TEXT_QUOTES_EXTENSION=function(){this.mixin(module$contents$Blockly$libraryBlocks$texts_QUOTE_IMAGE_MIXIN);this.quoteField_("TEXT")},module$contents$Blockly$libraryBlocks$texts_TEXT_JOIN_MUTATOR_MIXIN={mutationToDom:function(){var a=(0,$.module$exports$Blockly$utils$xml.createElement)("mutation");a.setAttribute("items",this.itemCount_);return a},domToMutation:function(a){this.itemCount_=parseInt(a.getAttribute("items"),10);this.updateShape_()},
|
||||
saveExtraState:function(){return{itemCount:this.itemCount_}},loadExtraState:function(a){this.itemCount_=a.itemCount;this.updateShape_()},decompose:function(a){var b=a.newBlock("text_create_join_container");b.initSvg();for(var c=b.getInput("STACK").connection,d=0;d<this.itemCount_;d++){var e=a.newBlock("text_create_join_item");e.initSvg();c.connect(e.previousConnection);c=e.nextConnection}return b},compose:function(a){var b=a.getInputTargetBlock("STACK");for(a=[];b&&!b.isInsertionMarker();)a.push(b.valueConnection_),
|
||||
b=b.nextConnection&&b.nextConnection.targetBlock();for(b=0;b<this.itemCount_;b++){var c=this.getInput("ADD"+b).connection.targetConnection;c&&-1===a.indexOf(c)&&c.disconnect()}this.itemCount_=a.length;this.updateShape_();for(b=0;b<this.itemCount_;b++)$.module$exports$Blockly$Mutator.Mutator.reconnect(a[b],this,"ADD"+b)},saveConnections:function(a){a=a.getInputTargetBlock("STACK");for(var b=0;a;){var c=this.getInput("ADD"+b);a.valueConnection_=c&&c.connection.targetConnection;a=a.nextConnection&&a.nextConnection.targetBlock();
|
||||
b++}},updateShape_:function(){this.itemCount_&&this.getInput("EMPTY")?this.removeInput("EMPTY"):this.itemCount_||this.getInput("EMPTY")||this.appendDummyInput("EMPTY").appendField(this.newQuote_(!0)).appendField(this.newQuote_(!1));for(var a=0;a<this.itemCount_;a++)if(!this.getInput("ADD"+a)){var b=this.appendValueInput("ADD"+a).setAlign($.module$exports$Blockly$Input.Align.RIGHT);0===a&&b.appendField($.module$exports$Blockly$Msg.Msg.TEXT_JOIN_TITLE_CREATEWITH)}for(a=this.itemCount_;this.getInput("ADD"+
|
||||
a);a++)this.removeInput("ADD"+a)}},module$contents$Blockly$libraryBlocks$texts_TEXT_JOIN_EXTENSION=function(){this.mixin(module$contents$Blockly$libraryBlocks$texts_QUOTE_IMAGE_MIXIN);this.itemCount_=2;this.updateShape_();this.setMutator(new $.module$exports$Blockly$Mutator.Mutator(["text_create_join_item"]))};(0,$.module$exports$Blockly$Extensions.register)("text_append_tooltip",(0,$.module$exports$Blockly$Extensions.buildTooltipWithFieldText)("%{BKY_TEXT_APPEND_TOOLTIP}","VAR"));
|
||||
var module$contents$Blockly$libraryBlocks$texts_TEXT_INDEXOF_TOOLTIP_EXTENSION=function(){var a=this;this.setTooltip(function(){return $.module$exports$Blockly$Msg.Msg.TEXT_INDEXOF_TOOLTIP.replace("%1",a.workspace.options.oneBasedIndex?"0":"-1")})},module$contents$Blockly$libraryBlocks$texts_TEXT_CHARAT_MUTATOR_MIXIN={mutationToDom:function(){var a=(0,$.module$exports$Blockly$utils$xml.createElement)("mutation");a.setAttribute("at",!!this.isAt_);return a},domToMutation:function(a){a="false"!==a.getAttribute("at");
|
||||
this.updateAt_(a)},updateAt_:function(a){this.removeInput("AT",!0);this.removeInput("ORDINAL",!0);a&&(this.appendValueInput("AT").setCheck("Number"),$.module$exports$Blockly$Msg.Msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL").appendField($.module$exports$Blockly$Msg.Msg.ORDINAL_NUMBER_SUFFIX));$.module$exports$Blockly$Msg.Msg.TEXT_CHARAT_TAIL&&(this.removeInput("TAIL",!0),this.appendDummyInput("TAIL").appendField($.module$exports$Blockly$Msg.Msg.TEXT_CHARAT_TAIL));this.isAt_=a}},module$contents$Blockly$libraryBlocks$texts_TEXT_CHARAT_EXTENSION=
|
||||
function(){this.getField("WHERE").setValidator(function(b){b="FROM_START"===b||"FROM_END"===b;b!==this.isAt_&&this.getSourceBlock().updateAt_(b)});this.updateAt_(!0);var a=this;this.setTooltip(function(){var b=a.getFieldValue("WHERE"),c=$.module$exports$Blockly$Msg.Msg.TEXT_CHARAT_TOOLTIP;("FROM_START"===b||"FROM_END"===b)&&(b="FROM_START"===b?$.module$exports$Blockly$Msg.Msg.LISTS_INDEX_FROM_START_TOOLTIP:$.module$exports$Blockly$Msg.Msg.LISTS_INDEX_FROM_END_TOOLTIP)&&(c+=" "+b.replace("%1",a.workspace.options.oneBasedIndex?
|
||||
"#1":"#0"));return c})};(0,$.module$exports$Blockly$Extensions.register)("text_indexOf_tooltip",module$contents$Blockly$libraryBlocks$texts_TEXT_INDEXOF_TOOLTIP_EXTENSION);(0,$.module$exports$Blockly$Extensions.register)("text_quotes",module$contents$Blockly$libraryBlocks$texts_TEXT_QUOTES_EXTENSION);(0,$.module$exports$Blockly$Extensions.registerMutator)("text_join_mutator",module$contents$Blockly$libraryBlocks$texts_TEXT_JOIN_MUTATOR_MIXIN,module$contents$Blockly$libraryBlocks$texts_TEXT_JOIN_EXTENSION);
|
||||
(0,$.module$exports$Blockly$Extensions.registerMutator)("text_charAt_mutator",module$contents$Blockly$libraryBlocks$texts_TEXT_CHARAT_MUTATOR_MIXIN,module$contents$Blockly$libraryBlocks$texts_TEXT_CHARAT_EXTENSION);(0,$.module$exports$Blockly$common.defineBlocks)(module$exports$Blockly$libraryBlocks$texts.blocks);var module$exports$Blockly$libraryBlocks$procedures={blocks:{}},module$contents$Blockly$libraryBlocks$procedures_PROCEDURE_DEF_COMMON={setStatements_:function(a){this.hasStatements_!==a&&(a?(this.appendStatementInput("STACK").appendField($.module$exports$Blockly$Msg.Msg.PROCEDURES_DEFNORETURN_DO),this.getInput("RETURN")&&this.moveInputBefore("STACK","RETURN")):this.removeInput("STACK",!0),this.hasStatements_=a)},updateParams_:function(){var a="";this.arguments_.length&&(a=$.module$exports$Blockly$Msg.Msg.PROCEDURES_BEFORE_PARAMS+
|
||||
" "+this.arguments_.join(", "));(0,$.module$exports$Blockly$Events.disable)();try{this.setFieldValue(a,"PARAMS")}finally{(0,$.module$exports$Blockly$Events.enable)()}},mutationToDom:function(a){var b=(0,$.module$exports$Blockly$utils$xml.createElement)("mutation");a&&b.setAttribute("name",this.getFieldValue("NAME"));for(var c=0;c<this.argumentVarModels_.length;c++){var d=(0,$.module$exports$Blockly$utils$xml.createElement)("arg"),e=this.argumentVarModels_[c];d.setAttribute("name",e.name);d.setAttribute("varid",
|
||||
e.getId());a&&this.paramIds_&&d.setAttribute("paramId",this.paramIds_[c]);b.appendChild(d)}this.hasStatements_||b.setAttribute("statements","false");return b},domToMutation:function(a){this.arguments_=[];this.argumentVarModels_=[];for(var b=0,c;c=a.childNodes[b];b++)if("arg"===c.nodeName.toLowerCase()){var d=c.getAttribute("name");c=c.getAttribute("varid")||c.getAttribute("varId");this.arguments_.push(d);c=(0,$.module$exports$Blockly$Variables.getOrCreateVariablePackage)(this.workspace,c,d,"");null!==
|
||||
c?this.argumentVarModels_.push(c):console.log("Failed to create a variable with name "+d+", ignoring.")}this.updateParams_();(0,$.module$exports$Blockly$Procedures.mutateCallers)(this);this.setStatements_("false"!==a.getAttribute("statements"))},saveExtraState:function(){if(!this.argumentVarModels_.length&&this.hasStatements_)return null;var a=Object.create(null);if(this.argumentVarModels_.length){a.params=[];for(var b=0;b<this.argumentVarModels_.length;b++)a.params.push({name:this.argumentVarModels_[b].name,
|
||||
id:this.argumentVarModels_[b].getId()})}this.hasStatements_||(a.hasStatements=!1);return a},loadExtraState:function(a){this.arguments_=[];this.argumentVarModels_=[];if(a.params)for(var b=0;b<a.params.length;b++){var c=a.params[b];c=(0,$.module$exports$Blockly$Variables.getOrCreateVariablePackage)(this.workspace,c.id,c.name,"");this.arguments_.push(c.name);this.argumentVarModels_.push(c)}this.updateParams_();(0,$.module$exports$Blockly$Procedures.mutateCallers)(this);this.setStatements_(!1===a.hasStatements?
|
||||
!1:!0)},decompose:function(a){var b=(0,$.module$exports$Blockly$utils$xml.createElement)("block");b.setAttribute("type","procedures_mutatorcontainer");var c=(0,$.module$exports$Blockly$utils$xml.createElement)("statement");c.setAttribute("name","STACK");b.appendChild(c);for(var d=0;d<this.arguments_.length;d++){var e=(0,$.module$exports$Blockly$utils$xml.createElement)("block");e.setAttribute("type","procedures_mutatorarg");var f=(0,$.module$exports$Blockly$utils$xml.createElement)("field");f.setAttribute("name",
|
||||
"NAME");var g=(0,$.module$exports$Blockly$utils$xml.createTextNode)(this.arguments_[d]);f.appendChild(g);e.appendChild(f);f=(0,$.module$exports$Blockly$utils$xml.createElement)("next");e.appendChild(f);c.appendChild(e);c=f}a=(0,$.module$exports$Blockly$Xml.domToBlock)(b,a);"procedures_defreturn"===this.type?a.setFieldValue(this.hasStatements_,"STATEMENTS"):a.removeInput("STATEMENT_INPUT");(0,$.module$exports$Blockly$Procedures.mutateCallers)(this);return a},compose:function(a){this.arguments_=[];
|
||||
this.paramIds_=[];this.argumentVarModels_=[];for(var b=a.getInputTargetBlock("STACK");b&&!b.isInsertionMarker();){var c=b.getFieldValue("NAME");this.arguments_.push(c);c=this.workspace.getVariable(c,"");this.argumentVarModels_.push(c);this.paramIds_.push(b.id);b=b.nextConnection&&b.nextConnection.targetBlock()}this.updateParams_();(0,$.module$exports$Blockly$Procedures.mutateCallers)(this);a=a.getFieldValue("STATEMENTS");if(null!==a&&(a="TRUE"===a,this.hasStatements_!==a))if(a)this.setStatements_(!0),
|
||||
$.module$exports$Blockly$Mutator.Mutator.reconnect(this.statementConnection_,this,"STACK"),this.statementConnection_=null;else{a=this.getInput("STACK").connection;if(this.statementConnection_=a.targetConnection)a=a.targetBlock(),a.unplug(),a.bumpNeighbours();this.setStatements_(!1)}},getVars:function(){return this.arguments_},getVarModels:function(){return this.argumentVarModels_},renameVarById:function(a,b){var c=this.workspace.getVariableById(a);if(""===c.type){c=c.name;b=this.workspace.getVariableById(b);
|
||||
for(var d=!1,e=0;e<this.argumentVarModels_.length;e++)this.argumentVarModels_[e].getId()===a&&(this.arguments_[e]=b.name,this.argumentVarModels_[e]=b,d=!0);d&&(this.displayRenamedVar_(c,b.name),(0,$.module$exports$Blockly$Procedures.mutateCallers)(this))}},updateVarName:function(a){for(var b=a.name,c=!1,d,e=0;e<this.argumentVarModels_.length;e++)this.argumentVarModels_[e].getId()===a.getId()&&(d=this.arguments_[e],this.arguments_[e]=b,c=!0);c&&(this.displayRenamedVar_(d,b),(0,$.module$exports$Blockly$Procedures.mutateCallers)(this))},
|
||||
displayRenamedVar_:function(a,b){this.updateParams_();if(this.mutator&&this.mutator.isVisible())for(var c=this.mutator.workspace_.getAllBlocks(!1),d=0,e;e=c[d];d++)"procedures_mutatorarg"===e.type&&$.module$exports$Blockly$Names.Names.equals(a,e.getFieldValue("NAME"))&&e.setFieldValue(b,"NAME")},customContextMenu:function(a){if(!this.isInFlyout){var b={enabled:!0},c=this.getFieldValue("NAME");b.text=$.module$exports$Blockly$Msg.Msg.PROCEDURES_CREATE_DO.replace("%1",c);var d=(0,$.module$exports$Blockly$utils$xml.createElement)("mutation");
|
||||
d.setAttribute("name",c);for(c=0;c<this.arguments_.length;c++){var e=(0,$.module$exports$Blockly$utils$xml.createElement)("arg");e.setAttribute("name",this.arguments_[c]);d.appendChild(e)}c=(0,$.module$exports$Blockly$utils$xml.createElement)("block");c.setAttribute("type",this.callType_);c.appendChild(d);b.callback=(0,$.module$exports$Blockly$ContextMenu.callbackFactory)(this,c);a.push(b);if(!this.isCollapsed())for(b=0;b<this.argumentVarModels_.length;b++)d={enabled:!0},c=this.argumentVarModels_[b],
|
||||
d.text=$.module$exports$Blockly$Msg.Msg.VARIABLES_SET_CREATE_GET.replace("%1",c.name),c=(0,$.module$exports$Blockly$Variables.generateVariableFieldDom)(c),e=(0,$.module$exports$Blockly$utils$xml.createElement)("block"),e.setAttribute("type","variables_get"),e.appendChild(c),d.callback=(0,$.module$exports$Blockly$ContextMenu.callbackFactory)(this,e),a.push(d)}}};
|
||||
module$exports$Blockly$libraryBlocks$procedures.blocks.procedures_defnoreturn=Object.assign({},module$contents$Blockly$libraryBlocks$procedures_PROCEDURE_DEF_COMMON,{init:function(){var a=(0,$.module$exports$Blockly$Procedures.findLegalName)("",this);a=new $.module$exports$Blockly$FieldTextInput.FieldTextInput(a,$.module$exports$Blockly$Procedures.rename);a.setSpellcheck(!1);this.appendDummyInput().appendField($.module$exports$Blockly$Msg.Msg.PROCEDURES_DEFNORETURN_TITLE).appendField(a,"NAME").appendField("",
|
||||
"PARAMS");this.setMutator(new $.module$exports$Blockly$Mutator.Mutator(["procedures_mutatorarg"]));(this.workspace.options.comments||this.workspace.options.parentWorkspace&&this.workspace.options.parentWorkspace.options.comments)&&$.module$exports$Blockly$Msg.Msg.PROCEDURES_DEFNORETURN_COMMENT&&this.setCommentText($.module$exports$Blockly$Msg.Msg.PROCEDURES_DEFNORETURN_COMMENT);this.setStyle("procedure_blocks");this.setTooltip($.module$exports$Blockly$Msg.Msg.PROCEDURES_DEFNORETURN_TOOLTIP);this.setHelpUrl($.module$exports$Blockly$Msg.Msg.PROCEDURES_DEFNORETURN_HELPURL);
|
||||
this.arguments_=[];this.argumentVarModels_=[];this.setStatements_(!0);this.statementConnection_=null},getProcedureDef:function(){return[this.getFieldValue("NAME"),this.arguments_,!1]},callType_:"procedures_callnoreturn"});
|
||||
module$exports$Blockly$libraryBlocks$procedures.blocks.procedures_defreturn=Object.assign({},module$contents$Blockly$libraryBlocks$procedures_PROCEDURE_DEF_COMMON,{init:function(){var a=(0,$.module$exports$Blockly$Procedures.findLegalName)("",this);a=new $.module$exports$Blockly$FieldTextInput.FieldTextInput(a,$.module$exports$Blockly$Procedures.rename);a.setSpellcheck(!1);this.appendDummyInput().appendField($.module$exports$Blockly$Msg.Msg.PROCEDURES_DEFRETURN_TITLE).appendField(a,"NAME").appendField("",
|
||||
"PARAMS");this.appendValueInput("RETURN").setAlign($.module$exports$Blockly$Input.Align.RIGHT).appendField($.module$exports$Blockly$Msg.Msg.PROCEDURES_DEFRETURN_RETURN);this.setMutator(new $.module$exports$Blockly$Mutator.Mutator(["procedures_mutatorarg"]));(this.workspace.options.comments||this.workspace.options.parentWorkspace&&this.workspace.options.parentWorkspace.options.comments)&&$.module$exports$Blockly$Msg.Msg.PROCEDURES_DEFRETURN_COMMENT&&this.setCommentText($.module$exports$Blockly$Msg.Msg.PROCEDURES_DEFRETURN_COMMENT);
|
||||
this.setStyle("procedure_blocks");this.setTooltip($.module$exports$Blockly$Msg.Msg.PROCEDURES_DEFRETURN_TOOLTIP);this.setHelpUrl($.module$exports$Blockly$Msg.Msg.PROCEDURES_DEFRETURN_HELPURL);this.arguments_=[];this.argumentVarModels_=[];this.setStatements_(!0);this.statementConnection_=null},getProcedureDef:function(){return[this.getFieldValue("NAME"),this.arguments_,!0]},callType_:"procedures_callreturn"});
|
||||
module$exports$Blockly$libraryBlocks$procedures.blocks.procedures_mutatorcontainer={init:function(){this.appendDummyInput().appendField($.module$exports$Blockly$Msg.Msg.PROCEDURES_MUTATORCONTAINER_TITLE);this.appendStatementInput("STACK");this.appendDummyInput("STATEMENT_INPUT").appendField($.module$exports$Blockly$Msg.Msg.PROCEDURES_ALLOW_STATEMENTS).appendField(new $.module$exports$Blockly$FieldCheckbox.FieldCheckbox("TRUE"),"STATEMENTS");this.setStyle("procedure_blocks");this.setTooltip($.module$exports$Blockly$Msg.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP);
|
||||
this.contextMenu=!1}};
|
||||
module$exports$Blockly$libraryBlocks$procedures.blocks.procedures_mutatorarg={init:function(){var a=new $.module$exports$Blockly$FieldTextInput.FieldTextInput($.module$exports$Blockly$Procedures.DEFAULT_ARG,this.validator_);a.oldShowEditorFn_=a.showEditor_;a.showEditor_=function(){this.createdVariables_=[];this.oldShowEditorFn_()};this.appendDummyInput().appendField($.module$exports$Blockly$Msg.Msg.PROCEDURES_MUTATORARG_TITLE).appendField(a,"NAME");this.setPreviousStatement(!0);this.setNextStatement(!0);
|
||||
this.setStyle("procedure_blocks");this.setTooltip($.module$exports$Blockly$Msg.Msg.PROCEDURES_MUTATORARG_TOOLTIP);this.contextMenu=!1;a.onFinishEditing_=this.deleteIntermediateVars_;a.createdVariables_=[];a.onFinishEditing_("x")},validator_:function(a){var b=this.getSourceBlock(),c=$.module$exports$Blockly$Mutator.Mutator.findParentWs(b.workspace);a=a.replace(/[\s\xa0]+/g," ").replace(/^ | $/g,"");if(!a)return null;for(var d=(b.workspace.targetWorkspace||b.workspace).getAllBlocks(!1),e=a.toLowerCase(),
|
||||
f=0;f<d.length;f++)if(d[f].id!==this.getSourceBlock().id){var g=d[f].getFieldValue("NAME");if(g&&g.toLowerCase()===e)return null}if(b.isInFlyout)return a;(b=c.getVariable(a,""))&&b.name!==a&&c.renameVariableById(b.getId(),a);b||(b=c.createVariable(a,""))&&this.createdVariables_&&this.createdVariables_.push(b);return a},deleteIntermediateVars_:function(a){var b=$.module$exports$Blockly$Mutator.Mutator.findParentWs(this.getSourceBlock().workspace);if(b)for(var c=0;c<this.createdVariables_.length;c++){var d=
|
||||
this.createdVariables_[c];d.name!==a&&b.deleteVariableById(d.getId())}}};
|
||||
var module$contents$Blockly$libraryBlocks$procedures_PROCEDURE_CALL_COMMON={getProcedureCall:function(){return this.getFieldValue("NAME")},renameProcedure:function(a,b){$.module$exports$Blockly$Names.Names.equals(a,this.getProcedureCall())&&(this.setFieldValue(b,"NAME"),this.setTooltip((this.outputConnection?$.module$exports$Blockly$Msg.Msg.PROCEDURES_CALLRETURN_TOOLTIP:$.module$exports$Blockly$Msg.Msg.PROCEDURES_CALLNORETURN_TOOLTIP).replace("%1",b)))},setProcedureParameters_:function(a,b){var c=
|
||||
(0,$.module$exports$Blockly$Procedures.getDefinition)(this.getProcedureCall(),this.workspace),d=c&&c.mutator&&c.mutator.isVisible();d||(this.quarkConnections_={},this.quarkIds_=null);if(b)if(a.join("\n")===this.arguments_.join("\n"))this.quarkIds_=b;else{if(b.length!==a.length)throw RangeError("paramNames and paramIds must be the same length.");this.setCollapsed(!1);this.quarkIds_||(this.quarkConnections_={},this.quarkIds_=[]);c=this.rendered;this.rendered=!1;for(var e=0;e<this.arguments_.length;e++){var f=
|
||||
this.getInput("ARG"+e);f&&(f=f.connection.targetConnection,this.quarkConnections_[this.quarkIds_[e]]=f,d&&f&&-1===b.indexOf(this.quarkIds_[e])&&(f.disconnect(),f.getSourceBlock().bumpNeighbours()))}this.arguments_=[].concat(a);this.argumentVarModels_=[];for(a=0;a<this.arguments_.length;a++)d=(0,$.module$exports$Blockly$Variables.getOrCreateVariablePackage)(this.workspace,null,this.arguments_[a],""),this.argumentVarModels_.push(d);this.updateShape_();if(this.quarkIds_=b)for(b=0;b<this.arguments_.length;b++)a=
|
||||
this.quarkIds_[b],a in this.quarkConnections_&&($.module$exports$Blockly$Mutator.Mutator.reconnect(this.quarkConnections_[a],this,"ARG"+b)||delete this.quarkConnections_[a]);(this.rendered=c)&&this.render()}},updateShape_:function(){for(var a=0;a<this.arguments_.length;a++){var b=this.getField("ARGNAME"+a);if(b){(0,$.module$exports$Blockly$Events.disable)();try{b.setValue(this.arguments_[a])}finally{(0,$.module$exports$Blockly$Events.enable)()}}else b=new $.module$exports$Blockly$FieldLabel.FieldLabel(this.arguments_[a]),
|
||||
this.appendValueInput("ARG"+a).setAlign($.module$exports$Blockly$Input.Align.RIGHT).appendField(b,"ARGNAME"+a).init()}for(a=this.arguments_.length;this.getInput("ARG"+a);a++)this.removeInput("ARG"+a);if(a=this.getInput("TOPROW"))this.arguments_.length?this.getField("WITH")||(a.appendField($.module$exports$Blockly$Msg.Msg.PROCEDURES_CALL_BEFORE_PARAMS,"WITH"),a.init()):this.getField("WITH")&&a.removeField("WITH")},mutationToDom:function(){var a=(0,$.module$exports$Blockly$utils$xml.createElement)("mutation");
|
||||
a.setAttribute("name",this.getProcedureCall());for(var b=0;b<this.arguments_.length;b++){var c=(0,$.module$exports$Blockly$utils$xml.createElement)("arg");c.setAttribute("name",this.arguments_[b]);a.appendChild(c)}return a},domToMutation:function(a){var b=a.getAttribute("name");this.renameProcedure(this.getProcedureCall(),b);b=[];for(var c=[],d=0,e;e=a.childNodes[d];d++)"arg"===e.nodeName.toLowerCase()&&(b.push(e.getAttribute("name")),c.push(e.getAttribute("paramId")));this.setProcedureParameters_(b,
|
||||
c)},saveExtraState:function(){var a=Object.create(null);a.name=this.getProcedureCall();this.arguments_.length&&(a.params=this.arguments_);return a},loadExtraState:function(a){this.renameProcedure(this.getProcedureCall(),a.name);if(a=a.params){var b=[];b.length=a.length;b.fill(null);this.setProcedureParameters_(a,b)}},getVars:function(){return this.arguments_},getVarModels:function(){return this.argumentVarModels_},onchange:function(a){if(this.workspace&&!this.workspace.isFlyout&&a.recordUndo)if(a.type===
|
||||
$.module$exports$Blockly$Events.BLOCK_CREATE&&-1!==a.ids.indexOf(this.id)){var b=this.getProcedureCall();b=(0,$.module$exports$Blockly$Procedures.getDefinition)(b,this.workspace);!b||b.type===this.defType_&&JSON.stringify(b.getVars())===JSON.stringify(this.arguments_)||(b=null);if(!b){(0,$.module$exports$Blockly$Events.setGroup)(a.group);a=(0,$.module$exports$Blockly$utils$xml.createElement)("xml");b=(0,$.module$exports$Blockly$utils$xml.createElement)("block");b.setAttribute("type",this.defType_);
|
||||
var c=this.getRelativeToSurfaceXY(),d=c.y+2*$.module$exports$Blockly$config.config.snapRadius;b.setAttribute("x",c.x+$.module$exports$Blockly$config.config.snapRadius*(this.RTL?-1:1));b.setAttribute("y",d);c=this.mutationToDom();b.appendChild(c);c=(0,$.module$exports$Blockly$utils$xml.createElement)("field");c.setAttribute("name","NAME");d=this.getProcedureCall();var e=(0,$.module$exports$Blockly$Procedures.findLegalName)(d,this);d!==e&&this.renameProcedure(d,e);c.appendChild((0,$.module$exports$Blockly$utils$xml.createTextNode)(d));
|
||||
b.appendChild(c);a.appendChild(b);(0,$.module$exports$Blockly$Xml.domToWorkspace)(a,this.workspace);(0,$.module$exports$Blockly$Events.setGroup)(!1)}}else a.type===$.module$exports$Blockly$Events.BLOCK_DELETE?(b=this.getProcedureCall(),(0,$.module$exports$Blockly$Procedures.getDefinition)(b,this.workspace)||((0,$.module$exports$Blockly$Events.setGroup)(a.group),this.dispose(!0),(0,$.module$exports$Blockly$Events.setGroup)(!1))):a.type===$.module$exports$Blockly$Events.CHANGE&&"disabled"===a.element&&
|
||||
(b=this.getProcedureCall(),(b=(0,$.module$exports$Blockly$Procedures.getDefinition)(b,this.workspace))&&b.id===a.blockId&&((b=(0,$.module$exports$Blockly$Events.getGroup)())&&console.log("Saw an existing group while responding to a definition change"),(0,$.module$exports$Blockly$Events.setGroup)(a.group),a.newValue?(this.previousEnabledState_=this.isEnabled(),this.setEnabled(!1)):this.setEnabled(this.previousEnabledState_),(0,$.module$exports$Blockly$Events.setGroup)(b)))},customContextMenu:function(a){if(this.workspace.isMovable()){var b=
|
||||
{enabled:!0};b.text=$.module$exports$Blockly$Msg.Msg.PROCEDURES_HIGHLIGHT_DEF;var c=this.getProcedureCall(),d=this.workspace;b.callback=function(){var e=(0,$.module$exports$Blockly$Procedures.getDefinition)(c,d);e&&(d.centerOnBlock(e.id),e.select())};a.push(b)}}};
|
||||
module$exports$Blockly$libraryBlocks$procedures.blocks.procedures_callnoreturn=Object.assign({},module$contents$Blockly$libraryBlocks$procedures_PROCEDURE_CALL_COMMON,{init:function(){this.appendDummyInput("TOPROW").appendField("","NAME");this.setPreviousStatement(!0);this.setNextStatement(!0);this.setStyle("procedure_blocks");this.setHelpUrl($.module$exports$Blockly$Msg.Msg.PROCEDURES_CALLNORETURN_HELPURL);this.arguments_=[];this.argumentVarModels_=[];this.quarkConnections_={};this.quarkIds_=null;
|
||||
this.previousEnabledState_=!0},defType_:"procedures_defnoreturn"});
|
||||
module$exports$Blockly$libraryBlocks$procedures.blocks.procedures_callreturn=Object.assign({},module$contents$Blockly$libraryBlocks$procedures_PROCEDURE_CALL_COMMON,{init:function(){this.appendDummyInput("TOPROW").appendField("","NAME");this.setOutput(!0);this.setStyle("procedure_blocks");this.setHelpUrl($.module$exports$Blockly$Msg.Msg.PROCEDURES_CALLRETURN_HELPURL);this.arguments_=[];this.argumentVarModels_=[];this.quarkConnections_={};this.quarkIds_=null;this.previousEnabledState_=!0},defType_:"procedures_defreturn"});
|
||||
module$exports$Blockly$libraryBlocks$procedures.blocks.procedures_ifreturn={init:function(){this.appendValueInput("CONDITION").setCheck("Boolean").appendField($.module$exports$Blockly$Msg.Msg.CONTROLS_IF_MSG_IF);this.appendValueInput("VALUE").appendField($.module$exports$Blockly$Msg.Msg.PROCEDURES_DEFRETURN_RETURN);this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setStyle("procedure_blocks");this.setTooltip($.module$exports$Blockly$Msg.Msg.PROCEDURES_IFRETURN_TOOLTIP);
|
||||
this.setHelpUrl($.module$exports$Blockly$Msg.Msg.PROCEDURES_IFRETURN_HELPURL);this.hasReturnValue_=!0},mutationToDom:function(){var a=(0,$.module$exports$Blockly$utils$xml.createElement)("mutation");a.setAttribute("value",Number(this.hasReturnValue_));return a},domToMutation:function(a){this.hasReturnValue_="1"===a.getAttribute("value");this.hasReturnValue_||(this.removeInput("VALUE"),this.appendDummyInput("VALUE").appendField($.module$exports$Blockly$Msg.Msg.PROCEDURES_DEFRETURN_RETURN))},onchange:function(a){if(!(this.workspace.isDragging&&
|
||||
this.workspace.isDragging()||a.type!==$.module$exports$Blockly$Events.BLOCK_MOVE)){var b=!1,c=this;do{if(-1!==this.FUNCTION_TYPES.indexOf(c.type)){b=!0;break}c=c.getSurroundParent()}while(c);b?("procedures_defnoreturn"===c.type&&this.hasReturnValue_?(this.removeInput("VALUE"),this.appendDummyInput("VALUE").appendField($.module$exports$Blockly$Msg.Msg.PROCEDURES_DEFRETURN_RETURN),this.hasReturnValue_=!1):"procedures_defreturn"!==c.type||this.hasReturnValue_||(this.removeInput("VALUE"),this.appendValueInput("VALUE").appendField($.module$exports$Blockly$Msg.Msg.PROCEDURES_DEFRETURN_RETURN),
|
||||
this.hasReturnValue_=!0),this.setWarningText(null)):this.setWarningText($.module$exports$Blockly$Msg.Msg.PROCEDURES_IFRETURN_WARNING);this.isInFlyout||(c=(0,$.module$exports$Blockly$Events.getGroup)(),(0,$.module$exports$Blockly$Events.setGroup)(a.group),this.setEnabled(b),(0,$.module$exports$Blockly$Events.setGroup)(c))}},FUNCTION_TYPES:["procedures_defnoreturn","procedures_defreturn"]};(0,$.module$exports$Blockly$common.defineBlocks)(module$exports$Blockly$libraryBlocks$procedures.blocks);var module$exports$Blockly$libraryBlocks$math={};
|
||||
module$exports$Blockly$libraryBlocks$math.blocks=(0,$.module$exports$Blockly$common.createBlockDefinitionsFromJsonArray)([{type:"math_number",message0:"%1",args0:[{type:"field_number",name:"NUM",value:0}],output:"Number",helpUrl:"%{BKY_MATH_NUMBER_HELPURL}",style:"math_blocks",tooltip:"%{BKY_MATH_NUMBER_TOOLTIP}",extensions:["parent_tooltip_when_inline"]},{type:"math_arithmetic",message0:"%1 %2 %3",args0:[{type:"input_value",name:"A",check:"Number"},{type:"field_dropdown",name:"OP",options:[["%{BKY_MATH_ADDITION_SYMBOL}",
|
||||
QUOTE_IMAGE_WIDTH:12,QUOTE_IMAGE_HEIGHT:12,quoteField_:function(a){for(let b=0,c;c=this.inputList[b];b++)for(let d=0,e;e=c.fieldRow[d];d++)if(a===e.name){c.insertFieldAt(d,this.newQuote_(!0));c.insertFieldAt(d+2,this.newQuote_(!1));return}console.warn('field named "'+a+'" not found in '+this.toDevString())},newQuote_:function(a){a=this.RTL?!a:a;return new $.FieldImage$$module$build$src$core$field_image(a?this.QUOTE_IMAGE_LEFT_DATAURI:this.QUOTE_IMAGE_RIGHT_DATAURI,this.QUOTE_IMAGE_WIDTH,this.QUOTE_IMAGE_HEIGHT,
|
||||
a?"\u201c":"\u201d")}},module$contents$Blockly$libraryBlocks$texts_TEXT_QUOTES_EXTENSION=function(){this.mixin(module$contents$Blockly$libraryBlocks$texts_QUOTE_IMAGE_MIXIN);this.quoteField_("TEXT")},module$contents$Blockly$libraryBlocks$texts_TEXT_JOIN_MUTATOR_MIXIN={mutationToDom:function(){const a=$.module$build$src$core$utils$xml.createElement("mutation");a.setAttribute("items",this.itemCount_);return a},domToMutation:function(a){this.itemCount_=parseInt(a.getAttribute("items"),10);this.updateShape_()},
|
||||
saveExtraState:function(){return{itemCount:this.itemCount_}},loadExtraState:function(a){this.itemCount_=a.itemCount;this.updateShape_()},decompose:function(a){const b=a.newBlock("text_create_join_container");b.initSvg();let c=b.getInput("STACK").connection;for(let d=0;d<this.itemCount_;d++){const e=a.newBlock("text_create_join_item");e.initSvg();c.connect(e.previousConnection);c=e.nextConnection}return b},compose:function(a){var b=a.getInputTargetBlock("STACK");for(a=[];b;)b.isInsertionMarker()||
|
||||
a.push(b.valueConnection_),b=b.getNextBlock();for(b=0;b<this.itemCount_;b++){const c=this.getInput("ADD"+b).connection.targetConnection;c&&-1===a.indexOf(c)&&c.disconnect()}this.itemCount_=a.length;this.updateShape_();for(b=0;b<this.itemCount_;b++)$.Mutator$$module$build$src$core$mutator.reconnect(a[b],this,"ADD"+b)},saveConnections:function(a){a=a.getInputTargetBlock("STACK");let b=0;for(;a;){if(a.isInsertionMarker()){a=a.getNextBlock();continue}const c=this.getInput("ADD"+b);a.valueConnection_=
|
||||
c&&c.connection.targetConnection;a=a.getNextBlock();b++}},updateShape_:function(){this.itemCount_&&this.getInput("EMPTY")?this.removeInput("EMPTY"):this.itemCount_||this.getInput("EMPTY")||this.appendDummyInput("EMPTY").appendField(this.newQuote_(!0)).appendField(this.newQuote_(!1));for(var a=0;a<this.itemCount_;a++)if(!this.getInput("ADD"+a)){const b=this.appendValueInput("ADD"+a).setAlign($.Align$$module$build$src$core$input.RIGHT);0===a&&b.appendField(module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_JOIN_TITLE_CREATEWITH)}for(a=
|
||||
this.itemCount_;this.getInput("ADD"+a);a++)this.removeInput("ADD"+a)}},module$contents$Blockly$libraryBlocks$texts_TEXT_JOIN_EXTENSION=function(){this.mixin(module$contents$Blockly$libraryBlocks$texts_QUOTE_IMAGE_MIXIN);this.itemCount_=2;this.updateShape_();this.setMutator(new $.Mutator$$module$build$src$core$mutator(["text_create_join_item"],this))};
|
||||
$.module$build$src$core$extensions.register("text_append_tooltip",$.module$build$src$core$extensions.buildTooltipWithFieldText("%{BKY_TEXT_APPEND_TOOLTIP}","VAR"));
|
||||
var module$contents$Blockly$libraryBlocks$texts_TEXT_INDEXOF_TOOLTIP_EXTENSION=function(){const a=this;this.setTooltip(function(){return module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_INDEXOF_TOOLTIP.replace("%1",a.workspace.options.oneBasedIndex?"0":"-1")})},module$contents$Blockly$libraryBlocks$texts_TEXT_CHARAT_MUTATOR_MIXIN={mutationToDom:function(){const a=$.module$build$src$core$utils$xml.createElement("mutation");a.setAttribute("at",!!this.isAt_);return a},domToMutation:function(a){a=
|
||||
"false"!==a.getAttribute("at");this.updateAt_(a)},updateAt_:function(a){this.removeInput("AT",!0);this.removeInput("ORDINAL",!0);a&&(this.appendValueInput("AT").setCheck("Number"),module$contents$Blockly$libraryBlocks$texts_Msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL").appendField(module$contents$Blockly$libraryBlocks$texts_Msg.ORDINAL_NUMBER_SUFFIX));module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_CHARAT_TAIL&&(this.removeInput("TAIL",!0),this.appendDummyInput("TAIL").appendField(module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_CHARAT_TAIL));
|
||||
this.isAt_=a}},module$contents$Blockly$libraryBlocks$texts_TEXT_CHARAT_EXTENSION=function(){this.getField("WHERE").setValidator(function(b){b="FROM_START"===b||"FROM_END"===b;b!==this.isAt_&&this.getSourceBlock().updateAt_(b)});this.updateAt_(!0);const a=this;this.setTooltip(function(){var b=a.getFieldValue("WHERE");let c=module$contents$Blockly$libraryBlocks$texts_Msg.TEXT_CHARAT_TOOLTIP;("FROM_START"===b||"FROM_END"===b)&&(b="FROM_START"===b?module$contents$Blockly$libraryBlocks$texts_Msg.LISTS_INDEX_FROM_START_TOOLTIP:
|
||||
module$contents$Blockly$libraryBlocks$texts_Msg.LISTS_INDEX_FROM_END_TOOLTIP)&&(c+=" "+b.replace("%1",a.workspace.options.oneBasedIndex?"#1":"#0"));return c})};$.module$build$src$core$extensions.register("text_indexOf_tooltip",module$contents$Blockly$libraryBlocks$texts_TEXT_INDEXOF_TOOLTIP_EXTENSION);$.module$build$src$core$extensions.register("text_quotes",module$contents$Blockly$libraryBlocks$texts_TEXT_QUOTES_EXTENSION);
|
||||
$.module$build$src$core$extensions.registerMutator("text_join_mutator",module$contents$Blockly$libraryBlocks$texts_TEXT_JOIN_MUTATOR_MIXIN,module$contents$Blockly$libraryBlocks$texts_TEXT_JOIN_EXTENSION);$.module$build$src$core$extensions.registerMutator("text_charAt_mutator",module$contents$Blockly$libraryBlocks$texts_TEXT_CHARAT_MUTATOR_MIXIN,module$contents$Blockly$libraryBlocks$texts_TEXT_CHARAT_EXTENSION);module$contents$Blockly$libraryBlocks$texts_defineBlocks(module$exports$Blockly$libraryBlocks$texts.blocks);var module$exports$Blockly$libraryBlocks$procedures={},module$contents$Blockly$libraryBlocks$procedures_ContextMenu=$.module$build$src$core$contextmenu,module$contents$Blockly$libraryBlocks$procedures_Events=$.module$build$src$core$events$events,module$contents$Blockly$libraryBlocks$procedures_Procedures=$.module$build$src$core$procedures,module$contents$Blockly$libraryBlocks$procedures_Variables=$.module$build$src$core$variables,module$contents$Blockly$libraryBlocks$procedures_Xml=$.module$build$src$core$xml,
|
||||
module$contents$Blockly$libraryBlocks$procedures_xmlUtils=$.module$build$src$core$utils$xml,module$contents$Blockly$libraryBlocks$procedures_Align=$.Align$$module$build$src$core$input,module$contents$Blockly$libraryBlocks$procedures_BlockDefinition=Object,module$contents$Blockly$libraryBlocks$procedures_config=$.config$$module$build$src$core$config,module$contents$Blockly$libraryBlocks$procedures_FieldCheckbox=$.FieldCheckbox$$module$build$src$core$field_checkbox,module$contents$Blockly$libraryBlocks$procedures_FieldLabel=
|
||||
$.FieldLabel$$module$build$src$core$field_label,module$contents$Blockly$libraryBlocks$procedures_FieldTextInput=$.FieldTextInput$$module$build$src$core$field_textinput,module$contents$Blockly$libraryBlocks$procedures_Msg=$.module$build$src$core$msg.Msg,module$contents$Blockly$libraryBlocks$procedures_Mutator=$.Mutator$$module$build$src$core$mutator,module$contents$Blockly$libraryBlocks$procedures_Names=$.module$build$src$core$names.Names,module$contents$Blockly$libraryBlocks$procedures_defineBlocks=
|
||||
$.module$build$src$core$common.defineBlocks;module$exports$Blockly$libraryBlocks$procedures.blocks={};
|
||||
var module$contents$Blockly$libraryBlocks$procedures_PROCEDURE_DEF_COMMON={setStatements_:function(a){this.hasStatements_!==a&&(a?(this.appendStatementInput("STACK").appendField(module$contents$Blockly$libraryBlocks$procedures_Msg.PROCEDURES_DEFNORETURN_DO),this.getInput("RETURN")&&this.moveInputBefore("STACK","RETURN")):this.removeInput("STACK",!0),this.hasStatements_=a)},updateParams_:function(){let a="";this.arguments_.length&&(a=module$contents$Blockly$libraryBlocks$procedures_Msg.PROCEDURES_BEFORE_PARAMS+
|
||||
" "+this.arguments_.join(", "));$.module$build$src$core$events$events.disable();try{this.setFieldValue(a,"PARAMS")}finally{$.module$build$src$core$events$events.enable()}},mutationToDom:function(a){const b=$.module$build$src$core$utils$xml.createElement("mutation");a&&b.setAttribute("name",this.getFieldValue("NAME"));for(let c=0;c<this.argumentVarModels_.length;c++){const d=$.module$build$src$core$utils$xml.createElement("arg"),e=this.argumentVarModels_[c];d.setAttribute("name",e.name);d.setAttribute("varid",
|
||||
e.getId());a&&this.paramIds_&&d.setAttribute("paramId",this.paramIds_[c]);b.appendChild(d)}this.hasStatements_||b.setAttribute("statements","false");return b},domToMutation:function(a){this.arguments_=[];this.argumentVarModels_=[];for(let c=0,d;d=a.childNodes[c];c++)if("arg"===d.nodeName.toLowerCase()){const e=d.getAttribute("name");var b=d.getAttribute("varid")||d.getAttribute("varId");this.arguments_.push(e);b=$.module$build$src$core$variables.getOrCreateVariablePackage(this.workspace,b,e,"");null!==
|
||||
b?this.argumentVarModels_.push(b):console.log("Failed to create a variable with name "+e+", ignoring.")}this.updateParams_();$.module$build$src$core$procedures.mutateCallers(this);this.setStatements_("false"!==a.getAttribute("statements"))},saveExtraState:function(){if(!this.argumentVarModels_.length&&this.hasStatements_)return null;const a=Object.create(null);if(this.argumentVarModels_.length){a.params=[];for(let b=0;b<this.argumentVarModels_.length;b++)a.params.push({name:this.argumentVarModels_[b].name,
|
||||
id:this.argumentVarModels_[b].getId()})}this.hasStatements_||(a.hasStatements=!1);return a},loadExtraState:function(a){this.arguments_=[];this.argumentVarModels_=[];if(a.params)for(let c=0;c<a.params.length;c++){var b=a.params[c];b=$.module$build$src$core$variables.getOrCreateVariablePackage(this.workspace,b.id,b.name,"");this.arguments_.push(b.name);this.argumentVarModels_.push(b)}this.updateParams_();$.module$build$src$core$procedures.mutateCallers(this);this.setStatements_(!1===a.hasStatements?
|
||||
!1:!0)},decompose:function(a){const b=$.module$build$src$core$utils$xml.createElement("block");b.setAttribute("type","procedures_mutatorcontainer");var c=$.module$build$src$core$utils$xml.createElement("statement");c.setAttribute("name","STACK");b.appendChild(c);for(let e=0;e<this.arguments_.length;e++){const f=$.module$build$src$core$utils$xml.createElement("block");f.setAttribute("type","procedures_mutatorarg");var d=$.module$build$src$core$utils$xml.createElement("field");d.setAttribute("name",
|
||||
"NAME");const g=$.module$build$src$core$utils$xml.createTextNode(this.arguments_[e]);d.appendChild(g);f.appendChild(d);d=$.module$build$src$core$utils$xml.createElement("next");f.appendChild(d);c.appendChild(f);c=d}a=$.module$build$src$core$xml.domToBlock(b,a);"procedures_defreturn"===this.type?a.setFieldValue(this.hasStatements_,"STATEMENTS"):a.removeInput("STATEMENT_INPUT");$.module$build$src$core$procedures.mutateCallers(this);return a},compose:function(a){this.arguments_=[];this.paramIds_=[];
|
||||
this.argumentVarModels_=[];let b=a.getInputTargetBlock("STACK");for(;b&&!b.isInsertionMarker();){var c=b.getFieldValue("NAME");this.arguments_.push(c);c=this.workspace.getVariable(c,"");this.argumentVarModels_.push(c);this.paramIds_.push(b.id);b=b.nextConnection&&b.nextConnection.targetBlock()}this.updateParams_();$.module$build$src$core$procedures.mutateCallers(this);a=a.getFieldValue("STATEMENTS");if(null!==a&&(a="TRUE"===a,this.hasStatements_!==a))if(a)this.setStatements_(!0),$.Mutator$$module$build$src$core$mutator.reconnect(this.statementConnection_,
|
||||
this,"STACK"),this.statementConnection_=null;else{a=this.getInput("STACK").connection;if(this.statementConnection_=a.targetConnection)a=a.targetBlock(),a.unplug(),a.bumpNeighbours();this.setStatements_(!1)}},getVars:function(){return this.arguments_},getVarModels:function(){return this.argumentVarModels_},renameVarById:function(a,b){var c=this.workspace.getVariableById(a);if(""===c.type){c=c.name;b=this.workspace.getVariableById(b);var d=!1;for(let e=0;e<this.argumentVarModels_.length;e++)this.argumentVarModels_[e].getId()===
|
||||
a&&(this.arguments_[e]=b.name,this.argumentVarModels_[e]=b,d=!0);d&&(this.displayRenamedVar_(c,b.name),$.module$build$src$core$procedures.mutateCallers(this))}},updateVarName:function(a){const b=a.name;let c=!1,d;for(let e=0;e<this.argumentVarModels_.length;e++)this.argumentVarModels_[e].getId()===a.getId()&&(d=this.arguments_[e],this.arguments_[e]=b,c=!0);c&&(this.displayRenamedVar_(d,b),$.module$build$src$core$procedures.mutateCallers(this))},displayRenamedVar_:function(a,b){this.updateParams_();
|
||||
if(this.mutator&&this.mutator.isVisible()){const c=this.mutator.workspace_.getAllBlocks(!1);for(let d=0,e;e=c[d];d++)"procedures_mutatorarg"===e.type&&$.module$build$src$core$names.Names.equals(a,e.getFieldValue("NAME"))&&e.setFieldValue(b,"NAME")}},customContextMenu:function(a){if(!this.isInFlyout){var b={enabled:!0},c=this.getFieldValue("NAME");b.text=module$contents$Blockly$libraryBlocks$procedures_Msg.PROCEDURES_CREATE_DO.replace("%1",c);var d=$.module$build$src$core$utils$xml.createElement("mutation");
|
||||
d.setAttribute("name",c);for(c=0;c<this.arguments_.length;c++){var e=$.module$build$src$core$utils$xml.createElement("arg");e.setAttribute("name",this.arguments_[c]);d.appendChild(e)}c=$.module$build$src$core$utils$xml.createElement("block");c.setAttribute("type",this.callType_);c.appendChild(d);b.callback=$.module$build$src$core$contextmenu.callbackFactory(this,c);a.push(b);if(!this.isCollapsed())for(b=0;b<this.argumentVarModels_.length;b++)d={enabled:!0},c=this.argumentVarModels_[b],d.text=module$contents$Blockly$libraryBlocks$procedures_Msg.VARIABLES_SET_CREATE_GET.replace("%1",
|
||||
c.name),c=$.module$build$src$core$variables.generateVariableFieldDom(c),e=$.module$build$src$core$utils$xml.createElement("block"),e.setAttribute("type","variables_get"),e.appendChild(c),d.callback=$.module$build$src$core$contextmenu.callbackFactory(this,e),a.push(d)}}};
|
||||
module$exports$Blockly$libraryBlocks$procedures.blocks.procedures_defnoreturn=Object.assign({},module$contents$Blockly$libraryBlocks$procedures_PROCEDURE_DEF_COMMON,{init:function(){var a=$.module$build$src$core$procedures.findLegalName("",this);a=new $.FieldTextInput$$module$build$src$core$field_textinput(a,$.module$build$src$core$procedures.rename);a.setSpellcheck(!1);this.appendDummyInput().appendField(module$contents$Blockly$libraryBlocks$procedures_Msg.PROCEDURES_DEFNORETURN_TITLE).appendField(a,
|
||||
"NAME").appendField("","PARAMS");this.setMutator(new $.Mutator$$module$build$src$core$mutator(["procedures_mutatorarg"],this));(this.workspace.options.comments||this.workspace.options.parentWorkspace&&this.workspace.options.parentWorkspace.options.comments)&&module$contents$Blockly$libraryBlocks$procedures_Msg.PROCEDURES_DEFNORETURN_COMMENT&&this.setCommentText(module$contents$Blockly$libraryBlocks$procedures_Msg.PROCEDURES_DEFNORETURN_COMMENT);this.setStyle("procedure_blocks");this.setTooltip(module$contents$Blockly$libraryBlocks$procedures_Msg.PROCEDURES_DEFNORETURN_TOOLTIP);
|
||||
this.setHelpUrl(module$contents$Blockly$libraryBlocks$procedures_Msg.PROCEDURES_DEFNORETURN_HELPURL);this.arguments_=[];this.argumentVarModels_=[];this.setStatements_(!0);this.statementConnection_=null},getProcedureDef:function(){return[this.getFieldValue("NAME"),this.arguments_,!1]},callType_:"procedures_callnoreturn"});
|
||||
module$exports$Blockly$libraryBlocks$procedures.blocks.procedures_defreturn=Object.assign({},module$contents$Blockly$libraryBlocks$procedures_PROCEDURE_DEF_COMMON,{init:function(){var a=$.module$build$src$core$procedures.findLegalName("",this);a=new $.FieldTextInput$$module$build$src$core$field_textinput(a,$.module$build$src$core$procedures.rename);a.setSpellcheck(!1);this.appendDummyInput().appendField(module$contents$Blockly$libraryBlocks$procedures_Msg.PROCEDURES_DEFRETURN_TITLE).appendField(a,
|
||||
"NAME").appendField("","PARAMS");this.appendValueInput("RETURN").setAlign($.Align$$module$build$src$core$input.RIGHT).appendField(module$contents$Blockly$libraryBlocks$procedures_Msg.PROCEDURES_DEFRETURN_RETURN);this.setMutator(new $.Mutator$$module$build$src$core$mutator(["procedures_mutatorarg"],this));(this.workspace.options.comments||this.workspace.options.parentWorkspace&&this.workspace.options.parentWorkspace.options.comments)&&module$contents$Blockly$libraryBlocks$procedures_Msg.PROCEDURES_DEFRETURN_COMMENT&&
|
||||
this.setCommentText(module$contents$Blockly$libraryBlocks$procedures_Msg.PROCEDURES_DEFRETURN_COMMENT);this.setStyle("procedure_blocks");this.setTooltip(module$contents$Blockly$libraryBlocks$procedures_Msg.PROCEDURES_DEFRETURN_TOOLTIP);this.setHelpUrl(module$contents$Blockly$libraryBlocks$procedures_Msg.PROCEDURES_DEFRETURN_HELPURL);this.arguments_=[];this.argumentVarModels_=[];this.setStatements_(!0);this.statementConnection_=null},getProcedureDef:function(){return[this.getFieldValue("NAME"),this.arguments_,
|
||||
!0]},callType_:"procedures_callreturn"});
|
||||
module$exports$Blockly$libraryBlocks$procedures.blocks.procedures_mutatorcontainer={init:function(){this.appendDummyInput().appendField(module$contents$Blockly$libraryBlocks$procedures_Msg.PROCEDURES_MUTATORCONTAINER_TITLE);this.appendStatementInput("STACK");this.appendDummyInput("STATEMENT_INPUT").appendField(module$contents$Blockly$libraryBlocks$procedures_Msg.PROCEDURES_ALLOW_STATEMENTS).appendField(new $.FieldCheckbox$$module$build$src$core$field_checkbox("TRUE"),"STATEMENTS");this.setStyle("procedure_blocks");
|
||||
this.setTooltip(module$contents$Blockly$libraryBlocks$procedures_Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP);this.contextMenu=!1}};
|
||||
module$exports$Blockly$libraryBlocks$procedures.blocks.procedures_mutatorarg={init:function(){const a=new $.FieldTextInput$$module$build$src$core$field_textinput($.module$build$src$core$procedures.DEFAULT_ARG,this.validator_);a.oldShowEditorFn_=a.showEditor_;a.showEditor_=function(){this.createdVariables_=[];this.oldShowEditorFn_()};this.appendDummyInput().appendField(module$contents$Blockly$libraryBlocks$procedures_Msg.PROCEDURES_MUTATORARG_TITLE).appendField(a,"NAME");this.setPreviousStatement(!0);
|
||||
this.setNextStatement(!0);this.setStyle("procedure_blocks");this.setTooltip(module$contents$Blockly$libraryBlocks$procedures_Msg.PROCEDURES_MUTATORARG_TOOLTIP);this.contextMenu=!1;a.onFinishEditing_=this.deleteIntermediateVars_;a.createdVariables_=[];a.onFinishEditing_("x")},validator_:function(a){var b=this.getSourceBlock();const c=$.Mutator$$module$build$src$core$mutator.findParentWs(b.workspace);a=a.replace(/[\s\xa0]+/g," ").replace(/^ | $/g,"");if(!a)return null;const d=(b.workspace.targetWorkspace||
|
||||
b.workspace).getAllBlocks(!1),e=a.toLowerCase();for(let f=0;f<d.length;f++){if(d[f].id===this.getSourceBlock().id)continue;const g=d[f].getFieldValue("NAME");if(g&&g.toLowerCase()===e)return null}if(b.isInFlyout)return a;(b=c.getVariable(a,""))&&b.name!==a&&c.renameVariableById(b.getId(),a);b||(b=c.createVariable(a,""))&&this.createdVariables_&&this.createdVariables_.push(b);return a},deleteIntermediateVars_:function(a){const b=$.Mutator$$module$build$src$core$mutator.findParentWs(this.getSourceBlock().workspace);
|
||||
if(b)for(let c=0;c<this.createdVariables_.length;c++){const d=this.createdVariables_[c];d.name!==a&&b.deleteVariableById(d.getId())}}};
|
||||
var module$contents$Blockly$libraryBlocks$procedures_PROCEDURE_CALL_COMMON={getProcedureCall:function(){return this.getFieldValue("NAME")},renameProcedure:function(a,b){$.module$build$src$core$names.Names.equals(a,this.getProcedureCall())&&(this.setFieldValue(b,"NAME"),this.setTooltip((this.outputConnection?module$contents$Blockly$libraryBlocks$procedures_Msg.PROCEDURES_CALLRETURN_TOOLTIP:module$contents$Blockly$libraryBlocks$procedures_Msg.PROCEDURES_CALLNORETURN_TOOLTIP).replace("%1",b)))},setProcedureParameters_:function(a,
|
||||
b){var c=$.module$build$src$core$procedures.getDefinition(this.getProcedureCall(),this.workspace),d=c&&c.mutator&&c.mutator.isVisible();d?this.setCollapsed(!1):(this.quarkConnections_={},this.quarkIds_=null);if(a.join("\n")===this.arguments_.join("\n"))this.quarkIds_=b;else{if(b.length!==a.length)throw RangeError("paramNames and paramIds must be the same length.");this.quarkIds_||(this.quarkConnections_={},this.quarkIds_=[]);c=this.rendered;this.rendered=!1;for(let f=0;f<this.arguments_.length;f++){var e=
|
||||
this.getInput("ARG"+f);e&&(e=e.connection.targetConnection,this.quarkConnections_[this.quarkIds_[f]]=e,d&&e&&-1===b.indexOf(this.quarkIds_[f])&&(e.disconnect(),e.getSourceBlock().bumpNeighbours()))}this.arguments_=[].concat(a);this.argumentVarModels_=[];for(a=0;a<this.arguments_.length;a++)d=$.module$build$src$core$variables.getOrCreateVariablePackage(this.workspace,null,this.arguments_[a],""),this.argumentVarModels_.push(d);this.updateShape_();if(this.quarkIds_=b)for(b=0;b<this.arguments_.length;b++)a=
|
||||
this.quarkIds_[b],a in this.quarkConnections_&&($.Mutator$$module$build$src$core$mutator.reconnect(this.quarkConnections_[a],this,"ARG"+b)||delete this.quarkConnections_[a]);(this.rendered=c)&&this.render()}},updateShape_:function(){for(var a=0;a<this.arguments_.length;a++){var b=this.getField("ARGNAME"+a);if(b){$.module$build$src$core$events$events.disable();try{b.setValue(this.arguments_[a])}finally{$.module$build$src$core$events$events.enable()}}else b=new $.FieldLabel$$module$build$src$core$field_label(this.arguments_[a]),
|
||||
this.appendValueInput("ARG"+a).setAlign($.Align$$module$build$src$core$input.RIGHT).appendField(b,"ARGNAME"+a).init()}for(a=this.arguments_.length;this.getInput("ARG"+a);a++)this.removeInput("ARG"+a);if(a=this.getInput("TOPROW"))this.arguments_.length?this.getField("WITH")||(a.appendField(module$contents$Blockly$libraryBlocks$procedures_Msg.PROCEDURES_CALL_BEFORE_PARAMS,"WITH"),a.init()):this.getField("WITH")&&a.removeField("WITH")},mutationToDom:function(){const a=$.module$build$src$core$utils$xml.createElement("mutation");
|
||||
a.setAttribute("name",this.getProcedureCall());for(let b=0;b<this.arguments_.length;b++){const c=$.module$build$src$core$utils$xml.createElement("arg");c.setAttribute("name",this.arguments_[b]);a.appendChild(c)}return a},domToMutation:function(a){var b=a.getAttribute("name");this.renameProcedure(this.getProcedureCall(),b);b=[];const c=[];for(let d=0,e;e=a.childNodes[d];d++)"arg"===e.nodeName.toLowerCase()&&(b.push(e.getAttribute("name")),c.push(e.getAttribute("paramId")));this.setProcedureParameters_(b,
|
||||
c)},saveExtraState:function(){const a=Object.create(null);a.name=this.getProcedureCall();this.arguments_.length&&(a.params=this.arguments_);return a},loadExtraState:function(a){this.renameProcedure(this.getProcedureCall(),a.name);if(a=a.params){const b=[];b.length=a.length;b.fill(null);this.setProcedureParameters_(a,b)}},getVars:function(){return this.arguments_},getVarModels:function(){return this.argumentVarModels_},onchange:function(a){if(this.workspace&&!this.workspace.isFlyout&&a.recordUndo)if(a.type===
|
||||
$.module$build$src$core$events$events.BLOCK_CREATE&&-1!==a.ids.indexOf(this.id)){var b=this.getProcedureCall();b=$.module$build$src$core$procedures.getDefinition(b,this.workspace);!b||b.type===this.defType_&&JSON.stringify(b.getVars())===JSON.stringify(this.arguments_)||(b=null);if(!b){$.module$build$src$core$events$events.setGroup(a.group);a=$.module$build$src$core$utils$xml.createElement("xml");b=$.module$build$src$core$utils$xml.createElement("block");b.setAttribute("type",this.defType_);var c=
|
||||
this.getRelativeToSurfaceXY(),d=c.y+2*$.config$$module$build$src$core$config.snapRadius;b.setAttribute("x",c.x+$.config$$module$build$src$core$config.snapRadius*(this.RTL?-1:1));b.setAttribute("y",d);c=this.mutationToDom();b.appendChild(c);c=$.module$build$src$core$utils$xml.createElement("field");c.setAttribute("name","NAME");d=this.getProcedureCall();const e=$.module$build$src$core$procedures.findLegalName(d,this);d!==e&&this.renameProcedure(d,e);c.appendChild($.module$build$src$core$utils$xml.createTextNode(d));
|
||||
b.appendChild(c);a.appendChild(b);$.module$build$src$core$xml.domToWorkspace(a,this.workspace);$.module$build$src$core$events$events.setGroup(!1)}}else a.type===$.module$build$src$core$events$events.BLOCK_DELETE&&a.blockId!=this.id?(b=this.getProcedureCall(),$.module$build$src$core$procedures.getDefinition(b,this.workspace)||($.module$build$src$core$events$events.setGroup(a.group),this.dispose(!0),$.module$build$src$core$events$events.setGroup(!1))):a.type===$.module$build$src$core$events$events.CHANGE&&
|
||||
"disabled"===a.element&&(b=this.getProcedureCall(),(b=$.module$build$src$core$procedures.getDefinition(b,this.workspace))&&b.id===a.blockId&&((b=$.module$build$src$core$events$events.getGroup())&&console.log("Saw an existing group while responding to a definition change"),$.module$build$src$core$events$events.setGroup(a.group),a.newValue?(this.previousEnabledState_=this.isEnabled(),this.setEnabled(!1)):this.setEnabled(this.previousEnabledState_),$.module$build$src$core$events$events.setGroup(b)))},
|
||||
customContextMenu:function(a){if(this.workspace.isMovable()){var b={enabled:!0};b.text=module$contents$Blockly$libraryBlocks$procedures_Msg.PROCEDURES_HIGHLIGHT_DEF;var c=this.getProcedureCall(),d=this.workspace;b.callback=function(){const e=$.module$build$src$core$procedures.getDefinition(c,d);e&&(d.centerOnBlock(e.id),e.select())};a.push(b)}}};
|
||||
module$exports$Blockly$libraryBlocks$procedures.blocks.procedures_callnoreturn=Object.assign({},module$contents$Blockly$libraryBlocks$procedures_PROCEDURE_CALL_COMMON,{init:function(){this.appendDummyInput("TOPROW").appendField("","NAME");this.setPreviousStatement(!0);this.setNextStatement(!0);this.setStyle("procedure_blocks");this.setHelpUrl(module$contents$Blockly$libraryBlocks$procedures_Msg.PROCEDURES_CALLNORETURN_HELPURL);this.arguments_=[];this.argumentVarModels_=[];this.quarkConnections_={};
|
||||
this.quarkIds_=null;this.previousEnabledState_=!0},defType_:"procedures_defnoreturn"});
|
||||
module$exports$Blockly$libraryBlocks$procedures.blocks.procedures_callreturn=Object.assign({},module$contents$Blockly$libraryBlocks$procedures_PROCEDURE_CALL_COMMON,{init:function(){this.appendDummyInput("TOPROW").appendField("","NAME");this.setOutput(!0);this.setStyle("procedure_blocks");this.setHelpUrl(module$contents$Blockly$libraryBlocks$procedures_Msg.PROCEDURES_CALLRETURN_HELPURL);this.arguments_=[];this.argumentVarModels_=[];this.quarkConnections_={};this.quarkIds_=null;this.previousEnabledState_=
|
||||
!0},defType_:"procedures_defreturn"});
|
||||
module$exports$Blockly$libraryBlocks$procedures.blocks.procedures_ifreturn={init:function(){this.appendValueInput("CONDITION").setCheck("Boolean").appendField(module$contents$Blockly$libraryBlocks$procedures_Msg.CONTROLS_IF_MSG_IF);this.appendValueInput("VALUE").appendField(module$contents$Blockly$libraryBlocks$procedures_Msg.PROCEDURES_DEFRETURN_RETURN);this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setStyle("procedure_blocks");this.setTooltip(module$contents$Blockly$libraryBlocks$procedures_Msg.PROCEDURES_IFRETURN_TOOLTIP);
|
||||
this.setHelpUrl(module$contents$Blockly$libraryBlocks$procedures_Msg.PROCEDURES_IFRETURN_HELPURL);this.hasReturnValue_=!0},mutationToDom:function(){const a=$.module$build$src$core$utils$xml.createElement("mutation");a.setAttribute("value",Number(this.hasReturnValue_));return a},domToMutation:function(a){this.hasReturnValue_="1"===a.getAttribute("value");this.hasReturnValue_||(this.removeInput("VALUE"),this.appendDummyInput("VALUE").appendField(module$contents$Blockly$libraryBlocks$procedures_Msg.PROCEDURES_DEFRETURN_RETURN))},
|
||||
onchange:function(a){if(!(this.workspace.isDragging&&this.workspace.isDragging()||a.type!==$.module$build$src$core$events$events.BLOCK_MOVE)){var b=!1,c=this;do{if(-1!==this.FUNCTION_TYPES.indexOf(c.type)){b=!0;break}c=c.getSurroundParent()}while(c);b?("procedures_defnoreturn"===c.type&&this.hasReturnValue_?(this.removeInput("VALUE"),this.appendDummyInput("VALUE").appendField(module$contents$Blockly$libraryBlocks$procedures_Msg.PROCEDURES_DEFRETURN_RETURN),this.hasReturnValue_=!1):"procedures_defreturn"!==
|
||||
c.type||this.hasReturnValue_||(this.removeInput("VALUE"),this.appendValueInput("VALUE").appendField(module$contents$Blockly$libraryBlocks$procedures_Msg.PROCEDURES_DEFRETURN_RETURN),this.hasReturnValue_=!0),this.setWarningText(null)):this.setWarningText(module$contents$Blockly$libraryBlocks$procedures_Msg.PROCEDURES_IFRETURN_WARNING);this.isInFlyout||(c=$.module$build$src$core$events$events.getGroup(),$.module$build$src$core$events$events.setGroup(a.group),this.setEnabled(b),$.module$build$src$core$events$events.setGroup(c))}},
|
||||
FUNCTION_TYPES:["procedures_defnoreturn","procedures_defreturn"]};module$contents$Blockly$libraryBlocks$procedures_defineBlocks(module$exports$Blockly$libraryBlocks$procedures.blocks);var module$exports$Blockly$libraryBlocks$math={},module$contents$Blockly$libraryBlocks$math_Extensions=$.module$build$src$core$extensions,module$contents$Blockly$libraryBlocks$math_FieldDropdown=$.module$build$src$core$field_dropdown,module$contents$Blockly$libraryBlocks$math_xmlUtils=$.module$build$src$core$utils$xml,module$contents$Blockly$libraryBlocks$math_BlockDefinition=Object,module$contents$Blockly$libraryBlocks$math_createBlockDefinitionsFromJsonArray=$.module$build$src$core$common.createBlockDefinitionsFromJsonArray,
|
||||
module$contents$Blockly$libraryBlocks$math_defineBlocks=$.module$build$src$core$common.defineBlocks;
|
||||
module$exports$Blockly$libraryBlocks$math.blocks=module$contents$Blockly$libraryBlocks$math_createBlockDefinitionsFromJsonArray([{type:"math_number",message0:"%1",args0:[{type:"field_number",name:"NUM",value:0}],output:"Number",helpUrl:"%{BKY_MATH_NUMBER_HELPURL}",style:"math_blocks",tooltip:"%{BKY_MATH_NUMBER_TOOLTIP}",extensions:["parent_tooltip_when_inline"]},{type:"math_arithmetic",message0:"%1 %2 %3",args0:[{type:"input_value",name:"A",check:"Number"},{type:"field_dropdown",name:"OP",options:[["%{BKY_MATH_ADDITION_SYMBOL}",
|
||||
"ADD"],["%{BKY_MATH_SUBTRACTION_SYMBOL}","MINUS"],["%{BKY_MATH_MULTIPLICATION_SYMBOL}","MULTIPLY"],["%{BKY_MATH_DIVISION_SYMBOL}","DIVIDE"],["%{BKY_MATH_POWER_SYMBOL}","POWER"]]},{type:"input_value",name:"B",check:"Number"}],inputsInline:!0,output:"Number",style:"math_blocks",helpUrl:"%{BKY_MATH_ARITHMETIC_HELPURL}",extensions:["math_op_tooltip"]},{type:"math_single",message0:"%1 %2",args0:[{type:"field_dropdown",name:"OP",options:[["%{BKY_MATH_SINGLE_OP_ROOT}","ROOT"],["%{BKY_MATH_SINGLE_OP_ABSOLUTE}",
|
||||
"ABS"],["-","NEG"],["ln","LN"],["log10","LOG10"],["e^","EXP"],["10^","POW10"]]},{type:"input_value",name:"NUM",check:"Number"}],output:"Number",style:"math_blocks",helpUrl:"%{BKY_MATH_SINGLE_HELPURL}",extensions:["math_op_tooltip"]},{type:"math_trig",message0:"%1 %2",args0:[{type:"field_dropdown",name:"OP",options:[["%{BKY_MATH_TRIG_SIN}","SIN"],["%{BKY_MATH_TRIG_COS}","COS"],["%{BKY_MATH_TRIG_TAN}","TAN"],["%{BKY_MATH_TRIG_ASIN}","ASIN"],["%{BKY_MATH_TRIG_ACOS}","ACOS"],["%{BKY_MATH_TRIG_ATAN}",
|
||||
"ATAN"]]},{type:"input_value",name:"NUM",check:"Number"}],output:"Number",style:"math_blocks",helpUrl:"%{BKY_MATH_TRIG_HELPURL}",extensions:["math_op_tooltip"]},{type:"math_constant",message0:"%1",args0:[{type:"field_dropdown",name:"CONSTANT",options:[["\u03c0","PI"],["e","E"],["\u03c6","GOLDEN_RATIO"],["sqrt(2)","SQRT2"],["sqrt(\u00bd)","SQRT1_2"],["\u221e","INFINITY"]]}],output:"Number",style:"math_blocks",tooltip:"%{BKY_MATH_CONSTANT_TOOLTIP}",helpUrl:"%{BKY_MATH_CONSTANT_HELPURL}"},{type:"math_number_property",
|
||||
@@ -118,94 +131,99 @@ args0:[{type:"input_value",name:"FROM",check:"Number"},{type:"input_value",name:
|
||||
name:"X",check:"Number"},{type:"input_value",name:"Y",check:"Number"}],inputsInline:!0,output:"Number",style:"math_blocks",tooltip:"%{BKY_MATH_ATAN2_TOOLTIP}",helpUrl:"%{BKY_MATH_ATAN2_HELPURL}"}]);
|
||||
var module$contents$Blockly$libraryBlocks$math_TOOLTIPS_BY_OP={ADD:"%{BKY_MATH_ARITHMETIC_TOOLTIP_ADD}",MINUS:"%{BKY_MATH_ARITHMETIC_TOOLTIP_MINUS}",MULTIPLY:"%{BKY_MATH_ARITHMETIC_TOOLTIP_MULTIPLY}",DIVIDE:"%{BKY_MATH_ARITHMETIC_TOOLTIP_DIVIDE}",POWER:"%{BKY_MATH_ARITHMETIC_TOOLTIP_POWER}",ROOT:"%{BKY_MATH_SINGLE_TOOLTIP_ROOT}",ABS:"%{BKY_MATH_SINGLE_TOOLTIP_ABS}",NEG:"%{BKY_MATH_SINGLE_TOOLTIP_NEG}",LN:"%{BKY_MATH_SINGLE_TOOLTIP_LN}",LOG10:"%{BKY_MATH_SINGLE_TOOLTIP_LOG10}",EXP:"%{BKY_MATH_SINGLE_TOOLTIP_EXP}",
|
||||
POW10:"%{BKY_MATH_SINGLE_TOOLTIP_POW10}",SIN:"%{BKY_MATH_TRIG_TOOLTIP_SIN}",COS:"%{BKY_MATH_TRIG_TOOLTIP_COS}",TAN:"%{BKY_MATH_TRIG_TOOLTIP_TAN}",ASIN:"%{BKY_MATH_TRIG_TOOLTIP_ASIN}",ACOS:"%{BKY_MATH_TRIG_TOOLTIP_ACOS}",ATAN:"%{BKY_MATH_TRIG_TOOLTIP_ATAN}",SUM:"%{BKY_MATH_ONLIST_TOOLTIP_SUM}",MIN:"%{BKY_MATH_ONLIST_TOOLTIP_MIN}",MAX:"%{BKY_MATH_ONLIST_TOOLTIP_MAX}",AVERAGE:"%{BKY_MATH_ONLIST_TOOLTIP_AVERAGE}",MEDIAN:"%{BKY_MATH_ONLIST_TOOLTIP_MEDIAN}",MODE:"%{BKY_MATH_ONLIST_TOOLTIP_MODE}",STD_DEV:"%{BKY_MATH_ONLIST_TOOLTIP_STD_DEV}",
|
||||
RANDOM:"%{BKY_MATH_ONLIST_TOOLTIP_RANDOM}"};(0,$.module$exports$Blockly$Extensions.register)("math_op_tooltip",(0,$.module$exports$Blockly$Extensions.buildTooltipForDropdown)("OP",module$contents$Blockly$libraryBlocks$math_TOOLTIPS_BY_OP));
|
||||
var module$contents$Blockly$libraryBlocks$math_IS_DIVISIBLEBY_MUTATOR_MIXIN={mutationToDom:function(){var a=(0,$.module$exports$Blockly$utils$xml.createElement)("mutation"),b="DIVISIBLE_BY"===this.getFieldValue("PROPERTY");a.setAttribute("divisor_input",b);return a},domToMutation:function(a){a="true"===a.getAttribute("divisor_input");this.updateShape_(a)},updateShape_:function(a){var b=this.getInput("DIVISOR");a?b||this.appendValueInput("DIVISOR").setCheck("Number"):b&&this.removeInput("DIVISOR")}},
|
||||
module$contents$Blockly$libraryBlocks$math_IS_DIVISIBLE_MUTATOR_EXTENSION=function(){this.getField("PROPERTY").setValidator(function(a){a="DIVISIBLE_BY"===a;this.getSourceBlock().updateShape_(a)})};(0,$.module$exports$Blockly$Extensions.registerMutator)("math_is_divisibleby_mutator",module$contents$Blockly$libraryBlocks$math_IS_DIVISIBLEBY_MUTATOR_MIXIN,module$contents$Blockly$libraryBlocks$math_IS_DIVISIBLE_MUTATOR_EXTENSION);
|
||||
(0,$.module$exports$Blockly$Extensions.register)("math_change_tooltip",(0,$.module$exports$Blockly$Extensions.buildTooltipWithFieldText)("%{BKY_MATH_CHANGE_TOOLTIP}","VAR"));
|
||||
var module$contents$Blockly$libraryBlocks$math_LIST_MODES_MUTATOR_MIXIN={updateType_:function(a){"MODE"===a?this.outputConnection.setCheck("Array"):this.outputConnection.setCheck("Number")},mutationToDom:function(){var a=(0,$.module$exports$Blockly$utils$xml.createElement)("mutation");a.setAttribute("op",this.getFieldValue("OP"));return a},domToMutation:function(a){this.updateType_(a.getAttribute("op"))}},module$contents$Blockly$libraryBlocks$math_LIST_MODES_MUTATOR_EXTENSION=function(){this.getField("OP").setValidator(function(a){this.updateType_(a)}.bind(this))};
|
||||
(0,$.module$exports$Blockly$Extensions.registerMutator)("math_modes_of_list_mutator",module$contents$Blockly$libraryBlocks$math_LIST_MODES_MUTATOR_MIXIN,module$contents$Blockly$libraryBlocks$math_LIST_MODES_MUTATOR_EXTENSION);(0,$.module$exports$Blockly$common.defineBlocks)(module$exports$Blockly$libraryBlocks$math.blocks);var module$exports$Blockly$libraryBlocks$loops={};
|
||||
module$exports$Blockly$libraryBlocks$loops.blocks=(0,$.module$exports$Blockly$common.createBlockDefinitionsFromJsonArray)([{type:"controls_repeat_ext",message0:"%{BKY_CONTROLS_REPEAT_TITLE}",args0:[{type:"input_value",name:"TIMES",check:"Number"}],message1:"%{BKY_CONTROLS_REPEAT_INPUT_DO} %1",args1:[{type:"input_statement",name:"DO"}],previousStatement:null,nextStatement:null,style:"loop_blocks",tooltip:"%{BKY_CONTROLS_REPEAT_TOOLTIP}",helpUrl:"%{BKY_CONTROLS_REPEAT_HELPURL}"},{type:"controls_repeat",
|
||||
RANDOM:"%{BKY_MATH_ONLIST_TOOLTIP_RANDOM}"};$.module$build$src$core$extensions.register("math_op_tooltip",$.module$build$src$core$extensions.buildTooltipForDropdown("OP",module$contents$Blockly$libraryBlocks$math_TOOLTIPS_BY_OP));
|
||||
var module$contents$Blockly$libraryBlocks$math_IS_DIVISIBLEBY_MUTATOR_MIXIN={mutationToDom:function(){const a=$.module$build$src$core$utils$xml.createElement("mutation"),b="DIVISIBLE_BY"===this.getFieldValue("PROPERTY");a.setAttribute("divisor_input",b);return a},domToMutation:function(a){a="true"===a.getAttribute("divisor_input");this.updateShape_(a)},updateShape_:function(a){const b=this.getInput("DIVISOR");a?b||this.appendValueInput("DIVISOR").setCheck("Number"):b&&this.removeInput("DIVISOR")}},
|
||||
module$contents$Blockly$libraryBlocks$math_IS_DIVISIBLE_MUTATOR_EXTENSION=function(){this.getField("PROPERTY").setValidator(function(a){a="DIVISIBLE_BY"===a;this.getSourceBlock().updateShape_(a)})};$.module$build$src$core$extensions.registerMutator("math_is_divisibleby_mutator",module$contents$Blockly$libraryBlocks$math_IS_DIVISIBLEBY_MUTATOR_MIXIN,module$contents$Blockly$libraryBlocks$math_IS_DIVISIBLE_MUTATOR_EXTENSION);
|
||||
$.module$build$src$core$extensions.register("math_change_tooltip",$.module$build$src$core$extensions.buildTooltipWithFieldText("%{BKY_MATH_CHANGE_TOOLTIP}","VAR"));
|
||||
var module$contents$Blockly$libraryBlocks$math_LIST_MODES_MUTATOR_MIXIN={updateType_:function(a){"MODE"===a?this.outputConnection.setCheck("Array"):this.outputConnection.setCheck("Number")},mutationToDom:function(){const a=$.module$build$src$core$utils$xml.createElement("mutation");a.setAttribute("op",this.getFieldValue("OP"));return a},domToMutation:function(a){this.updateType_(a.getAttribute("op"))}},module$contents$Blockly$libraryBlocks$math_LIST_MODES_MUTATOR_EXTENSION=function(){this.getField("OP").setValidator(function(a){this.updateType_(a)}.bind(this))};
|
||||
$.module$build$src$core$extensions.registerMutator("math_modes_of_list_mutator",module$contents$Blockly$libraryBlocks$math_LIST_MODES_MUTATOR_MIXIN,module$contents$Blockly$libraryBlocks$math_LIST_MODES_MUTATOR_EXTENSION);module$contents$Blockly$libraryBlocks$math_defineBlocks(module$exports$Blockly$libraryBlocks$math.blocks);var module$exports$Blockly$libraryBlocks$loops={},module$contents$Blockly$libraryBlocks$loops_ContextMenu=$.module$build$src$core$contextmenu,module$contents$Blockly$libraryBlocks$loops_Events=$.module$build$src$core$events$events,module$contents$Blockly$libraryBlocks$loops_Extensions=$.module$build$src$core$extensions,module$contents$Blockly$libraryBlocks$loops_Variables=$.module$build$src$core$variables,module$contents$Blockly$libraryBlocks$loops_xmlUtils=$.module$build$src$core$utils$xml,module$contents$Blockly$libraryBlocks$loops_BlockDefinition=
|
||||
Object,module$contents$Blockly$libraryBlocks$loops_Msg=$.module$build$src$core$msg.Msg,module$contents$Blockly$libraryBlocks$loops_createBlockDefinitionsFromJsonArray=$.module$build$src$core$common.createBlockDefinitionsFromJsonArray,module$contents$Blockly$libraryBlocks$loops_defineBlocks=$.module$build$src$core$common.defineBlocks;
|
||||
module$exports$Blockly$libraryBlocks$loops.blocks=module$contents$Blockly$libraryBlocks$loops_createBlockDefinitionsFromJsonArray([{type:"controls_repeat_ext",message0:"%{BKY_CONTROLS_REPEAT_TITLE}",args0:[{type:"input_value",name:"TIMES",check:"Number"}],message1:"%{BKY_CONTROLS_REPEAT_INPUT_DO} %1",args1:[{type:"input_statement",name:"DO"}],previousStatement:null,nextStatement:null,style:"loop_blocks",tooltip:"%{BKY_CONTROLS_REPEAT_TOOLTIP}",helpUrl:"%{BKY_CONTROLS_REPEAT_HELPURL}"},{type:"controls_repeat",
|
||||
message0:"%{BKY_CONTROLS_REPEAT_TITLE}",args0:[{type:"field_number",name:"TIMES",value:10,min:0,precision:1}],message1:"%{BKY_CONTROLS_REPEAT_INPUT_DO} %1",args1:[{type:"input_statement",name:"DO"}],previousStatement:null,nextStatement:null,style:"loop_blocks",tooltip:"%{BKY_CONTROLS_REPEAT_TOOLTIP}",helpUrl:"%{BKY_CONTROLS_REPEAT_HELPURL}"},{type:"controls_whileUntil",message0:"%1 %2",args0:[{type:"field_dropdown",name:"MODE",options:[["%{BKY_CONTROLS_WHILEUNTIL_OPERATOR_WHILE}","WHILE"],["%{BKY_CONTROLS_WHILEUNTIL_OPERATOR_UNTIL}",
|
||||
"UNTIL"]]},{type:"input_value",name:"BOOL",check:"Boolean"}],message1:"%{BKY_CONTROLS_REPEAT_INPUT_DO} %1",args1:[{type:"input_statement",name:"DO"}],previousStatement:null,nextStatement:null,style:"loop_blocks",helpUrl:"%{BKY_CONTROLS_WHILEUNTIL_HELPURL}",extensions:["controls_whileUntil_tooltip"]},{type:"controls_for",message0:"%{BKY_CONTROLS_FOR_TITLE}",args0:[{type:"field_variable",name:"VAR",variable:null},{type:"input_value",name:"FROM",check:"Number",align:"RIGHT"},{type:"input_value",name:"TO",
|
||||
check:"Number",align:"RIGHT"},{type:"input_value",name:"BY",check:"Number",align:"RIGHT"}],message1:"%{BKY_CONTROLS_REPEAT_INPUT_DO} %1",args1:[{type:"input_statement",name:"DO"}],inputsInline:!0,previousStatement:null,nextStatement:null,style:"loop_blocks",helpUrl:"%{BKY_CONTROLS_FOR_HELPURL}",extensions:["contextMenu_newGetVariableBlock","controls_for_tooltip"]},{type:"controls_forEach",message0:"%{BKY_CONTROLS_FOREACH_TITLE}",args0:[{type:"field_variable",name:"VAR",variable:null},{type:"input_value",
|
||||
name:"LIST",check:"Array"}],message1:"%{BKY_CONTROLS_REPEAT_INPUT_DO} %1",args1:[{type:"input_statement",name:"DO"}],previousStatement:null,nextStatement:null,style:"loop_blocks",helpUrl:"%{BKY_CONTROLS_FOREACH_HELPURL}",extensions:["contextMenu_newGetVariableBlock","controls_forEach_tooltip"]},{type:"controls_flow_statements",message0:"%1",args0:[{type:"field_dropdown",name:"FLOW",options:[["%{BKY_CONTROLS_FLOW_STATEMENTS_OPERATOR_BREAK}","BREAK"],["%{BKY_CONTROLS_FLOW_STATEMENTS_OPERATOR_CONTINUE}",
|
||||
"CONTINUE"]]}],previousStatement:null,style:"loop_blocks",helpUrl:"%{BKY_CONTROLS_FLOW_STATEMENTS_HELPURL}",suppressPrefixSuffix:!0,extensions:["controls_flow_tooltip","controls_flow_in_loop_check"]}]);var module$contents$Blockly$libraryBlocks$loops_WHILE_UNTIL_TOOLTIPS={WHILE:"%{BKY_CONTROLS_WHILEUNTIL_TOOLTIP_WHILE}",UNTIL:"%{BKY_CONTROLS_WHILEUNTIL_TOOLTIP_UNTIL}"};
|
||||
(0,$.module$exports$Blockly$Extensions.register)("controls_whileUntil_tooltip",(0,$.module$exports$Blockly$Extensions.buildTooltipForDropdown)("MODE",module$contents$Blockly$libraryBlocks$loops_WHILE_UNTIL_TOOLTIPS));var module$contents$Blockly$libraryBlocks$loops_BREAK_CONTINUE_TOOLTIPS={BREAK:"%{BKY_CONTROLS_FLOW_STATEMENTS_TOOLTIP_BREAK}",CONTINUE:"%{BKY_CONTROLS_FLOW_STATEMENTS_TOOLTIP_CONTINUE}"};
|
||||
(0,$.module$exports$Blockly$Extensions.register)("controls_flow_tooltip",(0,$.module$exports$Blockly$Extensions.buildTooltipForDropdown)("FLOW",module$contents$Blockly$libraryBlocks$loops_BREAK_CONTINUE_TOOLTIPS));
|
||||
var module$contents$Blockly$libraryBlocks$loops_CUSTOM_CONTEXT_MENU_CREATE_VARIABLES_GET_MIXIN={customContextMenu:function(a){if(!this.isInFlyout){var b=this.getField("VAR").getVariable(),c=b.name;if(!this.isCollapsed()&&null!==c){var d={enabled:!0};d.text=$.module$exports$Blockly$Msg.Msg.VARIABLES_SET_CREATE_GET.replace("%1",c);b=(0,$.module$exports$Blockly$Variables.generateVariableFieldDom)(b);c=(0,$.module$exports$Blockly$utils$xml.createElement)("block");c.setAttribute("type","variables_get");
|
||||
c.appendChild(b);d.callback=(0,$.module$exports$Blockly$ContextMenu.callbackFactory)(this,c);a.push(d)}}}};(0,$.module$exports$Blockly$Extensions.registerMixin)("contextMenu_newGetVariableBlock",module$contents$Blockly$libraryBlocks$loops_CUSTOM_CONTEXT_MENU_CREATE_VARIABLES_GET_MIXIN);(0,$.module$exports$Blockly$Extensions.register)("controls_for_tooltip",(0,$.module$exports$Blockly$Extensions.buildTooltipWithFieldText)("%{BKY_CONTROLS_FOR_TOOLTIP}","VAR"));
|
||||
(0,$.module$exports$Blockly$Extensions.register)("controls_forEach_tooltip",(0,$.module$exports$Blockly$Extensions.buildTooltipWithFieldText)("%{BKY_CONTROLS_FOREACH_TOOLTIP}","VAR"));module$exports$Blockly$libraryBlocks$loops.loopTypes=new Set(["controls_repeat","controls_repeat_ext","controls_forEach","controls_for","controls_whileUntil"]);
|
||||
var module$contents$Blockly$libraryBlocks$loops_CONTROL_FLOW_IN_LOOP_CHECK_MIXIN={getSurroundLoop:function(){var a=this;do{if(module$exports$Blockly$libraryBlocks$loops.loopTypes.has(a.type))return a;a=a.getSurroundParent()}while(a);return null},onchange:function(a){if(this.workspace.isDragging&&!this.workspace.isDragging()&&a.type===$.module$exports$Blockly$Events.BLOCK_MOVE){var b=this.getSurroundLoop(this);this.setWarningText(b?null:$.module$exports$Blockly$Msg.Msg.CONTROLS_FLOW_STATEMENTS_WARNING);
|
||||
if(!this.isInFlyout){var c=(0,$.module$exports$Blockly$Events.getGroup)();(0,$.module$exports$Blockly$Events.setGroup)(a.group);this.setEnabled(b);(0,$.module$exports$Blockly$Events.setGroup)(c)}}}};(0,$.module$exports$Blockly$Extensions.registerMixin)("controls_flow_in_loop_check",module$contents$Blockly$libraryBlocks$loops_CONTROL_FLOW_IN_LOOP_CHECK_MIXIN);(0,$.module$exports$Blockly$common.defineBlocks)(module$exports$Blockly$libraryBlocks$loops.blocks);var module$exports$Blockly$libraryBlocks$logic={};
|
||||
module$exports$Blockly$libraryBlocks$logic.blocks=(0,$.module$exports$Blockly$common.createBlockDefinitionsFromJsonArray)([{type:"logic_boolean",message0:"%1",args0:[{type:"field_dropdown",name:"BOOL",options:[["%{BKY_LOGIC_BOOLEAN_TRUE}","TRUE"],["%{BKY_LOGIC_BOOLEAN_FALSE}","FALSE"]]}],output:"Boolean",style:"logic_blocks",tooltip:"%{BKY_LOGIC_BOOLEAN_TOOLTIP}",helpUrl:"%{BKY_LOGIC_BOOLEAN_HELPURL}"},{type:"controls_if",message0:"%{BKY_CONTROLS_IF_MSG_IF} %1",args0:[{type:"input_value",name:"IF0",
|
||||
check:"Boolean"}],message1:"%{BKY_CONTROLS_IF_MSG_THEN} %1",args1:[{type:"input_statement",name:"DO0"}],previousStatement:null,nextStatement:null,style:"logic_blocks",helpUrl:"%{BKY_CONTROLS_IF_HELPURL}",suppressPrefixSuffix:!0,mutator:"controls_if_mutator",extensions:["controls_if_tooltip"]},{type:"controls_ifelse",message0:"%{BKY_CONTROLS_IF_MSG_IF} %1",args0:[{type:"input_value",name:"IF0",check:"Boolean"}],message1:"%{BKY_CONTROLS_IF_MSG_THEN} %1",args1:[{type:"input_statement",name:"DO0"}],message2:"%{BKY_CONTROLS_IF_MSG_ELSE} %1",
|
||||
args2:[{type:"input_statement",name:"ELSE"}],previousStatement:null,nextStatement:null,style:"logic_blocks",tooltip:"%{BKYCONTROLS_IF_TOOLTIP_2}",helpUrl:"%{BKY_CONTROLS_IF_HELPURL}",suppressPrefixSuffix:!0,extensions:["controls_if_tooltip"]},{type:"logic_compare",message0:"%1 %2 %3",args0:[{type:"input_value",name:"A"},{type:"field_dropdown",name:"OP",options:[["=","EQ"],["\u2260","NEQ"],["\u200f<","LT"],["\u200f\u2264","LTE"],["\u200f>","GT"],["\u200f\u2265","GTE"]]},{type:"input_value",name:"B"}],
|
||||
inputsInline:!0,output:"Boolean",style:"logic_blocks",helpUrl:"%{BKY_LOGIC_COMPARE_HELPURL}",extensions:["logic_compare","logic_op_tooltip"]},{type:"logic_operation",message0:"%1 %2 %3",args0:[{type:"input_value",name:"A",check:"Boolean"},{type:"field_dropdown",name:"OP",options:[["%{BKY_LOGIC_OPERATION_AND}","AND"],["%{BKY_LOGIC_OPERATION_OR}","OR"]]},{type:"input_value",name:"B",check:"Boolean"}],inputsInline:!0,output:"Boolean",style:"logic_blocks",helpUrl:"%{BKY_LOGIC_OPERATION_HELPURL}",extensions:["logic_op_tooltip"]},
|
||||
{type:"logic_negate",message0:"%{BKY_LOGIC_NEGATE_TITLE}",args0:[{type:"input_value",name:"BOOL",check:"Boolean"}],output:"Boolean",style:"logic_blocks",tooltip:"%{BKY_LOGIC_NEGATE_TOOLTIP}",helpUrl:"%{BKY_LOGIC_NEGATE_HELPURL}"},{type:"logic_null",message0:"%{BKY_LOGIC_NULL}",output:null,style:"logic_blocks",tooltip:"%{BKY_LOGIC_NULL_TOOLTIP}",helpUrl:"%{BKY_LOGIC_NULL_HELPURL}"},{type:"logic_ternary",message0:"%{BKY_LOGIC_TERNARY_CONDITION} %1",args0:[{type:"input_value",name:"IF",check:"Boolean"}],
|
||||
message1:"%{BKY_LOGIC_TERNARY_IF_TRUE} %1",args1:[{type:"input_value",name:"THEN"}],message2:"%{BKY_LOGIC_TERNARY_IF_FALSE} %1",args2:[{type:"input_value",name:"ELSE"}],output:null,style:"logic_blocks",tooltip:"%{BKY_LOGIC_TERNARY_TOOLTIP}",helpUrl:"%{BKY_LOGIC_TERNARY_HELPURL}",extensions:["logic_ternary"]},{type:"controls_if_if",message0:"%{BKY_CONTROLS_IF_IF_TITLE_IF}",nextStatement:null,enableContextMenu:!1,style:"logic_blocks",tooltip:"%{BKY_CONTROLS_IF_IF_TOOLTIP}"},{type:"controls_if_elseif",
|
||||
message0:"%{BKY_CONTROLS_IF_ELSEIF_TITLE_ELSEIF}",previousStatement:null,nextStatement:null,enableContextMenu:!1,style:"logic_blocks",tooltip:"%{BKY_CONTROLS_IF_ELSEIF_TOOLTIP}"},{type:"controls_if_else",message0:"%{BKY_CONTROLS_IF_ELSE_TITLE_ELSE}",previousStatement:null,enableContextMenu:!1,style:"logic_blocks",tooltip:"%{BKY_CONTROLS_IF_ELSE_TOOLTIP}"}]);
|
||||
var module$contents$Blockly$libraryBlocks$logic_TOOLTIPS_BY_OP={EQ:"%{BKY_LOGIC_COMPARE_TOOLTIP_EQ}",NEQ:"%{BKY_LOGIC_COMPARE_TOOLTIP_NEQ}",LT:"%{BKY_LOGIC_COMPARE_TOOLTIP_LT}",LTE:"%{BKY_LOGIC_COMPARE_TOOLTIP_LTE}",GT:"%{BKY_LOGIC_COMPARE_TOOLTIP_GT}",GTE:"%{BKY_LOGIC_COMPARE_TOOLTIP_GTE}",AND:"%{BKY_LOGIC_OPERATION_TOOLTIP_AND}",OR:"%{BKY_LOGIC_OPERATION_TOOLTIP_OR}"};
|
||||
(0,$.module$exports$Blockly$Extensions.register)("logic_op_tooltip",(0,$.module$exports$Blockly$Extensions.buildTooltipForDropdown)("OP",module$contents$Blockly$libraryBlocks$logic_TOOLTIPS_BY_OP));
|
||||
var module$contents$Blockly$libraryBlocks$logic_CONTROLS_IF_MUTATOR_MIXIN={elseifCount_:0,elseCount_:0,mutationToDom:function(){if(!this.elseifCount_&&!this.elseCount_)return null;var a=(0,$.module$exports$Blockly$utils$xml.createElement)("mutation");this.elseifCount_&&a.setAttribute("elseif",this.elseifCount_);this.elseCount_&&a.setAttribute("else",1);return a},domToMutation:function(a){this.elseifCount_=parseInt(a.getAttribute("elseif"),10)||0;this.elseCount_=parseInt(a.getAttribute("else"),10)||
|
||||
0;this.rebuildShape_()},saveExtraState:function(){if(!this.elseifCount_&&!this.elseCount_)return null;var a=Object.create(null);this.elseifCount_&&(a.elseIfCount=this.elseifCount_);this.elseCount_&&(a.hasElse=!0);return a},loadExtraState:function(a){this.elseifCount_=a.elseIfCount||0;this.elseCount_=a.hasElse?1:0;this.updateShape_()},decompose:function(a){var b=a.newBlock("controls_if_if");b.initSvg();for(var c=b.nextConnection,d=1;d<=this.elseifCount_;d++){var e=a.newBlock("controls_if_elseif");
|
||||
e.initSvg();c.connect(e.previousConnection);c=e.nextConnection}this.elseCount_&&(a=a.newBlock("controls_if_else"),a.initSvg(),c.connect(a.previousConnection));return b},compose:function(a){a=a.nextConnection.targetBlock();this.elseCount_=this.elseifCount_=0;for(var b=[null],c=[null],d=null;a&&!a.isInsertionMarker();){switch(a.type){case "controls_if_elseif":this.elseifCount_++;b.push(a.valueConnection_);c.push(a.statementConnection_);break;case "controls_if_else":this.elseCount_++;d=a.statementConnection_;
|
||||
break;default:throw TypeError("Unknown block type: "+a.type);}a=a.nextConnection&&a.nextConnection.targetBlock()}this.updateShape_();this.reconnectChildBlocks_(b,c,d)},saveConnections:function(a){a=a.nextConnection.targetBlock();for(var b=1;a;){switch(a.type){case "controls_if_elseif":var c=this.getInput("IF"+b),d=this.getInput("DO"+b);a.valueConnection_=c&&c.connection.targetConnection;a.statementConnection_=d&&d.connection.targetConnection;b++;break;case "controls_if_else":c=this.getInput("ELSE");
|
||||
a.statementConnection_=c&&c.connection.targetConnection;break;default:throw TypeError("Unknown block type: "+a.type);}a=a.nextConnection&&a.nextConnection.targetBlock()}},rebuildShape_:function(){var a=[null],b=[null],c=null;this.getInput("ELSE")&&(c=this.getInput("ELSE").connection.targetConnection);for(var d=1;this.getInput("IF"+d);d++){var e=this.getInput("IF"+d),f=this.getInput("DO"+d);a.push(e.connection.targetConnection);b.push(f.connection.targetConnection)}this.updateShape_();this.reconnectChildBlocks_(a,
|
||||
b,c)},updateShape_:function(){this.getInput("ELSE")&&this.removeInput("ELSE");for(var a=1;this.getInput("IF"+a);a++)this.removeInput("IF"+a),this.removeInput("DO"+a);for(a=1;a<=this.elseifCount_;a++)this.appendValueInput("IF"+a).setCheck("Boolean").appendField($.module$exports$Blockly$Msg.Msg.CONTROLS_IF_MSG_ELSEIF),this.appendStatementInput("DO"+a).appendField($.module$exports$Blockly$Msg.Msg.CONTROLS_IF_MSG_THEN);this.elseCount_&&this.appendStatementInput("ELSE").appendField($.module$exports$Blockly$Msg.Msg.CONTROLS_IF_MSG_ELSE)},
|
||||
reconnectChildBlocks_:function(a,b,c){for(var d=1;d<=this.elseifCount_;d++)$.module$exports$Blockly$Mutator.Mutator.reconnect(a[d],this,"IF"+d),$.module$exports$Blockly$Mutator.Mutator.reconnect(b[d],this,"DO"+d);$.module$exports$Blockly$Mutator.Mutator.reconnect(c,this,"ELSE")}};(0,$.module$exports$Blockly$Extensions.registerMutator)("controls_if_mutator",module$contents$Blockly$libraryBlocks$logic_CONTROLS_IF_MUTATOR_MIXIN,null,["controls_if_elseif","controls_if_else"]);
|
||||
var module$contents$Blockly$libraryBlocks$logic_CONTROLS_IF_TOOLTIP_EXTENSION=function(){this.setTooltip(function(){if(this.elseifCount_||this.elseCount_){if(!this.elseifCount_&&this.elseCount_)return $.module$exports$Blockly$Msg.Msg.CONTROLS_IF_TOOLTIP_2;if(this.elseifCount_&&!this.elseCount_)return $.module$exports$Blockly$Msg.Msg.CONTROLS_IF_TOOLTIP_3;if(this.elseifCount_&&this.elseCount_)return $.module$exports$Blockly$Msg.Msg.CONTROLS_IF_TOOLTIP_4}else return $.module$exports$Blockly$Msg.Msg.CONTROLS_IF_TOOLTIP_1;
|
||||
return""}.bind(this))};(0,$.module$exports$Blockly$Extensions.register)("controls_if_tooltip",module$contents$Blockly$libraryBlocks$logic_CONTROLS_IF_TOOLTIP_EXTENSION);
|
||||
var module$contents$Blockly$libraryBlocks$logic_LOGIC_COMPARE_ONCHANGE_MIXIN={onchange:function(a){this.prevBlocks_||(this.prevBlocks_=[null,null]);var b=this.getInputTargetBlock("A"),c=this.getInputTargetBlock("B");b&&c&&!this.workspace.connectionChecker.doTypeChecks(b.outputConnection,c.outputConnection)&&((0,$.module$exports$Blockly$Events.setGroup)(a.group),a=this.prevBlocks_[0],a!==b&&(b.unplug(),!a||a.isDisposed()||a.isShadow()||this.getInput("A").connection.connect(a.outputConnection)),b=this.prevBlocks_[1],
|
||||
b!==c&&(c.unplug(),!b||b.isDisposed()||b.isShadow()||this.getInput("B").connection.connect(b.outputConnection)),this.bumpNeighbours(),(0,$.module$exports$Blockly$Events.setGroup)(!1));this.prevBlocks_[0]=this.getInputTargetBlock("A");this.prevBlocks_[1]=this.getInputTargetBlock("B")}},module$contents$Blockly$libraryBlocks$logic_LOGIC_COMPARE_EXTENSION=function(){this.mixin(module$contents$Blockly$libraryBlocks$logic_LOGIC_COMPARE_ONCHANGE_MIXIN)};
|
||||
(0,$.module$exports$Blockly$Extensions.register)("logic_compare",module$contents$Blockly$libraryBlocks$logic_LOGIC_COMPARE_EXTENSION);
|
||||
var module$contents$Blockly$libraryBlocks$logic_LOGIC_TERNARY_ONCHANGE_MIXIN={prevParentConnection_:null,onchange:function(a){var b=this.getInputTargetBlock("THEN"),c=this.getInputTargetBlock("ELSE"),d=this.outputConnection.targetConnection;if((b||c)&&d)for(var e=0;2>e;e++){var f=1===e?b:c;f&&!f.workspace.connectionChecker.doTypeChecks(f.outputConnection,d)&&((0,$.module$exports$Blockly$Events.setGroup)(a.group),d===this.prevParentConnection_?(this.unplug(),d.getSourceBlock().bumpNeighbours()):(f.unplug(),
|
||||
f.bumpNeighbours()),(0,$.module$exports$Blockly$Events.setGroup)(!1))}this.prevParentConnection_=d}};(0,$.module$exports$Blockly$Extensions.registerMixin)("logic_ternary",module$contents$Blockly$libraryBlocks$logic_LOGIC_TERNARY_ONCHANGE_MIXIN);(0,$.module$exports$Blockly$common.defineBlocks)(module$exports$Blockly$libraryBlocks$logic.blocks);var module$exports$Blockly$libraryBlocks$lists={};
|
||||
module$exports$Blockly$libraryBlocks$lists.blocks=(0,$.module$exports$Blockly$common.createBlockDefinitionsFromJsonArray)([{type:"lists_create_empty",message0:"%{BKY_LISTS_CREATE_EMPTY_TITLE}",output:"Array",style:"list_blocks",tooltip:"%{BKY_LISTS_CREATE_EMPTY_TOOLTIP}",helpUrl:"%{BKY_LISTS_CREATE_EMPTY_HELPURL}"},{type:"lists_repeat",message0:"%{BKY_LISTS_REPEAT_TITLE}",args0:[{type:"input_value",name:"ITEM"},{type:"input_value",name:"NUM",check:"Number"}],output:"Array",style:"list_blocks",tooltip:"%{BKY_LISTS_REPEAT_TOOLTIP}",
|
||||
helpUrl:"%{BKY_LISTS_REPEAT_HELPURL}"},{type:"lists_reverse",message0:"%{BKY_LISTS_REVERSE_MESSAGE0}",args0:[{type:"input_value",name:"LIST",check:"Array"}],output:"Array",inputsInline:!0,style:"list_blocks",tooltip:"%{BKY_LISTS_REVERSE_TOOLTIP}",helpUrl:"%{BKY_LISTS_REVERSE_HELPURL}"},{type:"lists_isEmpty",message0:"%{BKY_LISTS_ISEMPTY_TITLE}",args0:[{type:"input_value",name:"VALUE",check:["String","Array"]}],output:"Boolean",style:"list_blocks",tooltip:"%{BKY_LISTS_ISEMPTY_TOOLTIP}",helpUrl:"%{BKY_LISTS_ISEMPTY_HELPURL}"},
|
||||
{type:"lists_length",message0:"%{BKY_LISTS_LENGTH_TITLE}",args0:[{type:"input_value",name:"VALUE",check:["String","Array"]}],output:"Number",style:"list_blocks",tooltip:"%{BKY_LISTS_LENGTH_TOOLTIP}",helpUrl:"%{BKY_LISTS_LENGTH_HELPURL}"}]);
|
||||
module$exports$Blockly$libraryBlocks$lists.blocks.lists_create_with={init:function(){this.setHelpUrl($.module$exports$Blockly$Msg.Msg.LISTS_CREATE_WITH_HELPURL);this.setStyle("list_blocks");this.itemCount_=3;this.updateShape_();this.setOutput(!0,"Array");this.setMutator(new $.module$exports$Blockly$Mutator.Mutator(["lists_create_with_item"]));this.setTooltip($.module$exports$Blockly$Msg.Msg.LISTS_CREATE_WITH_TOOLTIP)},mutationToDom:function(){var a=(0,$.module$exports$Blockly$utils$xml.createElement)("mutation");
|
||||
a.setAttribute("items",this.itemCount_);return a},domToMutation:function(a){this.itemCount_=parseInt(a.getAttribute("items"),10);this.updateShape_()},saveExtraState:function(){return{itemCount:this.itemCount_}},loadExtraState:function(a){this.itemCount_=a.itemCount;this.updateShape_()},decompose:function(a){var b=a.newBlock("lists_create_with_container");b.initSvg();for(var c=b.getInput("STACK").connection,d=0;d<this.itemCount_;d++){var e=a.newBlock("lists_create_with_item");e.initSvg();c.connect(e.previousConnection);
|
||||
c=e.nextConnection}return b},compose:function(a){var b=a.getInputTargetBlock("STACK");for(a=[];b&&!b.isInsertionMarker();)a.push(b.valueConnection_),b=b.nextConnection&&b.nextConnection.targetBlock();for(b=0;b<this.itemCount_;b++){var c=this.getInput("ADD"+b).connection.targetConnection;c&&-1===a.indexOf(c)&&c.disconnect()}this.itemCount_=a.length;this.updateShape_();for(b=0;b<this.itemCount_;b++)$.module$exports$Blockly$Mutator.Mutator.reconnect(a[b],this,"ADD"+b)},saveConnections:function(a){a=
|
||||
a.getInputTargetBlock("STACK");for(var b=0;a;){var c=this.getInput("ADD"+b);a.valueConnection_=c&&c.connection.targetConnection;a=a.nextConnection&&a.nextConnection.targetBlock();b++}},updateShape_:function(){this.itemCount_&&this.getInput("EMPTY")?this.removeInput("EMPTY"):this.itemCount_||this.getInput("EMPTY")||this.appendDummyInput("EMPTY").appendField($.module$exports$Blockly$Msg.Msg.LISTS_CREATE_EMPTY_TITLE);for(var a=0;a<this.itemCount_;a++)if(!this.getInput("ADD"+a)){var b=this.appendValueInput("ADD"+
|
||||
a).setAlign($.module$exports$Blockly$Input.Align.RIGHT);0===a&&b.appendField($.module$exports$Blockly$Msg.Msg.LISTS_CREATE_WITH_INPUT_WITH)}for(a=this.itemCount_;this.getInput("ADD"+a);a++)this.removeInput("ADD"+a)}};
|
||||
module$exports$Blockly$libraryBlocks$lists.blocks.lists_create_with_container={init:function(){this.setStyle("list_blocks");this.appendDummyInput().appendField($.module$exports$Blockly$Msg.Msg.LISTS_CREATE_WITH_CONTAINER_TITLE_ADD);this.appendStatementInput("STACK");this.setTooltip($.module$exports$Blockly$Msg.Msg.LISTS_CREATE_WITH_CONTAINER_TOOLTIP);this.contextMenu=!1}};
|
||||
module$exports$Blockly$libraryBlocks$lists.blocks.lists_create_with_item={init:function(){this.setStyle("list_blocks");this.appendDummyInput().appendField($.module$exports$Blockly$Msg.Msg.LISTS_CREATE_WITH_ITEM_TITLE);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip($.module$exports$Blockly$Msg.Msg.LISTS_CREATE_WITH_ITEM_TOOLTIP);this.contextMenu=!1}};
|
||||
module$exports$Blockly$libraryBlocks$lists.blocks.lists_indexOf={init:function(){var a=[[$.module$exports$Blockly$Msg.Msg.LISTS_INDEX_OF_FIRST,"FIRST"],[$.module$exports$Blockly$Msg.Msg.LISTS_INDEX_OF_LAST,"LAST"]];this.setHelpUrl($.module$exports$Blockly$Msg.Msg.LISTS_INDEX_OF_HELPURL);this.setStyle("list_blocks");this.setOutput(!0,"Number");this.appendValueInput("VALUE").setCheck("Array").appendField($.module$exports$Blockly$Msg.Msg.LISTS_INDEX_OF_INPUT_IN_LIST);this.appendValueInput("FIND").appendField(new $.module$exports$Blockly$FieldDropdown.FieldDropdown(a),
|
||||
"END");this.setInputsInline(!0);var b=this;this.setTooltip(function(){return $.module$exports$Blockly$Msg.Msg.LISTS_INDEX_OF_TOOLTIP.replace("%1",b.workspace.options.oneBasedIndex?"0":"-1")})}};
|
||||
module$exports$Blockly$libraryBlocks$lists.blocks.lists_getIndex={init:function(){var a=[[$.module$exports$Blockly$Msg.Msg.LISTS_GET_INDEX_GET,"GET"],[$.module$exports$Blockly$Msg.Msg.LISTS_GET_INDEX_GET_REMOVE,"GET_REMOVE"],[$.module$exports$Blockly$Msg.Msg.LISTS_GET_INDEX_REMOVE,"REMOVE"]];this.WHERE_OPTIONS=[[$.module$exports$Blockly$Msg.Msg.LISTS_GET_INDEX_FROM_START,"FROM_START"],[$.module$exports$Blockly$Msg.Msg.LISTS_GET_INDEX_FROM_END,"FROM_END"],[$.module$exports$Blockly$Msg.Msg.LISTS_GET_INDEX_FIRST,
|
||||
"FIRST"],[$.module$exports$Blockly$Msg.Msg.LISTS_GET_INDEX_LAST,"LAST"],[$.module$exports$Blockly$Msg.Msg.LISTS_GET_INDEX_RANDOM,"RANDOM"]];this.setHelpUrl($.module$exports$Blockly$Msg.Msg.LISTS_GET_INDEX_HELPURL);this.setStyle("list_blocks");a=new $.module$exports$Blockly$FieldDropdown.FieldDropdown(a,function(c){c="REMOVE"===c;this.getSourceBlock().updateStatement_(c)});this.appendValueInput("VALUE").setCheck("Array").appendField($.module$exports$Blockly$Msg.Msg.LISTS_GET_INDEX_INPUT_IN_LIST);this.appendDummyInput().appendField(a,
|
||||
"MODE").appendField("","SPACE");this.appendDummyInput("AT");$.module$exports$Blockly$Msg.Msg.LISTS_GET_INDEX_TAIL&&this.appendDummyInput("TAIL").appendField($.module$exports$Blockly$Msg.Msg.LISTS_GET_INDEX_TAIL);this.setInputsInline(!0);this.setOutput(!0);this.updateAt_(!0);var b=this;this.setTooltip(function(){var c=b.getFieldValue("MODE"),d=b.getFieldValue("WHERE"),e="";switch(c+" "+d){case "GET FROM_START":case "GET FROM_END":e=$.module$exports$Blockly$Msg.Msg.LISTS_GET_INDEX_TOOLTIP_GET_FROM;
|
||||
break;case "GET FIRST":e=$.module$exports$Blockly$Msg.Msg.LISTS_GET_INDEX_TOOLTIP_GET_FIRST;break;case "GET LAST":e=$.module$exports$Blockly$Msg.Msg.LISTS_GET_INDEX_TOOLTIP_GET_LAST;break;case "GET RANDOM":e=$.module$exports$Blockly$Msg.Msg.LISTS_GET_INDEX_TOOLTIP_GET_RANDOM;break;case "GET_REMOVE FROM_START":case "GET_REMOVE FROM_END":e=$.module$exports$Blockly$Msg.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FROM;break;case "GET_REMOVE FIRST":e=$.module$exports$Blockly$Msg.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FIRST;
|
||||
break;case "GET_REMOVE LAST":e=$.module$exports$Blockly$Msg.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_LAST;break;case "GET_REMOVE RANDOM":e=$.module$exports$Blockly$Msg.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_RANDOM;break;case "REMOVE FROM_START":case "REMOVE FROM_END":e=$.module$exports$Blockly$Msg.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_FROM;break;case "REMOVE FIRST":e=$.module$exports$Blockly$Msg.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_FIRST;break;case "REMOVE LAST":e=$.module$exports$Blockly$Msg.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_LAST;
|
||||
break;case "REMOVE RANDOM":e=$.module$exports$Blockly$Msg.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_RANDOM}if("FROM_START"===d||"FROM_END"===d)e+=" "+("FROM_START"===d?$.module$exports$Blockly$Msg.Msg.LISTS_INDEX_FROM_START_TOOLTIP:$.module$exports$Blockly$Msg.Msg.LISTS_INDEX_FROM_END_TOOLTIP).replace("%1",b.workspace.options.oneBasedIndex?"#1":"#0");return e})},mutationToDom:function(){var a=(0,$.module$exports$Blockly$utils$xml.createElement)("mutation");a.setAttribute("statement",!this.outputConnection);
|
||||
var b=this.getInput("AT").type===$.module$exports$Blockly$ConnectionType.ConnectionType.INPUT_VALUE;a.setAttribute("at",b);return a},domToMutation:function(a){var b="true"===a.getAttribute("statement");this.updateStatement_(b);a="false"!==a.getAttribute("at");this.updateAt_(a)},updateStatement_:function(a){a!==!this.outputConnection&&(this.unplug(!0,!0),a?(this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0)):(this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0)))},
|
||||
updateAt_:function(a){this.removeInput("AT");this.removeInput("ORDINAL",!0);a?(this.appendValueInput("AT").setCheck("Number"),$.module$exports$Blockly$Msg.Msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL").appendField($.module$exports$Blockly$Msg.Msg.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT");var b=new $.module$exports$Blockly$FieldDropdown.FieldDropdown(this.WHERE_OPTIONS,function(c){var d="FROM_START"===c||"FROM_END"===c;if(d!==a){var e=this.getSourceBlock();e.updateAt_(d);e.setFieldValue(c,
|
||||
"WHERE");return null}});this.getInput("AT").appendField(b,"WHERE");$.module$exports$Blockly$Msg.Msg.LISTS_GET_INDEX_TAIL&&this.moveInputBefore("TAIL",null)}};
|
||||
module$exports$Blockly$libraryBlocks$lists.blocks.lists_setIndex={init:function(){var a=[[$.module$exports$Blockly$Msg.Msg.LISTS_SET_INDEX_SET,"SET"],[$.module$exports$Blockly$Msg.Msg.LISTS_SET_INDEX_INSERT,"INSERT"]];this.WHERE_OPTIONS=[[$.module$exports$Blockly$Msg.Msg.LISTS_GET_INDEX_FROM_START,"FROM_START"],[$.module$exports$Blockly$Msg.Msg.LISTS_GET_INDEX_FROM_END,"FROM_END"],[$.module$exports$Blockly$Msg.Msg.LISTS_GET_INDEX_FIRST,"FIRST"],[$.module$exports$Blockly$Msg.Msg.LISTS_GET_INDEX_LAST,
|
||||
"LAST"],[$.module$exports$Blockly$Msg.Msg.LISTS_GET_INDEX_RANDOM,"RANDOM"]];this.setHelpUrl($.module$exports$Blockly$Msg.Msg.LISTS_SET_INDEX_HELPURL);this.setStyle("list_blocks");this.appendValueInput("LIST").setCheck("Array").appendField($.module$exports$Blockly$Msg.Msg.LISTS_SET_INDEX_INPUT_IN_LIST);this.appendDummyInput().appendField(new $.module$exports$Blockly$FieldDropdown.FieldDropdown(a),"MODE").appendField("","SPACE");this.appendDummyInput("AT");this.appendValueInput("TO").appendField($.module$exports$Blockly$Msg.Msg.LISTS_SET_INDEX_INPUT_TO);
|
||||
this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip($.module$exports$Blockly$Msg.Msg.LISTS_SET_INDEX_TOOLTIP);this.updateAt_(!0);var b=this;this.setTooltip(function(){var c=b.getFieldValue("MODE"),d=b.getFieldValue("WHERE"),e="";switch(c+" "+d){case "SET FROM_START":case "SET FROM_END":e=$.module$exports$Blockly$Msg.Msg.LISTS_SET_INDEX_TOOLTIP_SET_FROM;break;case "SET FIRST":e=$.module$exports$Blockly$Msg.Msg.LISTS_SET_INDEX_TOOLTIP_SET_FIRST;break;case "SET LAST":e=
|
||||
$.module$exports$Blockly$Msg.Msg.LISTS_SET_INDEX_TOOLTIP_SET_LAST;break;case "SET RANDOM":e=$.module$exports$Blockly$Msg.Msg.LISTS_SET_INDEX_TOOLTIP_SET_RANDOM;break;case "INSERT FROM_START":case "INSERT FROM_END":e=$.module$exports$Blockly$Msg.Msg.LISTS_SET_INDEX_TOOLTIP_INSERT_FROM;break;case "INSERT FIRST":e=$.module$exports$Blockly$Msg.Msg.LISTS_SET_INDEX_TOOLTIP_INSERT_FIRST;break;case "INSERT LAST":e=$.module$exports$Blockly$Msg.Msg.LISTS_SET_INDEX_TOOLTIP_INSERT_LAST;break;case "INSERT RANDOM":e=
|
||||
$.module$exports$Blockly$Msg.Msg.LISTS_SET_INDEX_TOOLTIP_INSERT_RANDOM}if("FROM_START"===d||"FROM_END"===d)e+=" "+$.module$exports$Blockly$Msg.Msg.LISTS_INDEX_FROM_START_TOOLTIP.replace("%1",b.workspace.options.oneBasedIndex?"#1":"#0");return e})},mutationToDom:function(){var a=(0,$.module$exports$Blockly$utils$xml.createElement)("mutation"),b=this.getInput("AT").type===$.module$exports$Blockly$ConnectionType.ConnectionType.INPUT_VALUE;a.setAttribute("at",b);return a},domToMutation:function(a){a=
|
||||
"false"!==a.getAttribute("at");this.updateAt_(a)},updateAt_:function(a){this.removeInput("AT");this.removeInput("ORDINAL",!0);a?(this.appendValueInput("AT").setCheck("Number"),$.module$exports$Blockly$Msg.Msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL").appendField($.module$exports$Blockly$Msg.Msg.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT");var b=new $.module$exports$Blockly$FieldDropdown.FieldDropdown(this.WHERE_OPTIONS,function(c){var d="FROM_START"===c||"FROM_END"===c;if(d!==
|
||||
a){var e=this.getSourceBlock();e.updateAt_(d);e.setFieldValue(c,"WHERE");return null}});this.moveInputBefore("AT","TO");this.getInput("ORDINAL")&&this.moveInputBefore("ORDINAL","TO");this.getInput("AT").appendField(b,"WHERE")}};
|
||||
module$exports$Blockly$libraryBlocks$lists.blocks.lists_getSublist={init:function(){this.WHERE_OPTIONS_1=[[$.module$exports$Blockly$Msg.Msg.LISTS_GET_SUBLIST_START_FROM_START,"FROM_START"],[$.module$exports$Blockly$Msg.Msg.LISTS_GET_SUBLIST_START_FROM_END,"FROM_END"],[$.module$exports$Blockly$Msg.Msg.LISTS_GET_SUBLIST_START_FIRST,"FIRST"]];this.WHERE_OPTIONS_2=[[$.module$exports$Blockly$Msg.Msg.LISTS_GET_SUBLIST_END_FROM_START,"FROM_START"],[$.module$exports$Blockly$Msg.Msg.LISTS_GET_SUBLIST_END_FROM_END,
|
||||
"FROM_END"],[$.module$exports$Blockly$Msg.Msg.LISTS_GET_SUBLIST_END_LAST,"LAST"]];this.setHelpUrl($.module$exports$Blockly$Msg.Msg.LISTS_GET_SUBLIST_HELPURL);this.setStyle("list_blocks");this.appendValueInput("LIST").setCheck("Array").appendField($.module$exports$Blockly$Msg.Msg.LISTS_GET_SUBLIST_INPUT_IN_LIST);this.appendDummyInput("AT1");this.appendDummyInput("AT2");$.module$exports$Blockly$Msg.Msg.LISTS_GET_SUBLIST_TAIL&&this.appendDummyInput("TAIL").appendField($.module$exports$Blockly$Msg.Msg.LISTS_GET_SUBLIST_TAIL);
|
||||
this.setInputsInline(!0);this.setOutput(!0,"Array");this.updateAt_(1,!0);this.updateAt_(2,!0);this.setTooltip($.module$exports$Blockly$Msg.Msg.LISTS_GET_SUBLIST_TOOLTIP)},mutationToDom:function(){var a=(0,$.module$exports$Blockly$utils$xml.createElement)("mutation"),b=this.getInput("AT1").type===$.module$exports$Blockly$ConnectionType.ConnectionType.INPUT_VALUE;a.setAttribute("at1",b);b=this.getInput("AT2").type===$.module$exports$Blockly$ConnectionType.ConnectionType.INPUT_VALUE;a.setAttribute("at2",
|
||||
b);return a},domToMutation:function(a){var b="true"===a.getAttribute("at1");a="true"===a.getAttribute("at2");this.updateAt_(1,b);this.updateAt_(2,a)},updateAt_:function(a,b){this.removeInput("AT"+a);this.removeInput("ORDINAL"+a,!0);b?(this.appendValueInput("AT"+a).setCheck("Number"),$.module$exports$Blockly$Msg.Msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL"+a).appendField($.module$exports$Blockly$Msg.Msg.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT"+a);var c=new $.module$exports$Blockly$FieldDropdown.FieldDropdown(this["WHERE_OPTIONS_"+
|
||||
a],function(d){var e="FROM_START"===d||"FROM_END"===d;if(e!==b){var f=this.getSourceBlock();f.updateAt_(a,e);f.setFieldValue(d,"WHERE"+a);return null}});this.getInput("AT"+a).appendField(c,"WHERE"+a);1===a&&(this.moveInputBefore("AT1","AT2"),this.getInput("ORDINAL1")&&this.moveInputBefore("ORDINAL1","AT2"));$.module$exports$Blockly$Msg.Msg.LISTS_GET_SUBLIST_TAIL&&this.moveInputBefore("TAIL",null)}};
|
||||
module$exports$Blockly$libraryBlocks$lists.blocks.lists_sort={init:function(){this.jsonInit({message0:$.module$exports$Blockly$Msg.Msg.LISTS_SORT_TITLE,args0:[{type:"field_dropdown",name:"TYPE",options:[[$.module$exports$Blockly$Msg.Msg.LISTS_SORT_TYPE_NUMERIC,"NUMERIC"],[$.module$exports$Blockly$Msg.Msg.LISTS_SORT_TYPE_TEXT,"TEXT"],[$.module$exports$Blockly$Msg.Msg.LISTS_SORT_TYPE_IGNORECASE,"IGNORE_CASE"]]},{type:"field_dropdown",name:"DIRECTION",options:[[$.module$exports$Blockly$Msg.Msg.LISTS_SORT_ORDER_ASCENDING,
|
||||
"1"],[$.module$exports$Blockly$Msg.Msg.LISTS_SORT_ORDER_DESCENDING,"-1"]]},{type:"input_value",name:"LIST",check:"Array"}],output:"Array",style:"list_blocks",tooltip:$.module$exports$Blockly$Msg.Msg.LISTS_SORT_TOOLTIP,helpUrl:$.module$exports$Blockly$Msg.Msg.LISTS_SORT_HELPURL})}};
|
||||
module$exports$Blockly$libraryBlocks$lists.blocks.lists_split={init:function(){var a=this,b=new $.module$exports$Blockly$FieldDropdown.FieldDropdown([[$.module$exports$Blockly$Msg.Msg.LISTS_SPLIT_LIST_FROM_TEXT,"SPLIT"],[$.module$exports$Blockly$Msg.Msg.LISTS_SPLIT_TEXT_FROM_LIST,"JOIN"]],function(c){a.updateType_(c)});this.setHelpUrl($.module$exports$Blockly$Msg.Msg.LISTS_SPLIT_HELPURL);this.setStyle("list_blocks");this.appendValueInput("INPUT").setCheck("String").appendField(b,"MODE");this.appendValueInput("DELIM").setCheck("String").appendField($.module$exports$Blockly$Msg.Msg.LISTS_SPLIT_WITH_DELIMITER);
|
||||
this.setInputsInline(!0);this.setOutput(!0,"Array");this.setTooltip(function(){var c=a.getFieldValue("MODE");if("SPLIT"===c)return $.module$exports$Blockly$Msg.Msg.LISTS_SPLIT_TOOLTIP_SPLIT;if("JOIN"===c)return $.module$exports$Blockly$Msg.Msg.LISTS_SPLIT_TOOLTIP_JOIN;throw Error("Unknown mode: "+c);})},updateType_:function(a){if(this.getFieldValue("MODE")!==a){var b=this.getInput("INPUT").connection;b.setShadowDom(null);var c=b.targetBlock();c&&(b.disconnect(),c.isShadow()?c.dispose():this.bumpNeighbours())}"SPLIT"===
|
||||
a?(this.outputConnection.setCheck("Array"),this.getInput("INPUT").setCheck("String")):(this.outputConnection.setCheck("String"),this.getInput("INPUT").setCheck("Array"))},mutationToDom:function(){var a=(0,$.module$exports$Blockly$utils$xml.createElement)("mutation");a.setAttribute("mode",this.getFieldValue("MODE"));return a},domToMutation:function(a){this.updateType_(a.getAttribute("mode"))}};(0,$.module$exports$Blockly$common.defineBlocks)(module$exports$Blockly$libraryBlocks$lists.blocks);var module$exports$Blockly$libraryBlocks$colour={};
|
||||
module$exports$Blockly$libraryBlocks$colour.blocks=(0,$.module$exports$Blockly$common.createBlockDefinitionsFromJsonArray)([{type:"colour_picker",message0:"%1",args0:[{type:"field_colour",name:"COLOUR",colour:"#ff0000"}],output:"Colour",helpUrl:"%{BKY_COLOUR_PICKER_HELPURL}",style:"colour_blocks",tooltip:"%{BKY_COLOUR_PICKER_TOOLTIP}",extensions:["parent_tooltip_when_inline"]},{type:"colour_random",message0:"%{BKY_COLOUR_RANDOM_TITLE}",output:"Colour",helpUrl:"%{BKY_COLOUR_RANDOM_HELPURL}",style:"colour_blocks",
|
||||
tooltip:"%{BKY_COLOUR_RANDOM_TOOLTIP}"},{type:"colour_rgb",message0:"%{BKY_COLOUR_RGB_TITLE} %{BKY_COLOUR_RGB_RED} %1 %{BKY_COLOUR_RGB_GREEN} %2 %{BKY_COLOUR_RGB_BLUE} %3",args0:[{type:"input_value",name:"RED",check:"Number",align:"RIGHT"},{type:"input_value",name:"GREEN",check:"Number",align:"RIGHT"},{type:"input_value",name:"BLUE",check:"Number",align:"RIGHT"}],output:"Colour",helpUrl:"%{BKY_COLOUR_RGB_HELPURL}",style:"colour_blocks",tooltip:"%{BKY_COLOUR_RGB_TOOLTIP}"},{type:"colour_blend",message0:"%{BKY_COLOUR_BLEND_TITLE} %{BKY_COLOUR_BLEND_COLOUR1} %1 %{BKY_COLOUR_BLEND_COLOUR2} %2 %{BKY_COLOUR_BLEND_RATIO} %3",
|
||||
args0:[{type:"input_value",name:"COLOUR1",check:"Colour",align:"RIGHT"},{type:"input_value",name:"COLOUR2",check:"Colour",align:"RIGHT"},{type:"input_value",name:"RATIO",check:"Number",align:"RIGHT"}],output:"Colour",helpUrl:"%{BKY_COLOUR_BLEND_HELPURL}",style:"colour_blocks",tooltip:"%{BKY_COLOUR_BLEND_TOOLTIP}"}]);(0,$.module$exports$Blockly$common.defineBlocks)(module$exports$Blockly$libraryBlocks$colour.blocks);$.Blockly.libraryBlocks={};$.Blockly.libraryBlocks.colour=module$exports$Blockly$libraryBlocks$colour;$.Blockly.libraryBlocks.lists=module$exports$Blockly$libraryBlocks$lists;$.Blockly.libraryBlocks.logic=module$exports$Blockly$libraryBlocks$logic;$.Blockly.libraryBlocks.loops=module$exports$Blockly$libraryBlocks$loops;$.Blockly.libraryBlocks.math=module$exports$Blockly$libraryBlocks$math;$.Blockly.libraryBlocks.procedures=module$exports$Blockly$libraryBlocks$procedures;
|
||||
$.Blockly.libraryBlocks.texts=module$exports$Blockly$libraryBlocks$texts;$.Blockly.libraryBlocks.variables=module$exports$Blockly$libraryBlocks$variables;$.Blockly.libraryBlocks.variablesDynamic=module$exports$Blockly$libraryBlocks$variablesDynamic;
|
||||
var module$contents$Blockly$libraryBlocks_blocks=Object.assign({},module$exports$Blockly$libraryBlocks$colour.blocks,module$exports$Blockly$libraryBlocks$lists.blocks,module$exports$Blockly$libraryBlocks$logic.blocks,module$exports$Blockly$libraryBlocks$loops.blocks,module$exports$Blockly$libraryBlocks$math.blocks,module$exports$Blockly$libraryBlocks$procedures.blocks,module$exports$Blockly$libraryBlocks$variables.blocks,module$exports$Blockly$libraryBlocks$variablesDynamic.blocks);
|
||||
$.Blockly.libraryBlocks.blocks=module$contents$Blockly$libraryBlocks_blocks;
|
||||
$.Blockly.libraryBlocks.__namespace__=$;
|
||||
return $.Blockly.libraryBlocks;
|
||||
$.module$build$src$core$extensions.register("controls_whileUntil_tooltip",$.module$build$src$core$extensions.buildTooltipForDropdown("MODE",module$contents$Blockly$libraryBlocks$loops_WHILE_UNTIL_TOOLTIPS));var module$contents$Blockly$libraryBlocks$loops_BREAK_CONTINUE_TOOLTIPS={BREAK:"%{BKY_CONTROLS_FLOW_STATEMENTS_TOOLTIP_BREAK}",CONTINUE:"%{BKY_CONTROLS_FLOW_STATEMENTS_TOOLTIP_CONTINUE}"};
|
||||
$.module$build$src$core$extensions.register("controls_flow_tooltip",$.module$build$src$core$extensions.buildTooltipForDropdown("FLOW",module$contents$Blockly$libraryBlocks$loops_BREAK_CONTINUE_TOOLTIPS));
|
||||
var module$contents$Blockly$libraryBlocks$loops_CUSTOM_CONTEXT_MENU_CREATE_VARIABLES_GET_MIXIN={customContextMenu:function(a){if(!this.isInFlyout){var b=this.getField("VAR").getVariable(),c=b.name;if(!this.isCollapsed()&&null!==c){const d={enabled:!0};d.text=module$contents$Blockly$libraryBlocks$loops_Msg.VARIABLES_SET_CREATE_GET.replace("%1",c);b=$.module$build$src$core$variables.generateVariableFieldDom(b);c=$.module$build$src$core$utils$xml.createElement("block");c.setAttribute("type","variables_get");
|
||||
c.appendChild(b);d.callback=$.module$build$src$core$contextmenu.callbackFactory(this,c);a.push(d)}}}};$.module$build$src$core$extensions.registerMixin("contextMenu_newGetVariableBlock",module$contents$Blockly$libraryBlocks$loops_CUSTOM_CONTEXT_MENU_CREATE_VARIABLES_GET_MIXIN);$.module$build$src$core$extensions.register("controls_for_tooltip",$.module$build$src$core$extensions.buildTooltipWithFieldText("%{BKY_CONTROLS_FOR_TOOLTIP}","VAR"));
|
||||
$.module$build$src$core$extensions.register("controls_forEach_tooltip",$.module$build$src$core$extensions.buildTooltipWithFieldText("%{BKY_CONTROLS_FOREACH_TOOLTIP}","VAR"));module$exports$Blockly$libraryBlocks$loops.loopTypes=new Set(["controls_repeat","controls_repeat_ext","controls_forEach","controls_for","controls_whileUntil"]);
|
||||
var module$contents$Blockly$libraryBlocks$loops_CONTROL_FLOW_IN_LOOP_CHECK_MIXIN={getSurroundLoop:function(){let a=this;do{if(module$exports$Blockly$libraryBlocks$loops.loopTypes.has(a.type))return a;a=a.getSurroundParent()}while(a);return null},onchange:function(a){if(this.workspace.isDragging&&!this.workspace.isDragging()&&a.type===$.module$build$src$core$events$events.BLOCK_MOVE){var b=this.getSurroundLoop(this);this.setWarningText(b?null:module$contents$Blockly$libraryBlocks$loops_Msg.CONTROLS_FLOW_STATEMENTS_WARNING);
|
||||
if(!this.isInFlyout){const c=$.module$build$src$core$events$events.getGroup();$.module$build$src$core$events$events.setGroup(a.group);this.setEnabled(b);$.module$build$src$core$events$events.setGroup(c)}}}};$.module$build$src$core$extensions.registerMixin("controls_flow_in_loop_check",module$contents$Blockly$libraryBlocks$loops_CONTROL_FLOW_IN_LOOP_CHECK_MIXIN);module$contents$Blockly$libraryBlocks$loops_defineBlocks(module$exports$Blockly$libraryBlocks$loops.blocks);var module$exports$Blockly$libraryBlocks$logic={},module$contents$Blockly$libraryBlocks$logic_Events=$.module$build$src$core$events$events,module$contents$Blockly$libraryBlocks$logic_Extensions=$.module$build$src$core$extensions,module$contents$Blockly$libraryBlocks$logic_xmlUtils=$.module$build$src$core$utils$xml,module$contents$Blockly$libraryBlocks$logic_BlockDefinition=Object,module$contents$Blockly$libraryBlocks$logic_Msg=$.module$build$src$core$msg.Msg,module$contents$Blockly$libraryBlocks$logic_Mutator=
|
||||
$.Mutator$$module$build$src$core$mutator,module$contents$Blockly$libraryBlocks$logic_createBlockDefinitionsFromJsonArray=$.module$build$src$core$common.createBlockDefinitionsFromJsonArray,module$contents$Blockly$libraryBlocks$logic_defineBlocks=$.module$build$src$core$common.defineBlocks;
|
||||
module$exports$Blockly$libraryBlocks$logic.blocks=module$contents$Blockly$libraryBlocks$logic_createBlockDefinitionsFromJsonArray([{type:"logic_boolean",message0:"%1",args0:[{type:"field_dropdown",name:"BOOL",options:[["%{BKY_LOGIC_BOOLEAN_TRUE}","TRUE"],["%{BKY_LOGIC_BOOLEAN_FALSE}","FALSE"]]}],output:"Boolean",style:"logic_blocks",tooltip:"%{BKY_LOGIC_BOOLEAN_TOOLTIP}",helpUrl:"%{BKY_LOGIC_BOOLEAN_HELPURL}"},{type:"controls_if",message0:"%{BKY_CONTROLS_IF_MSG_IF} %1",args0:[{type:"input_value",
|
||||
name:"IF0",check:"Boolean"}],message1:"%{BKY_CONTROLS_IF_MSG_THEN} %1",args1:[{type:"input_statement",name:"DO0"}],previousStatement:null,nextStatement:null,style:"logic_blocks",helpUrl:"%{BKY_CONTROLS_IF_HELPURL}",suppressPrefixSuffix:!0,mutator:"controls_if_mutator",extensions:["controls_if_tooltip"]},{type:"controls_ifelse",message0:"%{BKY_CONTROLS_IF_MSG_IF} %1",args0:[{type:"input_value",name:"IF0",check:"Boolean"}],message1:"%{BKY_CONTROLS_IF_MSG_THEN} %1",args1:[{type:"input_statement",name:"DO0"}],
|
||||
message2:"%{BKY_CONTROLS_IF_MSG_ELSE} %1",args2:[{type:"input_statement",name:"ELSE"}],previousStatement:null,nextStatement:null,style:"logic_blocks",tooltip:"%{BKYCONTROLS_IF_TOOLTIP_2}",helpUrl:"%{BKY_CONTROLS_IF_HELPURL}",suppressPrefixSuffix:!0,extensions:["controls_if_tooltip"]},{type:"logic_compare",message0:"%1 %2 %3",args0:[{type:"input_value",name:"A"},{type:"field_dropdown",name:"OP",options:[["=","EQ"],["\u2260","NEQ"],["\u200f<","LT"],["\u200f\u2264","LTE"],["\u200f>","GT"],["\u200f\u2265",
|
||||
"GTE"]]},{type:"input_value",name:"B"}],inputsInline:!0,output:"Boolean",style:"logic_blocks",helpUrl:"%{BKY_LOGIC_COMPARE_HELPURL}",extensions:["logic_compare","logic_op_tooltip"]},{type:"logic_operation",message0:"%1 %2 %3",args0:[{type:"input_value",name:"A",check:"Boolean"},{type:"field_dropdown",name:"OP",options:[["%{BKY_LOGIC_OPERATION_AND}","AND"],["%{BKY_LOGIC_OPERATION_OR}","OR"]]},{type:"input_value",name:"B",check:"Boolean"}],inputsInline:!0,output:"Boolean",style:"logic_blocks",helpUrl:"%{BKY_LOGIC_OPERATION_HELPURL}",
|
||||
extensions:["logic_op_tooltip"]},{type:"logic_negate",message0:"%{BKY_LOGIC_NEGATE_TITLE}",args0:[{type:"input_value",name:"BOOL",check:"Boolean"}],output:"Boolean",style:"logic_blocks",tooltip:"%{BKY_LOGIC_NEGATE_TOOLTIP}",helpUrl:"%{BKY_LOGIC_NEGATE_HELPURL}"},{type:"logic_null",message0:"%{BKY_LOGIC_NULL}",output:null,style:"logic_blocks",tooltip:"%{BKY_LOGIC_NULL_TOOLTIP}",helpUrl:"%{BKY_LOGIC_NULL_HELPURL}"},{type:"logic_ternary",message0:"%{BKY_LOGIC_TERNARY_CONDITION} %1",args0:[{type:"input_value",
|
||||
name:"IF",check:"Boolean"}],message1:"%{BKY_LOGIC_TERNARY_IF_TRUE} %1",args1:[{type:"input_value",name:"THEN"}],message2:"%{BKY_LOGIC_TERNARY_IF_FALSE} %1",args2:[{type:"input_value",name:"ELSE"}],output:null,style:"logic_blocks",tooltip:"%{BKY_LOGIC_TERNARY_TOOLTIP}",helpUrl:"%{BKY_LOGIC_TERNARY_HELPURL}",extensions:["logic_ternary"]},{type:"controls_if_if",message0:"%{BKY_CONTROLS_IF_IF_TITLE_IF}",nextStatement:null,enableContextMenu:!1,style:"logic_blocks",tooltip:"%{BKY_CONTROLS_IF_IF_TOOLTIP}"},
|
||||
{type:"controls_if_elseif",message0:"%{BKY_CONTROLS_IF_ELSEIF_TITLE_ELSEIF}",previousStatement:null,nextStatement:null,enableContextMenu:!1,style:"logic_blocks",tooltip:"%{BKY_CONTROLS_IF_ELSEIF_TOOLTIP}"},{type:"controls_if_else",message0:"%{BKY_CONTROLS_IF_ELSE_TITLE_ELSE}",previousStatement:null,enableContextMenu:!1,style:"logic_blocks",tooltip:"%{BKY_CONTROLS_IF_ELSE_TOOLTIP}"}]);
|
||||
var module$contents$Blockly$libraryBlocks$logic_TOOLTIPS_BY_OP={EQ:"%{BKY_LOGIC_COMPARE_TOOLTIP_EQ}",NEQ:"%{BKY_LOGIC_COMPARE_TOOLTIP_NEQ}",LT:"%{BKY_LOGIC_COMPARE_TOOLTIP_LT}",LTE:"%{BKY_LOGIC_COMPARE_TOOLTIP_LTE}",GT:"%{BKY_LOGIC_COMPARE_TOOLTIP_GT}",GTE:"%{BKY_LOGIC_COMPARE_TOOLTIP_GTE}",AND:"%{BKY_LOGIC_OPERATION_TOOLTIP_AND}",OR:"%{BKY_LOGIC_OPERATION_TOOLTIP_OR}"};$.module$build$src$core$extensions.register("logic_op_tooltip",$.module$build$src$core$extensions.buildTooltipForDropdown("OP",module$contents$Blockly$libraryBlocks$logic_TOOLTIPS_BY_OP));
|
||||
var module$contents$Blockly$libraryBlocks$logic_CONTROLS_IF_MUTATOR_MIXIN={elseifCount_:0,elseCount_:0,mutationToDom:function(){if(!this.elseifCount_&&!this.elseCount_)return null;const a=$.module$build$src$core$utils$xml.createElement("mutation");this.elseifCount_&&a.setAttribute("elseif",this.elseifCount_);this.elseCount_&&a.setAttribute("else",1);return a},domToMutation:function(a){this.elseifCount_=parseInt(a.getAttribute("elseif"),10)||0;this.elseCount_=parseInt(a.getAttribute("else"),10)||0;
|
||||
this.rebuildShape_()},saveExtraState:function(){if(!this.elseifCount_&&!this.elseCount_)return null;const a=Object.create(null);this.elseifCount_&&(a.elseIfCount=this.elseifCount_);this.elseCount_&&(a.hasElse=!0);return a},loadExtraState:function(a){this.elseifCount_=a.elseIfCount||0;this.elseCount_=a.hasElse?1:0;this.updateShape_()},decompose:function(a){const b=a.newBlock("controls_if_if");b.initSvg();let c=b.nextConnection;for(let d=1;d<=this.elseifCount_;d++){const e=a.newBlock("controls_if_elseif");
|
||||
e.initSvg();c.connect(e.previousConnection);c=e.nextConnection}this.elseCount_&&(a=a.newBlock("controls_if_else"),a.initSvg(),c.connect(a.previousConnection));return b},compose:function(a){a=a.nextConnection.targetBlock();this.elseCount_=this.elseifCount_=0;const b=[null],c=[null];let d=null;for(;a;){if(!a.isInsertionMarker())switch(a.type){case "controls_if_elseif":this.elseifCount_++;b.push(a.valueConnection_);c.push(a.statementConnection_);break;case "controls_if_else":this.elseCount_++;d=a.statementConnection_;
|
||||
break;default:throw TypeError("Unknown block type: "+a.type);}a=a.getNextBlock()}this.updateShape_();this.reconnectChildBlocks_(b,c,d)},saveConnections:function(a){a=a.nextConnection.targetBlock();let b=1;for(;a;){if(!a.isInsertionMarker())switch(a.type){case "controls_if_elseif":var c=this.getInput("IF"+b);const d=this.getInput("DO"+b);a.valueConnection_=c&&c.connection.targetConnection;a.statementConnection_=d&&d.connection.targetConnection;b++;break;case "controls_if_else":c=this.getInput("ELSE");
|
||||
a.statementConnection_=c&&c.connection.targetConnection;break;default:throw TypeError("Unknown block type: "+a.type);}a=a.getNextBlock()}},rebuildShape_:function(){const a=[null],b=[null];let c=null;this.getInput("ELSE")&&(c=this.getInput("ELSE").connection.targetConnection);for(let d=1;this.getInput("IF"+d);d++){const e=this.getInput("IF"+d),f=this.getInput("DO"+d);a.push(e.connection.targetConnection);b.push(f.connection.targetConnection)}this.updateShape_();this.reconnectChildBlocks_(a,b,c)},updateShape_:function(){this.getInput("ELSE")&&
|
||||
this.removeInput("ELSE");for(var a=1;this.getInput("IF"+a);a++)this.removeInput("IF"+a),this.removeInput("DO"+a);for(a=1;a<=this.elseifCount_;a++)this.appendValueInput("IF"+a).setCheck("Boolean").appendField(module$contents$Blockly$libraryBlocks$logic_Msg.CONTROLS_IF_MSG_ELSEIF),this.appendStatementInput("DO"+a).appendField(module$contents$Blockly$libraryBlocks$logic_Msg.CONTROLS_IF_MSG_THEN);this.elseCount_&&this.appendStatementInput("ELSE").appendField(module$contents$Blockly$libraryBlocks$logic_Msg.CONTROLS_IF_MSG_ELSE)},
|
||||
reconnectChildBlocks_:function(a,b,c){for(let d=1;d<=this.elseifCount_;d++)$.Mutator$$module$build$src$core$mutator.reconnect(a[d],this,"IF"+d),$.Mutator$$module$build$src$core$mutator.reconnect(b[d],this,"DO"+d);$.Mutator$$module$build$src$core$mutator.reconnect(c,this,"ELSE")}};$.module$build$src$core$extensions.registerMutator("controls_if_mutator",module$contents$Blockly$libraryBlocks$logic_CONTROLS_IF_MUTATOR_MIXIN,null,["controls_if_elseif","controls_if_else"]);
|
||||
var module$contents$Blockly$libraryBlocks$logic_CONTROLS_IF_TOOLTIP_EXTENSION=function(){this.setTooltip(function(){if(this.elseifCount_||this.elseCount_){if(!this.elseifCount_&&this.elseCount_)return module$contents$Blockly$libraryBlocks$logic_Msg.CONTROLS_IF_TOOLTIP_2;if(this.elseifCount_&&!this.elseCount_)return module$contents$Blockly$libraryBlocks$logic_Msg.CONTROLS_IF_TOOLTIP_3;if(this.elseifCount_&&this.elseCount_)return module$contents$Blockly$libraryBlocks$logic_Msg.CONTROLS_IF_TOOLTIP_4}else return module$contents$Blockly$libraryBlocks$logic_Msg.CONTROLS_IF_TOOLTIP_1;
|
||||
return""}.bind(this))};$.module$build$src$core$extensions.register("controls_if_tooltip",module$contents$Blockly$libraryBlocks$logic_CONTROLS_IF_TOOLTIP_EXTENSION);
|
||||
var module$contents$Blockly$libraryBlocks$logic_LOGIC_COMPARE_ONCHANGE_MIXIN={onchange:function(a){this.prevBlocks_||(this.prevBlocks_=[null,null]);var b=this.getInputTargetBlock("A");const c=this.getInputTargetBlock("B");b&&c&&!this.workspace.connectionChecker.doTypeChecks(b.outputConnection,c.outputConnection)&&($.module$build$src$core$events$events.setGroup(a.group),a=this.prevBlocks_[0],a!==b&&(b.unplug(),!a||a.isDisposed()||a.isShadow()||this.getInput("A").connection.connect(a.outputConnection)),
|
||||
b=this.prevBlocks_[1],b!==c&&(c.unplug(),!b||b.isDisposed()||b.isShadow()||this.getInput("B").connection.connect(b.outputConnection)),this.bumpNeighbours(),$.module$build$src$core$events$events.setGroup(!1));this.prevBlocks_[0]=this.getInputTargetBlock("A");this.prevBlocks_[1]=this.getInputTargetBlock("B")}},module$contents$Blockly$libraryBlocks$logic_LOGIC_COMPARE_EXTENSION=function(){this.mixin(module$contents$Blockly$libraryBlocks$logic_LOGIC_COMPARE_ONCHANGE_MIXIN)};
|
||||
$.module$build$src$core$extensions.register("logic_compare",module$contents$Blockly$libraryBlocks$logic_LOGIC_COMPARE_EXTENSION);
|
||||
var module$contents$Blockly$libraryBlocks$logic_LOGIC_TERNARY_ONCHANGE_MIXIN={prevParentConnection_:null,onchange:function(a){const b=this.getInputTargetBlock("THEN"),c=this.getInputTargetBlock("ELSE"),d=this.outputConnection.targetConnection;if((b||c)&&d)for(let e=0;2>e;e++){const f=1===e?b:c;f&&!f.workspace.connectionChecker.doTypeChecks(f.outputConnection,d)&&($.module$build$src$core$events$events.setGroup(a.group),d===this.prevParentConnection_?(this.unplug(),d.getSourceBlock().bumpNeighbours()):
|
||||
(f.unplug(),f.bumpNeighbours()),$.module$build$src$core$events$events.setGroup(!1))}this.prevParentConnection_=d}};$.module$build$src$core$extensions.registerMixin("logic_ternary",module$contents$Blockly$libraryBlocks$logic_LOGIC_TERNARY_ONCHANGE_MIXIN);module$contents$Blockly$libraryBlocks$logic_defineBlocks(module$exports$Blockly$libraryBlocks$logic.blocks);var module$exports$Blockly$libraryBlocks$lists={},module$contents$Blockly$libraryBlocks$lists_xmlUtils=$.module$build$src$core$utils$xml,module$contents$Blockly$libraryBlocks$lists_Xml=$.module$build$src$core$xml,module$contents$Blockly$libraryBlocks$lists_Align=$.Align$$module$build$src$core$input,module$contents$Blockly$libraryBlocks$lists_BlockDefinition=Object,module$contents$Blockly$libraryBlocks$lists_ConnectionType=$.module$build$src$core$connection_type.ConnectionType,module$contents$Blockly$libraryBlocks$lists_FieldDropdown=
|
||||
$.module$build$src$core$field_dropdown.FieldDropdown,module$contents$Blockly$libraryBlocks$lists_Msg=$.module$build$src$core$msg.Msg,module$contents$Blockly$libraryBlocks$lists_Mutator=$.Mutator$$module$build$src$core$mutator,module$contents$Blockly$libraryBlocks$lists_createBlockDefinitionsFromJsonArray=$.module$build$src$core$common.createBlockDefinitionsFromJsonArray,module$contents$Blockly$libraryBlocks$lists_defineBlocks=$.module$build$src$core$common.defineBlocks;
|
||||
module$exports$Blockly$libraryBlocks$lists.blocks=module$contents$Blockly$libraryBlocks$lists_createBlockDefinitionsFromJsonArray([{type:"lists_create_empty",message0:"%{BKY_LISTS_CREATE_EMPTY_TITLE}",output:"Array",style:"list_blocks",tooltip:"%{BKY_LISTS_CREATE_EMPTY_TOOLTIP}",helpUrl:"%{BKY_LISTS_CREATE_EMPTY_HELPURL}"},{type:"lists_repeat",message0:"%{BKY_LISTS_REPEAT_TITLE}",args0:[{type:"input_value",name:"ITEM"},{type:"input_value",name:"NUM",check:"Number"}],output:"Array",style:"list_blocks",
|
||||
tooltip:"%{BKY_LISTS_REPEAT_TOOLTIP}",helpUrl:"%{BKY_LISTS_REPEAT_HELPURL}"},{type:"lists_reverse",message0:"%{BKY_LISTS_REVERSE_MESSAGE0}",args0:[{type:"input_value",name:"LIST",check:"Array"}],output:"Array",inputsInline:!0,style:"list_blocks",tooltip:"%{BKY_LISTS_REVERSE_TOOLTIP}",helpUrl:"%{BKY_LISTS_REVERSE_HELPURL}"},{type:"lists_isEmpty",message0:"%{BKY_LISTS_ISEMPTY_TITLE}",args0:[{type:"input_value",name:"VALUE",check:["String","Array"]}],output:"Boolean",style:"list_blocks",tooltip:"%{BKY_LISTS_ISEMPTY_TOOLTIP}",
|
||||
helpUrl:"%{BKY_LISTS_ISEMPTY_HELPURL}"},{type:"lists_length",message0:"%{BKY_LISTS_LENGTH_TITLE}",args0:[{type:"input_value",name:"VALUE",check:["String","Array"]}],output:"Number",style:"list_blocks",tooltip:"%{BKY_LISTS_LENGTH_TOOLTIP}",helpUrl:"%{BKY_LISTS_LENGTH_HELPURL}"}]);
|
||||
module$exports$Blockly$libraryBlocks$lists.blocks.lists_create_with={init:function(){this.setHelpUrl(module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_CREATE_WITH_HELPURL);this.setStyle("list_blocks");this.itemCount_=3;this.updateShape_();this.setOutput(!0,"Array");this.setMutator(new $.Mutator$$module$build$src$core$mutator(["lists_create_with_item"],this));this.setTooltip(module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_CREATE_WITH_TOOLTIP)},mutationToDom:function(){const a=$.module$build$src$core$utils$xml.createElement("mutation");
|
||||
a.setAttribute("items",this.itemCount_);return a},domToMutation:function(a){this.itemCount_=parseInt(a.getAttribute("items"),10);this.updateShape_()},saveExtraState:function(){return{itemCount:this.itemCount_}},loadExtraState:function(a){this.itemCount_=a.itemCount;this.updateShape_()},decompose:function(a){const b=a.newBlock("lists_create_with_container");b.initSvg();let c=b.getInput("STACK").connection;for(let d=0;d<this.itemCount_;d++){const e=a.newBlock("lists_create_with_item");e.initSvg();c.connect(e.previousConnection);
|
||||
c=e.nextConnection}return b},compose:function(a){var b=a.getInputTargetBlock("STACK");for(a=[];b;)b.isInsertionMarker()||a.push(b.valueConnection_),b=b.getNextBlock();for(b=0;b<this.itemCount_;b++){const c=this.getInput("ADD"+b).connection.targetConnection;c&&-1===a.indexOf(c)&&c.disconnect()}this.itemCount_=a.length;this.updateShape_();for(b=0;b<this.itemCount_;b++)$.Mutator$$module$build$src$core$mutator.reconnect(a[b],this,"ADD"+b)},saveConnections:function(a){a=a.getInputTargetBlock("STACK");
|
||||
let b=0;for(;a;){if(a.isInsertionMarker()){a=a.getNextBlock();continue}const c=this.getInput("ADD"+b);a.valueConnection_=c&&c.connection.targetConnection;a=a.getNextBlock();b++}},updateShape_:function(){this.itemCount_&&this.getInput("EMPTY")?this.removeInput("EMPTY"):this.itemCount_||this.getInput("EMPTY")||this.appendDummyInput("EMPTY").appendField(module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_CREATE_EMPTY_TITLE);for(var a=0;a<this.itemCount_;a++)if(!this.getInput("ADD"+a)){const b=this.appendValueInput("ADD"+
|
||||
a).setAlign($.Align$$module$build$src$core$input.RIGHT);0===a&&b.appendField(module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_CREATE_WITH_INPUT_WITH)}for(a=this.itemCount_;this.getInput("ADD"+a);a++)this.removeInput("ADD"+a)}};
|
||||
module$exports$Blockly$libraryBlocks$lists.blocks.lists_create_with_container={init:function(){this.setStyle("list_blocks");this.appendDummyInput().appendField(module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_CREATE_WITH_CONTAINER_TITLE_ADD);this.appendStatementInput("STACK");this.setTooltip(module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_CREATE_WITH_CONTAINER_TOOLTIP);this.contextMenu=!1}};
|
||||
module$exports$Blockly$libraryBlocks$lists.blocks.lists_create_with_item={init:function(){this.setStyle("list_blocks");this.appendDummyInput().appendField(module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_CREATE_WITH_ITEM_TITLE);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_CREATE_WITH_ITEM_TOOLTIP);this.contextMenu=!1}};
|
||||
module$exports$Blockly$libraryBlocks$lists.blocks.lists_indexOf={init:function(){const a=[[module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_INDEX_OF_FIRST,"FIRST"],[module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_INDEX_OF_LAST,"LAST"]];this.setHelpUrl(module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_INDEX_OF_HELPURL);this.setStyle("list_blocks");this.setOutput(!0,"Number");this.appendValueInput("VALUE").setCheck("Array").appendField(module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_INDEX_OF_INPUT_IN_LIST);
|
||||
this.appendValueInput("FIND").appendField(new module$contents$Blockly$libraryBlocks$lists_FieldDropdown(a),"END");this.setInputsInline(!0);const b=this;this.setTooltip(function(){return module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_INDEX_OF_TOOLTIP.replace("%1",b.workspace.options.oneBasedIndex?"0":"-1")})}};
|
||||
module$exports$Blockly$libraryBlocks$lists.blocks.lists_getIndex={init:function(){var a=[[module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_GET_INDEX_GET,"GET"],[module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_GET_INDEX_GET_REMOVE,"GET_REMOVE"],[module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_GET_INDEX_REMOVE,"REMOVE"]];this.WHERE_OPTIONS=[[module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_GET_INDEX_FROM_START,"FROM_START"],[module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_GET_INDEX_FROM_END,
|
||||
"FROM_END"],[module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_GET_INDEX_FIRST,"FIRST"],[module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_GET_INDEX_LAST,"LAST"],[module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_GET_INDEX_RANDOM,"RANDOM"]];this.setHelpUrl(module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_GET_INDEX_HELPURL);this.setStyle("list_blocks");a=new module$contents$Blockly$libraryBlocks$lists_FieldDropdown(a,function(c){c="REMOVE"===c;this.getSourceBlock().updateStatement_(c)});
|
||||
this.appendValueInput("VALUE").setCheck("Array").appendField(module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_GET_INDEX_INPUT_IN_LIST);this.appendDummyInput().appendField(a,"MODE").appendField("","SPACE");this.appendDummyInput("AT");module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_GET_INDEX_TAIL&&this.appendDummyInput("TAIL").appendField(module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_GET_INDEX_TAIL);this.setInputsInline(!0);this.setOutput(!0);this.updateAt_(!0);const b=this;this.setTooltip(function(){const c=
|
||||
b.getFieldValue("MODE"),d=b.getFieldValue("WHERE");let e="";switch(c+" "+d){case "GET FROM_START":case "GET FROM_END":e=module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_GET_INDEX_TOOLTIP_GET_FROM;break;case "GET FIRST":e=module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_GET_INDEX_TOOLTIP_GET_FIRST;break;case "GET LAST":e=module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_GET_INDEX_TOOLTIP_GET_LAST;break;case "GET RANDOM":e=module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_GET_INDEX_TOOLTIP_GET_RANDOM;
|
||||
break;case "GET_REMOVE FROM_START":case "GET_REMOVE FROM_END":e=module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FROM;break;case "GET_REMOVE FIRST":e=module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FIRST;break;case "GET_REMOVE LAST":e=module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_LAST;break;case "GET_REMOVE RANDOM":e=module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_RANDOM;
|
||||
break;case "REMOVE FROM_START":case "REMOVE FROM_END":e=module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_FROM;break;case "REMOVE FIRST":e=module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_FIRST;break;case "REMOVE LAST":e=module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_LAST;break;case "REMOVE RANDOM":e=module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_RANDOM}if("FROM_START"===d||"FROM_END"===
|
||||
d)e+=" "+("FROM_START"===d?module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_INDEX_FROM_START_TOOLTIP:module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_INDEX_FROM_END_TOOLTIP).replace("%1",b.workspace.options.oneBasedIndex?"#1":"#0");return e})},mutationToDom:function(){const a=$.module$build$src$core$utils$xml.createElement("mutation");a.setAttribute("statement",!this.outputConnection);const b=this.getInput("AT").type===$.module$build$src$core$connection_type.ConnectionType.INPUT_VALUE;
|
||||
a.setAttribute("at",b);return a},domToMutation:function(a){const b="true"===a.getAttribute("statement");this.updateStatement_(b);a="false"!==a.getAttribute("at");this.updateAt_(a)},saveExtraState:function(){return this.outputConnection?null:{isStatement:!0}},loadExtraState:function(a){a.isStatement?this.updateStatement_(!0):"string"===typeof a&&this.domToMutation($.module$build$src$core$xml.textToDom(a))},updateStatement_:function(a){a!==!this.outputConnection&&(this.unplug(!0,!0),a?(this.setOutput(!1),
|
||||
this.setPreviousStatement(!0),this.setNextStatement(!0)):(this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0)))},updateAt_:function(a){this.removeInput("AT");this.removeInput("ORDINAL",!0);a?(this.appendValueInput("AT").setCheck("Number"),module$contents$Blockly$libraryBlocks$lists_Msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL").appendField(module$contents$Blockly$libraryBlocks$lists_Msg.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT");const b=new module$contents$Blockly$libraryBlocks$lists_FieldDropdown(this.WHERE_OPTIONS,
|
||||
function(c){const d="FROM_START"===c||"FROM_END"===c;if(d!==a){const e=this.getSourceBlock();e.updateAt_(d);e.setFieldValue(c,"WHERE");return null}});this.getInput("AT").appendField(b,"WHERE");module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_GET_INDEX_TAIL&&this.moveInputBefore("TAIL",null)}};
|
||||
module$exports$Blockly$libraryBlocks$lists.blocks.lists_setIndex={init:function(){const a=[[module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_SET_INDEX_SET,"SET"],[module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_SET_INDEX_INSERT,"INSERT"]];this.WHERE_OPTIONS=[[module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_GET_INDEX_FROM_START,"FROM_START"],[module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_GET_INDEX_FROM_END,"FROM_END"],[module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_GET_INDEX_FIRST,
|
||||
"FIRST"],[module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_GET_INDEX_LAST,"LAST"],[module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_GET_INDEX_RANDOM,"RANDOM"]];this.setHelpUrl(module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_SET_INDEX_HELPURL);this.setStyle("list_blocks");this.appendValueInput("LIST").setCheck("Array").appendField(module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_SET_INDEX_INPUT_IN_LIST);this.appendDummyInput().appendField(new module$contents$Blockly$libraryBlocks$lists_FieldDropdown(a),
|
||||
"MODE").appendField("","SPACE");this.appendDummyInput("AT");this.appendValueInput("TO").appendField(module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_SET_INDEX_INPUT_TO);this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_SET_INDEX_TOOLTIP);this.updateAt_(!0);const b=this;this.setTooltip(function(){const c=b.getFieldValue("MODE"),d=b.getFieldValue("WHERE");let e="";switch(c+" "+d){case "SET FROM_START":case "SET FROM_END":e=
|
||||
module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_SET_INDEX_TOOLTIP_SET_FROM;break;case "SET FIRST":e=module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_SET_INDEX_TOOLTIP_SET_FIRST;break;case "SET LAST":e=module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_SET_INDEX_TOOLTIP_SET_LAST;break;case "SET RANDOM":e=module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_SET_INDEX_TOOLTIP_SET_RANDOM;break;case "INSERT FROM_START":case "INSERT FROM_END":e=module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_SET_INDEX_TOOLTIP_INSERT_FROM;
|
||||
break;case "INSERT FIRST":e=module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_SET_INDEX_TOOLTIP_INSERT_FIRST;break;case "INSERT LAST":e=module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_SET_INDEX_TOOLTIP_INSERT_LAST;break;case "INSERT RANDOM":e=module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_SET_INDEX_TOOLTIP_INSERT_RANDOM}if("FROM_START"===d||"FROM_END"===d)e+=" "+module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_INDEX_FROM_START_TOOLTIP.replace("%1",b.workspace.options.oneBasedIndex?
|
||||
"#1":"#0");return e})},mutationToDom:function(){const a=$.module$build$src$core$utils$xml.createElement("mutation"),b=this.getInput("AT").type===$.module$build$src$core$connection_type.ConnectionType.INPUT_VALUE;a.setAttribute("at",b);return a},domToMutation:function(a){a="false"!==a.getAttribute("at");this.updateAt_(a)},saveExtraState:function(){return null},loadExtraState:function(){},updateAt_:function(a){this.removeInput("AT");this.removeInput("ORDINAL",!0);a?(this.appendValueInput("AT").setCheck("Number"),
|
||||
module$contents$Blockly$libraryBlocks$lists_Msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL").appendField(module$contents$Blockly$libraryBlocks$lists_Msg.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT");const b=new module$contents$Blockly$libraryBlocks$lists_FieldDropdown(this.WHERE_OPTIONS,function(c){const d="FROM_START"===c||"FROM_END"===c;if(d!==a){const e=this.getSourceBlock();e.updateAt_(d);e.setFieldValue(c,"WHERE");return null}});this.moveInputBefore("AT","TO");this.getInput("ORDINAL")&&
|
||||
this.moveInputBefore("ORDINAL","TO");this.getInput("AT").appendField(b,"WHERE")}};
|
||||
module$exports$Blockly$libraryBlocks$lists.blocks.lists_getSublist={init:function(){this.WHERE_OPTIONS_1=[[module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_GET_SUBLIST_START_FROM_START,"FROM_START"],[module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_GET_SUBLIST_START_FROM_END,"FROM_END"],[module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_GET_SUBLIST_START_FIRST,"FIRST"]];this.WHERE_OPTIONS_2=[[module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_GET_SUBLIST_END_FROM_START,"FROM_START"],
|
||||
[module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_GET_SUBLIST_END_FROM_END,"FROM_END"],[module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_GET_SUBLIST_END_LAST,"LAST"]];this.setHelpUrl(module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_GET_SUBLIST_HELPURL);this.setStyle("list_blocks");this.appendValueInput("LIST").setCheck("Array").appendField(module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_GET_SUBLIST_INPUT_IN_LIST);this.appendDummyInput("AT1");this.appendDummyInput("AT2");module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_GET_SUBLIST_TAIL&&
|
||||
this.appendDummyInput("TAIL").appendField(module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_GET_SUBLIST_TAIL);this.setInputsInline(!0);this.setOutput(!0,"Array");this.updateAt_(1,!0);this.updateAt_(2,!0);this.setTooltip(module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_GET_SUBLIST_TOOLTIP)},mutationToDom:function(){const a=$.module$build$src$core$utils$xml.createElement("mutation");var b=this.getInput("AT1").type===$.module$build$src$core$connection_type.ConnectionType.INPUT_VALUE;a.setAttribute("at1",
|
||||
b);b=this.getInput("AT2").type===$.module$build$src$core$connection_type.ConnectionType.INPUT_VALUE;a.setAttribute("at2",b);return a},domToMutation:function(a){const b="true"===a.getAttribute("at1");a="true"===a.getAttribute("at2");this.updateAt_(1,b);this.updateAt_(2,a)},saveExtraState:function(){return null},loadExtraState:function(){},updateAt_:function(a,b){this.removeInput("AT"+a);this.removeInput("ORDINAL"+a,!0);b?(this.appendValueInput("AT"+a).setCheck("Number"),module$contents$Blockly$libraryBlocks$lists_Msg.ORDINAL_NUMBER_SUFFIX&&
|
||||
this.appendDummyInput("ORDINAL"+a).appendField(module$contents$Blockly$libraryBlocks$lists_Msg.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT"+a);const c=new module$contents$Blockly$libraryBlocks$lists_FieldDropdown(this["WHERE_OPTIONS_"+a],function(d){const e="FROM_START"===d||"FROM_END"===d;if(e!==b){const f=this.getSourceBlock();f.updateAt_(a,e);f.setFieldValue(d,"WHERE"+a);return null}});this.getInput("AT"+a).appendField(c,"WHERE"+a);1===a&&(this.moveInputBefore("AT1","AT2"),this.getInput("ORDINAL1")&&
|
||||
this.moveInputBefore("ORDINAL1","AT2"));module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_GET_SUBLIST_TAIL&&this.moveInputBefore("TAIL",null)}};
|
||||
module$exports$Blockly$libraryBlocks$lists.blocks.lists_sort={init:function(){this.jsonInit({message0:"%{BKY_LISTS_SORT_TITLE}",args0:[{type:"field_dropdown",name:"TYPE",options:[["%{BKY_LISTS_SORT_TYPE_NUMERIC}","NUMERIC"],["%{BKY_LISTS_SORT_TYPE_TEXT}","TEXT"],["%{BKY_LISTS_SORT_TYPE_IGNORECASE}","IGNORE_CASE"]]},{type:"field_dropdown",name:"DIRECTION",options:[["%{BKY_LISTS_SORT_ORDER_ASCENDING}","1"],["%{BKY_LISTS_SORT_ORDER_DESCENDING}","-1"]]},{type:"input_value",name:"LIST",check:"Array"}],
|
||||
output:"Array",style:"list_blocks",tooltip:"%{BKY_LISTS_SORT_TOOLTIP}",helpUrl:"%{BKY_LISTS_SORT_HELPURL}"})}};
|
||||
module$exports$Blockly$libraryBlocks$lists.blocks.lists_split={init:function(){const a=this,b=new module$contents$Blockly$libraryBlocks$lists_FieldDropdown([[module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_SPLIT_LIST_FROM_TEXT,"SPLIT"],[module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_SPLIT_TEXT_FROM_LIST,"JOIN"]],function(c){a.updateType_(c)});this.setHelpUrl(module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_SPLIT_HELPURL);this.setStyle("list_blocks");this.appendValueInput("INPUT").setCheck("String").appendField(b,
|
||||
"MODE");this.appendValueInput("DELIM").setCheck("String").appendField(module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_SPLIT_WITH_DELIMITER);this.setInputsInline(!0);this.setOutput(!0,"Array");this.setTooltip(function(){const c=a.getFieldValue("MODE");if("SPLIT"===c)return module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_SPLIT_TOOLTIP_SPLIT;if("JOIN"===c)return module$contents$Blockly$libraryBlocks$lists_Msg.LISTS_SPLIT_TOOLTIP_JOIN;throw Error("Unknown mode: "+c);})},updateType_:function(a){if(this.getFieldValue("MODE")!==
|
||||
a){const b=this.getInput("INPUT").connection;b.setShadowDom(null);const c=b.targetBlock();c&&(b.disconnect(),c.isShadow()?c.dispose():this.bumpNeighbours())}"SPLIT"===a?(this.outputConnection.setCheck("Array"),this.getInput("INPUT").setCheck("String")):(this.outputConnection.setCheck("String"),this.getInput("INPUT").setCheck("Array"))},mutationToDom:function(){const a=$.module$build$src$core$utils$xml.createElement("mutation");a.setAttribute("mode",this.getFieldValue("MODE"));return a},domToMutation:function(a){this.updateType_(a.getAttribute("mode"))},
|
||||
saveExtraState:function(){return null},loadExtraState:function(){}};module$contents$Blockly$libraryBlocks$lists_defineBlocks(module$exports$Blockly$libraryBlocks$lists.blocks);var module$exports$Blockly$libraryBlocks$colour={},module$contents$Blockly$libraryBlocks$colour_BlockDefinition=Object,module$contents$Blockly$libraryBlocks$colour_createBlockDefinitionsFromJsonArray=$.module$build$src$core$common.createBlockDefinitionsFromJsonArray,module$contents$Blockly$libraryBlocks$colour_defineBlocks=$.module$build$src$core$common.defineBlocks;
|
||||
module$exports$Blockly$libraryBlocks$colour.blocks=module$contents$Blockly$libraryBlocks$colour_createBlockDefinitionsFromJsonArray([{type:"colour_picker",message0:"%1",args0:[{type:"field_colour",name:"COLOUR",colour:"#ff0000"}],output:"Colour",helpUrl:"%{BKY_COLOUR_PICKER_HELPURL}",style:"colour_blocks",tooltip:"%{BKY_COLOUR_PICKER_TOOLTIP}",extensions:["parent_tooltip_when_inline"]},{type:"colour_random",message0:"%{BKY_COLOUR_RANDOM_TITLE}",output:"Colour",helpUrl:"%{BKY_COLOUR_RANDOM_HELPURL}",
|
||||
style:"colour_blocks",tooltip:"%{BKY_COLOUR_RANDOM_TOOLTIP}"},{type:"colour_rgb",message0:"%{BKY_COLOUR_RGB_TITLE} %{BKY_COLOUR_RGB_RED} %1 %{BKY_COLOUR_RGB_GREEN} %2 %{BKY_COLOUR_RGB_BLUE} %3",args0:[{type:"input_value",name:"RED",check:"Number",align:"RIGHT"},{type:"input_value",name:"GREEN",check:"Number",align:"RIGHT"},{type:"input_value",name:"BLUE",check:"Number",align:"RIGHT"}],output:"Colour",helpUrl:"%{BKY_COLOUR_RGB_HELPURL}",style:"colour_blocks",tooltip:"%{BKY_COLOUR_RGB_TOOLTIP}"},{type:"colour_blend",
|
||||
message0:"%{BKY_COLOUR_BLEND_TITLE} %{BKY_COLOUR_BLEND_COLOUR1} %1 %{BKY_COLOUR_BLEND_COLOUR2} %2 %{BKY_COLOUR_BLEND_RATIO} %3",args0:[{type:"input_value",name:"COLOUR1",check:"Colour",align:"RIGHT"},{type:"input_value",name:"COLOUR2",check:"Colour",align:"RIGHT"},{type:"input_value",name:"RATIO",check:"Number",align:"RIGHT"}],output:"Colour",helpUrl:"%{BKY_COLOUR_BLEND_HELPURL}",style:"colour_blocks",tooltip:"%{BKY_COLOUR_BLEND_TOOLTIP}"}]);module$contents$Blockly$libraryBlocks$colour_defineBlocks(module$exports$Blockly$libraryBlocks$colour.blocks);var module$exports$Blockly$libraryBlocks={},module$contents$Blockly$libraryBlocks_BlockDefinition=Object;module$exports$Blockly$libraryBlocks.colour=module$exports$Blockly$libraryBlocks$colour;module$exports$Blockly$libraryBlocks.lists=module$exports$Blockly$libraryBlocks$lists;module$exports$Blockly$libraryBlocks.logic=module$exports$Blockly$libraryBlocks$logic;module$exports$Blockly$libraryBlocks.loops=module$exports$Blockly$libraryBlocks$loops;module$exports$Blockly$libraryBlocks.math=module$exports$Blockly$libraryBlocks$math;
|
||||
module$exports$Blockly$libraryBlocks.procedures=module$exports$Blockly$libraryBlocks$procedures;module$exports$Blockly$libraryBlocks.texts=module$exports$Blockly$libraryBlocks$texts;module$exports$Blockly$libraryBlocks.variables=module$exports$Blockly$libraryBlocks$variables;module$exports$Blockly$libraryBlocks.variablesDynamic=module$exports$Blockly$libraryBlocks$variablesDynamic;
|
||||
module$exports$Blockly$libraryBlocks.blocks=Object.assign({},module$exports$Blockly$libraryBlocks$colour.blocks,module$exports$Blockly$libraryBlocks$lists.blocks,module$exports$Blockly$libraryBlocks$logic.blocks,module$exports$Blockly$libraryBlocks$loops.blocks,module$exports$Blockly$libraryBlocks$math.blocks,module$exports$Blockly$libraryBlocks$procedures.blocks,module$exports$Blockly$libraryBlocks$variables.blocks,module$exports$Blockly$libraryBlocks$variablesDynamic.blocks);
|
||||
module$exports$Blockly$libraryBlocks.__namespace__=$;
|
||||
return module$exports$Blockly$libraryBlocks;
|
||||
}));
|
||||
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
+387
-99
@@ -8,109 +8,397 @@
|
||||
module.exports = factory(require("./blockly_compressed.js"));
|
||||
} else { // Browser
|
||||
var factoryExports = factory(root.Blockly);
|
||||
root.Blockly.Dart = factoryExports;
|
||||
root.Blockly.Dart = factoryExports.dartGenerator;
|
||||
root.Blockly.Dart.__namespace__ = factoryExports.__namespace__;
|
||||
}
|
||||
}(this, function(__parent__) {
|
||||
var $=__parent__.__namespace__;
|
||||
var module$contents$Blockly$Dart_Dart=new $.module$exports$Blockly$Generator.Generator("Dart");module$contents$Blockly$Dart_Dart.addReservedWords("assert,break,case,catch,class,const,continue,default,do,else,enum,extends,false,final,finally,for,if,in,is,new,null,rethrow,return,super,switch,this,throw,true,try,var,void,while,with,print,identityHashCode,identical,BidirectionalIterator,Comparable,double,Function,int,Invocation,Iterable,Iterator,List,Map,Match,num,Pattern,RegExp,Set,StackTrace,String,StringSink,Type,bool,DateTime,Deprecated,Duration,Expando,Null,Object,RuneIterator,Runes,Stopwatch,StringBuffer,Symbol,Uri,Comparator,AbstractClassInstantiationError,ArgumentError,AssertionError,CastError,ConcurrentModificationError,CyclicInitializationError,Error,Exception,FallThroughError,FormatException,IntegerDivisionByZeroException,NoSuchMethodError,NullThrownError,OutOfMemoryError,RangeError,StackOverflowError,StateError,TypeError,UnimplementedError,UnsupportedError");
|
||||
module$contents$Blockly$Dart_Dart.ORDER_ATOMIC=0;module$contents$Blockly$Dart_Dart.ORDER_UNARY_POSTFIX=1;module$contents$Blockly$Dart_Dart.ORDER_UNARY_PREFIX=2;module$contents$Blockly$Dart_Dart.ORDER_MULTIPLICATIVE=3;module$contents$Blockly$Dart_Dart.ORDER_ADDITIVE=4;module$contents$Blockly$Dart_Dart.ORDER_SHIFT=5;module$contents$Blockly$Dart_Dart.ORDER_BITWISE_AND=6;module$contents$Blockly$Dart_Dart.ORDER_BITWISE_XOR=7;module$contents$Blockly$Dart_Dart.ORDER_BITWISE_OR=8;
|
||||
module$contents$Blockly$Dart_Dart.ORDER_RELATIONAL=9;module$contents$Blockly$Dart_Dart.ORDER_EQUALITY=10;module$contents$Blockly$Dart_Dart.ORDER_LOGICAL_AND=11;module$contents$Blockly$Dart_Dart.ORDER_LOGICAL_OR=12;module$contents$Blockly$Dart_Dart.ORDER_IF_NULL=13;module$contents$Blockly$Dart_Dart.ORDER_CONDITIONAL=14;module$contents$Blockly$Dart_Dart.ORDER_CASCADE=15;module$contents$Blockly$Dart_Dart.ORDER_ASSIGNMENT=16;module$contents$Blockly$Dart_Dart.ORDER_NONE=99;
|
||||
module$contents$Blockly$Dart_Dart.isInitialized=!1;
|
||||
module$contents$Blockly$Dart_Dart.init=function(a){Object.getPrototypeOf(this).init.call(this);this.nameDB_?this.nameDB_.reset():this.nameDB_=new $.module$exports$Blockly$Names.Names(this.RESERVED_WORDS_);this.nameDB_.setVariableMap(a.getVariableMap());this.nameDB_.populateVariables(a);this.nameDB_.populateProcedures(a);for(var b=[],c=(0,$.module$exports$Blockly$Variables.allDeveloperVariables)(a),d=0;d<c.length;d++)b.push(this.nameDB_.getName(c[d],$.module$exports$Blockly$Names.NameType.DEVELOPER_VARIABLE));
|
||||
a=(0,$.module$exports$Blockly$Variables.allUsedVarModels)(a);for(c=0;c<a.length;c++)b.push(this.nameDB_.getName(a[c].getId(),$.module$exports$Blockly$Names.NameType.VARIABLE));b.length&&(this.definitions_.variables="var "+b.join(", ")+";");this.isInitialized=!0};
|
||||
module$contents$Blockly$Dart_Dart.finish=function(a){a&&(a=this.prefixLines(a,this.INDENT));a="main() {\n"+a+"}";var b=[],c=[],d;for(d in this.definitions_){var e=this.definitions_[d];e.match(/^import\s/)?b.push(e):c.push(e)}a=Object.getPrototypeOf(this).finish.call(this,a);this.isInitialized=!1;this.nameDB_.reset();return(b.join("\n")+"\n\n"+c.join("\n\n")).replace(/\n\n+/g,"\n\n").replace(/\n*$/,"\n\n\n")+a};module$contents$Blockly$Dart_Dart.scrubNakedValue=function(a){return a+";\n"};
|
||||
module$contents$Blockly$Dart_Dart.quote_=function(a){a=a.replace(/\\/g,"\\\\").replace(/\n/g,"\\\n").replace(/\$/g,"\\$").replace(/'/g,"\\'");return"'"+a+"'"};module$contents$Blockly$Dart_Dart.multiline_quote_=function(a){return a.split(/\n/g).map(this.quote_).join(" + '\\n' + \n")};
|
||||
module$contents$Blockly$Dart_Dart.scrub_=function(a,b,c){var d="";if(!a.outputConnection||!a.outputConnection.targetConnection){var e=a.getCommentText();e&&(e=(0,$.module$exports$Blockly$utils$string.wrap)(e,this.COMMENT_WRAP-3),d=a.getProcedureDef?d+this.prefixLines(e+"\n","/// "):d+this.prefixLines(e+"\n","// "));for(var f=0;f<a.inputList.length;f++)a.inputList[f].type===$.module$exports$Blockly$inputTypes.inputTypes.VALUE&&(e=a.inputList[f].connection.targetBlock())&&(e=this.allNestedComments(e))&&
|
||||
var module$exports$Blockly$Dart={},module$contents$Blockly$Dart_Variables=$.module$build$src$core$variables,module$contents$Blockly$Dart_stringUtils=$.module$build$src$core$utils$string,module$contents$Blockly$Dart_Generator=$.Generator$$module$build$src$core$generator,module$contents$Blockly$Dart_Names=$.module$build$src$core$names.Names,module$contents$Blockly$Dart_NameType=$.NameType$$module$build$src$core$names,module$contents$Blockly$Dart_inputTypes=$.module$build$src$core$input_types.inputTypes;
|
||||
module$exports$Blockly$Dart.dartGenerator=new $.Generator$$module$build$src$core$generator("Dart");module$exports$Blockly$Dart.dartGenerator.addReservedWords("assert,break,case,catch,class,const,continue,default,do,else,enum,extends,false,final,finally,for,if,in,is,new,null,rethrow,return,super,switch,this,throw,true,try,var,void,while,with,print,identityHashCode,identical,BidirectionalIterator,Comparable,double,Function,int,Invocation,Iterable,Iterator,List,Map,Match,num,Pattern,RegExp,Set,StackTrace,String,StringSink,Type,bool,DateTime,Deprecated,Duration,Expando,Null,Object,RuneIterator,Runes,Stopwatch,StringBuffer,Symbol,Uri,Comparator,AbstractClassInstantiationError,ArgumentError,AssertionError,CastError,ConcurrentModificationError,CyclicInitializationError,Error,Exception,FallThroughError,FormatException,IntegerDivisionByZeroException,NoSuchMethodError,NullThrownError,OutOfMemoryError,RangeError,StackOverflowError,StateError,TypeError,UnimplementedError,UnsupportedError");
|
||||
module$exports$Blockly$Dart.dartGenerator.ORDER_ATOMIC=0;module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX=1;module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_PREFIX=2;module$exports$Blockly$Dart.dartGenerator.ORDER_MULTIPLICATIVE=3;module$exports$Blockly$Dart.dartGenerator.ORDER_ADDITIVE=4;module$exports$Blockly$Dart.dartGenerator.ORDER_SHIFT=5;module$exports$Blockly$Dart.dartGenerator.ORDER_BITWISE_AND=6;module$exports$Blockly$Dart.dartGenerator.ORDER_BITWISE_XOR=7;
|
||||
module$exports$Blockly$Dart.dartGenerator.ORDER_BITWISE_OR=8;module$exports$Blockly$Dart.dartGenerator.ORDER_RELATIONAL=9;module$exports$Blockly$Dart.dartGenerator.ORDER_EQUALITY=10;module$exports$Blockly$Dart.dartGenerator.ORDER_LOGICAL_AND=11;module$exports$Blockly$Dart.dartGenerator.ORDER_LOGICAL_OR=12;module$exports$Blockly$Dart.dartGenerator.ORDER_IF_NULL=13;module$exports$Blockly$Dart.dartGenerator.ORDER_CONDITIONAL=14;module$exports$Blockly$Dart.dartGenerator.ORDER_CASCADE=15;
|
||||
module$exports$Blockly$Dart.dartGenerator.ORDER_ASSIGNMENT=16;module$exports$Blockly$Dart.dartGenerator.ORDER_NONE=99;module$exports$Blockly$Dart.dartGenerator.isInitialized=!1;
|
||||
module$exports$Blockly$Dart.dartGenerator.init=function(a){Object.getPrototypeOf(this).init.call(this);this.nameDB_?this.nameDB_.reset():this.nameDB_=new $.module$build$src$core$names.Names(this.RESERVED_WORDS_);this.nameDB_.setVariableMap(a.getVariableMap());this.nameDB_.populateVariables(a);this.nameDB_.populateProcedures(a);const b=[];var c=$.module$build$src$core$variables.allDeveloperVariables(a);for(let d=0;d<c.length;d++)b.push(this.nameDB_.getName(c[d],$.NameType$$module$build$src$core$names.DEVELOPER_VARIABLE));
|
||||
a=$.module$build$src$core$variables.allUsedVarModels(a);for(c=0;c<a.length;c++)b.push(this.nameDB_.getName(a[c].getId(),$.NameType$$module$build$src$core$names.VARIABLE));b.length&&(this.definitions_.variables="var "+b.join(", ")+";");this.isInitialized=!0};
|
||||
module$exports$Blockly$Dart.dartGenerator.finish=function(a){a&&(a=this.prefixLines(a,this.INDENT));a="main() {\n"+a+"}";const b=[],c=[];for(let d in this.definitions_){const e=this.definitions_[d];e.match(/^import\s/)?b.push(e):c.push(e)}a=Object.getPrototypeOf(this).finish.call(this,a);this.isInitialized=!1;this.nameDB_.reset();return(b.join("\n")+"\n\n"+c.join("\n\n")).replace(/\n\n+/g,"\n\n").replace(/\n*$/,"\n\n\n")+a};
|
||||
module$exports$Blockly$Dart.dartGenerator.scrubNakedValue=function(a){return a+";\n"};module$exports$Blockly$Dart.dartGenerator.quote_=function(a){a=a.replace(/\\/g,"\\\\").replace(/\n/g,"\\\n").replace(/\$/g,"\\$").replace(/'/g,"\\'");return"'"+a+"'"};module$exports$Blockly$Dart.dartGenerator.multiline_quote_=function(a){return a.split(/\n/g).map(this.quote_).join(" + '\\n' + \n")};
|
||||
module$exports$Blockly$Dart.dartGenerator.scrub_=function(a,b,c){let d="";if(!a.outputConnection||!a.outputConnection.targetConnection){var e=a.getCommentText();e&&(e=$.module$build$src$core$utils$string.wrap(e,this.COMMENT_WRAP-3),d=a.getProcedureDef?d+this.prefixLines(e+"\n","/// "):d+this.prefixLines(e+"\n","// "));for(let f=0;f<a.inputList.length;f++)a.inputList[f].type===$.module$build$src$core$input_types.inputTypes.VALUE&&(e=a.inputList[f].connection.targetBlock())&&(e=this.allNestedComments(e))&&
|
||||
(d+=this.prefixLines(e,"// "))}a=a.nextConnection&&a.nextConnection.targetBlock();c=c?"":this.blockToCode(a);return d+b+c};
|
||||
module$contents$Blockly$Dart_Dart.getAdjusted=function(a,b,c,d,e){c=c||0;e=e||this.ORDER_NONE;a.workspace.options.oneBasedIndex&&c--;var f=a.workspace.options.oneBasedIndex?"1":"0",g;if(c)var h=g=this.ORDER_ADDITIVE;else d?h=g=this.ORDER_UNARY_PREFIX:g=e;a=this.valueToCode(a,b,g)||f;(0,$.module$exports$Blockly$utils$string.isNumber)(a)?(a=parseInt(a,10)+c,d&&(a=-a)):(0<c?a=a+" + "+c:0>c&&(a=a+" - "+-c),d&&(a=c?"-("+a+")":"-"+a),h=Math.floor(h),e=Math.floor(e),h&&e>=h&&(a="("+a+")"));return a};
|
||||
$.Blockly.Dart=module$contents$Blockly$Dart_Dart;var module$exports$Blockly$Dart$variables={};$.Blockly.Dart.variables_get=function(a){return[$.Blockly.Dart.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE),$.Blockly.Dart.ORDER_ATOMIC]};$.Blockly.Dart.variables_set=function(a){var b=$.Blockly.Dart.valueToCode(a,"VALUE",$.Blockly.Dart.ORDER_ASSIGNMENT)||"0";return $.Blockly.Dart.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE)+" = "+b+";\n"};var module$exports$Blockly$Dart$variablesDynamic={};$.Blockly.Dart.variables_get_dynamic=$.Blockly.Dart.variables_get;$.Blockly.Dart.variables_set_dynamic=$.Blockly.Dart.variables_set;var module$exports$Blockly$Dart$texts={};$.Blockly.Dart.addReservedWords("Html,Math");$.Blockly.Dart.text=function(a){return[$.Blockly.Dart.quote_(a.getFieldValue("TEXT")),$.Blockly.Dart.ORDER_ATOMIC]};$.Blockly.Dart.text_multiline=function(a){a=$.Blockly.Dart.multiline_quote_(a.getFieldValue("TEXT"));var b=-1!==a.indexOf("+")?$.Blockly.Dart.ORDER_ADDITIVE:$.Blockly.Dart.ORDER_ATOMIC;return[a,b]};
|
||||
$.Blockly.Dart.text_join=function(a){switch(a.itemCount_){case 0:return["''",$.Blockly.Dart.ORDER_ATOMIC];case 1:return[($.Blockly.Dart.valueToCode(a,"ADD0",$.Blockly.Dart.ORDER_UNARY_POSTFIX)||"''")+".toString()",$.Blockly.Dart.ORDER_UNARY_POSTFIX];default:for(var b=Array(a.itemCount_),c=0;c<a.itemCount_;c++)b[c]=$.Blockly.Dart.valueToCode(a,"ADD"+c,$.Blockly.Dart.ORDER_NONE)||"''";return["["+b.join(",")+"].join()",$.Blockly.Dart.ORDER_UNARY_POSTFIX]}};
|
||||
$.Blockly.Dart.text_append=function(a){var b=$.Blockly.Dart.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE);a=$.Blockly.Dart.valueToCode(a,"TEXT",$.Blockly.Dart.ORDER_NONE)||"''";return b+" = ["+b+", "+a+"].join();\n"};$.Blockly.Dart.text_length=function(a){return[($.Blockly.Dart.valueToCode(a,"VALUE",$.Blockly.Dart.ORDER_UNARY_POSTFIX)||"''")+".length",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
|
||||
$.Blockly.Dart.text_isEmpty=function(a){return[($.Blockly.Dart.valueToCode(a,"VALUE",$.Blockly.Dart.ORDER_UNARY_POSTFIX)||"''")+".isEmpty",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
|
||||
$.Blockly.Dart.text_indexOf=function(a){var b="FIRST"===a.getFieldValue("END")?"indexOf":"lastIndexOf",c=$.Blockly.Dart.valueToCode(a,"FIND",$.Blockly.Dart.ORDER_NONE)||"''";b=($.Blockly.Dart.valueToCode(a,"VALUE",$.Blockly.Dart.ORDER_UNARY_POSTFIX)||"''")+"."+b+"("+c+")";return a.workspace.options.oneBasedIndex?[b+" + 1",$.Blockly.Dart.ORDER_ADDITIVE]:[b,$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
|
||||
$.Blockly.Dart.text_charAt=function(a){var b=a.getFieldValue("WHERE")||"FROM_START",c=$.Blockly.Dart.valueToCode(a,"VALUE","FIRST"===b||"FROM_START"===b?$.Blockly.Dart.ORDER_UNARY_POSTFIX:$.Blockly.Dart.ORDER_NONE)||"''";switch(b){case "FIRST":return[c+"[0]",$.Blockly.Dart.ORDER_UNARY_POSTFIX];case "FROM_START":return a=$.Blockly.Dart.getAdjusted(a,"AT"),[c+"["+a+"]",$.Blockly.Dart.ORDER_UNARY_POSTFIX];case "LAST":case "FROM_END":return a=$.Blockly.Dart.getAdjusted(a,"AT",1),[$.Blockly.Dart.provideFunction_("text_get_from_end",
|
||||
"\nString "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(String text, num x) {\n return text[text.length - x];\n}\n")+"("+c+", "+a+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX];case "RANDOM":return $.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;",[$.Blockly.Dart.provideFunction_("text_random_letter","\nString "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(String text) {\n int x = new Math.Random().nextInt(text.length);\n return text[x];\n}\n")+"("+c+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX]}throw Error("Unhandled option (text_charAt).");
|
||||
};
|
||||
$.Blockly.Dart.text_getSubstring=function(a){var b=a.getFieldValue("WHERE1"),c=a.getFieldValue("WHERE2"),d="FROM_END"!==b&&"FROM_START"===c,e=$.Blockly.Dart.valueToCode(a,"STRING",d?$.Blockly.Dart.ORDER_UNARY_POSTFIX:$.Blockly.Dart.ORDER_NONE)||"''";if("FIRST"===b&&"LAST"===c)return[e,$.Blockly.Dart.ORDER_NONE];if(e.match(/^'?\w+'?$/)||d){switch(b){case "FROM_START":b=$.Blockly.Dart.getAdjusted(a,"AT1");break;case "FROM_END":b=$.Blockly.Dart.getAdjusted(a,"AT1",1,!1,$.Blockly.Dart.ORDER_ADDITIVE);b=
|
||||
e+".length - "+b;break;case "FIRST":b="0";break;default:throw Error("Unhandled option (text_getSubstring).");}switch(c){case "FROM_START":var f=$.Blockly.Dart.getAdjusted(a,"AT2",1);break;case "FROM_END":f=$.Blockly.Dart.getAdjusted(a,"AT2",0,!1,$.Blockly.Dart.ORDER_ADDITIVE);f=e+".length - "+f;break;case "LAST":break;default:throw Error("Unhandled option (text_getSubstring).");}c="LAST"===c?e+".substring("+b+")":e+".substring("+b+", "+f+")"}else f=$.Blockly.Dart.getAdjusted(a,"AT1"),a=$.Blockly.Dart.getAdjusted(a,
|
||||
"AT2"),c=$.Blockly.Dart.provideFunction_("text_get_substring","\nString "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(String text, String where1, num at1, String where2, num at2) {\n int getAt(String where, num at) {\n if (where == 'FROM_END') {\n at = text.length - 1 - at;\n } else if (where == 'FIRST') {\n at = 0;\n } else if (where == 'LAST') {\n at = text.length - 1;\n } else if (where != 'FROM_START') {\n throw 'Unhandled option (text_getSubstring).';\n }\n return at;\n }\n at1 = getAt(where1, at1);\n at2 = getAt(where2, at2) + 1;\n return text.substring(at1, at2);\n}\n")+
|
||||
"("+e+", '"+b+"', "+f+", '"+c+"', "+a+")";return[c,$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
|
||||
$.Blockly.Dart.text_changeCase=function(a){var b={UPPERCASE:".toUpperCase()",LOWERCASE:".toLowerCase()",TITLECASE:null}[a.getFieldValue("CASE")];a=$.Blockly.Dart.valueToCode(a,"TEXT",b?$.Blockly.Dart.ORDER_UNARY_POSTFIX:$.Blockly.Dart.ORDER_NONE)||"''";return[b?a+b:$.Blockly.Dart.provideFunction_("text_toTitleCase","\nString "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(String str) {\n RegExp exp = new RegExp(r'\\b');\n List<String> list = str.split(exp);\n final title = new StringBuffer();\n for (String part in list) {\n if (part.length > 0) {\n title.write(part[0].toUpperCase());\n if (part.length > 0) {\n title.write(part.substring(1).toLowerCase());\n }\n }\n }\n return title.toString();\n}\n")+"("+
|
||||
a+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};$.Blockly.Dart.text_trim=function(a){var b={LEFT:".replaceFirst(new RegExp(r'^\\s+'), '')",RIGHT:".replaceFirst(new RegExp(r'\\s+$'), '')",BOTH:".trim()"}[a.getFieldValue("MODE")];return[($.Blockly.Dart.valueToCode(a,"TEXT",$.Blockly.Dart.ORDER_UNARY_POSTFIX)||"''")+b,$.Blockly.Dart.ORDER_UNARY_POSTFIX]};$.Blockly.Dart.text_print=function(a){return"print("+($.Blockly.Dart.valueToCode(a,"TEXT",$.Blockly.Dart.ORDER_NONE)||"''")+");\n"};
|
||||
$.Blockly.Dart.text_prompt_ext=function(a){$.Blockly.Dart.definitions_.import_dart_html="import 'dart:html' as Html;";var b="Html.window.prompt("+(a.getField("TEXT")?$.Blockly.Dart.quote_(a.getFieldValue("TEXT")):$.Blockly.Dart.valueToCode(a,"TEXT",$.Blockly.Dart.ORDER_NONE)||"''")+", '')";"NUMBER"===a.getFieldValue("TYPE")&&($.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;",b="Math.parseDouble("+b+")");return[b,$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
|
||||
$.Blockly.Dart.text_prompt=$.Blockly.Dart.text_prompt_ext;
|
||||
$.Blockly.Dart.text_count=function(a){var b=$.Blockly.Dart.valueToCode(a,"TEXT",$.Blockly.Dart.ORDER_NONE)||"''";a=$.Blockly.Dart.valueToCode(a,"SUB",$.Blockly.Dart.ORDER_NONE)||"''";return[$.Blockly.Dart.provideFunction_("text_count","\nint "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(String haystack, String needle) {\n if (needle.length == 0) {\n return haystack.length + 1;\n }\n int index = 0;\n int count = 0;\n while (index != -1) {\n index = haystack.indexOf(needle, index);\n if (index != -1) {\n count++;\n index += needle.length;\n }\n }\n return count;\n}\n")+"("+
|
||||
b+", "+a+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};$.Blockly.Dart.text_replace=function(a){var b=$.Blockly.Dart.valueToCode(a,"TEXT",$.Blockly.Dart.ORDER_UNARY_POSTFIX)||"''",c=$.Blockly.Dart.valueToCode(a,"FROM",$.Blockly.Dart.ORDER_NONE)||"''";a=$.Blockly.Dart.valueToCode(a,"TO",$.Blockly.Dart.ORDER_NONE)||"''";return[b+".replaceAll("+c+", "+a+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
|
||||
$.Blockly.Dart.text_reverse=function(a){return["new String.fromCharCodes("+($.Blockly.Dart.valueToCode(a,"TEXT",$.Blockly.Dart.ORDER_UNARY_POSTFIX)||"''")+".runes.toList().reversed)",$.Blockly.Dart.ORDER_UNARY_PREFIX]};var module$exports$Blockly$Dart$procedures={};
|
||||
$.Blockly.Dart.procedures_defreturn=function(a){var b=$.Blockly.Dart.nameDB_.getName(a.getFieldValue("NAME"),$.module$exports$Blockly$Names.NameType.PROCEDURE),c="";$.Blockly.Dart.STATEMENT_PREFIX&&(c+=$.Blockly.Dart.injectId($.Blockly.Dart.STATEMENT_PREFIX,a));$.Blockly.Dart.STATEMENT_SUFFIX&&(c+=$.Blockly.Dart.injectId($.Blockly.Dart.STATEMENT_SUFFIX,a));c&&(c=$.Blockly.Dart.prefixLines(c,$.Blockly.Dart.INDENT));var d="";$.Blockly.Dart.INFINITE_LOOP_TRAP&&(d=$.Blockly.Dart.prefixLines($.Blockly.Dart.injectId($.Blockly.Dart.INFINITE_LOOP_TRAP,
|
||||
a),$.Blockly.Dart.INDENT));var e=$.Blockly.Dart.statementToCode(a,"STACK"),f=$.Blockly.Dart.valueToCode(a,"RETURN",$.Blockly.Dart.ORDER_NONE)||"",g="";e&&f&&(g=c);f&&(f=$.Blockly.Dart.INDENT+"return "+f+";\n");for(var h=f?"dynamic":"void",k=[],l=a.getVars(),m=0;m<l.length;m++)k[m]=$.Blockly.Dart.nameDB_.getName(l[m],$.module$exports$Blockly$Names.NameType.VARIABLE);c=h+" "+b+"("+k.join(", ")+") {\n"+c+d+e+g+f+"}";c=$.Blockly.Dart.scrub_(a,c);$.Blockly.Dart.definitions_["%"+b]=c;return null};
|
||||
$.Blockly.Dart.procedures_defnoreturn=$.Blockly.Dart.procedures_defreturn;$.Blockly.Dart.procedures_callreturn=function(a){for(var b=$.Blockly.Dart.nameDB_.getName(a.getFieldValue("NAME"),$.module$exports$Blockly$Names.NameType.PROCEDURE),c=[],d=a.getVars(),e=0;e<d.length;e++)c[e]=$.Blockly.Dart.valueToCode(a,"ARG"+e,$.Blockly.Dart.ORDER_NONE)||"null";return[b+"("+c.join(", ")+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
|
||||
$.Blockly.Dart.procedures_callnoreturn=function(a){return $.Blockly.Dart.procedures_callreturn(a)[0]+";\n"};
|
||||
$.Blockly.Dart.procedures_ifreturn=function(a){var b="if ("+($.Blockly.Dart.valueToCode(a,"CONDITION",$.Blockly.Dart.ORDER_NONE)||"false")+") {\n";$.Blockly.Dart.STATEMENT_SUFFIX&&(b+=$.Blockly.Dart.prefixLines($.Blockly.Dart.injectId($.Blockly.Dart.STATEMENT_SUFFIX,a),$.Blockly.Dart.INDENT));a.hasReturnValue_?(a=$.Blockly.Dart.valueToCode(a,"VALUE",$.Blockly.Dart.ORDER_NONE)||"null",b+=$.Blockly.Dart.INDENT+"return "+a+";\n"):b+=$.Blockly.Dart.INDENT+"return;\n";return b+"}\n"};var module$exports$Blockly$Dart$math={};$.Blockly.Dart.addReservedWords("Math");$.Blockly.Dart.math_number=function(a){a=Number(a.getFieldValue("NUM"));if(Infinity===a){a="double.infinity";var b=$.Blockly.Dart.ORDER_UNARY_POSTFIX}else-Infinity===a?(a="-double.infinity",b=$.Blockly.Dart.ORDER_UNARY_PREFIX):b=0>a?$.Blockly.Dart.ORDER_UNARY_PREFIX:$.Blockly.Dart.ORDER_ATOMIC;return[a,b]};
|
||||
$.Blockly.Dart.math_arithmetic=function(a){var b={ADD:[" + ",$.Blockly.Dart.ORDER_ADDITIVE],MINUS:[" - ",$.Blockly.Dart.ORDER_ADDITIVE],MULTIPLY:[" * ",$.Blockly.Dart.ORDER_MULTIPLICATIVE],DIVIDE:[" / ",$.Blockly.Dart.ORDER_MULTIPLICATIVE],POWER:[null,$.Blockly.Dart.ORDER_NONE]}[a.getFieldValue("OP")],c=b[0];b=b[1];var d=$.Blockly.Dart.valueToCode(a,"A",b)||"0";a=$.Blockly.Dart.valueToCode(a,"B",b)||"0";return c?[d+c+a,b]:($.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;",
|
||||
["Math.pow("+d+", "+a+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX])};
|
||||
$.Blockly.Dart.math_single=function(a){var b=a.getFieldValue("OP");if("NEG"===b)return a=$.Blockly.Dart.valueToCode(a,"NUM",$.Blockly.Dart.ORDER_UNARY_PREFIX)||"0","-"===a[0]&&(a=" "+a),["-"+a,$.Blockly.Dart.ORDER_UNARY_PREFIX];$.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";a="ABS"===b||"ROUND"===b.substring(0,5)?$.Blockly.Dart.valueToCode(a,"NUM",$.Blockly.Dart.ORDER_UNARY_POSTFIX)||"0":"SIN"===b||"COS"===b||"TAN"===b?$.Blockly.Dart.valueToCode(a,"NUM",$.Blockly.Dart.ORDER_MULTIPLICATIVE)||
|
||||
"0":$.Blockly.Dart.valueToCode(a,"NUM",$.Blockly.Dart.ORDER_NONE)||"0";switch(b){case "ABS":var c=a+".abs()";break;case "ROOT":c="Math.sqrt("+a+")";break;case "LN":c="Math.log("+a+")";break;case "EXP":c="Math.exp("+a+")";break;case "POW10":c="Math.pow(10,"+a+")";break;case "ROUND":c=a+".round()";break;case "ROUNDUP":c=a+".ceil()";break;case "ROUNDDOWN":c=a+".floor()";break;case "SIN":c="Math.sin("+a+" / 180 * Math.pi)";break;case "COS":c="Math.cos("+a+" / 180 * Math.pi)";break;case "TAN":c="Math.tan("+
|
||||
a+" / 180 * Math.pi)"}if(c)return[c,$.Blockly.Dart.ORDER_UNARY_POSTFIX];switch(b){case "LOG10":c="Math.log("+a+") / Math.log(10)";break;case "ASIN":c="Math.asin("+a+") / Math.pi * 180";break;case "ACOS":c="Math.acos("+a+") / Math.pi * 180";break;case "ATAN":c="Math.atan("+a+") / Math.pi * 180";break;default:throw Error("Unknown math operator: "+b);}return[c,$.Blockly.Dart.ORDER_MULTIPLICATIVE]};
|
||||
$.Blockly.Dart.math_constant=function(a){var b={PI:["Math.pi",$.Blockly.Dart.ORDER_UNARY_POSTFIX],E:["Math.e",$.Blockly.Dart.ORDER_UNARY_POSTFIX],GOLDEN_RATIO:["(1 + Math.sqrt(5)) / 2",$.Blockly.Dart.ORDER_MULTIPLICATIVE],SQRT2:["Math.sqrt2",$.Blockly.Dart.ORDER_UNARY_POSTFIX],SQRT1_2:["Math.sqrt1_2",$.Blockly.Dart.ORDER_UNARY_POSTFIX],INFINITY:["double.infinity",$.Blockly.Dart.ORDER_ATOMIC]};a=a.getFieldValue("CONSTANT");"INFINITY"!==a&&($.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;");
|
||||
return b[a]};
|
||||
$.Blockly.Dart.math_number_property=function(a){var b={EVEN:[" % 2 == 0",$.Blockly.Dart.ORDER_MULTIPLICATIVE,$.Blockly.Dart.ORDER_EQUALITY],ODD:[" % 2 == 1",$.Blockly.Dart.ORDER_MULTIPLICATIVE,$.Blockly.Dart.ORDER_EQUALITY],WHOLE:[" % 1 == 0",$.Blockly.Dart.ORDER_MULTIPLICATIVE,$.Blockly.Dart.ORDER_EQUALITY],POSITIVE:[" > 0",$.Blockly.Dart.ORDER_RELATIONAL,$.Blockly.Dart.ORDER_RELATIONAL],NEGATIVE:[" < 0",$.Blockly.Dart.ORDER_RELATIONAL,$.Blockly.Dart.ORDER_RELATIONAL],DIVISIBLE_BY:[null,$.Blockly.Dart.ORDER_MULTIPLICATIVE,
|
||||
$.Blockly.Dart.ORDER_EQUALITY],PRIME:[null,$.Blockly.Dart.ORDER_NONE,$.Blockly.Dart.ORDER_UNARY_POSTFIX]},c=a.getFieldValue("PROPERTY");b=$.$jscomp.makeIterator(b[c]);var d=b.next().value,e=b.next().value;b=b.next().value;e=$.Blockly.Dart.valueToCode(a,"NUMBER_TO_CHECK",e)||"0";if("PRIME"===c)$.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;",a=$.Blockly.Dart.provideFunction_("math_isPrime","\nbool "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(n) {\n // https://en.wikipedia.org/wiki/Primality_test#Naive_methods\n if (n == 2 || n == 3) {\n return true;\n }\n // False if n is null, negative, is 1, or not whole.\n // And false if n is divisible by 2 or 3.\n if (n == null || n <= 1 || n % 1 != 0 || n % 2 == 0 || n % 3 == 0) {\n return false;\n }\n // Check all the numbers of form 6k +/- 1, up to sqrt(n).\n for (var x = 6; x <= Math.sqrt(n) + 1; x += 6) {\n if (n % (x - 1) == 0 || n % (x + 1) == 0) {\n return false;\n }\n }\n return true;\n}\n")+
|
||||
"("+e+")";else if("DIVISIBLE_BY"===c){a=$.Blockly.Dart.valueToCode(a,"DIVISOR",$.Blockly.Dart.ORDER_MULTIPLICATIVE)||"0";if("0"===a)return["false",$.Blockly.Dart.ORDER_ATOMIC];a=e+" % "+a+" == 0"}else a=e+d;return[a,b]};$.Blockly.Dart.math_change=function(a){var b=$.Blockly.Dart.valueToCode(a,"DELTA",$.Blockly.Dart.ORDER_ADDITIVE)||"0";a=$.Blockly.Dart.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE);return a+" = ("+a+" is num ? "+a+" : 0) + "+b+";\n"};
|
||||
$.Blockly.Dart.math_round=$.Blockly.Dart.math_single;$.Blockly.Dart.math_trig=$.Blockly.Dart.math_single;
|
||||
$.Blockly.Dart.math_on_list=function(a){var b=a.getFieldValue("OP");a=$.Blockly.Dart.valueToCode(a,"LIST",$.Blockly.Dart.ORDER_NONE)||"[]";switch(b){case "SUM":b=$.Blockly.Dart.provideFunction_("math_sum","\nnum "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(List<num> myList) {\n num sumVal = 0;\n myList.forEach((num entry) {sumVal += entry;});\n return sumVal;\n}\n")+"("+a+")";break;case "MIN":$.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";b=$.Blockly.Dart.provideFunction_("math_min",
|
||||
"\nnum "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(List<num> myList) {\n if (myList.isEmpty) return null;\n num minVal = myList[0];\n myList.forEach((num entry) {minVal = Math.min(minVal, entry);});\n return minVal;\n}\n")+"("+a+")";break;case "MAX":$.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";b=$.Blockly.Dart.provideFunction_("math_max","\nnum "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(List<num> myList) {\n if (myList.isEmpty) return null;\n num maxVal = myList[0];\n myList.forEach((num entry) {maxVal = Math.max(maxVal, entry);});\n return maxVal;\n}\n")+
|
||||
"("+a+")";break;case "AVERAGE":b=$.Blockly.Dart.provideFunction_("math_mean","\nnum "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(List myList) {\n // First filter list for numbers only.\n List localList = new List.from(myList);\n localList.removeWhere((a) => a is! num);\n if (localList.isEmpty) return null;\n num sumVal = 0;\n localList.forEach((var entry) {sumVal += entry;});\n return sumVal / localList.length;\n}\n")+"("+a+")";break;case "MEDIAN":b=$.Blockly.Dart.provideFunction_("math_median",
|
||||
"\nnum "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(List myList) {\n // First filter list for numbers only, then sort, then return middle value\n // or the average of two middle values if list has an even number of elements.\n List localList = new List.from(myList);\n localList.removeWhere((a) => a is! num);\n if (localList.isEmpty) return null;\n localList.sort((a, b) => (a - b));\n int index = localList.length ~/ 2;\n if (localList.length % 2 == 1) {\n return localList[index];\n } else {\n return (localList[index - 1] + localList[index]) / 2;\n }\n}\n")+
|
||||
"("+a+")";break;case "MODE":$.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";b=$.Blockly.Dart.provideFunction_("math_modes","\nList "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(List values) {\n List modes = [];\n List counts = [];\n int maxCount = 0;\n for (int i = 0; i < values.length; i++) {\n var value = values[i];\n bool found = false;\n int thisCount;\n for (int j = 0; j < counts.length; j++) {\n if (counts[j][0] == value) {\n thisCount = ++counts[j][1];\n found = true;\n break;\n }\n }\n if (!found) {\n counts.add([value, 1]);\n thisCount = 1;\n }\n maxCount = Math.max(thisCount, maxCount);\n }\n for (int j = 0; j < counts.length; j++) {\n if (counts[j][1] == maxCount) {\n modes.add(counts[j][0]);\n }\n }\n return modes;\n}\n")+
|
||||
"("+a+")";break;case "STD_DEV":$.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";b=$.Blockly.Dart.provideFunction_("math_standard_deviation","\nnum "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(List myList) {\n // First filter list for numbers only.\n List numbers = new List.from(myList);\n numbers.removeWhere((a) => a is! num);\n if (numbers.isEmpty) return null;\n num n = numbers.length;\n num sum = 0;\n numbers.forEach((x) => sum += x);\n num mean = sum / n;\n num sumSquare = 0;\n numbers.forEach((x) => sumSquare += Math.pow(x - mean, 2));\n return Math.sqrt(sumSquare / n);\n}\n")+
|
||||
"("+a+")";break;case "RANDOM":$.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";b=$.Blockly.Dart.provideFunction_("math_random_item","\ndynamic "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(List myList) {\n int x = new Math.Random().nextInt(myList.length);\n return myList[x];\n}\n")+"("+a+")";break;default:throw Error("Unknown operator: "+b);}return[b,$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
|
||||
$.Blockly.Dart.math_modulo=function(a){var b=$.Blockly.Dart.valueToCode(a,"DIVIDEND",$.Blockly.Dart.ORDER_MULTIPLICATIVE)||"0";a=$.Blockly.Dart.valueToCode(a,"DIVISOR",$.Blockly.Dart.ORDER_MULTIPLICATIVE)||"0";return[b+" % "+a,$.Blockly.Dart.ORDER_MULTIPLICATIVE]};
|
||||
$.Blockly.Dart.math_constrain=function(a){$.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";var b=$.Blockly.Dart.valueToCode(a,"VALUE",$.Blockly.Dart.ORDER_NONE)||"0",c=$.Blockly.Dart.valueToCode(a,"LOW",$.Blockly.Dart.ORDER_NONE)||"0";a=$.Blockly.Dart.valueToCode(a,"HIGH",$.Blockly.Dart.ORDER_NONE)||"double.infinity";return["Math.min(Math.max("+b+", "+c+"), "+a+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
|
||||
$.Blockly.Dart.math_random_int=function(a){$.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";var b=$.Blockly.Dart.valueToCode(a,"FROM",$.Blockly.Dart.ORDER_NONE)||"0";a=$.Blockly.Dart.valueToCode(a,"TO",$.Blockly.Dart.ORDER_NONE)||"0";return[$.Blockly.Dart.provideFunction_("math_random_int","\nint "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(num a, num b) {\n if (a > b) {\n // Swap a and b to ensure a is smaller.\n num c = a;\n a = b;\n b = c;\n }\n return new Math.Random().nextInt(b - a + 1) + a;\n}\n")+
|
||||
"("+b+", "+a+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};$.Blockly.Dart.math_random_float=function(a){$.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";return["new Math.Random().nextDouble()",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
|
||||
$.Blockly.Dart.math_atan2=function(a){$.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";var b=$.Blockly.Dart.valueToCode(a,"X",$.Blockly.Dart.ORDER_NONE)||"0";return["Math.atan2("+($.Blockly.Dart.valueToCode(a,"Y",$.Blockly.Dart.ORDER_NONE)||"0")+", "+b+") / Math.pi * 180",$.Blockly.Dart.ORDER_MULTIPLICATIVE]};var module$exports$Blockly$Dart$loops={};
|
||||
$.Blockly.Dart.controls_repeat_ext=function(a){var b=a.getField("TIMES")?String(Number(a.getFieldValue("TIMES"))):$.Blockly.Dart.valueToCode(a,"TIMES",$.Blockly.Dart.ORDER_ASSIGNMENT)||"0";var c=$.Blockly.Dart.statementToCode(a,"DO");c=$.Blockly.Dart.addLoopTrap(c,a);a="";var d=$.Blockly.Dart.nameDB_.getDistinctName("count",$.module$exports$Blockly$Names.NameType.VARIABLE),e=b;b.match(/^\w+$/)||(0,$.module$exports$Blockly$utils$string.isNumber)(b)||(e=$.Blockly.Dart.nameDB_.getDistinctName("repeat_end",$.module$exports$Blockly$Names.NameType.VARIABLE),
|
||||
a+="var "+e+" = "+b+";\n");return a+("for (int "+d+" = 0; "+d+" < "+e+"; "+d+"++) {\n"+c+"}\n")};$.Blockly.Dart.controls_repeat=$.Blockly.Dart.controls_repeat_ext;$.Blockly.Dart.controls_whileUntil=function(a){var b="UNTIL"===a.getFieldValue("MODE"),c=$.Blockly.Dart.valueToCode(a,"BOOL",b?$.Blockly.Dart.ORDER_UNARY_PREFIX:$.Blockly.Dart.ORDER_NONE)||"false",d=$.Blockly.Dart.statementToCode(a,"DO");d=$.Blockly.Dart.addLoopTrap(d,a);b&&(c="!"+c);return"while ("+c+") {\n"+d+"}\n"};
|
||||
$.Blockly.Dart.controls_for=function(a){var b=$.Blockly.Dart.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE),c=$.Blockly.Dart.valueToCode(a,"FROM",$.Blockly.Dart.ORDER_ASSIGNMENT)||"0",d=$.Blockly.Dart.valueToCode(a,"TO",$.Blockly.Dart.ORDER_ASSIGNMENT)||"0",e=$.Blockly.Dart.valueToCode(a,"BY",$.Blockly.Dart.ORDER_ASSIGNMENT)||"1",f=$.Blockly.Dart.statementToCode(a,"DO");f=$.Blockly.Dart.addLoopTrap(f,a);if((0,$.module$exports$Blockly$utils$string.isNumber)(c)&&
|
||||
(0,$.module$exports$Blockly$utils$string.isNumber)(d)&&(0,$.module$exports$Blockly$utils$string.isNumber)(e)){var g=Number(c)<=Number(d);a="for ("+b+" = "+c+"; "+b+(g?" <= ":" >= ")+d+"; "+b;b=Math.abs(Number(e));a=(1===b?a+(g?"++":"--"):a+((g?" += ":" -= ")+b))+(") {\n"+f+"}\n")}else a="",g=c,c.match(/^\w+$/)||(0,$.module$exports$Blockly$utils$string.isNumber)(c)||(g=$.Blockly.Dart.nameDB_.getDistinctName(b+"_start",$.module$exports$Blockly$Names.NameType.VARIABLE),a+="var "+g+" = "+c+";\n"),c=d,
|
||||
d.match(/^\w+$/)||(0,$.module$exports$Blockly$utils$string.isNumber)(d)||(c=$.Blockly.Dart.nameDB_.getDistinctName(b+"_end",$.module$exports$Blockly$Names.NameType.VARIABLE),a+="var "+c+" = "+d+";\n"),d=$.Blockly.Dart.nameDB_.getDistinctName(b+"_inc",$.module$exports$Blockly$Names.NameType.VARIABLE),a+="num "+d+" = ",a=(0,$.module$exports$Blockly$utils$string.isNumber)(e)?a+(Math.abs(e)+";\n"):a+("("+e+").abs();\n"),a=a+("if ("+g+" > "+c+") {\n")+($.Blockly.Dart.INDENT+d+" = -"+d+";\n"),a+="}\n",
|
||||
a+="for ("+b+" = "+g+"; "+d+" >= 0 ? "+b+" <= "+c+" : "+b+" >= "+c+"; "+b+" += "+d+") {\n"+f+"}\n";return a};$.Blockly.Dart.controls_forEach=function(a){var b=$.Blockly.Dart.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE),c=$.Blockly.Dart.valueToCode(a,"LIST",$.Blockly.Dart.ORDER_ASSIGNMENT)||"[]",d=$.Blockly.Dart.statementToCode(a,"DO");d=$.Blockly.Dart.addLoopTrap(d,a);return"for (var "+b+" in "+c+") {\n"+d+"}\n"};
|
||||
$.Blockly.Dart.controls_flow_statements=function(a){var b="";$.Blockly.Dart.STATEMENT_PREFIX&&(b+=$.Blockly.Dart.injectId($.Blockly.Dart.STATEMENT_PREFIX,a));$.Blockly.Dart.STATEMENT_SUFFIX&&(b+=$.Blockly.Dart.injectId($.Blockly.Dart.STATEMENT_SUFFIX,a));if($.Blockly.Dart.STATEMENT_PREFIX){var c=a.getSurroundLoop();c&&!c.suppressPrefixSuffix&&(b+=$.Blockly.Dart.injectId($.Blockly.Dart.STATEMENT_PREFIX,c))}switch(a.getFieldValue("FLOW")){case "BREAK":return b+"break;\n";case "CONTINUE":return b+"continue;\n"}throw Error("Unknown flow statement.");
|
||||
};var module$exports$Blockly$Dart$logic={};
|
||||
$.Blockly.Dart.controls_if=function(a){var b=0,c="";$.Blockly.Dart.STATEMENT_PREFIX&&(c+=$.Blockly.Dart.injectId($.Blockly.Dart.STATEMENT_PREFIX,a));do{var d=$.Blockly.Dart.valueToCode(a,"IF"+b,$.Blockly.Dart.ORDER_NONE)||"false";var e=$.Blockly.Dart.statementToCode(a,"DO"+b);$.Blockly.Dart.STATEMENT_SUFFIX&&(e=$.Blockly.Dart.prefixLines($.Blockly.Dart.injectId($.Blockly.Dart.STATEMENT_SUFFIX,a),$.Blockly.Dart.INDENT)+e);c+=(0<b?"else ":"")+"if ("+d+") {\n"+e+"}";b++}while(a.getInput("IF"+b));if(a.getInput("ELSE")||
|
||||
$.Blockly.Dart.STATEMENT_SUFFIX)e=$.Blockly.Dart.statementToCode(a,"ELSE"),$.Blockly.Dart.STATEMENT_SUFFIX&&(e=$.Blockly.Dart.prefixLines($.Blockly.Dart.injectId($.Blockly.Dart.STATEMENT_SUFFIX,a),$.Blockly.Dart.INDENT)+e),c+=" else {\n"+e+"}";return c+"\n"};$.Blockly.Dart.controls_ifelse=$.Blockly.Dart.controls_if;
|
||||
$.Blockly.Dart.logic_compare=function(a){var b={EQ:"==",NEQ:"!=",LT:"<",LTE:"<=",GT:">",GTE:">="}[a.getFieldValue("OP")],c="=="===b||"!="===b?$.Blockly.Dart.ORDER_EQUALITY:$.Blockly.Dart.ORDER_RELATIONAL,d=$.Blockly.Dart.valueToCode(a,"A",c)||"0";a=$.Blockly.Dart.valueToCode(a,"B",c)||"0";return[d+" "+b+" "+a,c]};
|
||||
$.Blockly.Dart.logic_operation=function(a){var b="AND"===a.getFieldValue("OP")?"&&":"||",c="&&"===b?$.Blockly.Dart.ORDER_LOGICAL_AND:$.Blockly.Dart.ORDER_LOGICAL_OR,d=$.Blockly.Dart.valueToCode(a,"A",c);a=$.Blockly.Dart.valueToCode(a,"B",c);if(d||a){var e="&&"===b?"true":"false";d||(d=e);a||(a=e)}else a=d="false";return[d+" "+b+" "+a,c]};$.Blockly.Dart.logic_negate=function(a){var b=$.Blockly.Dart.ORDER_UNARY_PREFIX;return["!"+($.Blockly.Dart.valueToCode(a,"BOOL",b)||"true"),b]};
|
||||
$.Blockly.Dart.logic_boolean=function(a){return["TRUE"===a.getFieldValue("BOOL")?"true":"false",$.Blockly.Dart.ORDER_ATOMIC]};$.Blockly.Dart.logic_null=function(a){return["null",$.Blockly.Dart.ORDER_ATOMIC]};
|
||||
$.Blockly.Dart.logic_ternary=function(a){var b=$.Blockly.Dart.valueToCode(a,"IF",$.Blockly.Dart.ORDER_CONDITIONAL)||"false",c=$.Blockly.Dart.valueToCode(a,"THEN",$.Blockly.Dart.ORDER_CONDITIONAL)||"null";a=$.Blockly.Dart.valueToCode(a,"ELSE",$.Blockly.Dart.ORDER_CONDITIONAL)||"null";return[b+" ? "+c+" : "+a,$.Blockly.Dart.ORDER_CONDITIONAL]};var module$exports$Blockly$Dart$lists={};$.Blockly.Dart.addReservedWords("Math");$.Blockly.Dart.lists_create_empty=function(a){return["[]",$.Blockly.Dart.ORDER_ATOMIC]};$.Blockly.Dart.lists_create_with=function(a){for(var b=Array(a.itemCount_),c=0;c<a.itemCount_;c++)b[c]=$.Blockly.Dart.valueToCode(a,"ADD"+c,$.Blockly.Dart.ORDER_NONE)||"null";return["["+b.join(", ")+"]",$.Blockly.Dart.ORDER_ATOMIC]};
|
||||
$.Blockly.Dart.lists_repeat=function(a){var b=$.Blockly.Dart.valueToCode(a,"ITEM",$.Blockly.Dart.ORDER_NONE)||"null";return["new List.filled("+($.Blockly.Dart.valueToCode(a,"NUM",$.Blockly.Dart.ORDER_NONE)||"0")+", "+b+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};$.Blockly.Dart.lists_length=function(a){return[($.Blockly.Dart.valueToCode(a,"VALUE",$.Blockly.Dart.ORDER_UNARY_POSTFIX)||"[]")+".length",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
|
||||
$.Blockly.Dart.lists_isEmpty=function(a){return[($.Blockly.Dart.valueToCode(a,"VALUE",$.Blockly.Dart.ORDER_UNARY_POSTFIX)||"[]")+".isEmpty",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
|
||||
$.Blockly.Dart.lists_indexOf=function(a){var b="FIRST"===a.getFieldValue("END")?"indexOf":"lastIndexOf",c=$.Blockly.Dart.valueToCode(a,"FIND",$.Blockly.Dart.ORDER_NONE)||"''";b=($.Blockly.Dart.valueToCode(a,"VALUE",$.Blockly.Dart.ORDER_UNARY_POSTFIX)||"[]")+"."+b+"("+c+")";return a.workspace.options.oneBasedIndex?[b+" + 1",$.Blockly.Dart.ORDER_ADDITIVE]:[b,$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
|
||||
$.Blockly.Dart.lists_getIndex=function(a){function b(){var f=$.Blockly.Dart.nameDB_.getDistinctName("tmp_list",$.module$exports$Blockly$Names.NameType.VARIABLE),g="List "+f+" = "+e+";\n";e=f;return g}var c=a.getFieldValue("MODE")||"GET",d=a.getFieldValue("WHERE")||"FROM_START",e=$.Blockly.Dart.valueToCode(a,"VALUE","RANDOM"===d||"FROM_END"===d?$.Blockly.Dart.ORDER_NONE:$.Blockly.Dart.ORDER_UNARY_POSTFIX)||"[]";if(("RANDOM"!==d||"REMOVE"!==c)&&"FROM_END"!==d||e.match(/^\w+$/))switch(d){case "FIRST":if("GET"===
|
||||
c)return[e+".first",$.Blockly.Dart.ORDER_UNARY_POSTFIX];if("GET_REMOVE"===c)return[e+".removeAt(0)",$.Blockly.Dart.ORDER_UNARY_POSTFIX];if("REMOVE"===c)return e+".removeAt(0);\n";break;case "LAST":if("GET"===c)return[e+".last",$.Blockly.Dart.ORDER_UNARY_POSTFIX];if("GET_REMOVE"===c)return[e+".removeLast()",$.Blockly.Dart.ORDER_UNARY_POSTFIX];if("REMOVE"===c)return e+".removeLast();\n";break;case "FROM_START":a=$.Blockly.Dart.getAdjusted(a,"AT");if("GET"===c)return[e+"["+a+"]",$.Blockly.Dart.ORDER_UNARY_POSTFIX];
|
||||
if("GET_REMOVE"===c)return[e+".removeAt("+a+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX];if("REMOVE"===c)return e+".removeAt("+a+");\n";break;case "FROM_END":a=$.Blockly.Dart.getAdjusted(a,"AT",1,!1,$.Blockly.Dart.ORDER_ADDITIVE);if("GET"===c)return[e+"["+e+".length - "+a+"]",$.Blockly.Dart.ORDER_UNARY_POSTFIX];if("GET_REMOVE"===c||"REMOVE"===c){a=e+".removeAt("+e+".length - "+a+")";if("GET_REMOVE"===c)return[a,$.Blockly.Dart.ORDER_UNARY_POSTFIX];if("REMOVE"===c)return a+";\n"}break;case "RANDOM":$.Blockly.Dart.definitions_.import_dart_math=
|
||||
"import 'dart:math' as Math;";if("REMOVE"===c)return c=$.Blockly.Dart.nameDB_.getDistinctName("tmp_x",$.module$exports$Blockly$Names.NameType.VARIABLE),"int "+c+" = new Math.Random().nextInt("+e+".length);\n"+(e+".removeAt("+c+");\n");if("GET"===c)return[$.Blockly.Dart.provideFunction_("lists_get_random_item","\ndynamic "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(List my_list) {\n int x = new Math.Random().nextInt(my_list.length);\n return my_list[x];\n}\n")+"("+e+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX];
|
||||
if("GET_REMOVE"===c)return[$.Blockly.Dart.provideFunction_("lists_remove_random_item","\ndynamic "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(List my_list) {\n int x = new Math.Random().nextInt(my_list.length);\n return my_list.removeAt(x);\n}\n")+"("+e+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX]}else{if("RANDOM"===d)return $.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;",c=b(),a=$.Blockly.Dart.nameDB_.getDistinctName("tmp_x",$.module$exports$Blockly$Names.NameType.VARIABLE),
|
||||
c+("int "+a+" = new Math.Random().nextInt("+e+".length);\n")+(e+".removeAt("+a+");\n");if("REMOVE"===c)return c=$.Blockly.Dart.getAdjusted(a,"AT",1,!1,$.Blockly.Dart.ORDER_ADDITIVE),b()+(e+".removeAt("+e+".length - "+c+");\n");if("GET"===c)return c=$.Blockly.Dart.getAdjusted(a,"AT",1),[$.Blockly.Dart.provideFunction_("lists_get_from_end","\ndynamic "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(List my_list, num x) {\n x = my_list.length - x;\n return my_list[x];\n}\n")+"("+e+", "+c+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX];
|
||||
if("GET_REMOVE"===c)return c=$.Blockly.Dart.getAdjusted(a,"AT",1),[$.Blockly.Dart.provideFunction_("lists_remove_from_end","\ndynamic "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(List my_list, num x) {\n x = my_list.length - x;\n return my_list.removeAt(x);\n}\n")+"("+e+", "+c+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX]}throw Error("Unhandled combination (lists_getIndex).");};
|
||||
$.Blockly.Dart.lists_setIndex=function(a){function b(){if(e.match(/^\w+$/))return"";var g=$.Blockly.Dart.nameDB_.getDistinctName("tmp_list",$.module$exports$Blockly$Names.NameType.VARIABLE),h="List "+g+" = "+e+";\n";e=g;return h}var c=a.getFieldValue("MODE")||"GET",d=a.getFieldValue("WHERE")||"FROM_START",e=$.Blockly.Dart.valueToCode(a,"LIST",$.Blockly.Dart.ORDER_UNARY_POSTFIX)||"[]",f=$.Blockly.Dart.valueToCode(a,"TO",$.Blockly.Dart.ORDER_ASSIGNMENT)||"null";switch(d){case "FIRST":if("SET"===c)return e+
|
||||
"[0] = "+f+";\n";if("INSERT"===c)return e+".insert(0, "+f+");\n";break;case "LAST":if("SET"===c)return b()+(e+"["+e+".length - 1] = "+f+";\n");if("INSERT"===c)return e+".add("+f+");\n";break;case "FROM_START":a=$.Blockly.Dart.getAdjusted(a,"AT");if("SET"===c)return e+"["+a+"] = "+f+";\n";if("INSERT"===c)return e+".insert("+a+", "+f+");\n";break;case "FROM_END":a=$.Blockly.Dart.getAdjusted(a,"AT",1,!1,$.Blockly.Dart.ORDER_ADDITIVE);d=b();if("SET"===c)return d+(e+"["+e+".length - "+a+"] = "+f+";\n");
|
||||
if("INSERT"===c)return d+(e+".insert("+e+".length - "+a+", "+f+");\n");break;case "RANDOM":$.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";a=b();d=$.Blockly.Dart.nameDB_.getDistinctName("tmp_x",$.module$exports$Blockly$Names.NameType.VARIABLE);a+="int "+d+" = new Math.Random().nextInt("+e+".length);\n";if("SET"===c)return a+(e+"["+d+"] = "+f+";\n");if("INSERT"===c)return a+(e+".insert("+d+", "+f+");\n")}throw Error("Unhandled combination (lists_setIndex).");};
|
||||
$.Blockly.Dart.lists_getSublist=function(a){var b=$.Blockly.Dart.valueToCode(a,"LIST",$.Blockly.Dart.ORDER_UNARY_POSTFIX)||"[]",c=a.getFieldValue("WHERE1"),d=a.getFieldValue("WHERE2");if(b.match(/^\w+$/)||"FROM_END"!==c&&"FROM_START"===d){switch(c){case "FROM_START":c=$.Blockly.Dart.getAdjusted(a,"AT1");break;case "FROM_END":c=$.Blockly.Dart.getAdjusted(a,"AT1",1,!1,$.Blockly.Dart.ORDER_ADDITIVE);c=b+".length - "+c;break;case "FIRST":c="0";break;default:throw Error("Unhandled option (lists_getSublist).");
|
||||
}switch(d){case "FROM_START":var e=$.Blockly.Dart.getAdjusted(a,"AT2",1);break;case "FROM_END":e=$.Blockly.Dart.getAdjusted(a,"AT2",0,!1,$.Blockly.Dart.ORDER_ADDITIVE);e=b+".length - "+e;break;case "LAST":break;default:throw Error("Unhandled option (lists_getSublist).");}b="LAST"===d?b+".sublist("+c+")":b+".sublist("+c+", "+e+")"}else e=$.Blockly.Dart.getAdjusted(a,"AT1"),a=$.Blockly.Dart.getAdjusted(a,"AT2"),b=$.Blockly.Dart.provideFunction_("lists_get_sublist","\nList "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+
|
||||
"(List list, String where1, num at1, String where2, num at2) {\n int getAt(String where, num at) {\n if (where == 'FROM_END') {\n at = list.length - 1 - at;\n } else if (where == 'FIRST') {\n at = 0;\n } else if (where == 'LAST') {\n at = list.length - 1;\n } else if (where != 'FROM_START') {\n throw 'Unhandled option (lists_getSublist).';\n }\n return at;\n }\n at1 = getAt(where1, at1);\n at2 = getAt(where2, at2) + 1;\n return list.sublist(at1, at2);\n}\n")+
|
||||
"("+b+", '"+c+"', "+e+", '"+d+"', "+a+")";return[b,$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
|
||||
$.Blockly.Dart.lists_sort=function(a){var b=$.Blockly.Dart.valueToCode(a,"LIST",$.Blockly.Dart.ORDER_NONE)||"[]",c="1"===a.getFieldValue("DIRECTION")?1:-1;a=a.getFieldValue("TYPE");return[$.Blockly.Dart.provideFunction_("lists_sort","\nList "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(List list, String type, int direction) {\n var compareFuncs = {\n 'NUMERIC': (a, b) => (direction * a.compareTo(b)).toInt(),\n 'TEXT': (a, b) => direction * a.toString().compareTo(b.toString()),\n 'IGNORE_CASE':\n (a, b) => direction *\n a.toString().toLowerCase().compareTo(b.toString().toLowerCase())\n };\n list = new List.from(list);\n var compare = compareFuncs[type];\n list.sort(compare);\n return list;\n}\n")+"("+
|
||||
b+', "'+a+'", '+c+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};$.Blockly.Dart.lists_split=function(a){var b=$.Blockly.Dart.valueToCode(a,"INPUT",$.Blockly.Dart.ORDER_UNARY_POSTFIX),c=$.Blockly.Dart.valueToCode(a,"DELIM",$.Blockly.Dart.ORDER_NONE)||"''";a=a.getFieldValue("MODE");if("SPLIT"===a)b||(b="''"),a="split";else if("JOIN"===a)b||(b="[]"),a="join";else throw Error("Unknown mode: "+a);return[b+"."+a+"("+c+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
|
||||
$.Blockly.Dart.lists_reverse=function(a){return["new List.from("+($.Blockly.Dart.valueToCode(a,"LIST",$.Blockly.Dart.ORDER_NONE)||"[]")+".reversed)",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};var module$exports$Blockly$Dart$colour={};$.Blockly.Dart.addReservedWords("Math");$.Blockly.Dart.colour_picker=function(a){return[$.Blockly.Dart.quote_(a.getFieldValue("COLOUR")),$.Blockly.Dart.ORDER_ATOMIC]};
|
||||
$.Blockly.Dart.colour_random=function(a){$.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";return[$.Blockly.Dart.provideFunction_("colour_random","\nString "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"() {\n String hex = '0123456789abcdef';\n var rnd = new Math.Random();\n return '#${hex[rnd.nextInt(16)]}${hex[rnd.nextInt(16)]}'\n '${hex[rnd.nextInt(16)]}${hex[rnd.nextInt(16)]}'\n '${hex[rnd.nextInt(16)]}${hex[rnd.nextInt(16)]}';\n}\n")+"()",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
|
||||
$.Blockly.Dart.colour_rgb=function(a){var b=$.Blockly.Dart.valueToCode(a,"RED",$.Blockly.Dart.ORDER_NONE)||0,c=$.Blockly.Dart.valueToCode(a,"GREEN",$.Blockly.Dart.ORDER_NONE)||0;a=$.Blockly.Dart.valueToCode(a,"BLUE",$.Blockly.Dart.ORDER_NONE)||0;$.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";return[$.Blockly.Dart.provideFunction_("colour_rgb","\nString "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(num r, num g, num b) {\n num rn = (Math.max(Math.min(r, 100), 0) * 2.55).round();\n String rs = rn.toInt().toRadixString(16);\n rs = '0$rs';\n rs = rs.substring(rs.length - 2);\n num gn = (Math.max(Math.min(g, 100), 0) * 2.55).round();\n String gs = gn.toInt().toRadixString(16);\n gs = '0$gs';\n gs = gs.substring(gs.length - 2);\n num bn = (Math.max(Math.min(b, 100), 0) * 2.55).round();\n String bs = bn.toInt().toRadixString(16);\n bs = '0$bs';\n bs = bs.substring(bs.length - 2);\n return '#$rs$gs$bs';\n}\n")+
|
||||
"("+b+", "+c+", "+a+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
|
||||
$.Blockly.Dart.colour_blend=function(a){var b=$.Blockly.Dart.valueToCode(a,"COLOUR1",$.Blockly.Dart.ORDER_NONE)||"'#000000'",c=$.Blockly.Dart.valueToCode(a,"COLOUR2",$.Blockly.Dart.ORDER_NONE)||"'#000000'";a=$.Blockly.Dart.valueToCode(a,"RATIO",$.Blockly.Dart.ORDER_NONE)||.5;$.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";return[$.Blockly.Dart.provideFunction_("colour_blend","\nString "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(String c1, String c2, num ratio) {\n ratio = Math.max(Math.min(ratio, 1), 0);\n int r1 = int.parse('0x${c1.substring(1, 3)}');\n int g1 = int.parse('0x${c1.substring(3, 5)}');\n int b1 = int.parse('0x${c1.substring(5, 7)}');\n int r2 = int.parse('0x${c2.substring(1, 3)}');\n int g2 = int.parse('0x${c2.substring(3, 5)}');\n int b2 = int.parse('0x${c2.substring(5, 7)}');\n num rn = (r1 * (1 - ratio) + r2 * ratio).round();\n String rs = rn.toInt().toRadixString(16);\n num gn = (g1 * (1 - ratio) + g2 * ratio).round();\n String gs = gn.toInt().toRadixString(16);\n num bn = (b1 * (1 - ratio) + b2 * ratio).round();\n String bs = bn.toInt().toRadixString(16);\n rs = '0$rs';\n rs = rs.substring(rs.length - 2);\n gs = '0$gs';\n gs = gs.substring(gs.length - 2);\n bs = '0$bs';\n bs = bs.substring(bs.length - 2);\n return '#$rs$gs$bs';\n}\n")+
|
||||
"("+b+", "+c+", "+a+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};var module$exports$Blockly$Dart$all={};
|
||||
$.Blockly.Dart.__namespace__=$;
|
||||
return $.Blockly.Dart;
|
||||
module$exports$Blockly$Dart.dartGenerator.getAdjusted=function(a,b,c,d,e){c=c||0;e=e||this.ORDER_NONE;a.workspace.options.oneBasedIndex&&c--;const f=a.workspace.options.oneBasedIndex?"1":"0";let g,h;c?h=g=this.ORDER_ADDITIVE:d?h=g=this.ORDER_UNARY_PREFIX:g=e;a=this.valueToCode(a,b,g)||f;$.module$build$src$core$utils$string.isNumber(a)?(a=parseInt(a,10)+c,d&&(a=-a)):(0<c?a=a+" + "+c:0>c&&(a=a+" - "+-c),d&&(a=c?"-("+a+")":"-"+a),h=Math.floor(h),e=Math.floor(e),h&&e>=h&&(a="("+a+")"));return a};var module$exports$Blockly$Dart$variables={},module$contents$Blockly$Dart$variables_NameType=$.NameType$$module$build$src$core$names;module$exports$Blockly$Dart.dartGenerator.variables_get=function(a){return[module$exports$Blockly$Dart.dartGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE),module$exports$Blockly$Dart.dartGenerator.ORDER_ATOMIC]};
|
||||
module$exports$Blockly$Dart.dartGenerator.variables_set=function(a){const b=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Dart.dartGenerator.ORDER_ASSIGNMENT)||"0";return module$exports$Blockly$Dart.dartGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE)+" = "+b+";\n"};var module$exports$Blockly$Dart$variablesDynamic={};module$exports$Blockly$Dart.dartGenerator.variables_get_dynamic=module$exports$Blockly$Dart.dartGenerator.variables_get;module$exports$Blockly$Dart.dartGenerator.variables_set_dynamic=module$exports$Blockly$Dart.dartGenerator.variables_set;var module$exports$Blockly$Dart$texts={},module$contents$Blockly$Dart$texts_NameType=$.NameType$$module$build$src$core$names;module$exports$Blockly$Dart.dartGenerator.addReservedWords("Html,Math");module$exports$Blockly$Dart.dartGenerator.text=function(a){return[module$exports$Blockly$Dart.dartGenerator.quote_(a.getFieldValue("TEXT")),module$exports$Blockly$Dart.dartGenerator.ORDER_ATOMIC]};
|
||||
module$exports$Blockly$Dart.dartGenerator.text_multiline=function(a){a=module$exports$Blockly$Dart.dartGenerator.multiline_quote_(a.getFieldValue("TEXT"));const b=-1!==a.indexOf("+")?module$exports$Blockly$Dart.dartGenerator.ORDER_ADDITIVE:module$exports$Blockly$Dart.dartGenerator.ORDER_ATOMIC;return[a,b]};
|
||||
module$exports$Blockly$Dart.dartGenerator.text_join=function(a){switch(a.itemCount_){case 0:return["''",module$exports$Blockly$Dart.dartGenerator.ORDER_ATOMIC];case 1:return[(module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"ADD0",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX)||"''")+".toString()",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX];default:const b=Array(a.itemCount_);for(let c=0;c<a.itemCount_;c++)b[c]=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,
|
||||
"ADD"+c,module$exports$Blockly$Dart.dartGenerator.ORDER_NONE)||"''";return["["+b.join(",")+"].join()",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX]}};
|
||||
module$exports$Blockly$Dart.dartGenerator.text_append=function(a){const b=module$exports$Blockly$Dart.dartGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE);a=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"TEXT",module$exports$Blockly$Dart.dartGenerator.ORDER_NONE)||"''";return b+" = ["+b+", "+a+"].join();\n"};
|
||||
module$exports$Blockly$Dart.dartGenerator.text_length=function(a){return[(module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX)||"''")+".length",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX]};
|
||||
module$exports$Blockly$Dart.dartGenerator.text_isEmpty=function(a){return[(module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX)||"''")+".isEmpty",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX]};
|
||||
module$exports$Blockly$Dart.dartGenerator.text_indexOf=function(a){var b="FIRST"===a.getFieldValue("END")?"indexOf":"lastIndexOf";const c=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"FIND",module$exports$Blockly$Dart.dartGenerator.ORDER_NONE)||"''";b=(module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX)||"''")+"."+b+"("+c+")";return a.workspace.options.oneBasedIndex?[b+" + 1",module$exports$Blockly$Dart.dartGenerator.ORDER_ADDITIVE]:
|
||||
[b,module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX]};
|
||||
module$exports$Blockly$Dart.dartGenerator.text_charAt=function(a){const b=a.getFieldValue("WHERE")||"FROM_START",c=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"VALUE","FIRST"===b||"FROM_START"===b?module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX:module$exports$Blockly$Dart.dartGenerator.ORDER_NONE)||"''";switch(b){case "FIRST":return[c+"[0]",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX];case "FROM_START":return a=module$exports$Blockly$Dart.dartGenerator.getAdjusted(a,
|
||||
"AT"),[c+"["+a+"]",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX];case "LAST":case "FROM_END":return a=module$exports$Blockly$Dart.dartGenerator.getAdjusted(a,"AT",1),[module$exports$Blockly$Dart.dartGenerator.provideFunction_("text_get_from_end",`
|
||||
String ${module$exports$Blockly$Dart.dartGenerator.FUNCTION_NAME_PLACEHOLDER_}(String text, num x) {
|
||||
return text[text.length - x];
|
||||
}
|
||||
`)+"("+c+", "+a+")",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX];case "RANDOM":return module$exports$Blockly$Dart.dartGenerator.definitions_.import_dart_math="import 'dart:math' as Math;",[module$exports$Blockly$Dart.dartGenerator.provideFunction_("text_random_letter",`
|
||||
String ${module$exports$Blockly$Dart.dartGenerator.FUNCTION_NAME_PLACEHOLDER_}(String text) {
|
||||
int x = new Math.Random().nextInt(text.length);
|
||||
return text[x];
|
||||
}
|
||||
`)+"("+c+")",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX]}throw Error("Unhandled option (text_charAt).");};
|
||||
module$exports$Blockly$Dart.dartGenerator.text_getSubstring=function(a){var b=a.getFieldValue("WHERE1"),c=a.getFieldValue("WHERE2");const d="FROM_END"!==b&&"FROM_START"===c,e=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"STRING",d?module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX:module$exports$Blockly$Dart.dartGenerator.ORDER_NONE)||"''";if("FIRST"===b&&"LAST"===c)return[e,module$exports$Blockly$Dart.dartGenerator.ORDER_NONE];if(e.match(/^'?\w+'?$/)||d){switch(b){case "FROM_START":b=
|
||||
module$exports$Blockly$Dart.dartGenerator.getAdjusted(a,"AT1");break;case "FROM_END":b=module$exports$Blockly$Dart.dartGenerator.getAdjusted(a,"AT1",1,!1,module$exports$Blockly$Dart.dartGenerator.ORDER_ADDITIVE);b=e+".length - "+b;break;case "FIRST":b="0";break;default:throw Error("Unhandled option (text_getSubstring).");}switch(c){case "FROM_START":var f=module$exports$Blockly$Dart.dartGenerator.getAdjusted(a,"AT2",1);break;case "FROM_END":f=module$exports$Blockly$Dart.dartGenerator.getAdjusted(a,
|
||||
"AT2",0,!1,module$exports$Blockly$Dart.dartGenerator.ORDER_ADDITIVE);f=e+".length - "+f;break;case "LAST":break;default:throw Error("Unhandled option (text_getSubstring).");}c="LAST"===c?e+".substring("+b+")":e+".substring("+b+", "+f+")"}else f=module$exports$Blockly$Dart.dartGenerator.getAdjusted(a,"AT1"),a=module$exports$Blockly$Dart.dartGenerator.getAdjusted(a,"AT2"),c=module$exports$Blockly$Dart.dartGenerator.provideFunction_("text_get_substring",`
|
||||
String ${module$exports$Blockly$Dart.dartGenerator.FUNCTION_NAME_PLACEHOLDER_}(String text, String where1, num at1, String where2, num at2) {
|
||||
int getAt(String where, num at) {
|
||||
if (where == 'FROM_END') {
|
||||
at = text.length - 1 - at;
|
||||
} else if (where == 'FIRST') {
|
||||
at = 0;
|
||||
} else if (where == 'LAST') {
|
||||
at = text.length - 1;
|
||||
} else if (where != 'FROM_START') {
|
||||
throw 'Unhandled option (text_getSubstring).';
|
||||
}
|
||||
return at;
|
||||
}
|
||||
at1 = getAt(where1, at1);
|
||||
at2 = getAt(where2, at2) + 1;
|
||||
return text.substring(at1, at2);
|
||||
}
|
||||
`)+"("+e+", '"+b+"', "+f+", '"+c+"', "+a+")";return[c,module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX]};
|
||||
module$exports$Blockly$Dart.dartGenerator.text_changeCase=function(a){const b={UPPERCASE:".toUpperCase()",LOWERCASE:".toLowerCase()",TITLECASE:null}[a.getFieldValue("CASE")];a=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"TEXT",b?module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX:module$exports$Blockly$Dart.dartGenerator.ORDER_NONE)||"''";return[b?a+b:module$exports$Blockly$Dart.dartGenerator.provideFunction_("text_toTitleCase",`
|
||||
String ${module$exports$Blockly$Dart.dartGenerator.FUNCTION_NAME_PLACEHOLDER_}(String str) {
|
||||
RegExp exp = new RegExp(r'\\b');
|
||||
List<String> list = str.split(exp);
|
||||
final title = new StringBuffer();
|
||||
for (String part in list) {
|
||||
if (part.length > 0) {
|
||||
title.write(part[0].toUpperCase());
|
||||
if (part.length > 0) {
|
||||
title.write(part.substring(1).toLowerCase());
|
||||
}
|
||||
}
|
||||
}
|
||||
return title.toString();
|
||||
}
|
||||
`)+"("+a+")",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX]};module$exports$Blockly$Dart.dartGenerator.text_trim=function(a){const b={LEFT:".replaceFirst(new RegExp(r'^\\s+'), '')",RIGHT:".replaceFirst(new RegExp(r'\\s+$'), '')",BOTH:".trim()"}[a.getFieldValue("MODE")];return[(module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"TEXT",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX)||"''")+b,module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX]};
|
||||
module$exports$Blockly$Dart.dartGenerator.text_print=function(a){return"print("+(module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"TEXT",module$exports$Blockly$Dart.dartGenerator.ORDER_NONE)||"''")+");\n"};
|
||||
module$exports$Blockly$Dart.dartGenerator.text_prompt_ext=function(a){module$exports$Blockly$Dart.dartGenerator.definitions_.import_dart_html="import 'dart:html' as Html;";let b="Html.window.prompt("+(a.getField("TEXT")?module$exports$Blockly$Dart.dartGenerator.quote_(a.getFieldValue("TEXT")):module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"TEXT",module$exports$Blockly$Dart.dartGenerator.ORDER_NONE)||"''")+", '')";"NUMBER"===a.getFieldValue("TYPE")&&(module$exports$Blockly$Dart.dartGenerator.definitions_.import_dart_math=
|
||||
"import 'dart:math' as Math;",b="Math.parseDouble("+b+")");return[b,module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX]};module$exports$Blockly$Dart.dartGenerator.text_prompt=module$exports$Blockly$Dart.dartGenerator.text_prompt_ext;
|
||||
module$exports$Blockly$Dart.dartGenerator.text_count=function(a){const b=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"TEXT",module$exports$Blockly$Dart.dartGenerator.ORDER_NONE)||"''";a=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"SUB",module$exports$Blockly$Dart.dartGenerator.ORDER_NONE)||"''";return[module$exports$Blockly$Dart.dartGenerator.provideFunction_("text_count",`
|
||||
int ${module$exports$Blockly$Dart.dartGenerator.FUNCTION_NAME_PLACEHOLDER_}(String haystack, String needle) {
|
||||
if (needle.length == 0) {
|
||||
return haystack.length + 1;
|
||||
}
|
||||
int index = 0;
|
||||
int count = 0;
|
||||
while (index != -1) {
|
||||
index = haystack.indexOf(needle, index);
|
||||
if (index != -1) {
|
||||
count++;
|
||||
index += needle.length;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
`)+"("+b+", "+a+")",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX]};
|
||||
module$exports$Blockly$Dart.dartGenerator.text_replace=function(a){const b=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"TEXT",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX)||"''",c=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"FROM",module$exports$Blockly$Dart.dartGenerator.ORDER_NONE)||"''";a=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"TO",module$exports$Blockly$Dart.dartGenerator.ORDER_NONE)||"''";return[b+".replaceAll("+c+", "+a+")",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX]};
|
||||
module$exports$Blockly$Dart.dartGenerator.text_reverse=function(a){return["new String.fromCharCodes("+(module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"TEXT",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX)||"''")+".runes.toList().reversed)",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_PREFIX]};var module$exports$Blockly$Dart$procedures={},module$contents$Blockly$Dart$procedures_NameType=$.NameType$$module$build$src$core$names;
|
||||
module$exports$Blockly$Dart.dartGenerator.procedures_defreturn=function(a){const b=module$exports$Blockly$Dart.dartGenerator.nameDB_.getName(a.getFieldValue("NAME"),$.NameType$$module$build$src$core$names.PROCEDURE);var c="";module$exports$Blockly$Dart.dartGenerator.STATEMENT_PREFIX&&(c+=module$exports$Blockly$Dart.dartGenerator.injectId(module$exports$Blockly$Dart.dartGenerator.STATEMENT_PREFIX,a));module$exports$Blockly$Dart.dartGenerator.STATEMENT_SUFFIX&&(c+=module$exports$Blockly$Dart.dartGenerator.injectId(module$exports$Blockly$Dart.dartGenerator.STATEMENT_SUFFIX,
|
||||
a));c&&(c=module$exports$Blockly$Dart.dartGenerator.prefixLines(c,module$exports$Blockly$Dart.dartGenerator.INDENT));let d="";module$exports$Blockly$Dart.dartGenerator.INFINITE_LOOP_TRAP&&(d=module$exports$Blockly$Dart.dartGenerator.prefixLines(module$exports$Blockly$Dart.dartGenerator.injectId(module$exports$Blockly$Dart.dartGenerator.INFINITE_LOOP_TRAP,a),module$exports$Blockly$Dart.dartGenerator.INDENT));const e=module$exports$Blockly$Dart.dartGenerator.statementToCode(a,"STACK");let f=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,
|
||||
"RETURN",module$exports$Blockly$Dart.dartGenerator.ORDER_NONE)||"",g="";e&&f&&(g=c);f&&(f=module$exports$Blockly$Dart.dartGenerator.INDENT+"return "+f+";\n");const h=f?"dynamic":"void",k=[],l=a.getVars();for(let m=0;m<l.length;m++)k[m]=module$exports$Blockly$Dart.dartGenerator.nameDB_.getName(l[m],$.NameType$$module$build$src$core$names.VARIABLE);c=h+" "+b+"("+k.join(", ")+") {\n"+c+d+e+g+f+"}";c=module$exports$Blockly$Dart.dartGenerator.scrub_(a,c);module$exports$Blockly$Dart.dartGenerator.definitions_["%"+
|
||||
b]=c;return null};module$exports$Blockly$Dart.dartGenerator.procedures_defnoreturn=module$exports$Blockly$Dart.dartGenerator.procedures_defreturn;
|
||||
module$exports$Blockly$Dart.dartGenerator.procedures_callreturn=function(a){const b=module$exports$Blockly$Dart.dartGenerator.nameDB_.getName(a.getFieldValue("NAME"),$.NameType$$module$build$src$core$names.PROCEDURE),c=[],d=a.getVars();for(let e=0;e<d.length;e++)c[e]=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"ARG"+e,module$exports$Blockly$Dart.dartGenerator.ORDER_NONE)||"null";return[b+"("+c.join(", ")+")",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX]};
|
||||
module$exports$Blockly$Dart.dartGenerator.procedures_callnoreturn=function(a){return module$exports$Blockly$Dart.dartGenerator.procedures_callreturn(a)[0]+";\n"};
|
||||
module$exports$Blockly$Dart.dartGenerator.procedures_ifreturn=function(a){let b="if ("+(module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"CONDITION",module$exports$Blockly$Dart.dartGenerator.ORDER_NONE)||"false")+") {\n";module$exports$Blockly$Dart.dartGenerator.STATEMENT_SUFFIX&&(b+=module$exports$Blockly$Dart.dartGenerator.prefixLines(module$exports$Blockly$Dart.dartGenerator.injectId(module$exports$Blockly$Dart.dartGenerator.STATEMENT_SUFFIX,a),module$exports$Blockly$Dart.dartGenerator.INDENT));
|
||||
a.hasReturnValue_?(a=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Dart.dartGenerator.ORDER_NONE)||"null",b+=module$exports$Blockly$Dart.dartGenerator.INDENT+"return "+a+";\n"):b+=module$exports$Blockly$Dart.dartGenerator.INDENT+"return;\n";return b+"}\n"};var module$exports$Blockly$Dart$math={},module$contents$Blockly$Dart$math_NameType=$.NameType$$module$build$src$core$names;module$exports$Blockly$Dart.dartGenerator.addReservedWords("Math");
|
||||
module$exports$Blockly$Dart.dartGenerator.math_number=function(a){a=Number(a.getFieldValue("NUM"));let b;Infinity===a?(a="double.infinity",b=module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX):-Infinity===a?(a="-double.infinity",b=module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_PREFIX):b=0>a?module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_PREFIX:module$exports$Blockly$Dart.dartGenerator.ORDER_ATOMIC;return[a,b]};
|
||||
module$exports$Blockly$Dart.dartGenerator.math_arithmetic=function(a){var b={ADD:[" + ",module$exports$Blockly$Dart.dartGenerator.ORDER_ADDITIVE],MINUS:[" - ",module$exports$Blockly$Dart.dartGenerator.ORDER_ADDITIVE],MULTIPLY:[" * ",module$exports$Blockly$Dart.dartGenerator.ORDER_MULTIPLICATIVE],DIVIDE:[" / ",module$exports$Blockly$Dart.dartGenerator.ORDER_MULTIPLICATIVE],POWER:[null,module$exports$Blockly$Dart.dartGenerator.ORDER_NONE]}[a.getFieldValue("OP")];const c=b[0];b=b[1];const d=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,
|
||||
"A",b)||"0";a=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"B",b)||"0";return c?[d+c+a,b]:(module$exports$Blockly$Dart.dartGenerator.definitions_.import_dart_math="import 'dart:math' as Math;",["Math.pow("+d+", "+a+")",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX])};
|
||||
module$exports$Blockly$Dart.dartGenerator.math_single=function(a){const b=a.getFieldValue("OP");let c;if("NEG"===b)return a=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"NUM",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_PREFIX)||"0","-"===a[0]&&(a=" "+a),["-"+a,module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_PREFIX];module$exports$Blockly$Dart.dartGenerator.definitions_.import_dart_math="import 'dart:math' as Math;";a="ABS"===b||"ROUND"===b.substring(0,5)?module$exports$Blockly$Dart.dartGenerator.valueToCode(a,
|
||||
"NUM",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX)||"0":"SIN"===b||"COS"===b||"TAN"===b?module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"NUM",module$exports$Blockly$Dart.dartGenerator.ORDER_MULTIPLICATIVE)||"0":module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"NUM",module$exports$Blockly$Dart.dartGenerator.ORDER_NONE)||"0";switch(b){case "ABS":c=a+".abs()";break;case "ROOT":c="Math.sqrt("+a+")";break;case "LN":c="Math.log("+a+")";break;case "EXP":c="Math.exp("+a+")";
|
||||
break;case "POW10":c="Math.pow(10,"+a+")";break;case "ROUND":c=a+".round()";break;case "ROUNDUP":c=a+".ceil()";break;case "ROUNDDOWN":c=a+".floor()";break;case "SIN":c="Math.sin("+a+" / 180 * Math.pi)";break;case "COS":c="Math.cos("+a+" / 180 * Math.pi)";break;case "TAN":c="Math.tan("+a+" / 180 * Math.pi)"}if(c)return[c,module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX];switch(b){case "LOG10":c="Math.log("+a+") / Math.log(10)";break;case "ASIN":c="Math.asin("+a+") / Math.pi * 180";break;
|
||||
case "ACOS":c="Math.acos("+a+") / Math.pi * 180";break;case "ATAN":c="Math.atan("+a+") / Math.pi * 180";break;default:throw Error("Unknown math operator: "+b);}return[c,module$exports$Blockly$Dart.dartGenerator.ORDER_MULTIPLICATIVE]};
|
||||
module$exports$Blockly$Dart.dartGenerator.math_constant=function(a){const b={PI:["Math.pi",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX],E:["Math.e",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX],GOLDEN_RATIO:["(1 + Math.sqrt(5)) / 2",module$exports$Blockly$Dart.dartGenerator.ORDER_MULTIPLICATIVE],SQRT2:["Math.sqrt2",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX],SQRT1_2:["Math.sqrt1_2",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX],
|
||||
INFINITY:["double.infinity",module$exports$Blockly$Dart.dartGenerator.ORDER_ATOMIC]};a=a.getFieldValue("CONSTANT");"INFINITY"!==a&&(module$exports$Blockly$Dart.dartGenerator.definitions_.import_dart_math="import 'dart:math' as Math;");return b[a]};
|
||||
module$exports$Blockly$Dart.dartGenerator.math_number_property=function(a){var b={EVEN:[" % 2 == 0",module$exports$Blockly$Dart.dartGenerator.ORDER_MULTIPLICATIVE,module$exports$Blockly$Dart.dartGenerator.ORDER_EQUALITY],ODD:[" % 2 == 1",module$exports$Blockly$Dart.dartGenerator.ORDER_MULTIPLICATIVE,module$exports$Blockly$Dart.dartGenerator.ORDER_EQUALITY],WHOLE:[" % 1 == 0",module$exports$Blockly$Dart.dartGenerator.ORDER_MULTIPLICATIVE,module$exports$Blockly$Dart.dartGenerator.ORDER_EQUALITY],POSITIVE:[" > 0",
|
||||
module$exports$Blockly$Dart.dartGenerator.ORDER_RELATIONAL,module$exports$Blockly$Dart.dartGenerator.ORDER_RELATIONAL],NEGATIVE:[" < 0",module$exports$Blockly$Dart.dartGenerator.ORDER_RELATIONAL,module$exports$Blockly$Dart.dartGenerator.ORDER_RELATIONAL],DIVISIBLE_BY:[null,module$exports$Blockly$Dart.dartGenerator.ORDER_MULTIPLICATIVE,module$exports$Blockly$Dart.dartGenerator.ORDER_EQUALITY],PRIME:[null,module$exports$Blockly$Dart.dartGenerator.ORDER_NONE,module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX]};
|
||||
const c=a.getFieldValue("PROPERTY"),[d,e,f]=b[c];b=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"NUMBER_TO_CHECK",e)||"0";if("PRIME"===c)module$exports$Blockly$Dart.dartGenerator.definitions_.import_dart_math="import 'dart:math' as Math;",a=module$exports$Blockly$Dart.dartGenerator.provideFunction_("math_isPrime",`
|
||||
bool ${module$exports$Blockly$Dart.dartGenerator.FUNCTION_NAME_PLACEHOLDER_}(n) {
|
||||
// https://en.wikipedia.org/wiki/Primality_test#Naive_methods
|
||||
if (n == 2 || n == 3) {
|
||||
return true;
|
||||
}
|
||||
// False if n is null, negative, is 1, or not whole.
|
||||
// And false if n is divisible by 2 or 3.
|
||||
if (n == null || n <= 1 || n % 1 != 0 || n % 2 == 0 || n % 3 == 0) {
|
||||
return false;
|
||||
}
|
||||
// Check all the numbers of form 6k +/- 1, up to sqrt(n).
|
||||
for (var x = 6; x <= Math.sqrt(n) + 1; x += 6) {
|
||||
if (n % (x - 1) == 0 || n % (x + 1) == 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
`)+"("+b+")";else if("DIVISIBLE_BY"===c){a=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"DIVISOR",module$exports$Blockly$Dart.dartGenerator.ORDER_MULTIPLICATIVE)||"0";if("0"===a)return["false",module$exports$Blockly$Dart.dartGenerator.ORDER_ATOMIC];a=b+" % "+a+" == 0"}else a=b+d;return[a,f]};
|
||||
module$exports$Blockly$Dart.dartGenerator.math_change=function(a){const b=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"DELTA",module$exports$Blockly$Dart.dartGenerator.ORDER_ADDITIVE)||"0";a=module$exports$Blockly$Dart.dartGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE);return a+" = ("+a+" is num ? "+a+" : 0) + "+b+";\n"};module$exports$Blockly$Dart.dartGenerator.math_round=module$exports$Blockly$Dart.dartGenerator.math_single;
|
||||
module$exports$Blockly$Dart.dartGenerator.math_trig=module$exports$Blockly$Dart.dartGenerator.math_single;module$exports$Blockly$Dart.dartGenerator.math_on_list=function(a){var b=a.getFieldValue("OP");a=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"LIST",module$exports$Blockly$Dart.dartGenerator.ORDER_NONE)||"[]";switch(b){case "SUM":b=module$exports$Blockly$Dart.dartGenerator.provideFunction_("math_sum",`
|
||||
num ${module$exports$Blockly$Dart.dartGenerator.FUNCTION_NAME_PLACEHOLDER_}(List<num> myList) {
|
||||
num sumVal = 0;
|
||||
myList.forEach((num entry) {sumVal += entry;});
|
||||
return sumVal;
|
||||
}
|
||||
`)+"("+a+")";break;case "MIN":module$exports$Blockly$Dart.dartGenerator.definitions_.import_dart_math="import 'dart:math' as Math;";b=module$exports$Blockly$Dart.dartGenerator.provideFunction_("math_min",`
|
||||
num ${module$exports$Blockly$Dart.dartGenerator.FUNCTION_NAME_PLACEHOLDER_}(List<num> myList) {
|
||||
if (myList.isEmpty) return null;
|
||||
num minVal = myList[0];
|
||||
myList.forEach((num entry) {minVal = Math.min(minVal, entry);});
|
||||
return minVal;
|
||||
}
|
||||
`)+"("+a+")";break;case "MAX":module$exports$Blockly$Dart.dartGenerator.definitions_.import_dart_math="import 'dart:math' as Math;";b=module$exports$Blockly$Dart.dartGenerator.provideFunction_("math_max",`
|
||||
num ${module$exports$Blockly$Dart.dartGenerator.FUNCTION_NAME_PLACEHOLDER_}(List<num> myList) {
|
||||
if (myList.isEmpty) return null;
|
||||
num maxVal = myList[0];
|
||||
myList.forEach((num entry) {maxVal = Math.max(maxVal, entry);});
|
||||
return maxVal;
|
||||
}
|
||||
`)+"("+a+")";break;case "AVERAGE":b=module$exports$Blockly$Dart.dartGenerator.provideFunction_("math_mean",`
|
||||
num ${module$exports$Blockly$Dart.dartGenerator.FUNCTION_NAME_PLACEHOLDER_}(List myList) {
|
||||
// First filter list for numbers only.
|
||||
List localList = new List.from(myList);
|
||||
localList.removeWhere((a) => a is! num);
|
||||
if (localList.isEmpty) return null;
|
||||
num sumVal = 0;
|
||||
localList.forEach((var entry) {sumVal += entry;});
|
||||
return sumVal / localList.length;
|
||||
}
|
||||
`)+"("+a+")";break;case "MEDIAN":b=module$exports$Blockly$Dart.dartGenerator.provideFunction_("math_median",`
|
||||
num ${module$exports$Blockly$Dart.dartGenerator.FUNCTION_NAME_PLACEHOLDER_}(List myList) {
|
||||
// First filter list for numbers only, then sort, then return middle value
|
||||
// or the average of two middle values if list has an even number of elements.
|
||||
List localList = new List.from(myList);
|
||||
localList.removeWhere((a) => a is! num);
|
||||
if (localList.isEmpty) return null;
|
||||
localList.sort((a, b) => (a - b));
|
||||
int index = localList.length ~/ 2;
|
||||
if (localList.length % 2 == 1) {
|
||||
return localList[index];
|
||||
} else {
|
||||
return (localList[index - 1] + localList[index]) / 2;
|
||||
}
|
||||
}
|
||||
`)+"("+a+")";break;case "MODE":module$exports$Blockly$Dart.dartGenerator.definitions_.import_dart_math="import 'dart:math' as Math;";b=module$exports$Blockly$Dart.dartGenerator.provideFunction_("math_modes",`
|
||||
List ${module$exports$Blockly$Dart.dartGenerator.FUNCTION_NAME_PLACEHOLDER_}(List values) {
|
||||
List modes = [];
|
||||
List counts = [];
|
||||
int maxCount = 0;
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
var value = values[i];
|
||||
bool found = false;
|
||||
int thisCount;
|
||||
for (int j = 0; j < counts.length; j++) {
|
||||
if (counts[j][0] == value) {
|
||||
thisCount = ++counts[j][1];
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
counts.add([value, 1]);
|
||||
thisCount = 1;
|
||||
}
|
||||
maxCount = Math.max(thisCount, maxCount);
|
||||
}
|
||||
for (int j = 0; j < counts.length; j++) {
|
||||
if (counts[j][1] == maxCount) {
|
||||
modes.add(counts[j][0]);
|
||||
}
|
||||
}
|
||||
return modes;
|
||||
}
|
||||
`)+"("+a+")";break;case "STD_DEV":module$exports$Blockly$Dart.dartGenerator.definitions_.import_dart_math="import 'dart:math' as Math;";b=module$exports$Blockly$Dart.dartGenerator.provideFunction_("math_standard_deviation",`
|
||||
num ${module$exports$Blockly$Dart.dartGenerator.FUNCTION_NAME_PLACEHOLDER_}(List myList) {
|
||||
// First filter list for numbers only.
|
||||
List numbers = new List.from(myList);
|
||||
numbers.removeWhere((a) => a is! num);
|
||||
if (numbers.isEmpty) return null;
|
||||
num n = numbers.length;
|
||||
num sum = 0;
|
||||
numbers.forEach((x) => sum += x);
|
||||
num mean = sum / n;
|
||||
num sumSquare = 0;
|
||||
numbers.forEach((x) => sumSquare += Math.pow(x - mean, 2));
|
||||
return Math.sqrt(sumSquare / n);
|
||||
}
|
||||
`)+"("+a+")";break;case "RANDOM":module$exports$Blockly$Dart.dartGenerator.definitions_.import_dart_math="import 'dart:math' as Math;";b=module$exports$Blockly$Dart.dartGenerator.provideFunction_("math_random_item",`
|
||||
dynamic ${module$exports$Blockly$Dart.dartGenerator.FUNCTION_NAME_PLACEHOLDER_}(List myList) {
|
||||
int x = new Math.Random().nextInt(myList.length);
|
||||
return myList[x];
|
||||
}
|
||||
`)+"("+a+")";break;default:throw Error("Unknown operator: "+b);}return[b,module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX]};
|
||||
module$exports$Blockly$Dart.dartGenerator.math_modulo=function(a){const b=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"DIVIDEND",module$exports$Blockly$Dart.dartGenerator.ORDER_MULTIPLICATIVE)||"0";a=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"DIVISOR",module$exports$Blockly$Dart.dartGenerator.ORDER_MULTIPLICATIVE)||"0";return[b+" % "+a,module$exports$Blockly$Dart.dartGenerator.ORDER_MULTIPLICATIVE]};
|
||||
module$exports$Blockly$Dart.dartGenerator.math_constrain=function(a){module$exports$Blockly$Dart.dartGenerator.definitions_.import_dart_math="import 'dart:math' as Math;";const b=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Dart.dartGenerator.ORDER_NONE)||"0",c=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"LOW",module$exports$Blockly$Dart.dartGenerator.ORDER_NONE)||"0";a=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"HIGH",module$exports$Blockly$Dart.dartGenerator.ORDER_NONE)||
|
||||
"double.infinity";return["Math.min(Math.max("+b+", "+c+"), "+a+")",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX]};
|
||||
module$exports$Blockly$Dart.dartGenerator.math_random_int=function(a){module$exports$Blockly$Dart.dartGenerator.definitions_.import_dart_math="import 'dart:math' as Math;";const b=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"FROM",module$exports$Blockly$Dart.dartGenerator.ORDER_NONE)||"0";a=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"TO",module$exports$Blockly$Dart.dartGenerator.ORDER_NONE)||"0";return[module$exports$Blockly$Dart.dartGenerator.provideFunction_("math_random_int",
|
||||
`
|
||||
int ${module$exports$Blockly$Dart.dartGenerator.FUNCTION_NAME_PLACEHOLDER_}(num a, num b) {
|
||||
if (a > b) {
|
||||
// Swap a and b to ensure a is smaller.
|
||||
num c = a;
|
||||
a = b;
|
||||
b = c;
|
||||
}
|
||||
return new Math.Random().nextInt(b - a + 1) + a;
|
||||
}
|
||||
`)+"("+b+", "+a+")",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX]};module$exports$Blockly$Dart.dartGenerator.math_random_float=function(a){module$exports$Blockly$Dart.dartGenerator.definitions_.import_dart_math="import 'dart:math' as Math;";return["new Math.Random().nextDouble()",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX]};
|
||||
module$exports$Blockly$Dart.dartGenerator.math_atan2=function(a){module$exports$Blockly$Dart.dartGenerator.definitions_.import_dart_math="import 'dart:math' as Math;";const b=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"X",module$exports$Blockly$Dart.dartGenerator.ORDER_NONE)||"0";return["Math.atan2("+(module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"Y",module$exports$Blockly$Dart.dartGenerator.ORDER_NONE)||"0")+", "+b+") / Math.pi * 180",module$exports$Blockly$Dart.dartGenerator.ORDER_MULTIPLICATIVE]};var module$exports$Blockly$Dart$loops={},module$contents$Blockly$Dart$loops_stringUtils=$.module$build$src$core$utils$string,module$contents$Blockly$Dart$loops_NameType=$.NameType$$module$build$src$core$names;
|
||||
module$exports$Blockly$Dart.dartGenerator.controls_repeat_ext=function(a){let b;b=a.getField("TIMES")?String(Number(a.getFieldValue("TIMES"))):module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"TIMES",module$exports$Blockly$Dart.dartGenerator.ORDER_ASSIGNMENT)||"0";let c=module$exports$Blockly$Dart.dartGenerator.statementToCode(a,"DO");c=module$exports$Blockly$Dart.dartGenerator.addLoopTrap(c,a);a="";const d=module$exports$Blockly$Dart.dartGenerator.nameDB_.getDistinctName("count",$.NameType$$module$build$src$core$names.VARIABLE);
|
||||
let e=b;b.match(/^\w+$/)||$.module$build$src$core$utils$string.isNumber(b)||(e=module$exports$Blockly$Dart.dartGenerator.nameDB_.getDistinctName("repeat_end",$.NameType$$module$build$src$core$names.VARIABLE),a+="var "+e+" = "+b+";\n");return a+("for (int "+d+" = 0; "+d+" < "+e+"; "+d+"++) {\n"+c+"}\n")};module$exports$Blockly$Dart.dartGenerator.controls_repeat=module$exports$Blockly$Dart.dartGenerator.controls_repeat_ext;
|
||||
module$exports$Blockly$Dart.dartGenerator.controls_whileUntil=function(a){const b="UNTIL"===a.getFieldValue("MODE");let c=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"BOOL",b?module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_PREFIX:module$exports$Blockly$Dart.dartGenerator.ORDER_NONE)||"false",d=module$exports$Blockly$Dart.dartGenerator.statementToCode(a,"DO");d=module$exports$Blockly$Dart.dartGenerator.addLoopTrap(d,a);b&&(c="!"+c);return"while ("+c+") {\n"+d+"}\n"};
|
||||
module$exports$Blockly$Dart.dartGenerator.controls_for=function(a){var b=module$exports$Blockly$Dart.dartGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE),c=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"FROM",module$exports$Blockly$Dart.dartGenerator.ORDER_ASSIGNMENT)||"0",d=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"TO",module$exports$Blockly$Dart.dartGenerator.ORDER_ASSIGNMENT)||"0";const e=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,
|
||||
"BY",module$exports$Blockly$Dart.dartGenerator.ORDER_ASSIGNMENT)||"1";let f=module$exports$Blockly$Dart.dartGenerator.statementToCode(a,"DO");f=module$exports$Blockly$Dart.dartGenerator.addLoopTrap(f,a);if($.module$build$src$core$utils$string.isNumber(c)&&$.module$build$src$core$utils$string.isNumber(d)&&$.module$build$src$core$utils$string.isNumber(e)){var g=Number(c)<=Number(d);a="for ("+b+" = "+c+"; "+b+(g?" <= ":" >= ")+d+"; "+b;b=Math.abs(Number(e));a=1===b?a+(g?"++":"--"):a+((g?" += ":" -= ")+
|
||||
b);a+=") {\n"+f+"}\n"}else a="",g=c,c.match(/^\w+$/)||$.module$build$src$core$utils$string.isNumber(c)||(g=module$exports$Blockly$Dart.dartGenerator.nameDB_.getDistinctName(b+"_start",$.NameType$$module$build$src$core$names.VARIABLE),a+="var "+g+" = "+c+";\n"),c=d,d.match(/^\w+$/)||$.module$build$src$core$utils$string.isNumber(d)||(c=module$exports$Blockly$Dart.dartGenerator.nameDB_.getDistinctName(b+"_end",$.NameType$$module$build$src$core$names.VARIABLE),a+="var "+c+" = "+d+";\n"),d=module$exports$Blockly$Dart.dartGenerator.nameDB_.getDistinctName(b+
|
||||
"_inc",$.NameType$$module$build$src$core$names.VARIABLE),a+="num "+d+" = ",a=$.module$build$src$core$utils$string.isNumber(e)?a+(Math.abs(e)+";\n"):a+("("+e+").abs();\n"),a+="if ("+g+" > "+c+") {\n",a+=module$exports$Blockly$Dart.dartGenerator.INDENT+d+" = -"+d+";\n",a=a+"}\nfor ("+(b+" = "+g+"; "+d+" >= 0 ? "+b+" <= "+c+" : "+b+" >= "+c+"; "+b+" += "+d+") {\n"+f+"}\n");return a};
|
||||
module$exports$Blockly$Dart.dartGenerator.controls_forEach=function(a){const b=module$exports$Blockly$Dart.dartGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE),c=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"LIST",module$exports$Blockly$Dart.dartGenerator.ORDER_ASSIGNMENT)||"[]";let d=module$exports$Blockly$Dart.dartGenerator.statementToCode(a,"DO");d=module$exports$Blockly$Dart.dartGenerator.addLoopTrap(d,a);return"for (var "+b+" in "+
|
||||
c+") {\n"+d+"}\n"};
|
||||
module$exports$Blockly$Dart.dartGenerator.controls_flow_statements=function(a){let b="";module$exports$Blockly$Dart.dartGenerator.STATEMENT_PREFIX&&(b+=module$exports$Blockly$Dart.dartGenerator.injectId(module$exports$Blockly$Dart.dartGenerator.STATEMENT_PREFIX,a));module$exports$Blockly$Dart.dartGenerator.STATEMENT_SUFFIX&&(b+=module$exports$Blockly$Dart.dartGenerator.injectId(module$exports$Blockly$Dart.dartGenerator.STATEMENT_SUFFIX,a));if(module$exports$Blockly$Dart.dartGenerator.STATEMENT_PREFIX){const c=a.getSurroundLoop();
|
||||
c&&!c.suppressPrefixSuffix&&(b+=module$exports$Blockly$Dart.dartGenerator.injectId(module$exports$Blockly$Dart.dartGenerator.STATEMENT_PREFIX,c))}switch(a.getFieldValue("FLOW")){case "BREAK":return b+"break;\n";case "CONTINUE":return b+"continue;\n"}throw Error("Unknown flow statement.");};var module$exports$Blockly$Dart$logic={};
|
||||
module$exports$Blockly$Dart.dartGenerator.controls_if=function(a){let b=0,c="",d,e;module$exports$Blockly$Dart.dartGenerator.STATEMENT_PREFIX&&(c+=module$exports$Blockly$Dart.dartGenerator.injectId(module$exports$Blockly$Dart.dartGenerator.STATEMENT_PREFIX,a));do e=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"IF"+b,module$exports$Blockly$Dart.dartGenerator.ORDER_NONE)||"false",d=module$exports$Blockly$Dart.dartGenerator.statementToCode(a,"DO"+b),module$exports$Blockly$Dart.dartGenerator.STATEMENT_SUFFIX&&
|
||||
(d=module$exports$Blockly$Dart.dartGenerator.prefixLines(module$exports$Blockly$Dart.dartGenerator.injectId(module$exports$Blockly$Dart.dartGenerator.STATEMENT_SUFFIX,a),module$exports$Blockly$Dart.dartGenerator.INDENT)+d),c+=(0<b?"else ":"")+"if ("+e+") {\n"+d+"}",b++;while(a.getInput("IF"+b));if(a.getInput("ELSE")||module$exports$Blockly$Dart.dartGenerator.STATEMENT_SUFFIX)d=module$exports$Blockly$Dart.dartGenerator.statementToCode(a,"ELSE"),module$exports$Blockly$Dart.dartGenerator.STATEMENT_SUFFIX&&
|
||||
(d=module$exports$Blockly$Dart.dartGenerator.prefixLines(module$exports$Blockly$Dart.dartGenerator.injectId(module$exports$Blockly$Dart.dartGenerator.STATEMENT_SUFFIX,a),module$exports$Blockly$Dart.dartGenerator.INDENT)+d),c+=" else {\n"+d+"}";return c+"\n"};module$exports$Blockly$Dart.dartGenerator.controls_ifelse=module$exports$Blockly$Dart.dartGenerator.controls_if;
|
||||
module$exports$Blockly$Dart.dartGenerator.logic_compare=function(a){const b={EQ:"==",NEQ:"!=",LT:"<",LTE:"<=",GT:">",GTE:">="}[a.getFieldValue("OP")],c="=="===b||"!="===b?module$exports$Blockly$Dart.dartGenerator.ORDER_EQUALITY:module$exports$Blockly$Dart.dartGenerator.ORDER_RELATIONAL,d=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"A",c)||"0";a=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"B",c)||"0";return[d+" "+b+" "+a,c]};
|
||||
module$exports$Blockly$Dart.dartGenerator.logic_operation=function(a){const b="AND"===a.getFieldValue("OP")?"&&":"||",c="&&"===b?module$exports$Blockly$Dart.dartGenerator.ORDER_LOGICAL_AND:module$exports$Blockly$Dart.dartGenerator.ORDER_LOGICAL_OR;let d=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"A",c);a=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"B",c);if(d||a){const e="&&"===b?"true":"false";d||(d=e);a||(a=e)}else a=d="false";return[d+" "+b+" "+a,c]};
|
||||
module$exports$Blockly$Dart.dartGenerator.logic_negate=function(a){const b=module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_PREFIX;return["!"+(module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"BOOL",b)||"true"),b]};module$exports$Blockly$Dart.dartGenerator.logic_boolean=function(a){return["TRUE"===a.getFieldValue("BOOL")?"true":"false",module$exports$Blockly$Dart.dartGenerator.ORDER_ATOMIC]};module$exports$Blockly$Dart.dartGenerator.logic_null=function(a){return["null",module$exports$Blockly$Dart.dartGenerator.ORDER_ATOMIC]};
|
||||
module$exports$Blockly$Dart.dartGenerator.logic_ternary=function(a){const b=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"IF",module$exports$Blockly$Dart.dartGenerator.ORDER_CONDITIONAL)||"false",c=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"THEN",module$exports$Blockly$Dart.dartGenerator.ORDER_CONDITIONAL)||"null";a=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"ELSE",module$exports$Blockly$Dart.dartGenerator.ORDER_CONDITIONAL)||"null";return[b+" ? "+c+" : "+a,module$exports$Blockly$Dart.dartGenerator.ORDER_CONDITIONAL]};var module$exports$Blockly$Dart$lists={},module$contents$Blockly$Dart$lists_NameType=$.NameType$$module$build$src$core$names;module$exports$Blockly$Dart.dartGenerator.addReservedWords("Math");module$exports$Blockly$Dart.dartGenerator.lists_create_empty=function(a){return["[]",module$exports$Blockly$Dart.dartGenerator.ORDER_ATOMIC]};
|
||||
module$exports$Blockly$Dart.dartGenerator.lists_create_with=function(a){const b=Array(a.itemCount_);for(let c=0;c<a.itemCount_;c++)b[c]=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"ADD"+c,module$exports$Blockly$Dart.dartGenerator.ORDER_NONE)||"null";return["["+b.join(", ")+"]",module$exports$Blockly$Dart.dartGenerator.ORDER_ATOMIC]};
|
||||
module$exports$Blockly$Dart.dartGenerator.lists_repeat=function(a){const b=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"ITEM",module$exports$Blockly$Dart.dartGenerator.ORDER_NONE)||"null";return["new List.filled("+(module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"NUM",module$exports$Blockly$Dart.dartGenerator.ORDER_NONE)||"0")+", "+b+")",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX]};
|
||||
module$exports$Blockly$Dart.dartGenerator.lists_length=function(a){return[(module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX)||"[]")+".length",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX]};
|
||||
module$exports$Blockly$Dart.dartGenerator.lists_isEmpty=function(a){return[(module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX)||"[]")+".isEmpty",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX]};
|
||||
module$exports$Blockly$Dart.dartGenerator.lists_indexOf=function(a){var b="FIRST"===a.getFieldValue("END")?"indexOf":"lastIndexOf";const c=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"FIND",module$exports$Blockly$Dart.dartGenerator.ORDER_NONE)||"''";b=(module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX)||"[]")+"."+b+"("+c+")";return a.workspace.options.oneBasedIndex?[b+" + 1",module$exports$Blockly$Dart.dartGenerator.ORDER_ADDITIVE]:
|
||||
[b,module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX]};
|
||||
module$exports$Blockly$Dart.dartGenerator.lists_getIndex=function(a){function b(){const f=module$exports$Blockly$Dart.dartGenerator.nameDB_.getDistinctName("tmp_list",$.NameType$$module$build$src$core$names.VARIABLE),g="List "+f+" = "+e+";\n";e=f;return g}var c=a.getFieldValue("MODE")||"GET";const d=a.getFieldValue("WHERE")||"FROM_START";let e=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"VALUE","RANDOM"===d||"FROM_END"===d?module$exports$Blockly$Dart.dartGenerator.ORDER_NONE:module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX)||
|
||||
"[]";if(("RANDOM"!==d||"REMOVE"!==c)&&"FROM_END"!==d||e.match(/^\w+$/))switch(d){case "FIRST":if("GET"===c)return[e+".first",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX];if("GET_REMOVE"===c)return[e+".removeAt(0)",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX];if("REMOVE"===c)return e+".removeAt(0);\n";break;case "LAST":if("GET"===c)return[e+".last",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX];if("GET_REMOVE"===c)return[e+".removeLast()",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX];
|
||||
if("REMOVE"===c)return e+".removeLast();\n";break;case "FROM_START":a=module$exports$Blockly$Dart.dartGenerator.getAdjusted(a,"AT");if("GET"===c)return[e+"["+a+"]",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX];if("GET_REMOVE"===c)return[e+".removeAt("+a+")",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX];if("REMOVE"===c)return e+".removeAt("+a+");\n";break;case "FROM_END":a=module$exports$Blockly$Dart.dartGenerator.getAdjusted(a,"AT",1,!1,module$exports$Blockly$Dart.dartGenerator.ORDER_ADDITIVE);
|
||||
if("GET"===c)return[e+"["+e+".length - "+a+"]",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX];if("GET_REMOVE"===c||"REMOVE"===c){a=e+".removeAt("+e+".length - "+a+")";if("GET_REMOVE"===c)return[a,module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX];if("REMOVE"===c)return a+";\n"}break;case "RANDOM":module$exports$Blockly$Dart.dartGenerator.definitions_.import_dart_math="import 'dart:math' as Math;";if("REMOVE"===c)return c=module$exports$Blockly$Dart.dartGenerator.nameDB_.getDistinctName("tmp_x",
|
||||
$.NameType$$module$build$src$core$names.VARIABLE),"int "+c+" = new Math.Random().nextInt("+e+".length);\n"+(e+".removeAt("+c+");\n");if("GET"===c)return[module$exports$Blockly$Dart.dartGenerator.provideFunction_("lists_get_random_item",`
|
||||
dynamic ${module$exports$Blockly$Dart.dartGenerator.FUNCTION_NAME_PLACEHOLDER_}(List my_list) {
|
||||
int x = new Math.Random().nextInt(my_list.length);
|
||||
return my_list[x];
|
||||
}
|
||||
`)+"("+e+")",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX];if("GET_REMOVE"===c)return[module$exports$Blockly$Dart.dartGenerator.provideFunction_("lists_remove_random_item",`
|
||||
dynamic ${module$exports$Blockly$Dart.dartGenerator.FUNCTION_NAME_PLACEHOLDER_}(List my_list) {
|
||||
int x = new Math.Random().nextInt(my_list.length);
|
||||
return my_list.removeAt(x);
|
||||
}
|
||||
`)+"("+e+")",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX]}else{if("RANDOM"===d)return module$exports$Blockly$Dart.dartGenerator.definitions_.import_dart_math="import 'dart:math' as Math;",c=b(),a=module$exports$Blockly$Dart.dartGenerator.nameDB_.getDistinctName("tmp_x",$.NameType$$module$build$src$core$names.VARIABLE),c+("int "+a+" = new Math.Random().nextInt("+e+".length);\n")+(e+".removeAt("+a+");\n");if("REMOVE"===c)return c=module$exports$Blockly$Dart.dartGenerator.getAdjusted(a,
|
||||
"AT",1,!1,module$exports$Blockly$Dart.dartGenerator.ORDER_ADDITIVE),b()+(e+".removeAt("+e+".length - "+c+");\n");if("GET"===c)return c=module$exports$Blockly$Dart.dartGenerator.getAdjusted(a,"AT",1),[module$exports$Blockly$Dart.dartGenerator.provideFunction_("lists_get_from_end",`
|
||||
dynamic ${module$exports$Blockly$Dart.dartGenerator.FUNCTION_NAME_PLACEHOLDER_}(List my_list, num x) {
|
||||
x = my_list.length - x;
|
||||
return my_list[x];
|
||||
}
|
||||
`)+"("+e+", "+c+")",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX];if("GET_REMOVE"===c)return c=module$exports$Blockly$Dart.dartGenerator.getAdjusted(a,"AT",1),[module$exports$Blockly$Dart.dartGenerator.provideFunction_("lists_remove_from_end",`
|
||||
dynamic ${module$exports$Blockly$Dart.dartGenerator.FUNCTION_NAME_PLACEHOLDER_}(List my_list, num x) {
|
||||
x = my_list.length - x;
|
||||
return my_list.removeAt(x);
|
||||
}
|
||||
`)+"("+e+", "+c+")",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX]}throw Error("Unhandled combination (lists_getIndex).");};
|
||||
module$exports$Blockly$Dart.dartGenerator.lists_setIndex=function(a){function b(){if(e.match(/^\w+$/))return"";const g=module$exports$Blockly$Dart.dartGenerator.nameDB_.getDistinctName("tmp_list",$.NameType$$module$build$src$core$names.VARIABLE),h="List "+g+" = "+e+";\n";e=g;return h}const c=a.getFieldValue("MODE")||"GET";var d=a.getFieldValue("WHERE")||"FROM_START";let e=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"LIST",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX)||
|
||||
"[]";const f=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"TO",module$exports$Blockly$Dart.dartGenerator.ORDER_ASSIGNMENT)||"null";switch(d){case "FIRST":if("SET"===c)return e+"[0] = "+f+";\n";if("INSERT"===c)return e+".insert(0, "+f+");\n";break;case "LAST":if("SET"===c)return b()+(e+"["+e+".length - 1] = "+f+";\n");if("INSERT"===c)return e+".add("+f+");\n";break;case "FROM_START":a=module$exports$Blockly$Dart.dartGenerator.getAdjusted(a,"AT");if("SET"===c)return e+"["+a+"] = "+f+";\n";
|
||||
if("INSERT"===c)return e+".insert("+a+", "+f+");\n";break;case "FROM_END":a=module$exports$Blockly$Dart.dartGenerator.getAdjusted(a,"AT",1,!1,module$exports$Blockly$Dart.dartGenerator.ORDER_ADDITIVE);d=b();if("SET"===c)return d+(e+"["+e+".length - "+a+"] = "+f+";\n");if("INSERT"===c)return d+(e+".insert("+e+".length - "+a+", "+f+");\n");break;case "RANDOM":module$exports$Blockly$Dart.dartGenerator.definitions_.import_dart_math="import 'dart:math' as Math;";a=b();d=module$exports$Blockly$Dart.dartGenerator.nameDB_.getDistinctName("tmp_x",
|
||||
$.NameType$$module$build$src$core$names.VARIABLE);a+="int "+d+" = new Math.Random().nextInt("+e+".length);\n";if("SET"===c)return a+(e+"["+d+"] = "+f+";\n");if("INSERT"===c)return a+(e+".insert("+d+", "+f+");\n")}throw Error("Unhandled combination (lists_setIndex).");};
|
||||
module$exports$Blockly$Dart.dartGenerator.lists_getSublist=function(a){var b=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"LIST",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX)||"[]",c=a.getFieldValue("WHERE1");const d=a.getFieldValue("WHERE2");if(b.match(/^\w+$/)||"FROM_END"!==c&&"FROM_START"===d){switch(c){case "FROM_START":c=module$exports$Blockly$Dart.dartGenerator.getAdjusted(a,"AT1");break;case "FROM_END":c=module$exports$Blockly$Dart.dartGenerator.getAdjusted(a,"AT1",
|
||||
1,!1,module$exports$Blockly$Dart.dartGenerator.ORDER_ADDITIVE);c=b+".length - "+c;break;case "FIRST":c="0";break;default:throw Error("Unhandled option (lists_getSublist).");}switch(d){case "FROM_START":var e=module$exports$Blockly$Dart.dartGenerator.getAdjusted(a,"AT2",1);break;case "FROM_END":e=module$exports$Blockly$Dart.dartGenerator.getAdjusted(a,"AT2",0,!1,module$exports$Blockly$Dart.dartGenerator.ORDER_ADDITIVE);e=b+".length - "+e;break;case "LAST":break;default:throw Error("Unhandled option (lists_getSublist).");
|
||||
}b="LAST"===d?b+".sublist("+c+")":b+".sublist("+c+", "+e+")"}else e=module$exports$Blockly$Dart.dartGenerator.getAdjusted(a,"AT1"),a=module$exports$Blockly$Dart.dartGenerator.getAdjusted(a,"AT2"),b=module$exports$Blockly$Dart.dartGenerator.provideFunction_("lists_get_sublist",`
|
||||
List ${module$exports$Blockly$Dart.dartGenerator.FUNCTION_NAME_PLACEHOLDER_}(List list, String where1, num at1, String where2, num at2) {
|
||||
int getAt(String where, num at) {
|
||||
if (where == 'FROM_END') {
|
||||
at = list.length - 1 - at;
|
||||
} else if (where == 'FIRST') {
|
||||
at = 0;
|
||||
} else if (where == 'LAST') {
|
||||
at = list.length - 1;
|
||||
} else if (where != 'FROM_START') {
|
||||
throw 'Unhandled option (lists_getSublist).';
|
||||
}
|
||||
return at;
|
||||
}
|
||||
at1 = getAt(where1, at1);
|
||||
at2 = getAt(where2, at2) + 1;
|
||||
return list.sublist(at1, at2);
|
||||
}
|
||||
`)+"("+b+", '"+c+"', "+e+", '"+d+"', "+a+")";return[b,module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX]};module$exports$Blockly$Dart.dartGenerator.lists_sort=function(a){const b=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"LIST",module$exports$Blockly$Dart.dartGenerator.ORDER_NONE)||"[]",c="1"===a.getFieldValue("DIRECTION")?1:-1;a=a.getFieldValue("TYPE");return[module$exports$Blockly$Dart.dartGenerator.provideFunction_("lists_sort",`
|
||||
List ${module$exports$Blockly$Dart.dartGenerator.FUNCTION_NAME_PLACEHOLDER_}(List list, String type, int direction) {
|
||||
var compareFuncs = {
|
||||
'NUMERIC': (a, b) => (direction * a.compareTo(b)).toInt(),
|
||||
'TEXT': (a, b) => direction * a.toString().compareTo(b.toString()),
|
||||
'IGNORE_CASE':
|
||||
(a, b) => direction *
|
||||
a.toString().toLowerCase().compareTo(b.toString().toLowerCase())
|
||||
};
|
||||
list = new List.from(list);
|
||||
var compare = compareFuncs[type];
|
||||
list.sort(compare);
|
||||
return list;
|
||||
}
|
||||
`)+"("+b+', "'+a+'", '+c+")",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX]};
|
||||
module$exports$Blockly$Dart.dartGenerator.lists_split=function(a){let b=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"INPUT",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX);const c=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"DELIM",module$exports$Blockly$Dart.dartGenerator.ORDER_NONE)||"''";a=a.getFieldValue("MODE");if("SPLIT"===a)b||(b="''"),a="split";else if("JOIN"===a)b||(b="[]"),a="join";else throw Error("Unknown mode: "+a);return[b+"."+a+"("+c+")",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX]};
|
||||
module$exports$Blockly$Dart.dartGenerator.lists_reverse=function(a){return["new List.from("+(module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"LIST",module$exports$Blockly$Dart.dartGenerator.ORDER_NONE)||"[]")+".reversed)",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX]};var module$exports$Blockly$Dart$colour={};module$exports$Blockly$Dart.dartGenerator.addReservedWords("Math");module$exports$Blockly$Dart.dartGenerator.colour_picker=function(a){return[module$exports$Blockly$Dart.dartGenerator.quote_(a.getFieldValue("COLOUR")),module$exports$Blockly$Dart.dartGenerator.ORDER_ATOMIC]};
|
||||
module$exports$Blockly$Dart.dartGenerator.colour_random=function(a){module$exports$Blockly$Dart.dartGenerator.definitions_.import_dart_math="import 'dart:math' as Math;";return[module$exports$Blockly$Dart.dartGenerator.provideFunction_("colour_random",`
|
||||
String ${module$exports$Blockly$Dart.dartGenerator.FUNCTION_NAME_PLACEHOLDER_}() {
|
||||
String hex = '0123456789abcdef';
|
||||
var rnd = new Math.Random();
|
||||
return '#\${hex[rnd.nextInt(16)]}\${hex[rnd.nextInt(16)]}'
|
||||
'\${hex[rnd.nextInt(16)]}\${hex[rnd.nextInt(16)]}'
|
||||
'\${hex[rnd.nextInt(16)]}\${hex[rnd.nextInt(16)]}';
|
||||
}
|
||||
`)+"()",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX]};
|
||||
module$exports$Blockly$Dart.dartGenerator.colour_rgb=function(a){const b=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"RED",module$exports$Blockly$Dart.dartGenerator.ORDER_NONE)||0,c=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"GREEN",module$exports$Blockly$Dart.dartGenerator.ORDER_NONE)||0;a=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"BLUE",module$exports$Blockly$Dart.dartGenerator.ORDER_NONE)||0;module$exports$Blockly$Dart.dartGenerator.definitions_.import_dart_math=
|
||||
"import 'dart:math' as Math;";return[module$exports$Blockly$Dart.dartGenerator.provideFunction_("colour_rgb",`
|
||||
String ${module$exports$Blockly$Dart.dartGenerator.FUNCTION_NAME_PLACEHOLDER_}(num r, num g, num b) {
|
||||
num rn = (Math.max(Math.min(r, 100), 0) * 2.55).round();
|
||||
String rs = rn.toInt().toRadixString(16);
|
||||
rs = '0$rs';
|
||||
rs = rs.substring(rs.length - 2);
|
||||
num gn = (Math.max(Math.min(g, 100), 0) * 2.55).round();
|
||||
String gs = gn.toInt().toRadixString(16);
|
||||
gs = '0$gs';
|
||||
gs = gs.substring(gs.length - 2);
|
||||
num bn = (Math.max(Math.min(b, 100), 0) * 2.55).round();
|
||||
String bs = bn.toInt().toRadixString(16);
|
||||
bs = '0$bs';
|
||||
bs = bs.substring(bs.length - 2);
|
||||
return '#$rs$gs$bs';
|
||||
}
|
||||
`)+"("+b+", "+c+", "+a+")",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX]};
|
||||
module$exports$Blockly$Dart.dartGenerator.colour_blend=function(a){const b=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"COLOUR1",module$exports$Blockly$Dart.dartGenerator.ORDER_NONE)||"'#000000'",c=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"COLOUR2",module$exports$Blockly$Dart.dartGenerator.ORDER_NONE)||"'#000000'";a=module$exports$Blockly$Dart.dartGenerator.valueToCode(a,"RATIO",module$exports$Blockly$Dart.dartGenerator.ORDER_NONE)||.5;module$exports$Blockly$Dart.dartGenerator.definitions_.import_dart_math=
|
||||
"import 'dart:math' as Math;";return[module$exports$Blockly$Dart.dartGenerator.provideFunction_("colour_blend",`
|
||||
String ${module$exports$Blockly$Dart.dartGenerator.FUNCTION_NAME_PLACEHOLDER_}(String c1, String c2, num ratio) {
|
||||
ratio = Math.max(Math.min(ratio, 1), 0);
|
||||
int r1 = int.parse('0x\${c1.substring(1, 3)}');
|
||||
int g1 = int.parse('0x\${c1.substring(3, 5)}');
|
||||
int b1 = int.parse('0x\${c1.substring(5, 7)}');
|
||||
int r2 = int.parse('0x\${c2.substring(1, 3)}');
|
||||
int g2 = int.parse('0x\${c2.substring(3, 5)}');
|
||||
int b2 = int.parse('0x\${c2.substring(5, 7)}');
|
||||
num rn = (r1 * (1 - ratio) + r2 * ratio).round();
|
||||
String rs = rn.toInt().toRadixString(16);
|
||||
num gn = (g1 * (1 - ratio) + g2 * ratio).round();
|
||||
String gs = gn.toInt().toRadixString(16);
|
||||
num bn = (b1 * (1 - ratio) + b2 * ratio).round();
|
||||
String bs = bn.toInt().toRadixString(16);
|
||||
rs = '0$rs';
|
||||
rs = rs.substring(rs.length - 2);
|
||||
gs = '0$gs';
|
||||
gs = gs.substring(gs.length - 2);
|
||||
bs = '0$bs';
|
||||
bs = bs.substring(bs.length - 2);
|
||||
return '#$rs$gs$bs';
|
||||
}
|
||||
`)+"("+b+", "+c+", "+a+")",module$exports$Blockly$Dart.dartGenerator.ORDER_UNARY_POSTFIX]};var module$exports$Blockly$Dart$all=module$exports$Blockly$Dart;
|
||||
module$exports$Blockly$Dart.__namespace__=$;
|
||||
return module$exports$Blockly$Dart;
|
||||
}));
|
||||
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
+314
-104
@@ -8,113 +8,323 @@
|
||||
module.exports = factory(require("./blockly_compressed.js"));
|
||||
} else { // Browser
|
||||
var factoryExports = factory(root.Blockly);
|
||||
root.Blockly.JavaScript = factoryExports;
|
||||
root.Blockly.JavaScript = factoryExports.javascriptGenerator;
|
||||
root.Blockly.JavaScript.__namespace__ = factoryExports.__namespace__;
|
||||
}
|
||||
}(this, function(__parent__) {
|
||||
var $=__parent__.__namespace__;
|
||||
var module$contents$Blockly$JavaScript_JavaScript=new $.module$exports$Blockly$Generator.Generator("JavaScript");module$contents$Blockly$JavaScript_JavaScript.addReservedWords("break,case,catch,class,const,continue,debugger,default,delete,do,else,export,extends,finally,for,function,if,import,in,instanceof,new,return,super,switch,this,throw,try,typeof,var,void,while,with,yield,enum,implements,interface,let,package,private,protected,public,static,await,null,true,false,arguments,"+Object.getOwnPropertyNames($.module$exports$Blockly$utils$global.globalThis).join(","));
|
||||
module$contents$Blockly$JavaScript_JavaScript.ORDER_ATOMIC=0;module$contents$Blockly$JavaScript_JavaScript.ORDER_NEW=1.1;module$contents$Blockly$JavaScript_JavaScript.ORDER_MEMBER=1.2;module$contents$Blockly$JavaScript_JavaScript.ORDER_FUNCTION_CALL=2;module$contents$Blockly$JavaScript_JavaScript.ORDER_INCREMENT=3;module$contents$Blockly$JavaScript_JavaScript.ORDER_DECREMENT=3;module$contents$Blockly$JavaScript_JavaScript.ORDER_BITWISE_NOT=4.1;
|
||||
module$contents$Blockly$JavaScript_JavaScript.ORDER_UNARY_PLUS=4.2;module$contents$Blockly$JavaScript_JavaScript.ORDER_UNARY_NEGATION=4.3;module$contents$Blockly$JavaScript_JavaScript.ORDER_LOGICAL_NOT=4.4;module$contents$Blockly$JavaScript_JavaScript.ORDER_TYPEOF=4.5;module$contents$Blockly$JavaScript_JavaScript.ORDER_VOID=4.6;module$contents$Blockly$JavaScript_JavaScript.ORDER_DELETE=4.7;module$contents$Blockly$JavaScript_JavaScript.ORDER_AWAIT=4.8;
|
||||
module$contents$Blockly$JavaScript_JavaScript.ORDER_EXPONENTIATION=5;module$contents$Blockly$JavaScript_JavaScript.ORDER_MULTIPLICATION=5.1;module$contents$Blockly$JavaScript_JavaScript.ORDER_DIVISION=5.2;module$contents$Blockly$JavaScript_JavaScript.ORDER_MODULUS=5.3;module$contents$Blockly$JavaScript_JavaScript.ORDER_SUBTRACTION=6.1;module$contents$Blockly$JavaScript_JavaScript.ORDER_ADDITION=6.2;module$contents$Blockly$JavaScript_JavaScript.ORDER_BITWISE_SHIFT=7;
|
||||
module$contents$Blockly$JavaScript_JavaScript.ORDER_RELATIONAL=8;module$contents$Blockly$JavaScript_JavaScript.ORDER_IN=8;module$contents$Blockly$JavaScript_JavaScript.ORDER_INSTANCEOF=8;module$contents$Blockly$JavaScript_JavaScript.ORDER_EQUALITY=9;module$contents$Blockly$JavaScript_JavaScript.ORDER_BITWISE_AND=10;module$contents$Blockly$JavaScript_JavaScript.ORDER_BITWISE_XOR=11;module$contents$Blockly$JavaScript_JavaScript.ORDER_BITWISE_OR=12;
|
||||
module$contents$Blockly$JavaScript_JavaScript.ORDER_LOGICAL_AND=13;module$contents$Blockly$JavaScript_JavaScript.ORDER_LOGICAL_OR=14;module$contents$Blockly$JavaScript_JavaScript.ORDER_CONDITIONAL=15;module$contents$Blockly$JavaScript_JavaScript.ORDER_ASSIGNMENT=16;module$contents$Blockly$JavaScript_JavaScript.ORDER_YIELD=17;module$contents$Blockly$JavaScript_JavaScript.ORDER_COMMA=18;module$contents$Blockly$JavaScript_JavaScript.ORDER_NONE=99;
|
||||
module$contents$Blockly$JavaScript_JavaScript.ORDER_OVERRIDES=[[module$contents$Blockly$JavaScript_JavaScript.ORDER_FUNCTION_CALL,module$contents$Blockly$JavaScript_JavaScript.ORDER_MEMBER],[module$contents$Blockly$JavaScript_JavaScript.ORDER_FUNCTION_CALL,module$contents$Blockly$JavaScript_JavaScript.ORDER_FUNCTION_CALL],[module$contents$Blockly$JavaScript_JavaScript.ORDER_MEMBER,module$contents$Blockly$JavaScript_JavaScript.ORDER_MEMBER],[module$contents$Blockly$JavaScript_JavaScript.ORDER_MEMBER,
|
||||
module$contents$Blockly$JavaScript_JavaScript.ORDER_FUNCTION_CALL],[module$contents$Blockly$JavaScript_JavaScript.ORDER_LOGICAL_NOT,module$contents$Blockly$JavaScript_JavaScript.ORDER_LOGICAL_NOT],[module$contents$Blockly$JavaScript_JavaScript.ORDER_MULTIPLICATION,module$contents$Blockly$JavaScript_JavaScript.ORDER_MULTIPLICATION],[module$contents$Blockly$JavaScript_JavaScript.ORDER_ADDITION,module$contents$Blockly$JavaScript_JavaScript.ORDER_ADDITION],[module$contents$Blockly$JavaScript_JavaScript.ORDER_LOGICAL_AND,
|
||||
module$contents$Blockly$JavaScript_JavaScript.ORDER_LOGICAL_AND],[module$contents$Blockly$JavaScript_JavaScript.ORDER_LOGICAL_OR,module$contents$Blockly$JavaScript_JavaScript.ORDER_LOGICAL_OR]];module$contents$Blockly$JavaScript_JavaScript.isInitialized=!1;
|
||||
module$contents$Blockly$JavaScript_JavaScript.init=function(a){Object.getPrototypeOf(this).init.call(this);this.nameDB_?this.nameDB_.reset():this.nameDB_=new $.module$exports$Blockly$Names.Names(this.RESERVED_WORDS_);this.nameDB_.setVariableMap(a.getVariableMap());this.nameDB_.populateVariables(a);this.nameDB_.populateProcedures(a);for(var b=[],c=(0,$.module$exports$Blockly$Variables.allDeveloperVariables)(a),d=0;d<c.length;d++)b.push(this.nameDB_.getName(c[d],$.module$exports$Blockly$Names.NameType.DEVELOPER_VARIABLE));
|
||||
a=(0,$.module$exports$Blockly$Variables.allUsedVarModels)(a);for(c=0;c<a.length;c++)b.push(this.nameDB_.getName(a[c].getId(),$.module$exports$Blockly$Names.NameType.VARIABLE));b.length&&(this.definitions_.variables="var "+b.join(", ")+";");this.isInitialized=!0};
|
||||
module$contents$Blockly$JavaScript_JavaScript.finish=function(a){var b=(0,$.module$exports$Blockly$utils$object.values)(this.definitions_);a=Object.getPrototypeOf(this).finish.call(this,a);this.isInitialized=!1;this.nameDB_.reset();return b.join("\n\n")+"\n\n\n"+a};module$contents$Blockly$JavaScript_JavaScript.scrubNakedValue=function(a){return a+";\n"};
|
||||
module$contents$Blockly$JavaScript_JavaScript.quote_=function(a){a=a.replace(/\\/g,"\\\\").replace(/\n/g,"\\\n").replace(/'/g,"\\'");return"'"+a+"'"};module$contents$Blockly$JavaScript_JavaScript.multiline_quote_=function(a){return a.split(/\n/g).map(this.quote_).join(" + '\\n' +\n")};
|
||||
module$contents$Blockly$JavaScript_JavaScript.scrub_=function(a,b,c){var d="";if(!a.outputConnection||!a.outputConnection.targetConnection){var e=a.getCommentText();e&&(e=(0,$.module$exports$Blockly$utils$string.wrap)(e,this.COMMENT_WRAP-3),d+=this.prefixLines(e+"\n","// "));for(var f=0;f<a.inputList.length;f++)a.inputList[f].type===$.module$exports$Blockly$inputTypes.inputTypes.VALUE&&(e=a.inputList[f].connection.targetBlock())&&(e=this.allNestedComments(e))&&(d+=this.prefixLines(e,"// "))}a=a.nextConnection&&
|
||||
a.nextConnection.targetBlock();c=c?"":this.blockToCode(a);return d+b+c};
|
||||
module$contents$Blockly$JavaScript_JavaScript.getAdjusted=function(a,b,c,d,e){c=c||0;e=e||this.ORDER_NONE;a.workspace.options.oneBasedIndex&&c--;var f=a.workspace.options.oneBasedIndex?"1":"0",g=e;if(0<c)var h=g=this.ORDER_ADDITION;else 0>c?h=g=this.ORDER_SUBTRACTION:d&&(h=g=this.ORDER_UNARY_NEGATION);a=this.valueToCode(a,b,g)||f;(0,$.module$exports$Blockly$utils$string.isNumber)(a)?(a=Number(a)+c,d&&(a=-a)):(0<c?a=a+" + "+c:0>c&&(a=a+" - "+-c),d&&(a=c?"-("+a+")":"-"+a),h=Math.floor(h),e=Math.floor(e),
|
||||
h&&e>=h&&(a="("+a+")"));return a};$.Blockly.JavaScript=module$contents$Blockly$JavaScript_JavaScript;var module$exports$Blockly$JavaScript$variables={};$.Blockly.JavaScript.variables_get=function(a){return[$.Blockly.JavaScript.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE),$.Blockly.JavaScript.ORDER_ATOMIC]};
|
||||
$.Blockly.JavaScript.variables_set=function(a){var b=$.Blockly.JavaScript.valueToCode(a,"VALUE",$.Blockly.JavaScript.ORDER_ASSIGNMENT)||"0";return $.Blockly.JavaScript.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE)+" = "+b+";\n"};var module$exports$Blockly$JavaScript$variablesDynamic={};$.Blockly.JavaScript.variables_get_dynamic=$.Blockly.JavaScript.variables_get;$.Blockly.JavaScript.variables_set_dynamic=$.Blockly.JavaScript.variables_set;var module$exports$Blockly$JavaScript$texts={},module$contents$Blockly$JavaScript$texts_strRegExp=/^\s*'([^']|\\')*'\s*$/,module$contents$Blockly$JavaScript$texts_forceString=function(a){return module$contents$Blockly$JavaScript$texts_strRegExp.test(a)?[a,$.Blockly.JavaScript.ORDER_ATOMIC]:["String("+a+")",$.Blockly.JavaScript.ORDER_FUNCTION_CALL]},module$contents$Blockly$JavaScript$texts_getSubstringIndex=function(a,b,c){return"FIRST"===b?"0":"FROM_END"===b?a+".length - 1 - "+c:"LAST"===b?a+".length - 1":
|
||||
c};$.Blockly.JavaScript.text=function(a){return[$.Blockly.JavaScript.quote_(a.getFieldValue("TEXT")),$.Blockly.JavaScript.ORDER_ATOMIC]};$.Blockly.JavaScript.text_multiline=function(a){a=$.Blockly.JavaScript.multiline_quote_(a.getFieldValue("TEXT"));var b=-1!==a.indexOf("+")?$.Blockly.JavaScript.ORDER_ADDITION:$.Blockly.JavaScript.ORDER_ATOMIC;return[a,b]};
|
||||
$.Blockly.JavaScript.text_join=function(a){switch(a.itemCount_){case 0:return["''",$.Blockly.JavaScript.ORDER_ATOMIC];case 1:return a=$.Blockly.JavaScript.valueToCode(a,"ADD0",$.Blockly.JavaScript.ORDER_NONE)||"''",module$contents$Blockly$JavaScript$texts_forceString(a);case 2:var b=$.Blockly.JavaScript.valueToCode(a,"ADD0",$.Blockly.JavaScript.ORDER_NONE)||"''";a=$.Blockly.JavaScript.valueToCode(a,"ADD1",$.Blockly.JavaScript.ORDER_NONE)||"''";return[module$contents$Blockly$JavaScript$texts_forceString(b)[0]+
|
||||
" + "+module$contents$Blockly$JavaScript$texts_forceString(a)[0],$.Blockly.JavaScript.ORDER_ADDITION];default:b=Array(a.itemCount_);for(var c=0;c<a.itemCount_;c++)b[c]=$.Blockly.JavaScript.valueToCode(a,"ADD"+c,$.Blockly.JavaScript.ORDER_NONE)||"''";return["["+b.join(",")+"].join('')",$.Blockly.JavaScript.ORDER_FUNCTION_CALL]}};
|
||||
$.Blockly.JavaScript.text_append=function(a){var b=$.Blockly.JavaScript.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE);a=$.Blockly.JavaScript.valueToCode(a,"TEXT",$.Blockly.JavaScript.ORDER_NONE)||"''";return b+" += "+module$contents$Blockly$JavaScript$texts_forceString(a)[0]+";\n"};$.Blockly.JavaScript.text_length=function(a){return[($.Blockly.JavaScript.valueToCode(a,"VALUE",$.Blockly.JavaScript.ORDER_MEMBER)||"''")+".length",$.Blockly.JavaScript.ORDER_MEMBER]};
|
||||
$.Blockly.JavaScript.text_isEmpty=function(a){return["!"+($.Blockly.JavaScript.valueToCode(a,"VALUE",$.Blockly.JavaScript.ORDER_MEMBER)||"''")+".length",$.Blockly.JavaScript.ORDER_LOGICAL_NOT]};
|
||||
$.Blockly.JavaScript.text_indexOf=function(a){var b="FIRST"===a.getFieldValue("END")?"indexOf":"lastIndexOf",c=$.Blockly.JavaScript.valueToCode(a,"FIND",$.Blockly.JavaScript.ORDER_NONE)||"''";b=($.Blockly.JavaScript.valueToCode(a,"VALUE",$.Blockly.JavaScript.ORDER_MEMBER)||"''")+"."+b+"("+c+")";return a.workspace.options.oneBasedIndex?[b+" + 1",$.Blockly.JavaScript.ORDER_ADDITION]:[b,$.Blockly.JavaScript.ORDER_FUNCTION_CALL]};
|
||||
$.Blockly.JavaScript.text_charAt=function(a){var b=a.getFieldValue("WHERE")||"FROM_START",c=$.Blockly.JavaScript.valueToCode(a,"VALUE","RANDOM"===b?$.Blockly.JavaScript.ORDER_NONE:$.Blockly.JavaScript.ORDER_MEMBER)||"''";switch(b){case "FIRST":return[c+".charAt(0)",$.Blockly.JavaScript.ORDER_FUNCTION_CALL];case "LAST":return[c+".slice(-1)",$.Blockly.JavaScript.ORDER_FUNCTION_CALL];case "FROM_START":return a=$.Blockly.JavaScript.getAdjusted(a,"AT"),[c+".charAt("+a+")",$.Blockly.JavaScript.ORDER_FUNCTION_CALL];
|
||||
case "FROM_END":return a=$.Blockly.JavaScript.getAdjusted(a,"AT",1,!0),[c+".slice("+a+").charAt(0)",$.Blockly.JavaScript.ORDER_FUNCTION_CALL];case "RANDOM":return[$.Blockly.JavaScript.provideFunction_("textRandomLetter","\nfunction "+$.Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_+"(text) {\n var x = Math.floor(Math.random() * text.length);\n return text[x];\n}\n")+"("+c+")",$.Blockly.JavaScript.ORDER_FUNCTION_CALL]}throw Error("Unhandled option (text_charAt).");};
|
||||
$.Blockly.JavaScript.text_getSubstring=function(a){var b=a.getFieldValue("WHERE1"),c=a.getFieldValue("WHERE2"),d="FROM_END"!==b&&"LAST"!==b&&"FROM_END"!==c&&"LAST"!==c,e=$.Blockly.JavaScript.valueToCode(a,"STRING",d?$.Blockly.JavaScript.ORDER_MEMBER:$.Blockly.JavaScript.ORDER_NONE)||"''";if("FIRST"===b&&"LAST"===c)return[e,$.Blockly.JavaScript.ORDER_NONE];if(e.match(/^'?\w+'?$/)||d){switch(b){case "FROM_START":b=$.Blockly.JavaScript.getAdjusted(a,"AT1");break;case "FROM_END":b=$.Blockly.JavaScript.getAdjusted(a,
|
||||
"AT1",1,!1,$.Blockly.JavaScript.ORDER_SUBTRACTION);b=e+".length - "+b;break;case "FIRST":b="0";break;default:throw Error("Unhandled option (text_getSubstring).");}switch(c){case "FROM_START":c=$.Blockly.JavaScript.getAdjusted(a,"AT2",1);break;case "FROM_END":c=$.Blockly.JavaScript.getAdjusted(a,"AT2",0,!1,$.Blockly.JavaScript.ORDER_SUBTRACTION);c=e+".length - "+c;break;case "LAST":c=e+".length";break;default:throw Error("Unhandled option (text_getSubstring).");}e=e+".slice("+b+", "+c+")"}else{d=$.Blockly.JavaScript.getAdjusted(a,
|
||||
"AT1");a=$.Blockly.JavaScript.getAdjusted(a,"AT2");var f={FIRST:"First",LAST:"Last",FROM_START:"FromStart",FROM_END:"FromEnd"};e=$.Blockly.JavaScript.provideFunction_("subsequence"+f[b]+f[c],"\nfunction "+$.Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_+"(sequence"+("FROM_END"===b||"FROM_START"===b?", at1":"")+("FROM_END"===c||"FROM_START"===c?", at2":"")+") {\n var start = "+module$contents$Blockly$JavaScript$texts_getSubstringIndex("sequence",b,"at1")+";\n var end = "+module$contents$Blockly$JavaScript$texts_getSubstringIndex("sequence",
|
||||
c,"at2")+" + 1;\n return sequence.slice(start, end);\n}\n")+"("+e+("FROM_END"===b||"FROM_START"===b?", "+d:"")+("FROM_END"===c||"FROM_START"===c?", "+a:"")+")"}return[e,$.Blockly.JavaScript.ORDER_FUNCTION_CALL]};
|
||||
$.Blockly.JavaScript.text_changeCase=function(a){var b={UPPERCASE:".toUpperCase()",LOWERCASE:".toLowerCase()",TITLECASE:null}[a.getFieldValue("CASE")];a=$.Blockly.JavaScript.valueToCode(a,"TEXT",b?$.Blockly.JavaScript.ORDER_MEMBER:$.Blockly.JavaScript.ORDER_NONE)||"''";return[b?a+b:$.Blockly.JavaScript.provideFunction_("textToTitleCase","\nfunction "+$.Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_+"(str) {\n return str.replace(/\\S+/g,\n function(txt) {return txt[0].toUpperCase() + txt.substring(1).toLowerCase();});\n}\n")+
|
||||
"("+a+")",$.Blockly.JavaScript.ORDER_FUNCTION_CALL]};$.Blockly.JavaScript.text_trim=function(a){var b={LEFT:".replace(/^[\\s\\xa0]+/, '')",RIGHT:".replace(/[\\s\\xa0]+$/, '')",BOTH:".trim()"}[a.getFieldValue("MODE")];return[($.Blockly.JavaScript.valueToCode(a,"TEXT",$.Blockly.JavaScript.ORDER_MEMBER)||"''")+b,$.Blockly.JavaScript.ORDER_FUNCTION_CALL]};
|
||||
$.Blockly.JavaScript.text_print=function(a){return"window.alert("+($.Blockly.JavaScript.valueToCode(a,"TEXT",$.Blockly.JavaScript.ORDER_NONE)||"''")+");\n"};$.Blockly.JavaScript.text_prompt_ext=function(a){var b="window.prompt("+(a.getField("TEXT")?$.Blockly.JavaScript.quote_(a.getFieldValue("TEXT")):$.Blockly.JavaScript.valueToCode(a,"TEXT",$.Blockly.JavaScript.ORDER_NONE)||"''")+")";"NUMBER"===a.getFieldValue("TYPE")&&(b="Number("+b+")");return[b,$.Blockly.JavaScript.ORDER_FUNCTION_CALL]};
|
||||
$.Blockly.JavaScript.text_prompt=$.Blockly.JavaScript.text_prompt_ext;
|
||||
$.Blockly.JavaScript.text_count=function(a){var b=$.Blockly.JavaScript.valueToCode(a,"TEXT",$.Blockly.JavaScript.ORDER_NONE)||"''";a=$.Blockly.JavaScript.valueToCode(a,"SUB",$.Blockly.JavaScript.ORDER_NONE)||"''";return[$.Blockly.JavaScript.provideFunction_("textCount","\nfunction "+$.Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_+"(haystack, needle) {\n if (needle.length === 0) {\n return haystack.length + 1;\n } else {\n return haystack.split(needle).length - 1;\n }\n}\n")+"("+b+", "+a+
|
||||
")",$.Blockly.JavaScript.ORDER_FUNCTION_CALL]};
|
||||
$.Blockly.JavaScript.text_replace=function(a){var b=$.Blockly.JavaScript.valueToCode(a,"TEXT",$.Blockly.JavaScript.ORDER_NONE)||"''",c=$.Blockly.JavaScript.valueToCode(a,"FROM",$.Blockly.JavaScript.ORDER_NONE)||"''";a=$.Blockly.JavaScript.valueToCode(a,"TO",$.Blockly.JavaScript.ORDER_NONE)||"''";return[$.Blockly.JavaScript.provideFunction_("textReplace","\nfunction "+$.Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_+"(haystack, needle, replacement) {\n needle = needle.replace(/([-()\\[\\]{}+?*.$\\^|,:#<!\\\\])/g, '\\\\$1')\n .replace(/\\x08/g, '\\\\x08');\n return haystack.replace(new RegExp(needle, 'g'), replacement);\n}\n")+"("+
|
||||
b+", "+c+", "+a+")",$.Blockly.JavaScript.ORDER_FUNCTION_CALL]};$.Blockly.JavaScript.text_reverse=function(a){return[($.Blockly.JavaScript.valueToCode(a,"TEXT",$.Blockly.JavaScript.ORDER_MEMBER)||"''")+".split('').reverse().join('')",$.Blockly.JavaScript.ORDER_FUNCTION_CALL]};var module$exports$Blockly$JavaScript$procedures={};
|
||||
$.Blockly.JavaScript.procedures_defreturn=function(a){var b=$.Blockly.JavaScript.nameDB_.getName(a.getFieldValue("NAME"),$.module$exports$Blockly$Names.NameType.PROCEDURE),c="";$.Blockly.JavaScript.STATEMENT_PREFIX&&(c+=$.Blockly.JavaScript.injectId($.Blockly.JavaScript.STATEMENT_PREFIX,a));$.Blockly.JavaScript.STATEMENT_SUFFIX&&(c+=$.Blockly.JavaScript.injectId($.Blockly.JavaScript.STATEMENT_SUFFIX,a));c&&(c=$.Blockly.JavaScript.prefixLines(c,$.Blockly.JavaScript.INDENT));var d="";$.Blockly.JavaScript.INFINITE_LOOP_TRAP&&
|
||||
(d=$.Blockly.JavaScript.prefixLines($.Blockly.JavaScript.injectId($.Blockly.JavaScript.INFINITE_LOOP_TRAP,a),$.Blockly.JavaScript.INDENT));var e=$.Blockly.JavaScript.statementToCode(a,"STACK"),f=$.Blockly.JavaScript.valueToCode(a,"RETURN",$.Blockly.JavaScript.ORDER_NONE)||"",g="";e&&f&&(g=c);f&&(f=$.Blockly.JavaScript.INDENT+"return "+f+";\n");for(var h=[],k=a.getVars(),l=0;l<k.length;l++)h[l]=$.Blockly.JavaScript.nameDB_.getName(k[l],$.module$exports$Blockly$Names.NameType.VARIABLE);c="function "+
|
||||
b+"("+h.join(", ")+") {\n"+c+d+e+g+f+"}";c=$.Blockly.JavaScript.scrub_(a,c);$.Blockly.JavaScript.definitions_["%"+b]=c;return null};$.Blockly.JavaScript.procedures_defnoreturn=$.Blockly.JavaScript.procedures_defreturn;
|
||||
$.Blockly.JavaScript.procedures_callreturn=function(a){for(var b=$.Blockly.JavaScript.nameDB_.getName(a.getFieldValue("NAME"),$.module$exports$Blockly$Names.NameType.PROCEDURE),c=[],d=a.getVars(),e=0;e<d.length;e++)c[e]=$.Blockly.JavaScript.valueToCode(a,"ARG"+e,$.Blockly.JavaScript.ORDER_NONE)||"null";return[b+"("+c.join(", ")+")",$.Blockly.JavaScript.ORDER_FUNCTION_CALL]};$.Blockly.JavaScript.procedures_callnoreturn=function(a){return $.Blockly.JavaScript.procedures_callreturn(a)[0]+";\n"};
|
||||
$.Blockly.JavaScript.procedures_ifreturn=function(a){var b="if ("+($.Blockly.JavaScript.valueToCode(a,"CONDITION",$.Blockly.JavaScript.ORDER_NONE)||"false")+") {\n";$.Blockly.JavaScript.STATEMENT_SUFFIX&&(b+=$.Blockly.JavaScript.prefixLines($.Blockly.JavaScript.injectId($.Blockly.JavaScript.STATEMENT_SUFFIX,a),$.Blockly.JavaScript.INDENT));a.hasReturnValue_?(a=$.Blockly.JavaScript.valueToCode(a,"VALUE",$.Blockly.JavaScript.ORDER_NONE)||"null",b+=$.Blockly.JavaScript.INDENT+"return "+a+";\n"):b+=$.Blockly.JavaScript.INDENT+
|
||||
"return;\n";return b+"}\n"};var module$exports$Blockly$JavaScript$math={};$.Blockly.JavaScript.math_number=function(a){a=Number(a.getFieldValue("NUM"));return[a,0<=a?$.Blockly.JavaScript.ORDER_ATOMIC:$.Blockly.JavaScript.ORDER_UNARY_NEGATION]};
|
||||
$.Blockly.JavaScript.math_arithmetic=function(a){var b={ADD:[" + ",$.Blockly.JavaScript.ORDER_ADDITION],MINUS:[" - ",$.Blockly.JavaScript.ORDER_SUBTRACTION],MULTIPLY:[" * ",$.Blockly.JavaScript.ORDER_MULTIPLICATION],DIVIDE:[" / ",$.Blockly.JavaScript.ORDER_DIVISION],POWER:[null,$.Blockly.JavaScript.ORDER_NONE]}[a.getFieldValue("OP")],c=b[0];b=b[1];var d=$.Blockly.JavaScript.valueToCode(a,"A",b)||"0";a=$.Blockly.JavaScript.valueToCode(a,"B",b)||"0";return c?[d+c+a,b]:["Math.pow("+d+", "+a+")",$.Blockly.JavaScript.ORDER_FUNCTION_CALL]};
|
||||
$.Blockly.JavaScript.math_single=function(a){var b=a.getFieldValue("OP");if("NEG"===b)return a=$.Blockly.JavaScript.valueToCode(a,"NUM",$.Blockly.JavaScript.ORDER_UNARY_NEGATION)||"0","-"===a[0]&&(a=" "+a),["-"+a,$.Blockly.JavaScript.ORDER_UNARY_NEGATION];a="SIN"===b||"COS"===b||"TAN"===b?$.Blockly.JavaScript.valueToCode(a,"NUM",$.Blockly.JavaScript.ORDER_DIVISION)||"0":$.Blockly.JavaScript.valueToCode(a,"NUM",$.Blockly.JavaScript.ORDER_NONE)||"0";switch(b){case "ABS":var c="Math.abs("+a+")";break;
|
||||
case "ROOT":c="Math.sqrt("+a+")";break;case "LN":c="Math.log("+a+")";break;case "EXP":c="Math.exp("+a+")";break;case "POW10":c="Math.pow(10,"+a+")";break;case "ROUND":c="Math.round("+a+")";break;case "ROUNDUP":c="Math.ceil("+a+")";break;case "ROUNDDOWN":c="Math.floor("+a+")";break;case "SIN":c="Math.sin("+a+" / 180 * Math.PI)";break;case "COS":c="Math.cos("+a+" / 180 * Math.PI)";break;case "TAN":c="Math.tan("+a+" / 180 * Math.PI)"}if(c)return[c,$.Blockly.JavaScript.ORDER_FUNCTION_CALL];switch(b){case "LOG10":c=
|
||||
"Math.log("+a+") / Math.log(10)";break;case "ASIN":c="Math.asin("+a+") / Math.PI * 180";break;case "ACOS":c="Math.acos("+a+") / Math.PI * 180";break;case "ATAN":c="Math.atan("+a+") / Math.PI * 180";break;default:throw Error("Unknown math operator: "+b);}return[c,$.Blockly.JavaScript.ORDER_DIVISION]};
|
||||
$.Blockly.JavaScript.math_constant=function(a){return{PI:["Math.PI",$.Blockly.JavaScript.ORDER_MEMBER],E:["Math.E",$.Blockly.JavaScript.ORDER_MEMBER],GOLDEN_RATIO:["(1 + Math.sqrt(5)) / 2",$.Blockly.JavaScript.ORDER_DIVISION],SQRT2:["Math.SQRT2",$.Blockly.JavaScript.ORDER_MEMBER],SQRT1_2:["Math.SQRT1_2",$.Blockly.JavaScript.ORDER_MEMBER],INFINITY:["Infinity",$.Blockly.JavaScript.ORDER_ATOMIC]}[a.getFieldValue("CONSTANT")]};
|
||||
$.Blockly.JavaScript.math_number_property=function(a){var b={EVEN:[" % 2 === 0",$.Blockly.JavaScript.ORDER_MODULUS,$.Blockly.JavaScript.ORDER_EQUALITY],ODD:[" % 2 === 1",$.Blockly.JavaScript.ORDER_MODULUS,$.Blockly.JavaScript.ORDER_EQUALITY],WHOLE:[" % 1 === 0",$.Blockly.JavaScript.ORDER_MODULUS,$.Blockly.JavaScript.ORDER_EQUALITY],POSITIVE:[" > 0",$.Blockly.JavaScript.ORDER_RELATIONAL,$.Blockly.JavaScript.ORDER_RELATIONAL],NEGATIVE:[" < 0",$.Blockly.JavaScript.ORDER_RELATIONAL,$.Blockly.JavaScript.ORDER_RELATIONAL],
|
||||
DIVISIBLE_BY:[null,$.Blockly.JavaScript.ORDER_MODULUS,$.Blockly.JavaScript.ORDER_EQUALITY],PRIME:[null,$.Blockly.JavaScript.ORDER_NONE,$.Blockly.JavaScript.ORDER_FUNCTION_CALL]},c=a.getFieldValue("PROPERTY");b=$.$jscomp.makeIterator(b[c]);var d=b.next().value,e=b.next().value;b=b.next().value;e=$.Blockly.JavaScript.valueToCode(a,"NUMBER_TO_CHECK",e)||"0";"PRIME"===c?a=$.Blockly.JavaScript.provideFunction_("mathIsPrime","\nfunction "+$.Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_+"(n) {\n // https://en.wikipedia.org/wiki/Primality_test#Naive_methods\n if (n == 2 || n == 3) {\n return true;\n }\n // False if n is NaN, negative, is 1, or not whole.\n // And false if n is divisible by 2 or 3.\n if (isNaN(n) || n <= 1 || n % 1 !== 0 || n % 2 === 0 || n % 3 === 0) {\n return false;\n }\n // Check all the numbers of form 6k +/- 1, up to sqrt(n).\n for (var x = 6; x <= Math.sqrt(n) + 1; x += 6) {\n if (n % (x - 1) === 0 || n % (x + 1) === 0) {\n return false;\n }\n }\n return true;\n}\n")+
|
||||
"("+e+")":"DIVISIBLE_BY"===c?(a=$.Blockly.JavaScript.valueToCode(a,"DIVISOR",$.Blockly.JavaScript.ORDER_MODULUS)||"0",a=e+" % "+a+" === 0"):a=e+d;return[a,b]};$.Blockly.JavaScript.math_change=function(a){var b=$.Blockly.JavaScript.valueToCode(a,"DELTA",$.Blockly.JavaScript.ORDER_ADDITION)||"0";a=$.Blockly.JavaScript.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE);return a+" = (typeof "+a+" === 'number' ? "+a+" : 0) + "+b+";\n"};
|
||||
$.Blockly.JavaScript.math_round=$.Blockly.JavaScript.math_single;$.Blockly.JavaScript.math_trig=$.Blockly.JavaScript.math_single;
|
||||
$.Blockly.JavaScript.math_on_list=function(a){var b=a.getFieldValue("OP");switch(b){case "SUM":a=$.Blockly.JavaScript.valueToCode(a,"LIST",$.Blockly.JavaScript.ORDER_MEMBER)||"[]";a+=".reduce(function(x, y) {return x + y;})";break;case "MIN":a=$.Blockly.JavaScript.valueToCode(a,"LIST",$.Blockly.JavaScript.ORDER_NONE)||"[]";a="Math.min.apply(null, "+a+")";break;case "MAX":a=$.Blockly.JavaScript.valueToCode(a,"LIST",$.Blockly.JavaScript.ORDER_NONE)||"[]";a="Math.max.apply(null, "+a+")";break;case "AVERAGE":b=
|
||||
$.Blockly.JavaScript.provideFunction_("mathMean","\nfunction "+$.Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_+"(myList) {\n return myList.reduce(function(x, y) {return x + y;}) / myList.length;\n}\n");a=$.Blockly.JavaScript.valueToCode(a,"LIST",$.Blockly.JavaScript.ORDER_NONE)||"[]";a=b+"("+a+")";break;case "MEDIAN":b=$.Blockly.JavaScript.provideFunction_("mathMedian","\nfunction "+$.Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_+"(myList) {\n var localList = myList.filter(function (x) {return typeof x === 'number';});\n if (!localList.length) return null;\n localList.sort(function(a, b) {return b - a;});\n if (localList.length % 2 === 0) {\n return (localList[localList.length / 2 - 1] + localList[localList.length / 2]) / 2;\n } else {\n return localList[(localList.length - 1) / 2];\n }\n}\n");
|
||||
a=$.Blockly.JavaScript.valueToCode(a,"LIST",$.Blockly.JavaScript.ORDER_NONE)||"[]";a=b+"("+a+")";break;case "MODE":b=$.Blockly.JavaScript.provideFunction_("mathModes","\nfunction "+$.Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_+"(values) {\n var modes = [];\n var counts = [];\n var maxCount = 0;\n for (var i = 0; i < values.length; i++) {\n var value = values[i];\n var found = false;\n var thisCount;\n for (var j = 0; j < counts.length; j++) {\n if (counts[j][0] === value) {\n thisCount = ++counts[j][1];\n found = true;\n break;\n }\n }\n if (!found) {\n counts.push([value, 1]);\n thisCount = 1;\n }\n maxCount = Math.max(thisCount, maxCount);\n }\n for (var j = 0; j < counts.length; j++) {\n if (counts[j][1] === maxCount) {\n modes.push(counts[j][0]);\n }\n }\n return modes;\n}\n");
|
||||
a=$.Blockly.JavaScript.valueToCode(a,"LIST",$.Blockly.JavaScript.ORDER_NONE)||"[]";a=b+"("+a+")";break;case "STD_DEV":b=$.Blockly.JavaScript.provideFunction_("mathStandardDeviation","\nfunction "+$.Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_+"(numbers) {\n var n = numbers.length;\n if (!n) return null;\n var mean = numbers.reduce(function(x, y) {return x + y;}) / n;\n var variance = 0;\n for (var j = 0; j < n; j++) {\n variance += Math.pow(numbers[j] - mean, 2);\n }\n variance = variance / n;\n return Math.sqrt(variance);\n}\n");
|
||||
a=$.Blockly.JavaScript.valueToCode(a,"LIST",$.Blockly.JavaScript.ORDER_NONE)||"[]";a=b+"("+a+")";break;case "RANDOM":b=$.Blockly.JavaScript.provideFunction_("mathRandomList","\nfunction "+$.Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_+"(list) {\n var x = Math.floor(Math.random() * list.length);\n return list[x];\n}\n");a=$.Blockly.JavaScript.valueToCode(a,"LIST",$.Blockly.JavaScript.ORDER_NONE)||"[]";a=b+"("+a+")";break;default:throw Error("Unknown operator: "+b);}return[a,$.Blockly.JavaScript.ORDER_FUNCTION_CALL]};
|
||||
$.Blockly.JavaScript.math_modulo=function(a){var b=$.Blockly.JavaScript.valueToCode(a,"DIVIDEND",$.Blockly.JavaScript.ORDER_MODULUS)||"0";a=$.Blockly.JavaScript.valueToCode(a,"DIVISOR",$.Blockly.JavaScript.ORDER_MODULUS)||"0";return[b+" % "+a,$.Blockly.JavaScript.ORDER_MODULUS]};
|
||||
$.Blockly.JavaScript.math_constrain=function(a){var b=$.Blockly.JavaScript.valueToCode(a,"VALUE",$.Blockly.JavaScript.ORDER_NONE)||"0",c=$.Blockly.JavaScript.valueToCode(a,"LOW",$.Blockly.JavaScript.ORDER_NONE)||"0";a=$.Blockly.JavaScript.valueToCode(a,"HIGH",$.Blockly.JavaScript.ORDER_NONE)||"Infinity";return["Math.min(Math.max("+b+", "+c+"), "+a+")",$.Blockly.JavaScript.ORDER_FUNCTION_CALL]};
|
||||
$.Blockly.JavaScript.math_random_int=function(a){var b=$.Blockly.JavaScript.valueToCode(a,"FROM",$.Blockly.JavaScript.ORDER_NONE)||"0";a=$.Blockly.JavaScript.valueToCode(a,"TO",$.Blockly.JavaScript.ORDER_NONE)||"0";return[$.Blockly.JavaScript.provideFunction_("mathRandomInt","\nfunction "+$.Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_+"(a, b) {\n if (a > b) {\n // Swap a and b to ensure a is smaller.\n var c = a;\n a = b;\n b = c;\n }\n return Math.floor(Math.random() * (b - a + 1) + a);\n}\n")+
|
||||
"("+b+", "+a+")",$.Blockly.JavaScript.ORDER_FUNCTION_CALL]};$.Blockly.JavaScript.math_random_float=function(a){return["Math.random()",$.Blockly.JavaScript.ORDER_FUNCTION_CALL]};$.Blockly.JavaScript.math_atan2=function(a){var b=$.Blockly.JavaScript.valueToCode(a,"X",$.Blockly.JavaScript.ORDER_NONE)||"0";return["Math.atan2("+($.Blockly.JavaScript.valueToCode(a,"Y",$.Blockly.JavaScript.ORDER_NONE)||"0")+", "+b+") / Math.PI * 180",$.Blockly.JavaScript.ORDER_DIVISION]};var module$exports$Blockly$JavaScript$loops={};
|
||||
$.Blockly.JavaScript.controls_repeat_ext=function(a){var b=a.getField("TIMES")?String(Number(a.getFieldValue("TIMES"))):$.Blockly.JavaScript.valueToCode(a,"TIMES",$.Blockly.JavaScript.ORDER_ASSIGNMENT)||"0";var c=$.Blockly.JavaScript.statementToCode(a,"DO");c=$.Blockly.JavaScript.addLoopTrap(c,a);a="";var d=$.Blockly.JavaScript.nameDB_.getDistinctName("count",$.module$exports$Blockly$Names.NameType.VARIABLE),e=b;b.match(/^\w+$/)||(0,$.module$exports$Blockly$utils$string.isNumber)(b)||(e=$.Blockly.JavaScript.nameDB_.getDistinctName("repeat_end",
|
||||
$.module$exports$Blockly$Names.NameType.VARIABLE),a+="var "+e+" = "+b+";\n");return a+("for (var "+d+" = 0; "+d+" < "+e+"; "+d+"++) {\n"+c+"}\n")};$.Blockly.JavaScript.controls_repeat=$.Blockly.JavaScript.controls_repeat_ext;
|
||||
$.Blockly.JavaScript.controls_whileUntil=function(a){var b="UNTIL"===a.getFieldValue("MODE"),c=$.Blockly.JavaScript.valueToCode(a,"BOOL",b?$.Blockly.JavaScript.ORDER_LOGICAL_NOT:$.Blockly.JavaScript.ORDER_NONE)||"false",d=$.Blockly.JavaScript.statementToCode(a,"DO");d=$.Blockly.JavaScript.addLoopTrap(d,a);b&&(c="!"+c);return"while ("+c+") {\n"+d+"}\n"};
|
||||
$.Blockly.JavaScript.controls_for=function(a){var b=$.Blockly.JavaScript.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE),c=$.Blockly.JavaScript.valueToCode(a,"FROM",$.Blockly.JavaScript.ORDER_ASSIGNMENT)||"0",d=$.Blockly.JavaScript.valueToCode(a,"TO",$.Blockly.JavaScript.ORDER_ASSIGNMENT)||"0",e=$.Blockly.JavaScript.valueToCode(a,"BY",$.Blockly.JavaScript.ORDER_ASSIGNMENT)||"1",f=$.Blockly.JavaScript.statementToCode(a,"DO");f=$.Blockly.JavaScript.addLoopTrap(f,
|
||||
a);if((0,$.module$exports$Blockly$utils$string.isNumber)(c)&&(0,$.module$exports$Blockly$utils$string.isNumber)(d)&&(0,$.module$exports$Blockly$utils$string.isNumber)(e)){var g=Number(c)<=Number(d);a="for ("+b+" = "+c+"; "+b+(g?" <= ":" >= ")+d+"; "+b;b=Math.abs(Number(e));a=(1===b?a+(g?"++":"--"):a+((g?" += ":" -= ")+b))+(") {\n"+f+"}\n")}else a="",g=c,c.match(/^\w+$/)||(0,$.module$exports$Blockly$utils$string.isNumber)(c)||(g=$.Blockly.JavaScript.nameDB_.getDistinctName(b+"_start",$.module$exports$Blockly$Names.NameType.VARIABLE),
|
||||
a+="var "+g+" = "+c+";\n"),c=d,d.match(/^\w+$/)||(0,$.module$exports$Blockly$utils$string.isNumber)(d)||(c=$.Blockly.JavaScript.nameDB_.getDistinctName(b+"_end",$.module$exports$Blockly$Names.NameType.VARIABLE),a+="var "+c+" = "+d+";\n"),d=$.Blockly.JavaScript.nameDB_.getDistinctName(b+"_inc",$.module$exports$Blockly$Names.NameType.VARIABLE),a+="var "+d+" = ",a=(0,$.module$exports$Blockly$utils$string.isNumber)(e)?a+(Math.abs(e)+";\n"):a+("Math.abs("+e+");\n"),a=a+("if ("+g+" > "+c+") {\n")+($.Blockly.JavaScript.INDENT+
|
||||
d+" = -"+d+";\n"),a+="}\n",a+="for ("+b+" = "+g+"; "+d+" >= 0 ? "+b+" <= "+c+" : "+b+" >= "+c+"; "+b+" += "+d+") {\n"+f+"}\n";return a};
|
||||
$.Blockly.JavaScript.controls_forEach=function(a){var b=$.Blockly.JavaScript.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE),c=$.Blockly.JavaScript.valueToCode(a,"LIST",$.Blockly.JavaScript.ORDER_ASSIGNMENT)||"[]",d=$.Blockly.JavaScript.statementToCode(a,"DO");d=$.Blockly.JavaScript.addLoopTrap(d,a);a="";var e=c;c.match(/^\w+$/)||(e=$.Blockly.JavaScript.nameDB_.getDistinctName(b+"_list",$.module$exports$Blockly$Names.NameType.VARIABLE),a+="var "+e+" = "+c+
|
||||
";\n");c=$.Blockly.JavaScript.nameDB_.getDistinctName(b+"_index",$.module$exports$Blockly$Names.NameType.VARIABLE);d=$.Blockly.JavaScript.INDENT+b+" = "+e+"["+c+"];\n"+d;return a+("for (var "+c+" in "+e+") {\n"+d+"}\n")};
|
||||
$.Blockly.JavaScript.controls_flow_statements=function(a){var b="";$.Blockly.JavaScript.STATEMENT_PREFIX&&(b+=$.Blockly.JavaScript.injectId($.Blockly.JavaScript.STATEMENT_PREFIX,a));$.Blockly.JavaScript.STATEMENT_SUFFIX&&(b+=$.Blockly.JavaScript.injectId($.Blockly.JavaScript.STATEMENT_SUFFIX,a));if($.Blockly.JavaScript.STATEMENT_PREFIX){var c=a.getSurroundLoop();c&&!c.suppressPrefixSuffix&&(b+=$.Blockly.JavaScript.injectId($.Blockly.JavaScript.STATEMENT_PREFIX,c))}switch(a.getFieldValue("FLOW")){case "BREAK":return b+
|
||||
"break;\n";case "CONTINUE":return b+"continue;\n"}throw Error("Unknown flow statement.");};var module$exports$Blockly$JavaScript$logic={};
|
||||
$.Blockly.JavaScript.controls_if=function(a){var b=0,c="";$.Blockly.JavaScript.STATEMENT_PREFIX&&(c+=$.Blockly.JavaScript.injectId($.Blockly.JavaScript.STATEMENT_PREFIX,a));do{var d=$.Blockly.JavaScript.valueToCode(a,"IF"+b,$.Blockly.JavaScript.ORDER_NONE)||"false",e=$.Blockly.JavaScript.statementToCode(a,"DO"+b);$.Blockly.JavaScript.STATEMENT_SUFFIX&&(e=$.Blockly.JavaScript.prefixLines($.Blockly.JavaScript.injectId($.Blockly.JavaScript.STATEMENT_SUFFIX,a),$.Blockly.JavaScript.INDENT)+e);c+=(0<b?
|
||||
" else ":"")+"if ("+d+") {\n"+e+"}";b++}while(a.getInput("IF"+b));if(a.getInput("ELSE")||$.Blockly.JavaScript.STATEMENT_SUFFIX)b=$.Blockly.JavaScript.statementToCode(a,"ELSE"),$.Blockly.JavaScript.STATEMENT_SUFFIX&&(b=$.Blockly.JavaScript.prefixLines($.Blockly.JavaScript.injectId($.Blockly.JavaScript.STATEMENT_SUFFIX,a),$.Blockly.JavaScript.INDENT)+b),c+=" else {\n"+b+"}";return c+"\n"};$.Blockly.JavaScript.controls_ifelse=$.Blockly.JavaScript.controls_if;
|
||||
$.Blockly.JavaScript.logic_compare=function(a){var b={EQ:"==",NEQ:"!=",LT:"<",LTE:"<=",GT:">",GTE:">="}[a.getFieldValue("OP")],c="=="===b||"!="===b?$.Blockly.JavaScript.ORDER_EQUALITY:$.Blockly.JavaScript.ORDER_RELATIONAL,d=$.Blockly.JavaScript.valueToCode(a,"A",c)||"0";a=$.Blockly.JavaScript.valueToCode(a,"B",c)||"0";return[d+" "+b+" "+a,c]};
|
||||
$.Blockly.JavaScript.logic_operation=function(a){var b="AND"===a.getFieldValue("OP")?"&&":"||",c="&&"===b?$.Blockly.JavaScript.ORDER_LOGICAL_AND:$.Blockly.JavaScript.ORDER_LOGICAL_OR,d=$.Blockly.JavaScript.valueToCode(a,"A",c);a=$.Blockly.JavaScript.valueToCode(a,"B",c);if(d||a){var e="&&"===b?"true":"false";d||(d=e);a||(a=e)}else a=d="false";return[d+" "+b+" "+a,c]};
|
||||
$.Blockly.JavaScript.logic_negate=function(a){var b=$.Blockly.JavaScript.ORDER_LOGICAL_NOT;return["!"+($.Blockly.JavaScript.valueToCode(a,"BOOL",b)||"true"),b]};$.Blockly.JavaScript.logic_boolean=function(a){return["TRUE"===a.getFieldValue("BOOL")?"true":"false",$.Blockly.JavaScript.ORDER_ATOMIC]};$.Blockly.JavaScript.logic_null=function(a){return["null",$.Blockly.JavaScript.ORDER_ATOMIC]};
|
||||
$.Blockly.JavaScript.logic_ternary=function(a){var b=$.Blockly.JavaScript.valueToCode(a,"IF",$.Blockly.JavaScript.ORDER_CONDITIONAL)||"false",c=$.Blockly.JavaScript.valueToCode(a,"THEN",$.Blockly.JavaScript.ORDER_CONDITIONAL)||"null";a=$.Blockly.JavaScript.valueToCode(a,"ELSE",$.Blockly.JavaScript.ORDER_CONDITIONAL)||"null";return[b+" ? "+c+" : "+a,$.Blockly.JavaScript.ORDER_CONDITIONAL]};var module$exports$Blockly$JavaScript$lists={};$.Blockly.JavaScript.lists_create_empty=function(a){return["[]",$.Blockly.JavaScript.ORDER_ATOMIC]};$.Blockly.JavaScript.lists_create_with=function(a){for(var b=Array(a.itemCount_),c=0;c<a.itemCount_;c++)b[c]=$.Blockly.JavaScript.valueToCode(a,"ADD"+c,$.Blockly.JavaScript.ORDER_NONE)||"null";return["["+b.join(", ")+"]",$.Blockly.JavaScript.ORDER_ATOMIC]};
|
||||
$.Blockly.JavaScript.lists_repeat=function(a){var b=$.Blockly.JavaScript.provideFunction_("listsRepeat","\nfunction "+$.Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_+"(value, n) {\n var array = [];\n for (var i = 0; i < n; i++) {\n array[i] = value;\n }\n return array;\n}\n"),c=$.Blockly.JavaScript.valueToCode(a,"ITEM",$.Blockly.JavaScript.ORDER_NONE)||"null";a=$.Blockly.JavaScript.valueToCode(a,"NUM",$.Blockly.JavaScript.ORDER_NONE)||"0";return[b+"("+c+", "+a+")",$.Blockly.JavaScript.ORDER_FUNCTION_CALL]};
|
||||
$.Blockly.JavaScript.lists_length=function(a){return[($.Blockly.JavaScript.valueToCode(a,"VALUE",$.Blockly.JavaScript.ORDER_MEMBER)||"[]")+".length",$.Blockly.JavaScript.ORDER_MEMBER]};$.Blockly.JavaScript.lists_isEmpty=function(a){return["!"+($.Blockly.JavaScript.valueToCode(a,"VALUE",$.Blockly.JavaScript.ORDER_MEMBER)||"[]")+".length",$.Blockly.JavaScript.ORDER_LOGICAL_NOT]};
|
||||
$.Blockly.JavaScript.lists_indexOf=function(a){var b="FIRST"===a.getFieldValue("END")?"indexOf":"lastIndexOf",c=$.Blockly.JavaScript.valueToCode(a,"FIND",$.Blockly.JavaScript.ORDER_NONE)||"''";b=($.Blockly.JavaScript.valueToCode(a,"VALUE",$.Blockly.JavaScript.ORDER_MEMBER)||"[]")+"."+b+"("+c+")";return a.workspace.options.oneBasedIndex?[b+" + 1",$.Blockly.JavaScript.ORDER_ADDITION]:[b,$.Blockly.JavaScript.ORDER_FUNCTION_CALL]};
|
||||
$.Blockly.JavaScript.lists_getIndex=function(a){var b=a.getFieldValue("MODE")||"GET",c=a.getFieldValue("WHERE")||"FROM_START",d=$.Blockly.JavaScript.valueToCode(a,"VALUE","RANDOM"===c?$.Blockly.JavaScript.ORDER_NONE:$.Blockly.JavaScript.ORDER_MEMBER)||"[]";switch(c){case "FIRST":if("GET"===b)return[d+"[0]",$.Blockly.JavaScript.ORDER_MEMBER];if("GET_REMOVE"===b)return[d+".shift()",$.Blockly.JavaScript.ORDER_MEMBER];if("REMOVE"===b)return d+".shift();\n";break;case "LAST":if("GET"===b)return[d+".slice(-1)[0]",
|
||||
$.Blockly.JavaScript.ORDER_MEMBER];if("GET_REMOVE"===b)return[d+".pop()",$.Blockly.JavaScript.ORDER_MEMBER];if("REMOVE"===b)return d+".pop();\n";break;case "FROM_START":a=$.Blockly.JavaScript.getAdjusted(a,"AT");if("GET"===b)return[d+"["+a+"]",$.Blockly.JavaScript.ORDER_MEMBER];if("GET_REMOVE"===b)return[d+".splice("+a+", 1)[0]",$.Blockly.JavaScript.ORDER_FUNCTION_CALL];if("REMOVE"===b)return d+".splice("+a+", 1);\n";break;case "FROM_END":a=$.Blockly.JavaScript.getAdjusted(a,"AT",1,!0);if("GET"===
|
||||
b)return[d+".slice("+a+")[0]",$.Blockly.JavaScript.ORDER_FUNCTION_CALL];if("GET_REMOVE"===b)return[d+".splice("+a+", 1)[0]",$.Blockly.JavaScript.ORDER_FUNCTION_CALL];if("REMOVE"===b)return d+".splice("+a+", 1);";break;case "RANDOM":d=$.Blockly.JavaScript.provideFunction_("listsGetRandomItem","\nfunction "+$.Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_+"(list, remove) {\n var x = Math.floor(Math.random() * list.length);\n if (remove) {\n return list.splice(x, 1)[0];\n } else {\n return list[x];\n }\n}\n")+
|
||||
"("+d+", "+("GET"!==b)+")";if("GET"===b||"GET_REMOVE"===b)return[d,$.Blockly.JavaScript.ORDER_FUNCTION_CALL];if("REMOVE"===b)return d+";\n"}throw Error("Unhandled combination (lists_getIndex).");};
|
||||
$.Blockly.JavaScript.lists_setIndex=function(a){function b(){if(c.match(/^\w+$/))return"";var g=$.Blockly.JavaScript.nameDB_.getDistinctName("tmpList",$.module$exports$Blockly$Names.NameType.VARIABLE),h="var "+g+" = "+c+";\n";c=g;return h}var c=$.Blockly.JavaScript.valueToCode(a,"LIST",$.Blockly.JavaScript.ORDER_MEMBER)||"[]",d=a.getFieldValue("MODE")||"GET",e=a.getFieldValue("WHERE")||"FROM_START",f=$.Blockly.JavaScript.valueToCode(a,"TO",$.Blockly.JavaScript.ORDER_ASSIGNMENT)||"null";switch(e){case "FIRST":if("SET"===
|
||||
d)return c+"[0] = "+f+";\n";if("INSERT"===d)return c+".unshift("+f+");\n";break;case "LAST":if("SET"===d)return b()+(c+"["+c+".length - 1] = "+f+";\n");if("INSERT"===d)return c+".push("+f+");\n";break;case "FROM_START":a=$.Blockly.JavaScript.getAdjusted(a,"AT");if("SET"===d)return c+"["+a+"] = "+f+";\n";if("INSERT"===d)return c+".splice("+a+", 0, "+f+");\n";break;case "FROM_END":a=$.Blockly.JavaScript.getAdjusted(a,"AT",1,!1,$.Blockly.JavaScript.ORDER_SUBTRACTION);e=b();if("SET"===d)return e+(c+"["+
|
||||
c+".length - "+a+"] = "+f+";\n");if("INSERT"===d)return e+(c+".splice("+c+".length - "+a+", 0, "+f+");\n");break;case "RANDOM":a=b();e=$.Blockly.JavaScript.nameDB_.getDistinctName("tmpX",$.module$exports$Blockly$Names.NameType.VARIABLE);a+="var "+e+" = Math.floor(Math.random() * "+c+".length);\n";if("SET"===d)return a+(c+"["+e+"] = "+f+";\n");if("INSERT"===d)return a+(c+".splice("+e+", 0, "+f+");\n")}throw Error("Unhandled combination (lists_setIndex).");};
|
||||
var module$contents$Blockly$JavaScript$lists_getSubstringIndex=function(a,b,c){return"FIRST"===b?"0":"FROM_END"===b?a+".length - 1 - "+c:"LAST"===b?a+".length - 1":c};
|
||||
$.Blockly.JavaScript.lists_getSublist=function(a){var b=$.Blockly.JavaScript.valueToCode(a,"LIST",$.Blockly.JavaScript.ORDER_MEMBER)||"[]",c=a.getFieldValue("WHERE1"),d=a.getFieldValue("WHERE2");if("FIRST"===c&&"LAST"===d)b+=".slice(0)";else if(b.match(/^\w+$/)||"FROM_END"!==c&&"FROM_START"===d){switch(c){case "FROM_START":c=$.Blockly.JavaScript.getAdjusted(a,"AT1");break;case "FROM_END":c=$.Blockly.JavaScript.getAdjusted(a,"AT1",1,!1,$.Blockly.JavaScript.ORDER_SUBTRACTION);c=b+".length - "+c;break;
|
||||
case "FIRST":c="0";break;default:throw Error("Unhandled option (lists_getSublist).");}switch(d){case "FROM_START":d=$.Blockly.JavaScript.getAdjusted(a,"AT2",1);break;case "FROM_END":d=$.Blockly.JavaScript.getAdjusted(a,"AT2",0,!1,$.Blockly.JavaScript.ORDER_SUBTRACTION);d=b+".length - "+d;break;case "LAST":d=b+".length";break;default:throw Error("Unhandled option (lists_getSublist).");}b=b+".slice("+c+", "+d+")"}else{var e=$.Blockly.JavaScript.getAdjusted(a,"AT1");a=$.Blockly.JavaScript.getAdjusted(a,
|
||||
"AT2");var f={FIRST:"First",LAST:"Last",FROM_START:"FromStart",FROM_END:"FromEnd"};b=$.Blockly.JavaScript.provideFunction_("subsequence"+f[c]+f[d],"\nfunction "+$.Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_+"(sequence"+("FROM_END"===c||"FROM_START"===c?", at1":"")+("FROM_END"===d||"FROM_START"===d?", at2":"")+") {\n var start = "+module$contents$Blockly$JavaScript$lists_getSubstringIndex("sequence",c,"at1")+";\n var end = "+module$contents$Blockly$JavaScript$lists_getSubstringIndex("sequence",
|
||||
d,"at2")+" + 1;\n return sequence.slice(start, end);\n}\n")+"("+b+("FROM_END"===c||"FROM_START"===c?", "+e:"")+("FROM_END"===d||"FROM_START"===d?", "+a:"")+")"}return[b,$.Blockly.JavaScript.ORDER_FUNCTION_CALL]};
|
||||
$.Blockly.JavaScript.lists_sort=function(a){var b=$.Blockly.JavaScript.valueToCode(a,"LIST",$.Blockly.JavaScript.ORDER_FUNCTION_CALL)||"[]",c="1"===a.getFieldValue("DIRECTION")?1:-1;a=a.getFieldValue("TYPE");var d=$.Blockly.JavaScript.provideFunction_("listsGetSortCompare","\nfunction "+$.Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_+"(type, direction) {\n var compareFuncs = {\n 'NUMERIC': function(a, b) {\n return Number(a) - Number(b); },\n 'TEXT': function(a, b) {\n return a.toString() > b.toString() ? 1 : -1; },\n 'IGNORE_CASE': function(a, b) {\n return a.toString().toLowerCase() > b.toString().toLowerCase() ? 1 : -1; },\n };\n var compare = compareFuncs[type];\n return function(a, b) { return compare(a, b) * direction; };\n}\n ");
|
||||
return[b+".slice().sort("+d+'("'+a+'", '+c+"))",$.Blockly.JavaScript.ORDER_FUNCTION_CALL]};$.Blockly.JavaScript.lists_split=function(a){var b=$.Blockly.JavaScript.valueToCode(a,"INPUT",$.Blockly.JavaScript.ORDER_MEMBER),c=$.Blockly.JavaScript.valueToCode(a,"DELIM",$.Blockly.JavaScript.ORDER_NONE)||"''";a=a.getFieldValue("MODE");if("SPLIT"===a)b||(b="''"),a="split";else if("JOIN"===a)b||(b="[]"),a="join";else throw Error("Unknown mode: "+a);return[b+"."+a+"("+c+")",$.Blockly.JavaScript.ORDER_FUNCTION_CALL]};
|
||||
$.Blockly.JavaScript.lists_reverse=function(a){return[($.Blockly.JavaScript.valueToCode(a,"LIST",$.Blockly.JavaScript.ORDER_FUNCTION_CALL)||"[]")+".slice().reverse()",$.Blockly.JavaScript.ORDER_FUNCTION_CALL]};var module$exports$Blockly$JavaScript$colour={};$.Blockly.JavaScript.colour_picker=function(a){return[$.Blockly.JavaScript.quote_(a.getFieldValue("COLOUR")),$.Blockly.JavaScript.ORDER_ATOMIC]};$.Blockly.JavaScript.colour_random=function(a){return[$.Blockly.JavaScript.provideFunction_("colourRandom","\nfunction "+$.Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_+"() {\n var num = Math.floor(Math.random() * Math.pow(2, 24));\n return '#' + ('00000' + num.toString(16)).substr(-6);\n}\n")+"()",$.Blockly.JavaScript.ORDER_FUNCTION_CALL]};
|
||||
$.Blockly.JavaScript.colour_rgb=function(a){var b=$.Blockly.JavaScript.valueToCode(a,"RED",$.Blockly.JavaScript.ORDER_NONE)||0,c=$.Blockly.JavaScript.valueToCode(a,"GREEN",$.Blockly.JavaScript.ORDER_NONE)||0;a=$.Blockly.JavaScript.valueToCode(a,"BLUE",$.Blockly.JavaScript.ORDER_NONE)||0;return[$.Blockly.JavaScript.provideFunction_("colourRgb","\nfunction "+$.Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_+"(r, g, b) {\n r = Math.max(Math.min(Number(r), 100), 0) * 2.55;\n g = Math.max(Math.min(Number(g), 100), 0) * 2.55;\n b = Math.max(Math.min(Number(b), 100), 0) * 2.55;\n r = ('0' + (Math.round(r) || 0).toString(16)).slice(-2);\n g = ('0' + (Math.round(g) || 0).toString(16)).slice(-2);\n b = ('0' + (Math.round(b) || 0).toString(16)).slice(-2);\n return '#' + r + g + b;\n}\n")+
|
||||
"("+b+", "+c+", "+a+")",$.Blockly.JavaScript.ORDER_FUNCTION_CALL]};
|
||||
$.Blockly.JavaScript.colour_blend=function(a){var b=$.Blockly.JavaScript.valueToCode(a,"COLOUR1",$.Blockly.JavaScript.ORDER_NONE)||"'#000000'",c=$.Blockly.JavaScript.valueToCode(a,"COLOUR2",$.Blockly.JavaScript.ORDER_NONE)||"'#000000'";a=$.Blockly.JavaScript.valueToCode(a,"RATIO",$.Blockly.JavaScript.ORDER_NONE)||.5;return[$.Blockly.JavaScript.provideFunction_("colourBlend","\nfunction "+$.Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_+"(c1, c2, ratio) {\n ratio = Math.max(Math.min(Number(ratio), 1), 0);\n var r1 = parseInt(c1.substring(1, 3), 16);\n var g1 = parseInt(c1.substring(3, 5), 16);\n var b1 = parseInt(c1.substring(5, 7), 16);\n var r2 = parseInt(c2.substring(1, 3), 16);\n var g2 = parseInt(c2.substring(3, 5), 16);\n var b2 = parseInt(c2.substring(5, 7), 16);\n var r = Math.round(r1 * (1 - ratio) + r2 * ratio);\n var g = Math.round(g1 * (1 - ratio) + g2 * ratio);\n var b = Math.round(b1 * (1 - ratio) + b2 * ratio);\n r = ('0' + (r || 0).toString(16)).slice(-2);\n g = ('0' + (g || 0).toString(16)).slice(-2);\n b = ('0' + (b || 0).toString(16)).slice(-2);\n return '#' + r + g + b;\n}\n")+
|
||||
"("+b+", "+c+", "+a+")",$.Blockly.JavaScript.ORDER_FUNCTION_CALL]};var module$exports$Blockly$JavaScript$all={};
|
||||
$.Blockly.JavaScript.__namespace__=$;
|
||||
return $.Blockly.JavaScript;
|
||||
var module$exports$Blockly$JavaScript={},module$contents$Blockly$JavaScript_Variables=$.module$build$src$core$variables,module$contents$Blockly$JavaScript_objectUtils=$.module$build$src$core$utils$object,module$contents$Blockly$JavaScript_stringUtils=$.module$build$src$core$utils$string,module$contents$Blockly$JavaScript_Generator=$.Generator$$module$build$src$core$generator,module$contents$Blockly$JavaScript_inputTypes=$.module$build$src$core$input_types.inputTypes,module$contents$Blockly$JavaScript_Names=
|
||||
$.module$build$src$core$names.Names,module$contents$Blockly$JavaScript_NameType=$.NameType$$module$build$src$core$names;module$exports$Blockly$JavaScript.javascriptGenerator=new $.Generator$$module$build$src$core$generator("JavaScript");
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.addReservedWords("break,case,catch,class,const,continue,debugger,default,delete,do,else,export,extends,finally,for,function,if,import,in,instanceof,new,return,super,switch,this,throw,try,typeof,var,void,while,with,yield,enum,implements,interface,let,package,private,protected,public,static,await,null,true,false,arguments,"+Object.getOwnPropertyNames(globalThis).join(","));module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ATOMIC=0;
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NEW=1.1;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER=1.2;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL=2;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_INCREMENT=3;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_DECREMENT=3;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_BITWISE_NOT=4.1;
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_UNARY_PLUS=4.2;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_UNARY_NEGATION=4.3;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_LOGICAL_NOT=4.4;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_TYPEOF=4.5;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_VOID=4.6;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_DELETE=4.7;
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_AWAIT=4.8;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_EXPONENTIATION=5;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MULTIPLICATION=5.1;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_DIVISION=5.2;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MODULUS=5.3;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_SUBTRACTION=6.1;
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ADDITION=6.2;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_BITWISE_SHIFT=7;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_RELATIONAL=8;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_IN=8;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_INSTANCEOF=8;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_EQUALITY=9;
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_BITWISE_AND=10;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_BITWISE_XOR=11;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_BITWISE_OR=12;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_LOGICAL_AND=13;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_LOGICAL_OR=14;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_CONDITIONAL=15;
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ASSIGNMENT=16;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_YIELD=17;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_COMMA=18;module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE=99;
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_OVERRIDES=[[module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER],[module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL],[module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER],[module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER,
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL],[module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_LOGICAL_NOT,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_LOGICAL_NOT],[module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MULTIPLICATION,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MULTIPLICATION],[module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ADDITION,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ADDITION],
|
||||
[module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_LOGICAL_AND,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_LOGICAL_AND],[module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_LOGICAL_OR,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_LOGICAL_OR]];module$exports$Blockly$JavaScript.javascriptGenerator.isInitialized=!1;
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.init=function(a){Object.getPrototypeOf(this).init.call(this);this.nameDB_?this.nameDB_.reset():this.nameDB_=new $.module$build$src$core$names.Names(this.RESERVED_WORDS_);this.nameDB_.setVariableMap(a.getVariableMap());this.nameDB_.populateVariables(a);this.nameDB_.populateProcedures(a);const b=[];var c=$.module$build$src$core$variables.allDeveloperVariables(a);for(let d=0;d<c.length;d++)b.push(this.nameDB_.getName(c[d],$.NameType$$module$build$src$core$names.DEVELOPER_VARIABLE));
|
||||
a=$.module$build$src$core$variables.allUsedVarModels(a);for(c=0;c<a.length;c++)b.push(this.nameDB_.getName(a[c].getId(),$.NameType$$module$build$src$core$names.VARIABLE));b.length&&(this.definitions_.variables="var "+b.join(", ")+";");this.isInitialized=!0};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.finish=function(a){const b=$.module$build$src$core$utils$object.values(this.definitions_);a=Object.getPrototypeOf(this).finish.call(this,a);this.isInitialized=!1;this.nameDB_.reset();return b.join("\n\n")+"\n\n\n"+a};module$exports$Blockly$JavaScript.javascriptGenerator.scrubNakedValue=function(a){return a+";\n"};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.quote_=function(a){a=a.replace(/\\/g,"\\\\").replace(/\n/g,"\\\n").replace(/'/g,"\\'");return"'"+a+"'"};module$exports$Blockly$JavaScript.javascriptGenerator.multiline_quote_=function(a){return a.split(/\n/g).map(this.quote_).join(" + '\\n' +\n")};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.scrub_=function(a,b,c){let d="";if(!a.outputConnection||!a.outputConnection.targetConnection){var e=a.getCommentText();e&&(e=$.module$build$src$core$utils$string.wrap(e,this.COMMENT_WRAP-3),d+=this.prefixLines(e+"\n","// "));for(let f=0;f<a.inputList.length;f++)a.inputList[f].type===$.module$build$src$core$input_types.inputTypes.VALUE&&(e=a.inputList[f].connection.targetBlock())&&(e=this.allNestedComments(e))&&(d+=this.prefixLines(e,"// "))}a=
|
||||
a.nextConnection&&a.nextConnection.targetBlock();c=c?"":this.blockToCode(a);return d+b+c};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.getAdjusted=function(a,b,c,d,e){c=c||0;e=e||this.ORDER_NONE;a.workspace.options.oneBasedIndex&&c--;const f=a.workspace.options.oneBasedIndex?"1":"0";let g,h=e;0<c?g=h=this.ORDER_ADDITION:0>c?g=h=this.ORDER_SUBTRACTION:d&&(g=h=this.ORDER_UNARY_NEGATION);a=this.valueToCode(a,b,h)||f;$.module$build$src$core$utils$string.isNumber(a)?(a=Number(a)+c,d&&(a=-a)):(0<c?a=a+" + "+c:0>c&&(a=a+" - "+-c),d&&(a=c?"-("+a+")":"-"+a),g=Math.floor(g),e=Math.floor(e),
|
||||
g&&e>=g&&(a="("+a+")"));return a};var module$exports$Blockly$JavaScript$variables={},module$contents$Blockly$JavaScript$variables_NameType=$.NameType$$module$build$src$core$names;module$exports$Blockly$JavaScript.javascriptGenerator.variables_get=function(a){return[module$exports$Blockly$JavaScript.javascriptGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE),module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ATOMIC]};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.variables_set=function(a){const b=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"VALUE",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ASSIGNMENT)||"0";return module$exports$Blockly$JavaScript.javascriptGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE)+" = "+b+";\n"};var module$exports$Blockly$JavaScript$variablesDynamic={};module$exports$Blockly$JavaScript.javascriptGenerator.variables_get_dynamic=module$exports$Blockly$JavaScript.javascriptGenerator.variables_get;module$exports$Blockly$JavaScript.javascriptGenerator.variables_set_dynamic=module$exports$Blockly$JavaScript.javascriptGenerator.variables_set;var module$exports$Blockly$JavaScript$texts={},module$contents$Blockly$JavaScript$texts_NameType=$.NameType$$module$build$src$core$names,module$contents$Blockly$JavaScript$texts_strRegExp=/^\s*'([^']|\\')*'\s*$/,module$contents$Blockly$JavaScript$texts_forceString=function(a){return module$contents$Blockly$JavaScript$texts_strRegExp.test(a)?[a,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ATOMIC]:["String("+a+")",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]},
|
||||
module$contents$Blockly$JavaScript$texts_getSubstringIndex=function(a,b,c){return"FIRST"===b?"0":"FROM_END"===b?a+".length - 1 - "+c:"LAST"===b?a+".length - 1":c};module$exports$Blockly$JavaScript.javascriptGenerator.text=function(a){return[module$exports$Blockly$JavaScript.javascriptGenerator.quote_(a.getFieldValue("TEXT")),module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ATOMIC]};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.text_multiline=function(a){a=module$exports$Blockly$JavaScript.javascriptGenerator.multiline_quote_(a.getFieldValue("TEXT"));const b=-1!==a.indexOf("+")?module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ADDITION:module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ATOMIC;return[a,b]};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.text_join=function(a){switch(a.itemCount_){case 0:return["''",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ATOMIC];case 1:return a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"ADD0",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"''",module$contents$Blockly$JavaScript$texts_forceString(a);case 2:var b=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"ADD0",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||
|
||||
"''";a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"ADD1",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"''";return[module$contents$Blockly$JavaScript$texts_forceString(b)[0]+" + "+module$contents$Blockly$JavaScript$texts_forceString(a)[0],module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ADDITION];default:b=Array(a.itemCount_);for(let c=0;c<a.itemCount_;c++)b[c]=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"ADD"+c,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||
|
||||
"''";return["["+b.join(",")+"].join('')",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]}};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.text_append=function(a){const b=module$exports$Blockly$JavaScript.javascriptGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE);a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"TEXT",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"''";return b+" += "+module$contents$Blockly$JavaScript$texts_forceString(a)[0]+";\n"};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.text_length=function(a){return[(module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"VALUE",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER)||"''")+".length",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER]};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.text_isEmpty=function(a){return["!"+(module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"VALUE",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER)||"''")+".length",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_LOGICAL_NOT]};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.text_indexOf=function(a){var b="FIRST"===a.getFieldValue("END")?"indexOf":"lastIndexOf";const c=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"FIND",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"''";b=(module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"VALUE",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER)||"''")+"."+b+"("+c+")";return a.workspace.options.oneBasedIndex?
|
||||
[b+" + 1",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ADDITION]:[b,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.text_charAt=function(a){const b=a.getFieldValue("WHERE")||"FROM_START",c=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"VALUE","RANDOM"===b?module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE:module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER)||"''";switch(b){case "FIRST":return[c+".charAt(0)",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL];case "LAST":return[c+".slice(-1)",
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL];case "FROM_START":return a=module$exports$Blockly$JavaScript.javascriptGenerator.getAdjusted(a,"AT"),[c+".charAt("+a+")",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL];case "FROM_END":return a=module$exports$Blockly$JavaScript.javascriptGenerator.getAdjusted(a,"AT",1,!0),[c+".slice("+a+").charAt(0)",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL];case "RANDOM":return[module$exports$Blockly$JavaScript.javascriptGenerator.provideFunction_("textRandomLetter",
|
||||
`
|
||||
function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(text) {
|
||||
var x = Math.floor(Math.random() * text.length);
|
||||
return text[x];
|
||||
}
|
||||
`)+"("+c+")",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]}throw Error("Unhandled option (text_charAt).");};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.text_getSubstring=function(a){var b=a.getFieldValue("WHERE1"),c=a.getFieldValue("WHERE2"),d="FROM_END"!==b&&"LAST"!==b&&"FROM_END"!==c&&"LAST"!==c,e=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"STRING",d?module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER:module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"''";if("FIRST"===b&&"LAST"===c)return[e,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE];
|
||||
if(e.match(/^'?\w+'?$/)||d){switch(b){case "FROM_START":b=module$exports$Blockly$JavaScript.javascriptGenerator.getAdjusted(a,"AT1");break;case "FROM_END":b=module$exports$Blockly$JavaScript.javascriptGenerator.getAdjusted(a,"AT1",1,!1,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_SUBTRACTION);b=e+".length - "+b;break;case "FIRST":b="0";break;default:throw Error("Unhandled option (text_getSubstring).");}switch(c){case "FROM_START":c=module$exports$Blockly$JavaScript.javascriptGenerator.getAdjusted(a,
|
||||
"AT2",1);break;case "FROM_END":c=module$exports$Blockly$JavaScript.javascriptGenerator.getAdjusted(a,"AT2",0,!1,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_SUBTRACTION);c=e+".length - "+c;break;case "LAST":c=e+".length";break;default:throw Error("Unhandled option (text_getSubstring).");}e=e+".slice("+b+", "+c+")"}else{d=module$exports$Blockly$JavaScript.javascriptGenerator.getAdjusted(a,"AT1");a=module$exports$Blockly$JavaScript.javascriptGenerator.getAdjusted(a,"AT2");const f={FIRST:"First",
|
||||
LAST:"Last",FROM_START:"FromStart",FROM_END:"FromEnd"};e=module$exports$Blockly$JavaScript.javascriptGenerator.provideFunction_("subsequence"+f[b]+f[c],`
|
||||
function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(sequence${"FROM_END"===b||"FROM_START"===b?", at1":""}${"FROM_END"===c||"FROM_START"===c?", at2":""}) {
|
||||
var start = ${module$contents$Blockly$JavaScript$texts_getSubstringIndex("sequence",b,"at1")};
|
||||
var end = ${module$contents$Blockly$JavaScript$texts_getSubstringIndex("sequence",c,"at2")} + 1;
|
||||
return sequence.slice(start, end);
|
||||
}
|
||||
`)+"("+e+("FROM_END"===b||"FROM_START"===b?", "+d:"")+("FROM_END"===c||"FROM_START"===c?", "+a:"")+")"}return[e,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.text_changeCase=function(a){const b={UPPERCASE:".toUpperCase()",LOWERCASE:".toLowerCase()",TITLECASE:null}[a.getFieldValue("CASE")];a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"TEXT",b?module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER:module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"''";return[b?a+b:module$exports$Blockly$JavaScript.javascriptGenerator.provideFunction_("textToTitleCase",
|
||||
`
|
||||
function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(str) {
|
||||
return str.replace(/\\S+/g,
|
||||
function(txt) {return txt[0].toUpperCase() + txt.substring(1).toLowerCase();});
|
||||
}
|
||||
`)+"("+a+")",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};module$exports$Blockly$JavaScript.javascriptGenerator.text_trim=function(a){const b={LEFT:".replace(/^[\\s\\xa0]+/, '')",RIGHT:".replace(/[\\s\\xa0]+$/, '')",BOTH:".trim()"}[a.getFieldValue("MODE")];return[(module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"TEXT",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER)||"''")+b,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.text_print=function(a){return"window.alert("+(module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"TEXT",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"''")+");\n"};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.text_prompt_ext=function(a){let b="window.prompt("+(a.getField("TEXT")?module$exports$Blockly$JavaScript.javascriptGenerator.quote_(a.getFieldValue("TEXT")):module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"TEXT",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"''")+")";"NUMBER"===a.getFieldValue("TYPE")&&(b="Number("+b+")");return[b,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.text_prompt=module$exports$Blockly$JavaScript.javascriptGenerator.text_prompt_ext;
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.text_count=function(a){const b=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"TEXT",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"''";a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"SUB",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"''";return[module$exports$Blockly$JavaScript.javascriptGenerator.provideFunction_("textCount",`
|
||||
function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle) {
|
||||
if (needle.length === 0) {
|
||||
return haystack.length + 1;
|
||||
} else {
|
||||
return haystack.split(needle).length - 1;
|
||||
}
|
||||
}
|
||||
`)+"("+b+", "+a+")",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.text_replace=function(a){const b=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"TEXT",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"''",c=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"FROM",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"''";a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"TO",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||
|
||||
"''";return[module$exports$Blockly$JavaScript.javascriptGenerator.provideFunction_("textReplace",`
|
||||
function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle, replacement) {
|
||||
needle = needle.replace(/([-()\\[\\]{}+?*.$\\^|,:#<!\\\\])/g, '\\\\$1')
|
||||
.replace(/\\x08/g, '\\\\x08');
|
||||
return haystack.replace(new RegExp(needle, 'g'), replacement);
|
||||
}
|
||||
`)+"("+b+", "+c+", "+a+")",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};module$exports$Blockly$JavaScript.javascriptGenerator.text_reverse=function(a){return[(module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"TEXT",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER)||"''")+".split('').reverse().join('')",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};var module$exports$Blockly$JavaScript$procedures={},module$contents$Blockly$JavaScript$procedures_NameType=$.NameType$$module$build$src$core$names;
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.procedures_defreturn=function(a){const b=module$exports$Blockly$JavaScript.javascriptGenerator.nameDB_.getName(a.getFieldValue("NAME"),$.NameType$$module$build$src$core$names.PROCEDURE);var c="";module$exports$Blockly$JavaScript.javascriptGenerator.STATEMENT_PREFIX&&(c+=module$exports$Blockly$JavaScript.javascriptGenerator.injectId(module$exports$Blockly$JavaScript.javascriptGenerator.STATEMENT_PREFIX,a));module$exports$Blockly$JavaScript.javascriptGenerator.STATEMENT_SUFFIX&&
|
||||
(c+=module$exports$Blockly$JavaScript.javascriptGenerator.injectId(module$exports$Blockly$JavaScript.javascriptGenerator.STATEMENT_SUFFIX,a));c&&(c=module$exports$Blockly$JavaScript.javascriptGenerator.prefixLines(c,module$exports$Blockly$JavaScript.javascriptGenerator.INDENT));let d="";module$exports$Blockly$JavaScript.javascriptGenerator.INFINITE_LOOP_TRAP&&(d=module$exports$Blockly$JavaScript.javascriptGenerator.prefixLines(module$exports$Blockly$JavaScript.javascriptGenerator.injectId(module$exports$Blockly$JavaScript.javascriptGenerator.INFINITE_LOOP_TRAP,
|
||||
a),module$exports$Blockly$JavaScript.javascriptGenerator.INDENT));const e=module$exports$Blockly$JavaScript.javascriptGenerator.statementToCode(a,"STACK");let f=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"RETURN",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"",g="";e&&f&&(g=c);f&&(f=module$exports$Blockly$JavaScript.javascriptGenerator.INDENT+"return "+f+";\n");const h=[],k=a.getVars();for(let l=0;l<k.length;l++)h[l]=module$exports$Blockly$JavaScript.javascriptGenerator.nameDB_.getName(k[l],
|
||||
$.NameType$$module$build$src$core$names.VARIABLE);c="function "+b+"("+h.join(", ")+") {\n"+c+d+e+g+f+"}";c=module$exports$Blockly$JavaScript.javascriptGenerator.scrub_(a,c);module$exports$Blockly$JavaScript.javascriptGenerator.definitions_["%"+b]=c;return null};module$exports$Blockly$JavaScript.javascriptGenerator.procedures_defnoreturn=module$exports$Blockly$JavaScript.javascriptGenerator.procedures_defreturn;
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.procedures_callreturn=function(a){const b=module$exports$Blockly$JavaScript.javascriptGenerator.nameDB_.getName(a.getFieldValue("NAME"),$.NameType$$module$build$src$core$names.PROCEDURE),c=[],d=a.getVars();for(let e=0;e<d.length;e++)c[e]=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"ARG"+e,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"null";return[b+"("+c.join(", ")+")",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.procedures_callnoreturn=function(a){return module$exports$Blockly$JavaScript.javascriptGenerator.procedures_callreturn(a)[0]+";\n"};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.procedures_ifreturn=function(a){let b="if ("+(module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"CONDITION",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"false")+") {\n";module$exports$Blockly$JavaScript.javascriptGenerator.STATEMENT_SUFFIX&&(b+=module$exports$Blockly$JavaScript.javascriptGenerator.prefixLines(module$exports$Blockly$JavaScript.javascriptGenerator.injectId(module$exports$Blockly$JavaScript.javascriptGenerator.STATEMENT_SUFFIX,
|
||||
a),module$exports$Blockly$JavaScript.javascriptGenerator.INDENT));a.hasReturnValue_?(a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"VALUE",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"null",b+=module$exports$Blockly$JavaScript.javascriptGenerator.INDENT+"return "+a+";\n"):b+=module$exports$Blockly$JavaScript.javascriptGenerator.INDENT+"return;\n";return b+"}\n"};var module$exports$Blockly$JavaScript$math={},module$contents$Blockly$JavaScript$math_NameType=$.NameType$$module$build$src$core$names;module$exports$Blockly$JavaScript.javascriptGenerator.math_number=function(a){a=Number(a.getFieldValue("NUM"));return[a,0<=a?module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ATOMIC:module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_UNARY_NEGATION]};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.math_arithmetic=function(a){var b={ADD:[" + ",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ADDITION],MINUS:[" - ",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_SUBTRACTION],MULTIPLY:[" * ",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MULTIPLICATION],DIVIDE:[" / ",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_DIVISION],POWER:[null,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE]}[a.getFieldValue("OP")];
|
||||
const c=b[0];b=b[1];const d=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"A",b)||"0";a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"B",b)||"0";return c?[d+c+a,b]:["Math.pow("+d+", "+a+")",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.math_single=function(a){const b=a.getFieldValue("OP");let c;if("NEG"===b)return a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"NUM",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_UNARY_NEGATION)||"0","-"===a[0]&&(a=" "+a),["-"+a,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_UNARY_NEGATION];a="SIN"===b||"COS"===b||"TAN"===b?module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"NUM",
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_DIVISION)||"0":module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"NUM",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"0";switch(b){case "ABS":c="Math.abs("+a+")";break;case "ROOT":c="Math.sqrt("+a+")";break;case "LN":c="Math.log("+a+")";break;case "EXP":c="Math.exp("+a+")";break;case "POW10":c="Math.pow(10,"+a+")";break;case "ROUND":c="Math.round("+a+")";break;case "ROUNDUP":c="Math.ceil("+a+")";break;
|
||||
case "ROUNDDOWN":c="Math.floor("+a+")";break;case "SIN":c="Math.sin("+a+" / 180 * Math.PI)";break;case "COS":c="Math.cos("+a+" / 180 * Math.PI)";break;case "TAN":c="Math.tan("+a+" / 180 * Math.PI)"}if(c)return[c,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL];switch(b){case "LOG10":c="Math.log("+a+") / Math.log(10)";break;case "ASIN":c="Math.asin("+a+") / Math.PI * 180";break;case "ACOS":c="Math.acos("+a+") / Math.PI * 180";break;case "ATAN":c="Math.atan("+a+") / Math.PI * 180";
|
||||
break;default:throw Error("Unknown math operator: "+b);}return[c,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_DIVISION]};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.math_constant=function(a){return{PI:["Math.PI",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER],E:["Math.E",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER],GOLDEN_RATIO:["(1 + Math.sqrt(5)) / 2",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_DIVISION],SQRT2:["Math.SQRT2",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER],SQRT1_2:["Math.SQRT1_2",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER],
|
||||
INFINITY:["Infinity",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ATOMIC]}[a.getFieldValue("CONSTANT")]};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.math_number_property=function(a){var b={EVEN:[" % 2 === 0",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MODULUS,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_EQUALITY],ODD:[" % 2 === 1",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MODULUS,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_EQUALITY],WHOLE:[" % 1 === 0",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MODULUS,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_EQUALITY],
|
||||
POSITIVE:[" > 0",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_RELATIONAL,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_RELATIONAL],NEGATIVE:[" < 0",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_RELATIONAL,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_RELATIONAL],DIVISIBLE_BY:[null,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MODULUS,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_EQUALITY],PRIME:[null,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE,
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};const c=a.getFieldValue("PROPERTY"),[d,e,f]=b[c];b=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"NUMBER_TO_CHECK",e)||"0";"PRIME"===c?a=module$exports$Blockly$JavaScript.javascriptGenerator.provideFunction_("mathIsPrime",`
|
||||
function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(n) {
|
||||
// https://en.wikipedia.org/wiki/Primality_test#Naive_methods
|
||||
if (n == 2 || n == 3) {
|
||||
return true;
|
||||
}
|
||||
// False if n is NaN, negative, is 1, or not whole.
|
||||
// And false if n is divisible by 2 or 3.
|
||||
if (isNaN(n) || n <= 1 || n % 1 !== 0 || n % 2 === 0 || n % 3 === 0) {
|
||||
return false;
|
||||
}
|
||||
// Check all the numbers of form 6k +/- 1, up to sqrt(n).
|
||||
for (var x = 6; x <= Math.sqrt(n) + 1; x += 6) {
|
||||
if (n % (x - 1) === 0 || n % (x + 1) === 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
`)+"("+b+")":"DIVISIBLE_BY"===c?(a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"DIVISOR",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MODULUS)||"0",a=b+" % "+a+" === 0"):a=b+d;return[a,f]};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.math_change=function(a){const b=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"DELTA",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ADDITION)||"0";a=module$exports$Blockly$JavaScript.javascriptGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE);return a+" = (typeof "+a+" === 'number' ? "+a+" : 0) + "+b+";\n"};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.math_round=module$exports$Blockly$JavaScript.javascriptGenerator.math_single;module$exports$Blockly$JavaScript.javascriptGenerator.math_trig=module$exports$Blockly$JavaScript.javascriptGenerator.math_single;
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.math_on_list=function(a){var b=a.getFieldValue("OP");switch(b){case "SUM":a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"LIST",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER)||"[]";a+=".reduce(function(x, y) {return x + y;}, 0)";break;case "MIN":a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"LIST",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"[]";a="Math.min.apply(null, "+
|
||||
a+")";break;case "MAX":a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"LIST",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"[]";a="Math.max.apply(null, "+a+")";break;case "AVERAGE":b=module$exports$Blockly$JavaScript.javascriptGenerator.provideFunction_("mathMean",`
|
||||
function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(myList) {
|
||||
return myList.reduce(function(x, y) {return x + y;}, 0) / myList.length;
|
||||
}
|
||||
`);a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"LIST",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"[]";a=b+"("+a+")";break;case "MEDIAN":b=module$exports$Blockly$JavaScript.javascriptGenerator.provideFunction_("mathMedian",`
|
||||
function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(myList) {
|
||||
var localList = myList.filter(function (x) {return typeof x === 'number';});
|
||||
if (!localList.length) return null;
|
||||
localList.sort(function(a, b) {return b - a;});
|
||||
if (localList.length % 2 === 0) {
|
||||
return (localList[localList.length / 2 - 1] + localList[localList.length / 2]) / 2;
|
||||
} else {
|
||||
return localList[(localList.length - 1) / 2];
|
||||
}
|
||||
}
|
||||
`);a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"LIST",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"[]";a=b+"("+a+")";break;case "MODE":b=module$exports$Blockly$JavaScript.javascriptGenerator.provideFunction_("mathModes",`
|
||||
function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(values) {
|
||||
var modes = [];
|
||||
var counts = [];
|
||||
var maxCount = 0;
|
||||
for (var i = 0; i < values.length; i++) {
|
||||
var value = values[i];
|
||||
var found = false;
|
||||
var thisCount;
|
||||
for (var j = 0; j < counts.length; j++) {
|
||||
if (counts[j][0] === value) {
|
||||
thisCount = ++counts[j][1];
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
counts.push([value, 1]);
|
||||
thisCount = 1;
|
||||
}
|
||||
maxCount = Math.max(thisCount, maxCount);
|
||||
}
|
||||
for (var j = 0; j < counts.length; j++) {
|
||||
if (counts[j][1] === maxCount) {
|
||||
modes.push(counts[j][0]);
|
||||
}
|
||||
}
|
||||
return modes;
|
||||
}
|
||||
`);a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"LIST",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"[]";a=b+"("+a+")";break;case "STD_DEV":b=module$exports$Blockly$JavaScript.javascriptGenerator.provideFunction_("mathStandardDeviation",`
|
||||
function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(numbers) {
|
||||
var n = numbers.length;
|
||||
if (!n) return null;
|
||||
var mean = numbers.reduce(function(x, y) {return x + y;}) / n;
|
||||
var variance = 0;
|
||||
for (var j = 0; j < n; j++) {
|
||||
variance += Math.pow(numbers[j] - mean, 2);
|
||||
}
|
||||
variance = variance / n;
|
||||
return Math.sqrt(variance);
|
||||
}
|
||||
`);a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"LIST",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"[]";a=b+"("+a+")";break;case "RANDOM":b=module$exports$Blockly$JavaScript.javascriptGenerator.provideFunction_("mathRandomList",`
|
||||
function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(list) {
|
||||
var x = Math.floor(Math.random() * list.length);
|
||||
return list[x];
|
||||
}
|
||||
`);a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"LIST",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"[]";a=b+"("+a+")";break;default:throw Error("Unknown operator: "+b);}return[a,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.math_modulo=function(a){const b=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"DIVIDEND",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MODULUS)||"0";a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"DIVISOR",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MODULUS)||"0";return[b+" % "+a,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MODULUS]};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.math_constrain=function(a){const b=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"VALUE",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"0",c=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"LOW",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"0";a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"HIGH",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||
|
||||
"Infinity";return["Math.min(Math.max("+b+", "+c+"), "+a+")",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.math_random_int=function(a){const b=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"FROM",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"0";a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"TO",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"0";return[module$exports$Blockly$JavaScript.javascriptGenerator.provideFunction_("mathRandomInt",`
|
||||
function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(a, b) {
|
||||
if (a > b) {
|
||||
// Swap a and b to ensure a is smaller.
|
||||
var c = a;
|
||||
a = b;
|
||||
b = c;
|
||||
}
|
||||
return Math.floor(Math.random() * (b - a + 1) + a);
|
||||
}
|
||||
`)+"("+b+", "+a+")",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};module$exports$Blockly$JavaScript.javascriptGenerator.math_random_float=function(a){return["Math.random()",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.math_atan2=function(a){const b=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"X",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"0";return["Math.atan2("+(module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"Y",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"0")+", "+b+") / Math.PI * 180",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_DIVISION]};var module$exports$Blockly$JavaScript$loops={},module$contents$Blockly$JavaScript$loops_stringUtils=$.module$build$src$core$utils$string,module$contents$Blockly$JavaScript$loops_NameType=$.NameType$$module$build$src$core$names;
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.controls_repeat_ext=function(a){let b;b=a.getField("TIMES")?String(Number(a.getFieldValue("TIMES"))):module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"TIMES",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ASSIGNMENT)||"0";let c=module$exports$Blockly$JavaScript.javascriptGenerator.statementToCode(a,"DO");c=module$exports$Blockly$JavaScript.javascriptGenerator.addLoopTrap(c,a);a="";const d=module$exports$Blockly$JavaScript.javascriptGenerator.nameDB_.getDistinctName("count",
|
||||
$.NameType$$module$build$src$core$names.VARIABLE);let e=b;b.match(/^\w+$/)||$.module$build$src$core$utils$string.isNumber(b)||(e=module$exports$Blockly$JavaScript.javascriptGenerator.nameDB_.getDistinctName("repeat_end",$.NameType$$module$build$src$core$names.VARIABLE),a+="var "+e+" = "+b+";\n");return a+("for (var "+d+" = 0; "+d+" < "+e+"; "+d+"++) {\n"+c+"}\n")};module$exports$Blockly$JavaScript.javascriptGenerator.controls_repeat=module$exports$Blockly$JavaScript.javascriptGenerator.controls_repeat_ext;
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.controls_whileUntil=function(a){const b="UNTIL"===a.getFieldValue("MODE");let c=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"BOOL",b?module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_LOGICAL_NOT:module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"false",d=module$exports$Blockly$JavaScript.javascriptGenerator.statementToCode(a,"DO");d=module$exports$Blockly$JavaScript.javascriptGenerator.addLoopTrap(d,
|
||||
a);b&&(c="!"+c);return"while ("+c+") {\n"+d+"}\n"};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.controls_for=function(a){var b=module$exports$Blockly$JavaScript.javascriptGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE),c=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"FROM",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ASSIGNMENT)||"0",d=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"TO",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ASSIGNMENT)||
|
||||
"0";const e=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"BY",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ASSIGNMENT)||"1";let f=module$exports$Blockly$JavaScript.javascriptGenerator.statementToCode(a,"DO");f=module$exports$Blockly$JavaScript.javascriptGenerator.addLoopTrap(f,a);if($.module$build$src$core$utils$string.isNumber(c)&&$.module$build$src$core$utils$string.isNumber(d)&&$.module$build$src$core$utils$string.isNumber(e)){var g=Number(c)<=Number(d);a=
|
||||
"for ("+b+" = "+c+"; "+b+(g?" <= ":" >= ")+d+"; "+b;b=Math.abs(Number(e));a=1===b?a+(g?"++":"--"):a+((g?" += ":" -= ")+b);a+=") {\n"+f+"}\n"}else a="",g=c,c.match(/^\w+$/)||$.module$build$src$core$utils$string.isNumber(c)||(g=module$exports$Blockly$JavaScript.javascriptGenerator.nameDB_.getDistinctName(b+"_start",$.NameType$$module$build$src$core$names.VARIABLE),a+="var "+g+" = "+c+";\n"),c=d,d.match(/^\w+$/)||$.module$build$src$core$utils$string.isNumber(d)||(c=module$exports$Blockly$JavaScript.javascriptGenerator.nameDB_.getDistinctName(b+
|
||||
"_end",$.NameType$$module$build$src$core$names.VARIABLE),a+="var "+c+" = "+d+";\n"),d=module$exports$Blockly$JavaScript.javascriptGenerator.nameDB_.getDistinctName(b+"_inc",$.NameType$$module$build$src$core$names.VARIABLE),a+="var "+d+" = ",a=$.module$build$src$core$utils$string.isNumber(e)?a+(Math.abs(e)+";\n"):a+("Math.abs("+e+");\n"),a+="if ("+g+" > "+c+") {\n",a+=module$exports$Blockly$JavaScript.javascriptGenerator.INDENT+d+" = -"+d+";\n",a=a+"}\nfor ("+(b+" = "+g+"; "+d+" >= 0 ? "+b+" <= "+
|
||||
c+" : "+b+" >= "+c+"; "+b+" += "+d+") {\n"+f+"}\n");return a};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.controls_forEach=function(a){const b=module$exports$Blockly$JavaScript.javascriptGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE);var c=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"LIST",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ASSIGNMENT)||"[]";let d=module$exports$Blockly$JavaScript.javascriptGenerator.statementToCode(a,"DO");d=module$exports$Blockly$JavaScript.javascriptGenerator.addLoopTrap(d,
|
||||
a);a="";let e=c;c.match(/^\w+$/)||(e=module$exports$Blockly$JavaScript.javascriptGenerator.nameDB_.getDistinctName(b+"_list",$.NameType$$module$build$src$core$names.VARIABLE),a+="var "+e+" = "+c+";\n");c=module$exports$Blockly$JavaScript.javascriptGenerator.nameDB_.getDistinctName(b+"_index",$.NameType$$module$build$src$core$names.VARIABLE);d=module$exports$Blockly$JavaScript.javascriptGenerator.INDENT+b+" = "+e+"["+c+"];\n"+d;return a+("for (var "+c+" in "+e+") {\n"+d+"}\n")};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.controls_flow_statements=function(a){let b="";module$exports$Blockly$JavaScript.javascriptGenerator.STATEMENT_PREFIX&&(b+=module$exports$Blockly$JavaScript.javascriptGenerator.injectId(module$exports$Blockly$JavaScript.javascriptGenerator.STATEMENT_PREFIX,a));module$exports$Blockly$JavaScript.javascriptGenerator.STATEMENT_SUFFIX&&(b+=module$exports$Blockly$JavaScript.javascriptGenerator.injectId(module$exports$Blockly$JavaScript.javascriptGenerator.STATEMENT_SUFFIX,
|
||||
a));if(module$exports$Blockly$JavaScript.javascriptGenerator.STATEMENT_PREFIX){const c=a.getSurroundLoop();c&&!c.suppressPrefixSuffix&&(b+=module$exports$Blockly$JavaScript.javascriptGenerator.injectId(module$exports$Blockly$JavaScript.javascriptGenerator.STATEMENT_PREFIX,c))}switch(a.getFieldValue("FLOW")){case "BREAK":return b+"break;\n";case "CONTINUE":return b+"continue;\n"}throw Error("Unknown flow statement.");};var module$exports$Blockly$JavaScript$logic={};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.controls_if=function(a){var b=0;let c="";module$exports$Blockly$JavaScript.javascriptGenerator.STATEMENT_PREFIX&&(c+=module$exports$Blockly$JavaScript.javascriptGenerator.injectId(module$exports$Blockly$JavaScript.javascriptGenerator.STATEMENT_PREFIX,a));do{const d=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"IF"+b,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"false";let e=module$exports$Blockly$JavaScript.javascriptGenerator.statementToCode(a,
|
||||
"DO"+b);module$exports$Blockly$JavaScript.javascriptGenerator.STATEMENT_SUFFIX&&(e=module$exports$Blockly$JavaScript.javascriptGenerator.prefixLines(module$exports$Blockly$JavaScript.javascriptGenerator.injectId(module$exports$Blockly$JavaScript.javascriptGenerator.STATEMENT_SUFFIX,a),module$exports$Blockly$JavaScript.javascriptGenerator.INDENT)+e);c+=(0<b?" else ":"")+"if ("+d+") {\n"+e+"}";b++}while(a.getInput("IF"+b));if(a.getInput("ELSE")||module$exports$Blockly$JavaScript.javascriptGenerator.STATEMENT_SUFFIX)b=
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.statementToCode(a,"ELSE"),module$exports$Blockly$JavaScript.javascriptGenerator.STATEMENT_SUFFIX&&(b=module$exports$Blockly$JavaScript.javascriptGenerator.prefixLines(module$exports$Blockly$JavaScript.javascriptGenerator.injectId(module$exports$Blockly$JavaScript.javascriptGenerator.STATEMENT_SUFFIX,a),module$exports$Blockly$JavaScript.javascriptGenerator.INDENT)+b),c+=" else {\n"+b+"}";return c+"\n"};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.controls_ifelse=module$exports$Blockly$JavaScript.javascriptGenerator.controls_if;
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.logic_compare=function(a){const b={EQ:"==",NEQ:"!=",LT:"<",LTE:"<=",GT:">",GTE:">="}[a.getFieldValue("OP")],c="=="===b||"!="===b?module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_EQUALITY:module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_RELATIONAL,d=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"A",c)||"0";a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"B",c)||"0";return[d+" "+b+
|
||||
" "+a,c]};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.logic_operation=function(a){const b="AND"===a.getFieldValue("OP")?"&&":"||",c="&&"===b?module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_LOGICAL_AND:module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_LOGICAL_OR;let d=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"A",c);a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"B",c);if(d||a){const e="&&"===b?"true":"false";d||(d=e);a||(a=e)}else a=
|
||||
d="false";return[d+" "+b+" "+a,c]};module$exports$Blockly$JavaScript.javascriptGenerator.logic_negate=function(a){const b=module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_LOGICAL_NOT;return["!"+(module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"BOOL",b)||"true"),b]};module$exports$Blockly$JavaScript.javascriptGenerator.logic_boolean=function(a){return["TRUE"===a.getFieldValue("BOOL")?"true":"false",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ATOMIC]};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.logic_null=function(a){return["null",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ATOMIC]};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.logic_ternary=function(a){const b=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"IF",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_CONDITIONAL)||"false",c=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"THEN",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_CONDITIONAL)||"null";a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"ELSE",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_CONDITIONAL)||
|
||||
"null";return[b+" ? "+c+" : "+a,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_CONDITIONAL]};var module$exports$Blockly$JavaScript$lists={},module$contents$Blockly$JavaScript$lists_NameType=$.NameType$$module$build$src$core$names;module$exports$Blockly$JavaScript.javascriptGenerator.lists_create_empty=function(a){return["[]",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ATOMIC]};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.lists_create_with=function(a){const b=Array(a.itemCount_);for(let c=0;c<a.itemCount_;c++)b[c]=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"ADD"+c,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"null";return["["+b.join(", ")+"]",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ATOMIC]};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.lists_repeat=function(a){const b=module$exports$Blockly$JavaScript.javascriptGenerator.provideFunction_("listsRepeat",`
|
||||
function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(value, n) {
|
||||
var array = [];
|
||||
for (var i = 0; i < n; i++) {
|
||||
array[i] = value;
|
||||
}
|
||||
return array;
|
||||
}
|
||||
`),c=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"ITEM",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"null";a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"NUM",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"0";return[b+"("+c+", "+a+")",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.lists_length=function(a){return[(module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"VALUE",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER)||"[]")+".length",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER]};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.lists_isEmpty=function(a){return["!"+(module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"VALUE",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER)||"[]")+".length",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_LOGICAL_NOT]};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.lists_indexOf=function(a){var b="FIRST"===a.getFieldValue("END")?"indexOf":"lastIndexOf";const c=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"FIND",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"''";b=(module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"VALUE",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER)||"[]")+"."+b+"("+c+")";return a.workspace.options.oneBasedIndex?
|
||||
[b+" + 1",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ADDITION]:[b,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.lists_getIndex=function(a){const b=a.getFieldValue("MODE")||"GET",c=a.getFieldValue("WHERE")||"FROM_START";var d=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"VALUE","RANDOM"===c?module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE:module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER)||"[]";switch(c){case "FIRST":if("GET"===b)return[d+"[0]",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER];
|
||||
if("GET_REMOVE"===b)return[d+".shift()",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER];if("REMOVE"===b)return d+".shift();\n";break;case "LAST":if("GET"===b)return[d+".slice(-1)[0]",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER];if("GET_REMOVE"===b)return[d+".pop()",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER];if("REMOVE"===b)return d+".pop();\n";break;case "FROM_START":a=module$exports$Blockly$JavaScript.javascriptGenerator.getAdjusted(a,
|
||||
"AT");if("GET"===b)return[d+"["+a+"]",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER];if("GET_REMOVE"===b)return[d+".splice("+a+", 1)[0]",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL];if("REMOVE"===b)return d+".splice("+a+", 1);\n";break;case "FROM_END":a=module$exports$Blockly$JavaScript.javascriptGenerator.getAdjusted(a,"AT",1,!0);if("GET"===b)return[d+".slice("+a+")[0]",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL];if("GET_REMOVE"===
|
||||
b)return[d+".splice("+a+", 1)[0]",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL];if("REMOVE"===b)return d+".splice("+a+", 1);";break;case "RANDOM":d=module$exports$Blockly$JavaScript.javascriptGenerator.provideFunction_("listsGetRandomItem",`
|
||||
function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(list, remove) {
|
||||
var x = Math.floor(Math.random() * list.length);
|
||||
if (remove) {
|
||||
return list.splice(x, 1)[0];
|
||||
} else {
|
||||
return list[x];
|
||||
}
|
||||
}
|
||||
`)+"("+d+", "+("GET"!==b)+")";if("GET"===b||"GET_REMOVE"===b)return[d,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL];if("REMOVE"===b)return d+";\n"}throw Error("Unhandled combination (lists_getIndex).");};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.lists_setIndex=function(a){function b(){if(c.match(/^\w+$/))return"";const g=module$exports$Blockly$JavaScript.javascriptGenerator.nameDB_.getDistinctName("tmpList",$.NameType$$module$build$src$core$names.VARIABLE),h="var "+g+" = "+c+";\n";c=g;return h}let c=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"LIST",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER)||"[]";const d=a.getFieldValue("MODE")||"GET";
|
||||
var e=a.getFieldValue("WHERE")||"FROM_START";const f=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"TO",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ASSIGNMENT)||"null";switch(e){case "FIRST":if("SET"===d)return c+"[0] = "+f+";\n";if("INSERT"===d)return c+".unshift("+f+");\n";break;case "LAST":if("SET"===d)return b()+(c+"["+c+".length - 1] = "+f+";\n");if("INSERT"===d)return c+".push("+f+");\n";break;case "FROM_START":a=module$exports$Blockly$JavaScript.javascriptGenerator.getAdjusted(a,
|
||||
"AT");if("SET"===d)return c+"["+a+"] = "+f+";\n";if("INSERT"===d)return c+".splice("+a+", 0, "+f+");\n";break;case "FROM_END":a=module$exports$Blockly$JavaScript.javascriptGenerator.getAdjusted(a,"AT",1,!1,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_SUBTRACTION);e=b();if("SET"===d)return e+(c+"["+c+".length - "+a+"] = "+f+";\n");if("INSERT"===d)return e+(c+".splice("+c+".length - "+a+", 0, "+f+");\n");break;case "RANDOM":a=b();e=module$exports$Blockly$JavaScript.javascriptGenerator.nameDB_.getDistinctName("tmpX",
|
||||
$.NameType$$module$build$src$core$names.VARIABLE);a+="var "+e+" = Math.floor(Math.random() * "+c+".length);\n";if("SET"===d)return a+(c+"["+e+"] = "+f+";\n");if("INSERT"===d)return a+(c+".splice("+e+", 0, "+f+");\n")}throw Error("Unhandled combination (lists_setIndex).");};var module$contents$Blockly$JavaScript$lists_getSubstringIndex=function(a,b,c){return"FIRST"===b?"0":"FROM_END"===b?a+".length - 1 - "+c:"LAST"===b?a+".length - 1":c};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.lists_getSublist=function(a){var b=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"LIST",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER)||"[]",c=a.getFieldValue("WHERE1"),d=a.getFieldValue("WHERE2");if("FIRST"===c&&"LAST"===d)b+=".slice(0)";else if(b.match(/^\w+$/)||"FROM_END"!==c&&"FROM_START"===d){switch(c){case "FROM_START":c=module$exports$Blockly$JavaScript.javascriptGenerator.getAdjusted(a,"AT1");
|
||||
break;case "FROM_END":c=module$exports$Blockly$JavaScript.javascriptGenerator.getAdjusted(a,"AT1",1,!1,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_SUBTRACTION);c=b+".length - "+c;break;case "FIRST":c="0";break;default:throw Error("Unhandled option (lists_getSublist).");}switch(d){case "FROM_START":d=module$exports$Blockly$JavaScript.javascriptGenerator.getAdjusted(a,"AT2",1);break;case "FROM_END":d=module$exports$Blockly$JavaScript.javascriptGenerator.getAdjusted(a,"AT2",0,!1,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_SUBTRACTION);
|
||||
d=b+".length - "+d;break;case "LAST":d=b+".length";break;default:throw Error("Unhandled option (lists_getSublist).");}b=b+".slice("+c+", "+d+")"}else{const e=module$exports$Blockly$JavaScript.javascriptGenerator.getAdjusted(a,"AT1");a=module$exports$Blockly$JavaScript.javascriptGenerator.getAdjusted(a,"AT2");const f={FIRST:"First",LAST:"Last",FROM_START:"FromStart",FROM_END:"FromEnd"};b=module$exports$Blockly$JavaScript.javascriptGenerator.provideFunction_("subsequence"+f[c]+f[d],`
|
||||
function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(sequence${"FROM_END"===c||"FROM_START"===c?", at1":""}${"FROM_END"===d||"FROM_START"===d?", at2":""}) {
|
||||
var start = ${module$contents$Blockly$JavaScript$lists_getSubstringIndex("sequence",c,"at1")};
|
||||
var end = ${module$contents$Blockly$JavaScript$lists_getSubstringIndex("sequence",d,"at2")} + 1;
|
||||
return sequence.slice(start, end);
|
||||
}
|
||||
`)+"("+b+("FROM_END"===c||"FROM_START"===c?", "+e:"")+("FROM_END"===d||"FROM_START"===d?", "+a:"")+")"}return[b,module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.lists_sort=function(a){const b=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"LIST",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL)||"[]",c="1"===a.getFieldValue("DIRECTION")?1:-1;a=a.getFieldValue("TYPE");const d=module$exports$Blockly$JavaScript.javascriptGenerator.provideFunction_("listsGetSortCompare",`
|
||||
function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(type, direction) {
|
||||
var compareFuncs = {
|
||||
'NUMERIC': function(a, b) {
|
||||
return Number(a) - Number(b); },
|
||||
'TEXT': function(a, b) {
|
||||
return a.toString() > b.toString() ? 1 : -1; },
|
||||
'IGNORE_CASE': function(a, b) {
|
||||
return a.toString().toLowerCase() > b.toString().toLowerCase() ? 1 : -1; },
|
||||
};
|
||||
var compare = compareFuncs[type];
|
||||
return function(a, b) { return compare(a, b) * direction; };
|
||||
}
|
||||
`);return[b+".slice().sort("+d+'("'+a+'", '+c+"))",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.lists_split=function(a){let b=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"INPUT",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_MEMBER);const c=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"DELIM",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"''";a=a.getFieldValue("MODE");if("SPLIT"===a)b||(b="''"),a="split";else if("JOIN"===a)b||(b="[]"),a="join";else throw Error("Unknown mode: "+
|
||||
a);return[b+"."+a+"("+c+")",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};module$exports$Blockly$JavaScript.javascriptGenerator.lists_reverse=function(a){return[(module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"LIST",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL)||"[]")+".slice().reverse()",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};var module$exports$Blockly$JavaScript$colour={};module$exports$Blockly$JavaScript.javascriptGenerator.colour_picker=function(a){return[module$exports$Blockly$JavaScript.javascriptGenerator.quote_(a.getFieldValue("COLOUR")),module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_ATOMIC]};module$exports$Blockly$JavaScript.javascriptGenerator.colour_random=function(a){return[module$exports$Blockly$JavaScript.javascriptGenerator.provideFunction_("colourRandom",`
|
||||
function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}() {
|
||||
var num = Math.floor(Math.random() * Math.pow(2, 24));
|
||||
return '#' + ('00000' + num.toString(16)).substr(-6);
|
||||
}
|
||||
`)+"()",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.colour_rgb=function(a){const b=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"RED",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||0,c=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"GREEN",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||0;a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"BLUE",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||
|
||||
0;return[module$exports$Blockly$JavaScript.javascriptGenerator.provideFunction_("colourRgb",`
|
||||
function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(r, g, b) {
|
||||
r = Math.max(Math.min(Number(r), 100), 0) * 2.55;
|
||||
g = Math.max(Math.min(Number(g), 100), 0) * 2.55;
|
||||
b = Math.max(Math.min(Number(b), 100), 0) * 2.55;
|
||||
r = ('0' + (Math.round(r) || 0).toString(16)).slice(-2);
|
||||
g = ('0' + (Math.round(g) || 0).toString(16)).slice(-2);
|
||||
b = ('0' + (Math.round(b) || 0).toString(16)).slice(-2);
|
||||
return '#' + r + g + b;
|
||||
}
|
||||
`)+"("+b+", "+c+", "+a+")",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$JavaScript.javascriptGenerator.colour_blend=function(a){const b=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"COLOUR1",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"'#000000'",c=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"COLOUR2",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||"'#000000'";a=module$exports$Blockly$JavaScript.javascriptGenerator.valueToCode(a,"RATIO",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_NONE)||
|
||||
.5;return[module$exports$Blockly$JavaScript.javascriptGenerator.provideFunction_("colourBlend",`
|
||||
function ${module$exports$Blockly$JavaScript.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(c1, c2, ratio) {
|
||||
ratio = Math.max(Math.min(Number(ratio), 1), 0);
|
||||
var r1 = parseInt(c1.substring(1, 3), 16);
|
||||
var g1 = parseInt(c1.substring(3, 5), 16);
|
||||
var b1 = parseInt(c1.substring(5, 7), 16);
|
||||
var r2 = parseInt(c2.substring(1, 3), 16);
|
||||
var g2 = parseInt(c2.substring(3, 5), 16);
|
||||
var b2 = parseInt(c2.substring(5, 7), 16);
|
||||
var r = Math.round(r1 * (1 - ratio) + r2 * ratio);
|
||||
var g = Math.round(g1 * (1 - ratio) + g2 * ratio);
|
||||
var b = Math.round(b1 * (1 - ratio) + b2 * ratio);
|
||||
r = ('0' + (r || 0).toString(16)).slice(-2);
|
||||
g = ('0' + (g || 0).toString(16)).slice(-2);
|
||||
b = ('0' + (b || 0).toString(16)).slice(-2);
|
||||
return '#' + r + g + b;
|
||||
}
|
||||
`)+"("+b+", "+c+", "+a+")",module$exports$Blockly$JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};var module$exports$Blockly$JavaScript$all=module$exports$Blockly$JavaScript;
|
||||
module$exports$Blockly$JavaScript.__namespace__=$;
|
||||
return module$exports$Blockly$JavaScript;
|
||||
}));
|
||||
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
+399
-81
@@ -8,90 +8,408 @@
|
||||
module.exports = factory(require("./blockly_compressed.js"));
|
||||
} else { // Browser
|
||||
var factoryExports = factory(root.Blockly);
|
||||
root.Blockly.Lua = factoryExports;
|
||||
root.Blockly.Lua = factoryExports.luaGenerator;
|
||||
root.Blockly.Lua.__namespace__ = factoryExports.__namespace__;
|
||||
}
|
||||
}(this, function(__parent__) {
|
||||
var $=__parent__.__namespace__;
|
||||
var module$contents$Blockly$Lua_Lua=new $.module$exports$Blockly$Generator.Generator("Lua");module$contents$Blockly$Lua_Lua.addReservedWords("_,__inext,assert,bit,colors,colours,coroutine,disk,dofile,error,fs,fetfenv,getmetatable,gps,help,io,ipairs,keys,loadfile,loadstring,math,native,next,os,paintutils,pairs,parallel,pcall,peripheral,print,printError,rawequal,rawget,rawset,read,rednet,redstone,rs,select,setfenv,setmetatable,sleep,string,table,term,textutils,tonumber,tostring,turtle,type,unpack,vector,write,xpcall,_VERSION,__indext,HTTP,and,break,do,else,elseif,end,false,for,function,if,in,local,nil,not,or,repeat,return,then,true,until,while,add,sub,mul,div,mod,pow,unm,concat,len,eq,lt,le,index,newindex,call,assert,collectgarbage,dofile,error,_G,getmetatable,inpairs,load,loadfile,next,pairs,pcall,print,rawequal,rawget,rawlen,rawset,select,setmetatable,tonumber,tostring,type,_VERSION,xpcall,require,package,string,table,math,bit32,io,file,os,debug");
|
||||
module$contents$Blockly$Lua_Lua.ORDER_ATOMIC=0;module$contents$Blockly$Lua_Lua.ORDER_HIGH=1;module$contents$Blockly$Lua_Lua.ORDER_EXPONENTIATION=2;module$contents$Blockly$Lua_Lua.ORDER_UNARY=3;module$contents$Blockly$Lua_Lua.ORDER_MULTIPLICATIVE=4;module$contents$Blockly$Lua_Lua.ORDER_ADDITIVE=5;module$contents$Blockly$Lua_Lua.ORDER_CONCATENATION=6;module$contents$Blockly$Lua_Lua.ORDER_RELATIONAL=7;module$contents$Blockly$Lua_Lua.ORDER_AND=8;module$contents$Blockly$Lua_Lua.ORDER_OR=9;
|
||||
module$contents$Blockly$Lua_Lua.ORDER_NONE=99;module$contents$Blockly$Lua_Lua.isInitialized=!1;module$contents$Blockly$Lua_Lua.init=function(a){Object.getPrototypeOf(this).init.call(this);this.nameDB_?this.nameDB_.reset():this.nameDB_=new $.module$exports$Blockly$Names.Names(this.RESERVED_WORDS_);this.nameDB_.setVariableMap(a.getVariableMap());this.nameDB_.populateVariables(a);this.nameDB_.populateProcedures(a);this.isInitialized=!0};
|
||||
module$contents$Blockly$Lua_Lua.finish=function(a){var b=(0,$.module$exports$Blockly$utils$object.values)(this.definitions_);a=Object.getPrototypeOf(this).finish.call(this,a);this.isInitialized=!1;this.nameDB_.reset();return b.join("\n\n")+"\n\n\n"+a};module$contents$Blockly$Lua_Lua.scrubNakedValue=function(a){return"local _ = "+a+"\n"};module$contents$Blockly$Lua_Lua.quote_=function(a){a=a.replace(/\\/g,"\\\\").replace(/\n/g,"\\\n").replace(/'/g,"\\'");return"'"+a+"'"};
|
||||
module$contents$Blockly$Lua_Lua.multiline_quote_=function(a){return a.split(/\n/g).map(this.quote_).join(" .. '\\n' ..\n")};
|
||||
module$contents$Blockly$Lua_Lua.scrub_=function(a,b,c){var d="";if(!a.outputConnection||!a.outputConnection.targetConnection){var e=a.getCommentText();e&&(e=(0,$.module$exports$Blockly$utils$string.wrap)(e,this.COMMENT_WRAP-3),d+=this.prefixLines(e,"-- ")+"\n");for(var f=0;f<a.inputList.length;f++)a.inputList[f].type===$.module$exports$Blockly$inputTypes.inputTypes.VALUE&&(e=a.inputList[f].connection.targetBlock())&&(e=this.allNestedComments(e))&&(d+=this.prefixLines(e,"-- "))}a=a.nextConnection&&
|
||||
a.nextConnection.targetBlock();c=c?"":this.blockToCode(a);return d+b+c};$.Blockly.Lua=module$contents$Blockly$Lua_Lua;var module$exports$Blockly$Lua$variables={};$.Blockly.Lua.variables_get=function(a){return[$.Blockly.Lua.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE),$.Blockly.Lua.ORDER_ATOMIC]};$.Blockly.Lua.variables_set=function(a){var b=$.Blockly.Lua.valueToCode(a,"VALUE",$.Blockly.Lua.ORDER_NONE)||"0";return $.Blockly.Lua.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE)+" = "+b+"\n"};var module$exports$Blockly$Lua$variablesDynamic={};$.Blockly.Lua.variables_get_dynamic=$.Blockly.Lua.variables_get;$.Blockly.Lua.variables_set_dynamic=$.Blockly.Lua.variables_set;var module$exports$Blockly$Lua$texts={};$.Blockly.Lua.text=function(a){return[$.Blockly.Lua.quote_(a.getFieldValue("TEXT")),$.Blockly.Lua.ORDER_ATOMIC]};$.Blockly.Lua.text_multiline=function(a){a=$.Blockly.Lua.multiline_quote_(a.getFieldValue("TEXT"));var b=-1!==a.indexOf("..")?$.Blockly.Lua.ORDER_CONCATENATION:$.Blockly.Lua.ORDER_ATOMIC;return[a,b]};
|
||||
$.Blockly.Lua.text_join=function(a){if(0===a.itemCount_)return["''",$.Blockly.Lua.ORDER_ATOMIC];if(1===a.itemCount_)return["tostring("+($.Blockly.Lua.valueToCode(a,"ADD0",$.Blockly.Lua.ORDER_NONE)||"''")+")",$.Blockly.Lua.ORDER_HIGH];if(2===a.itemCount_){var b=$.Blockly.Lua.valueToCode(a,"ADD0",$.Blockly.Lua.ORDER_CONCATENATION)||"''";a=$.Blockly.Lua.valueToCode(a,"ADD1",$.Blockly.Lua.ORDER_CONCATENATION)||"''";return[b+" .. "+a,$.Blockly.Lua.ORDER_CONCATENATION]}b=[];for(var c=0;c<a.itemCount_;c++)b[c]=
|
||||
$.Blockly.Lua.valueToCode(a,"ADD"+c,$.Blockly.Lua.ORDER_NONE)||"''";return["table.concat({"+b.join(", ")+"})",$.Blockly.Lua.ORDER_HIGH]};$.Blockly.Lua.text_append=function(a){var b=$.Blockly.Lua.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE);a=$.Blockly.Lua.valueToCode(a,"TEXT",$.Blockly.Lua.ORDER_CONCATENATION)||"''";return b+" = "+b+" .. "+a+"\n"};
|
||||
$.Blockly.Lua.text_length=function(a){return["#"+($.Blockly.Lua.valueToCode(a,"VALUE",$.Blockly.Lua.ORDER_UNARY)||"''"),$.Blockly.Lua.ORDER_UNARY]};$.Blockly.Lua.text_isEmpty=function(a){return["#"+($.Blockly.Lua.valueToCode(a,"VALUE",$.Blockly.Lua.ORDER_UNARY)||"''")+" == 0",$.Blockly.Lua.ORDER_RELATIONAL]};
|
||||
$.Blockly.Lua.text_indexOf=function(a){var b=$.Blockly.Lua.valueToCode(a,"FIND",$.Blockly.Lua.ORDER_NONE)||"''",c=$.Blockly.Lua.valueToCode(a,"VALUE",$.Blockly.Lua.ORDER_NONE)||"''";return[("FIRST"===a.getFieldValue("END")?$.Blockly.Lua.provideFunction_("firstIndexOf","\nfunction "+$.Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(str, substr)\n local i = string.find(str, substr, 1, true)\n if i == nil then\n return 0\n end\n return i\nend\n"):$.Blockly.Lua.provideFunction_("lastIndexOf","\nfunction "+
|
||||
$.Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(str, substr)\n local i = string.find(string.reverse(str), string.reverse(substr), 1, true)\n if i then\n return #str + 2 - i - #substr\n end\n return 0\nend\n"))+"("+c+", "+b+")",$.Blockly.Lua.ORDER_HIGH]};
|
||||
$.Blockly.Lua.text_charAt=function(a){var b=a.getFieldValue("WHERE")||"FROM_START",c=$.Blockly.Lua.valueToCode(a,"AT","FROM_END"===b?$.Blockly.Lua.ORDER_UNARY:$.Blockly.Lua.ORDER_NONE)||"1";a=$.Blockly.Lua.valueToCode(a,"VALUE",$.Blockly.Lua.ORDER_NONE)||"''";if("RANDOM"===b)b=$.Blockly.Lua.provideFunction_("text_random_letter","\nfunction "+$.Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(str)\n local index = math.random(string.len(str))\n return string.sub(str, index, index)\nend\n")+"("+a+")";else{if("FIRST"===
|
||||
b)b="1";else if("LAST"===b)b="-1";else if("FROM_START"===b)b=c;else if("FROM_END"===b)b="-"+c;else throw Error("Unhandled option (text_charAt).");b=b.match(/^-?\w*$/)?"string.sub("+a+", "+b+", "+b+")":$.Blockly.Lua.provideFunction_("text_char_at","\nfunction "+$.Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(str, index)\n return string.sub(str, index, index)\nend\n")+"("+a+", "+b+")"}return[b,$.Blockly.Lua.ORDER_HIGH]};
|
||||
$.Blockly.Lua.text_getSubstring=function(a){var b=$.Blockly.Lua.valueToCode(a,"STRING",$.Blockly.Lua.ORDER_NONE)||"''",c=a.getFieldValue("WHERE1"),d=$.Blockly.Lua.valueToCode(a,"AT1","FROM_END"===c?$.Blockly.Lua.ORDER_UNARY:$.Blockly.Lua.ORDER_NONE)||"1";if("FIRST"===c)c=1;else if("FROM_START"===c)c=d;else if("FROM_END"===c)c="-"+d;else throw Error("Unhandled option (text_getSubstring)");d=a.getFieldValue("WHERE2");a=$.Blockly.Lua.valueToCode(a,"AT2","FROM_END"===d?$.Blockly.Lua.ORDER_UNARY:$.Blockly.Lua.ORDER_NONE)||
|
||||
"1";if("LAST"===d)a=-1;else if("FROM_START"!==d)if("FROM_END"===d)a="-"+a;else throw Error("Unhandled option (text_getSubstring)");return["string.sub("+b+", "+c+", "+a+")",$.Blockly.Lua.ORDER_HIGH]};
|
||||
$.Blockly.Lua.text_changeCase=function(a){var b=a.getFieldValue("CASE");a=$.Blockly.Lua.valueToCode(a,"TEXT",$.Blockly.Lua.ORDER_NONE)||"''";var c;"UPPERCASE"===b?c="string.upper":"LOWERCASE"===b?c="string.lower":"TITLECASE"===b&&(c=$.Blockly.Lua.provideFunction_("text_titlecase","\nfunction "+$.Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+'(str)\n local buf = {}\n local inWord = false\n for i = 1, #str do\n local c = string.sub(str, i, i)\n if inWord then\n table.insert(buf, string.lower(c))\n if string.find(c, "%s") then\n inWord = false\n end\n else\n table.insert(buf, string.upper(c))\n inWord = true\n end\n end\n return table.concat(buf)\nend\n'));
|
||||
return[c+"("+a+")",$.Blockly.Lua.ORDER_HIGH]};$.Blockly.Lua.text_trim=function(a){var b={LEFT:"^%s*(,-)",RIGHT:"(.-)%s*$",BOTH:"^%s*(.-)%s*$"}[a.getFieldValue("MODE")];return["string.gsub("+($.Blockly.Lua.valueToCode(a,"TEXT",$.Blockly.Lua.ORDER_NONE)||"''")+', "'+b+'", "%1")',$.Blockly.Lua.ORDER_HIGH]};$.Blockly.Lua.text_print=function(a){return"print("+($.Blockly.Lua.valueToCode(a,"TEXT",$.Blockly.Lua.ORDER_NONE)||"''")+")\n"};
|
||||
$.Blockly.Lua.text_prompt_ext=function(a){var b=a.getField("TEXT")?$.Blockly.Lua.quote_(a.getFieldValue("TEXT")):$.Blockly.Lua.valueToCode(a,"TEXT",$.Blockly.Lua.ORDER_NONE)||"''";b=$.Blockly.Lua.provideFunction_("text_prompt","\nfunction "+$.Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(msg)\n io.write(msg)\n io.flush()\n return io.read()\nend\n")+"("+b+")";"NUMBER"===a.getFieldValue("TYPE")&&(b="tonumber("+b+", 10)");return[b,$.Blockly.Lua.ORDER_HIGH]};$.Blockly.Lua.text_prompt=$.Blockly.Lua.text_prompt_ext;
|
||||
$.Blockly.Lua.text_count=function(a){var b=$.Blockly.Lua.valueToCode(a,"TEXT",$.Blockly.Lua.ORDER_NONE)||"''";a=$.Blockly.Lua.valueToCode(a,"SUB",$.Blockly.Lua.ORDER_NONE)||"''";return[$.Blockly.Lua.provideFunction_("text_count","\nfunction "+$.Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(haystack, needle)\n if #needle == 0 then\n return #haystack + 1\n end\n local i = 1\n local count = 0\n while true do\n i = string.find(haystack, needle, i, true)\n if i == nil then\n break\n end\n count = count + 1\n i = i + #needle\n end\n return count\nend\n")+
|
||||
"("+b+", "+a+")",$.Blockly.Lua.ORDER_HIGH]};
|
||||
$.Blockly.Lua.text_replace=function(a){var b=$.Blockly.Lua.valueToCode(a,"TEXT",$.Blockly.Lua.ORDER_NONE)||"''",c=$.Blockly.Lua.valueToCode(a,"FROM",$.Blockly.Lua.ORDER_NONE)||"''";a=$.Blockly.Lua.valueToCode(a,"TO",$.Blockly.Lua.ORDER_NONE)||"''";return[$.Blockly.Lua.provideFunction_("text_replace","\nfunction "+$.Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(haystack, needle, replacement)\n local buf = {}\n local i = 1\n while i <= #haystack do\n if string.sub(haystack, i, i + #needle - 1) == needle then\n for j = 1, #replacement do\n table.insert(buf, string.sub(replacement, j, j))\n end\n i = i + #needle\n else\n table.insert(buf, string.sub(haystack, i, i))\n i = i + 1\n end\n end\n return table.concat(buf)\nend\n")+"("+
|
||||
b+", "+c+", "+a+")",$.Blockly.Lua.ORDER_HIGH]};$.Blockly.Lua.text_reverse=function(a){return["string.reverse("+($.Blockly.Lua.valueToCode(a,"TEXT",$.Blockly.Lua.ORDER_NONE)||"''")+")",$.Blockly.Lua.ORDER_HIGH]};var module$exports$Blockly$Lua$procedures={};
|
||||
$.Blockly.Lua.procedures_defreturn=function(a){var b=$.Blockly.Lua.nameDB_.getName(a.getFieldValue("NAME"),$.module$exports$Blockly$Names.NameType.PROCEDURE),c="";$.Blockly.Lua.STATEMENT_PREFIX&&(c+=$.Blockly.Lua.injectId($.Blockly.Lua.STATEMENT_PREFIX,a));$.Blockly.Lua.STATEMENT_SUFFIX&&(c+=$.Blockly.Lua.injectId($.Blockly.Lua.STATEMENT_SUFFIX,a));c&&(c=$.Blockly.Lua.prefixLines(c,$.Blockly.Lua.INDENT));var d="";$.Blockly.Lua.INFINITE_LOOP_TRAP&&(d=$.Blockly.Lua.prefixLines($.Blockly.Lua.injectId($.Blockly.Lua.INFINITE_LOOP_TRAP,a),
|
||||
$.Blockly.Lua.INDENT));var e=$.Blockly.Lua.statementToCode(a,"STACK"),f=$.Blockly.Lua.valueToCode(a,"RETURN",$.Blockly.Lua.ORDER_NONE)||"",g="";e&&f&&(g=c);f?f=$.Blockly.Lua.INDENT+"return "+f+"\n":e||(e="");for(var h=[],k=a.getVars(),l=0;l<k.length;l++)h[l]=$.Blockly.Lua.nameDB_.getName(k[l],$.module$exports$Blockly$Names.NameType.VARIABLE);c="function "+b+"("+h.join(", ")+")\n"+c+d+e+g+f+"end\n";c=$.Blockly.Lua.scrub_(a,c);$.Blockly.Lua.definitions_["%"+b]=c;return null};
|
||||
$.Blockly.Lua.procedures_defnoreturn=$.Blockly.Lua.procedures_defreturn;$.Blockly.Lua.procedures_callreturn=function(a){for(var b=$.Blockly.Lua.nameDB_.getName(a.getFieldValue("NAME"),$.module$exports$Blockly$Names.NameType.PROCEDURE),c=[],d=a.getVars(),e=0;e<d.length;e++)c[e]=$.Blockly.Lua.valueToCode(a,"ARG"+e,$.Blockly.Lua.ORDER_NONE)||"nil";return[b+"("+c.join(", ")+")",$.Blockly.Lua.ORDER_HIGH]};
|
||||
$.Blockly.Lua.procedures_callnoreturn=function(a){return $.Blockly.Lua.procedures_callreturn(a)[0]+"\n"};
|
||||
$.Blockly.Lua.procedures_ifreturn=function(a){var b="if "+($.Blockly.Lua.valueToCode(a,"CONDITION",$.Blockly.Lua.ORDER_NONE)||"false")+" then\n";$.Blockly.Lua.STATEMENT_SUFFIX&&(b+=$.Blockly.Lua.prefixLines($.Blockly.Lua.injectId($.Blockly.Lua.STATEMENT_SUFFIX,a),$.Blockly.Lua.INDENT));a.hasReturnValue_?(a=$.Blockly.Lua.valueToCode(a,"VALUE",$.Blockly.Lua.ORDER_NONE)||"nil",b+=$.Blockly.Lua.INDENT+"return "+a+"\n"):b+=$.Blockly.Lua.INDENT+"return\n";return b+"end\n"};var module$exports$Blockly$Lua$math={};$.Blockly.Lua.math_number=function(a){a=Number(a.getFieldValue("NUM"));return[a,0>a?$.Blockly.Lua.ORDER_UNARY:$.Blockly.Lua.ORDER_ATOMIC]};
|
||||
$.Blockly.Lua.math_arithmetic=function(a){var b={ADD:[" + ",$.Blockly.Lua.ORDER_ADDITIVE],MINUS:[" - ",$.Blockly.Lua.ORDER_ADDITIVE],MULTIPLY:[" * ",$.Blockly.Lua.ORDER_MULTIPLICATIVE],DIVIDE:[" / ",$.Blockly.Lua.ORDER_MULTIPLICATIVE],POWER:[" ^ ",$.Blockly.Lua.ORDER_EXPONENTIATION]}[a.getFieldValue("OP")],c=b[0];b=b[1];var d=$.Blockly.Lua.valueToCode(a,"A",b)||"0";a=$.Blockly.Lua.valueToCode(a,"B",b)||"0";return[d+c+a,b]};
|
||||
$.Blockly.Lua.math_single=function(a){var b=a.getFieldValue("OP");if("NEG"===b)return a=$.Blockly.Lua.valueToCode(a,"NUM",$.Blockly.Lua.ORDER_UNARY)||"0",["-"+a,$.Blockly.Lua.ORDER_UNARY];if("POW10"===b)return a=$.Blockly.Lua.valueToCode(a,"NUM",$.Blockly.Lua.ORDER_EXPONENTIATION)||"0",["10 ^ "+a,$.Blockly.Lua.ORDER_EXPONENTIATION];a="ROUND"===b?$.Blockly.Lua.valueToCode(a,"NUM",$.Blockly.Lua.ORDER_ADDITIVE)||"0":$.Blockly.Lua.valueToCode(a,"NUM",$.Blockly.Lua.ORDER_NONE)||"0";switch(b){case "ABS":b=
|
||||
"math.abs("+a+")";break;case "ROOT":b="math.sqrt("+a+")";break;case "LN":b="math.log("+a+")";break;case "LOG10":b="math.log("+a+", 10)";break;case "EXP":b="math.exp("+a+")";break;case "ROUND":b="math.floor("+a+" + .5)";break;case "ROUNDUP":b="math.ceil("+a+")";break;case "ROUNDDOWN":b="math.floor("+a+")";break;case "SIN":b="math.sin(math.rad("+a+"))";break;case "COS":b="math.cos(math.rad("+a+"))";break;case "TAN":b="math.tan(math.rad("+a+"))";break;case "ASIN":b="math.deg(math.asin("+a+"))";break;
|
||||
case "ACOS":b="math.deg(math.acos("+a+"))";break;case "ATAN":b="math.deg(math.atan("+a+"))";break;default:throw Error("Unknown math operator: "+b);}return[b,$.Blockly.Lua.ORDER_HIGH]};
|
||||
$.Blockly.Lua.math_constant=function(a){return{PI:["math.pi",$.Blockly.Lua.ORDER_HIGH],E:["math.exp(1)",$.Blockly.Lua.ORDER_HIGH],GOLDEN_RATIO:["(1 + math.sqrt(5)) / 2",$.Blockly.Lua.ORDER_MULTIPLICATIVE],SQRT2:["math.sqrt(2)",$.Blockly.Lua.ORDER_HIGH],SQRT1_2:["math.sqrt(1 / 2)",$.Blockly.Lua.ORDER_HIGH],INFINITY:["math.huge",$.Blockly.Lua.ORDER_HIGH]}[a.getFieldValue("CONSTANT")]};
|
||||
$.Blockly.Lua.math_number_property=function(a){var b={EVEN:[" % 2 == 0",$.Blockly.Lua.ORDER_MULTIPLICATIVE,$.Blockly.Lua.ORDER_RELATIONAL],ODD:[" % 2 == 1",$.Blockly.Lua.ORDER_MULTIPLICATIVE,$.Blockly.Lua.ORDER_RELATIONAL],WHOLE:[" % 1 == 0",$.Blockly.Lua.ORDER_MULTIPLICATIVE,$.Blockly.Lua.ORDER_RELATIONAL],POSITIVE:[" > 0",$.Blockly.Lua.ORDER_RELATIONAL,$.Blockly.Lua.ORDER_RELATIONAL],NEGATIVE:[" < 0",$.Blockly.Lua.ORDER_RELATIONAL,$.Blockly.Lua.ORDER_RELATIONAL],DIVISIBLE_BY:[null,$.Blockly.Lua.ORDER_MULTIPLICATIVE,
|
||||
$.Blockly.Lua.ORDER_RELATIONAL],PRIME:[null,$.Blockly.Lua.ORDER_NONE,$.Blockly.Lua.ORDER_HIGH]},c=a.getFieldValue("PROPERTY");b=$.$jscomp.makeIterator(b[c]);var d=b.next().value,e=b.next().value;b=b.next().value;e=$.Blockly.Lua.valueToCode(a,"NUMBER_TO_CHECK",e)||"0";if("PRIME"===c)a=$.Blockly.Lua.provideFunction_("math_isPrime","\nfunction "+$.Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(n)\n -- https://en.wikipedia.org/wiki/Primality_test#Naive_methods\n if n == 2 or n == 3 then\n return true\n end\n -- False if n is NaN, negative, is 1, or not whole.\n -- And false if n is divisible by 2 or 3.\n if not(n > 1) or n % 1 ~= 0 or n % 2 == 0 or n % 3 == 0 then\n return false\n end\n -- Check all the numbers of form 6k +/- 1, up to sqrt(n).\n for x = 6, math.sqrt(n) + 1.5, 6 do\n if n % (x - 1) == 0 or n % (x + 1) == 0 then\n return false\n end\n end\n return true\nend\n")+
|
||||
"("+e+")";else if("DIVISIBLE_BY"===c){a=$.Blockly.Lua.valueToCode(a,"DIVISOR",$.Blockly.Lua.ORDER_MULTIPLICATIVE)||"0";if("0"===a)return["nil",$.Blockly.Lua.ORDER_ATOMIC];a=e+" % "+a+" == 0"}else a=e+d;return[a,b]};$.Blockly.Lua.math_change=function(a){var b=$.Blockly.Lua.valueToCode(a,"DELTA",$.Blockly.Lua.ORDER_ADDITIVE)||"0";a=$.Blockly.Lua.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE);return a+" = "+a+" + "+b+"\n"};$.Blockly.Lua.math_round=$.Blockly.Lua.math_single;
|
||||
$.Blockly.Lua.math_trig=$.Blockly.Lua.math_single;
|
||||
$.Blockly.Lua.math_on_list=function(a){function b(){return $.Blockly.Lua.provideFunction_("math_sum","\nfunction "+$.Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(t)\n local result = 0\n for _, v in ipairs(t) do\n result = result + v\n end\n return result\nend\n")}var c=a.getFieldValue("OP");a=$.Blockly.Lua.valueToCode(a,"LIST",$.Blockly.Lua.ORDER_NONE)||"{}";switch(c){case "SUM":c=b();break;case "MIN":c=$.Blockly.Lua.provideFunction_("math_min","\nfunction "+$.Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+
|
||||
"(t)\n if #t == 0 then\n return 0\n end\n local result = math.huge\n for _, v in ipairs(t) do\n if v < result then\n result = v\n end\n end\n return result\nend\n");break;case "AVERAGE":c=$.Blockly.Lua.provideFunction_("math_average","\nfunction "+$.Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(t)\n if #t == 0 then\n return 0\n end\n return "+b()+"(t) / #t\nend\n");break;case "MAX":c=$.Blockly.Lua.provideFunction_("math_max","\nfunction "+$.Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+
|
||||
"(t)\n if #t == 0 then\n return 0\n end\n local result = -math.huge\n for _, v in ipairs(t) do\n if v > result then\n result = v\n end\n end\n return result\nend\n");break;case "MEDIAN":c=$.Blockly.Lua.provideFunction_("math_median","\nfunction "+$.Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(t)\n -- Source: http://lua-users.org/wiki/SimpleStats\n if #t == 0 then\n return 0\n end\n local temp = {}\n for _, v in ipairs(t) do\n if type(v) == 'number' then\n table.insert(temp, v)\n end\n end\n table.sort(temp)\n if #temp % 2 == 0 then\n return (temp[#temp / 2] + temp[(#temp / 2) + 1]) / 2\n else\n return temp[math.ceil(#temp / 2)]\n end\nend\n");
|
||||
break;case "MODE":c=$.Blockly.Lua.provideFunction_("math_modes","\nfunction "+$.Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(t)\n -- Source: http://lua-users.org/wiki/SimpleStats\n local counts = {}\n for _, v in ipairs(t) do\n if counts[v] == nil then\n counts[v] = 1\n else\n counts[v] = counts[v] + 1\n end\n end\n local biggestCount = 0\n for _, v in pairs(counts) do\n if v > biggestCount then\n biggestCount = v\n end\n end\n local temp = {}\n for k, v in pairs(counts) do\n if v == biggestCount then\n table.insert(temp, k)\n end\n end\n return temp\nend\n");
|
||||
break;case "STD_DEV":c=$.Blockly.Lua.provideFunction_("math_standard_deviation","\nfunction "+$.Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(t)\n local m\n local vm\n local total = 0\n local count = 0\n local result\n m = #t == 0 and 0 or "+b()+"(t) / #t\n for _, v in ipairs(t) do\n if type(v) == 'number' then\n vm = v - m\n total = total + (vm * vm)\n count = count + 1\n end\n end\n result = math.sqrt(total / (count-1))\n return result\nend\n");break;case "RANDOM":c=$.Blockly.Lua.provideFunction_("math_random_list",
|
||||
"\nfunction "+$.Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(t)\n if #t == 0 then\n return nil\n end\n return t[math.random(#t)]\nend\n");break;default:throw Error("Unknown operator: "+c);}return[c+"("+a+")",$.Blockly.Lua.ORDER_HIGH]};$.Blockly.Lua.math_modulo=function(a){var b=$.Blockly.Lua.valueToCode(a,"DIVIDEND",$.Blockly.Lua.ORDER_MULTIPLICATIVE)||"0";a=$.Blockly.Lua.valueToCode(a,"DIVISOR",$.Blockly.Lua.ORDER_MULTIPLICATIVE)||"0";return[b+" % "+a,$.Blockly.Lua.ORDER_MULTIPLICATIVE]};
|
||||
$.Blockly.Lua.math_constrain=function(a){var b=$.Blockly.Lua.valueToCode(a,"VALUE",$.Blockly.Lua.ORDER_NONE)||"0",c=$.Blockly.Lua.valueToCode(a,"LOW",$.Blockly.Lua.ORDER_NONE)||"-math.huge";a=$.Blockly.Lua.valueToCode(a,"HIGH",$.Blockly.Lua.ORDER_NONE)||"math.huge";return["math.min(math.max("+b+", "+c+"), "+a+")",$.Blockly.Lua.ORDER_HIGH]};
|
||||
$.Blockly.Lua.math_random_int=function(a){var b=$.Blockly.Lua.valueToCode(a,"FROM",$.Blockly.Lua.ORDER_NONE)||"0";a=$.Blockly.Lua.valueToCode(a,"TO",$.Blockly.Lua.ORDER_NONE)||"0";return["math.random("+b+", "+a+")",$.Blockly.Lua.ORDER_HIGH]};$.Blockly.Lua.math_random_float=function(a){return["math.random()",$.Blockly.Lua.ORDER_HIGH]};
|
||||
$.Blockly.Lua.math_atan2=function(a){var b=$.Blockly.Lua.valueToCode(a,"X",$.Blockly.Lua.ORDER_NONE)||"0";return["math.deg(math.atan2("+($.Blockly.Lua.valueToCode(a,"Y",$.Blockly.Lua.ORDER_NONE)||"0")+", "+b+"))",$.Blockly.Lua.ORDER_HIGH]};var module$exports$Blockly$Lua$loops={},module$contents$Blockly$Lua$loops_CONTINUE_STATEMENT="goto continue\n",module$contents$Blockly$Lua$loops_addContinueLabel=function(a){return-1!==a.indexOf(module$contents$Blockly$Lua$loops_CONTINUE_STATEMENT)?a+$.Blockly.Lua.INDENT+"::continue::\n":a};
|
||||
$.Blockly.Lua.controls_repeat_ext=function(a){var b=a.getField("TIMES")?String(Number(a.getFieldValue("TIMES"))):$.Blockly.Lua.valueToCode(a,"TIMES",$.Blockly.Lua.ORDER_NONE)||"0";b=(0,$.module$exports$Blockly$utils$string.isNumber)(b)?parseInt(b,10):"math.floor("+b+")";var c=$.Blockly.Lua.statementToCode(a,"DO");c=$.Blockly.Lua.addLoopTrap(c,a);c=module$contents$Blockly$Lua$loops_addContinueLabel(c);return"for "+$.Blockly.Lua.nameDB_.getDistinctName("count",$.module$exports$Blockly$Names.NameType.VARIABLE)+
|
||||
" = 1, "+b+" do\n"+c+"end\n"};$.Blockly.Lua.controls_repeat=$.Blockly.Lua.controls_repeat_ext;$.Blockly.Lua.controls_whileUntil=function(a){var b="UNTIL"===a.getFieldValue("MODE"),c=$.Blockly.Lua.valueToCode(a,"BOOL",b?$.Blockly.Lua.ORDER_UNARY:$.Blockly.Lua.ORDER_NONE)||"false",d=$.Blockly.Lua.statementToCode(a,"DO");d=$.Blockly.Lua.addLoopTrap(d,a);d=module$contents$Blockly$Lua$loops_addContinueLabel(d);b&&(c="not "+c);return"while "+c+" do\n"+d+"end\n"};
|
||||
$.Blockly.Lua.controls_for=function(a){var b=$.Blockly.Lua.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE),c=$.Blockly.Lua.valueToCode(a,"FROM",$.Blockly.Lua.ORDER_NONE)||"0",d=$.Blockly.Lua.valueToCode(a,"TO",$.Blockly.Lua.ORDER_NONE)||"0",e=$.Blockly.Lua.valueToCode(a,"BY",$.Blockly.Lua.ORDER_NONE)||"1",f=$.Blockly.Lua.statementToCode(a,"DO");f=$.Blockly.Lua.addLoopTrap(f,a);f=module$contents$Blockly$Lua$loops_addContinueLabel(f);a="";if((0,$.module$exports$Blockly$utils$string.isNumber)(c)&&
|
||||
(0,$.module$exports$Blockly$utils$string.isNumber)(d)&&(0,$.module$exports$Blockly$utils$string.isNumber)(e))var g=(Number(c)<=Number(d)?"":"-")+Math.abs(Number(e));else a="",g=$.Blockly.Lua.nameDB_.getDistinctName(b+"_inc",$.module$exports$Blockly$Names.NameType.VARIABLE),a+=g+" = ",a=(0,$.module$exports$Blockly$utils$string.isNumber)(e)?a+(Math.abs(e)+"\n"):a+("math.abs("+e+")\n"),a=a+("if ("+c+") > ("+d+") then\n")+($.Blockly.Lua.INDENT+g+" = -"+g+"\n"),a+="end\n";return a+("for "+b+" = "+c+", "+
|
||||
d+", "+g)+(" do\n"+f+"end\n")};$.Blockly.Lua.controls_forEach=function(a){var b=$.Blockly.Lua.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE),c=$.Blockly.Lua.valueToCode(a,"LIST",$.Blockly.Lua.ORDER_NONE)||"{}",d=$.Blockly.Lua.statementToCode(a,"DO");d=$.Blockly.Lua.addLoopTrap(d,a);d=module$contents$Blockly$Lua$loops_addContinueLabel(d);return"for _, "+b+" in ipairs("+c+") do \n"+d+"end\n"};
|
||||
$.Blockly.Lua.controls_flow_statements=function(a){var b="";$.Blockly.Lua.STATEMENT_PREFIX&&(b+=$.Blockly.Lua.injectId($.Blockly.Lua.STATEMENT_PREFIX,a));$.Blockly.Lua.STATEMENT_SUFFIX&&(b+=$.Blockly.Lua.injectId($.Blockly.Lua.STATEMENT_SUFFIX,a));if($.Blockly.Lua.STATEMENT_PREFIX){var c=a.getSurroundLoop();c&&!c.suppressPrefixSuffix&&(b+=$.Blockly.Lua.injectId($.Blockly.Lua.STATEMENT_PREFIX,c))}switch(a.getFieldValue("FLOW")){case "BREAK":return b+"break\n";case "CONTINUE":return b+module$contents$Blockly$Lua$loops_CONTINUE_STATEMENT}throw Error("Unknown flow statement.");
|
||||
};var module$exports$Blockly$Lua$logic={};
|
||||
$.Blockly.Lua.controls_if=function(a){var b=0,c="";$.Blockly.Lua.STATEMENT_PREFIX&&(c+=$.Blockly.Lua.injectId($.Blockly.Lua.STATEMENT_PREFIX,a));do{var d=$.Blockly.Lua.valueToCode(a,"IF"+b,$.Blockly.Lua.ORDER_NONE)||"false",e=$.Blockly.Lua.statementToCode(a,"DO"+b);$.Blockly.Lua.STATEMENT_SUFFIX&&(e=$.Blockly.Lua.prefixLines($.Blockly.Lua.injectId($.Blockly.Lua.STATEMENT_SUFFIX,a),$.Blockly.Lua.INDENT)+e);c+=(0<b?"else":"")+"if "+d+" then\n"+e;b++}while(a.getInput("IF"+b));if(a.getInput("ELSE")||
|
||||
$.Blockly.Lua.STATEMENT_SUFFIX)b=$.Blockly.Lua.statementToCode(a,"ELSE"),$.Blockly.Lua.STATEMENT_SUFFIX&&(b=$.Blockly.Lua.prefixLines($.Blockly.Lua.injectId($.Blockly.Lua.STATEMENT_SUFFIX,a),$.Blockly.Lua.INDENT)+b),c+="else\n"+b;return c+"end\n"};$.Blockly.Lua.controls_ifelse=$.Blockly.Lua.controls_if;
|
||||
$.Blockly.Lua.logic_compare=function(a){var b={EQ:"==",NEQ:"~=",LT:"<",LTE:"<=",GT:">",GTE:">="}[a.getFieldValue("OP")],c=$.Blockly.Lua.valueToCode(a,"A",$.Blockly.Lua.ORDER_RELATIONAL)||"0";a=$.Blockly.Lua.valueToCode(a,"B",$.Blockly.Lua.ORDER_RELATIONAL)||"0";return[c+" "+b+" "+a,$.Blockly.Lua.ORDER_RELATIONAL]};
|
||||
$.Blockly.Lua.logic_operation=function(a){var b="AND"===a.getFieldValue("OP")?"and":"or",c="and"===b?$.Blockly.Lua.ORDER_AND:$.Blockly.Lua.ORDER_OR,d=$.Blockly.Lua.valueToCode(a,"A",c);a=$.Blockly.Lua.valueToCode(a,"B",c);if(d||a){var e="and"===b?"true":"false";d||(d=e);a||(a=e)}else a=d="false";return[d+" "+b+" "+a,c]};$.Blockly.Lua.logic_negate=function(a){return["not "+($.Blockly.Lua.valueToCode(a,"BOOL",$.Blockly.Lua.ORDER_UNARY)||"true"),$.Blockly.Lua.ORDER_UNARY]};
|
||||
$.Blockly.Lua.logic_boolean=function(a){return["TRUE"===a.getFieldValue("BOOL")?"true":"false",$.Blockly.Lua.ORDER_ATOMIC]};$.Blockly.Lua.logic_null=function(a){return["nil",$.Blockly.Lua.ORDER_ATOMIC]};$.Blockly.Lua.logic_ternary=function(a){var b=$.Blockly.Lua.valueToCode(a,"IF",$.Blockly.Lua.ORDER_AND)||"false",c=$.Blockly.Lua.valueToCode(a,"THEN",$.Blockly.Lua.ORDER_AND)||"nil";a=$.Blockly.Lua.valueToCode(a,"ELSE",$.Blockly.Lua.ORDER_OR)||"nil";return[b+" and "+c+" or "+a,$.Blockly.Lua.ORDER_OR]};var module$exports$Blockly$Lua$lists={};$.Blockly.Lua.lists_create_empty=function(a){return["{}",$.Blockly.Lua.ORDER_HIGH]};$.Blockly.Lua.lists_create_with=function(a){for(var b=Array(a.itemCount_),c=0;c<a.itemCount_;c++)b[c]=$.Blockly.Lua.valueToCode(a,"ADD"+c,$.Blockly.Lua.ORDER_NONE)||"None";return["{"+b.join(", ")+"}",$.Blockly.Lua.ORDER_HIGH]};
|
||||
$.Blockly.Lua.lists_repeat=function(a){var b=$.Blockly.Lua.provideFunction_("create_list_repeated","\nfunction "+$.Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(item, count)\n local t = {}\n for i = 1, count do\n table.insert(t, item)\n end\n return t\nend\n "),c=$.Blockly.Lua.valueToCode(a,"ITEM",$.Blockly.Lua.ORDER_NONE)||"None";a=$.Blockly.Lua.valueToCode(a,"NUM",$.Blockly.Lua.ORDER_NONE)||"0";return[b+"("+c+", "+a+")",$.Blockly.Lua.ORDER_HIGH]};
|
||||
$.Blockly.Lua.lists_length=function(a){return["#"+($.Blockly.Lua.valueToCode(a,"VALUE",$.Blockly.Lua.ORDER_UNARY)||"{}"),$.Blockly.Lua.ORDER_UNARY]};$.Blockly.Lua.lists_isEmpty=function(a){return["#"+($.Blockly.Lua.valueToCode(a,"VALUE",$.Blockly.Lua.ORDER_UNARY)||"{}")+" == 0",$.Blockly.Lua.ORDER_RELATIONAL]};
|
||||
$.Blockly.Lua.lists_indexOf=function(a){var b=$.Blockly.Lua.valueToCode(a,"FIND",$.Blockly.Lua.ORDER_NONE)||"''",c=$.Blockly.Lua.valueToCode(a,"VALUE",$.Blockly.Lua.ORDER_NONE)||"{}";return[("FIRST"===a.getFieldValue("END")?$.Blockly.Lua.provideFunction_("first_index","\nfunction "+$.Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(t, elem)\n for k, v in ipairs(t) do\n if v == elem then\n return k\n end\n end\n return 0\nend\n"):$.Blockly.Lua.provideFunction_("last_index","\nfunction "+$.Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+
|
||||
"(t, elem)\n for i = #t, 1, -1 do\n if t[i] == elem then\n return i\n end\n end\n return 0\nend\n"))+"("+c+", "+b+")",$.Blockly.Lua.ORDER_HIGH]};var module$contents$Blockly$Lua$lists_getListIndex=function(a,b,c){return"FIRST"===b?"1":"FROM_END"===b?"#"+a+" + 1 - "+c:"LAST"===b?"#"+a:"RANDOM"===b?"math.random(#"+a+")":c};
|
||||
$.Blockly.Lua.lists_getIndex=function(a){var b=a.getFieldValue("MODE")||"GET",c=a.getFieldValue("WHERE")||"FROM_START",d=$.Blockly.Lua.valueToCode(a,"VALUE",$.Blockly.Lua.ORDER_HIGH)||"({})";if("LAST"!==c&&"FROM_END"!==c&&"RANDOM"!==c||d.match(/^\w+$/)){a=$.Blockly.Lua.valueToCode(a,"AT","GET"===b&&"FROM_END"===c?$.Blockly.Lua.ORDER_ADDITIVE:$.Blockly.Lua.ORDER_NONE)||"1";a=module$contents$Blockly$Lua$lists_getListIndex(d,c,a);if("GET"===b)return[d+"["+a+"]",$.Blockly.Lua.ORDER_HIGH];c="table.remove("+
|
||||
d+", "+a+")";return"GET_REMOVE"===b?[c,$.Blockly.Lua.ORDER_HIGH]:c+"\n"}if("REMOVE"===b)return b=$.Blockly.Lua.valueToCode(a,"AT","FROM_END"===c?$.Blockly.Lua.ORDER_ADDITIVE:$.Blockly.Lua.ORDER_NONE)||"1",a=$.Blockly.Lua.nameDB_.getDistinctName("tmp_list",$.module$exports$Blockly$Names.NameType.VARIABLE),b=module$contents$Blockly$Lua$lists_getListIndex(a,c,b),a+" = "+d+"\ntable.remove("+a+", "+b+")\n";a=$.Blockly.Lua.valueToCode(a,"AT",$.Blockly.Lua.ORDER_NONE)||"1";return[("GET"===b?$.Blockly.Lua.provideFunction_("list_get_"+
|
||||
c.toLowerCase(),["function "+$.Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(t"+("FROM_END"===c||"FROM_START"===c?", at)":")")," return t["+module$contents$Blockly$Lua$lists_getListIndex("t",c,"at")+"]","end"]):$.Blockly.Lua.provideFunction_("list_remove_"+c.toLowerCase(),["function "+$.Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(t"+("FROM_END"===c||"FROM_START"===c?", at)":")")," return table.remove(t, "+module$contents$Blockly$Lua$lists_getListIndex("t",c,"at")+")","end"]))+"("+d+("FROM_END"===c||"FROM_START"===
|
||||
c?", "+a:"")+")",$.Blockly.Lua.ORDER_HIGH]};
|
||||
$.Blockly.Lua.lists_setIndex=function(a){var b=$.Blockly.Lua.valueToCode(a,"LIST",$.Blockly.Lua.ORDER_HIGH)||"{}",c=a.getFieldValue("MODE")||"SET",d=a.getFieldValue("WHERE")||"FROM_START",e=$.Blockly.Lua.valueToCode(a,"AT",$.Blockly.Lua.ORDER_ADDITIVE)||"1";a=$.Blockly.Lua.valueToCode(a,"TO",$.Blockly.Lua.ORDER_NONE)||"None";var f="";if(("LAST"===d||"FROM_END"===d||"RANDOM"===d)&&!b.match(/^\w+$/)){var g=$.Blockly.Lua.nameDB_.getDistinctName("tmp_list",$.module$exports$Blockly$Names.NameType.VARIABLE);
|
||||
f=g+" = "+b+"\n";b=g}f="SET"===c?f+(b+"["+module$contents$Blockly$Lua$lists_getListIndex(b,d,e)+"] = "+a):f+("table.insert("+b+", "+(module$contents$Blockly$Lua$lists_getListIndex(b,d,e)+("LAST"===d?" + 1":""))+", "+a+")");return f+"\n"};
|
||||
$.Blockly.Lua.lists_getSublist=function(a){var b=$.Blockly.Lua.valueToCode(a,"LIST",$.Blockly.Lua.ORDER_NONE)||"{}",c=a.getFieldValue("WHERE1"),d=a.getFieldValue("WHERE2"),e=$.Blockly.Lua.valueToCode(a,"AT1",$.Blockly.Lua.ORDER_NONE)||"1";a=$.Blockly.Lua.valueToCode(a,"AT2",$.Blockly.Lua.ORDER_NONE)||"1";var f="FROM_END"===c||"FROM_START"===c?", at1":"",g="FROM_END"===d||"FROM_START"===d?", at2":"";return[$.Blockly.Lua.provideFunction_("list_sublist_"+c.toLowerCase()+"_"+d.toLowerCase(),"\nfunction "+
|
||||
$.Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(source"+f+g+")\n local t = {}\n local start = "+module$contents$Blockly$Lua$lists_getListIndex("source",c,"at1")+"\n local finish = "+module$contents$Blockly$Lua$lists_getListIndex("source",d,"at2")+"\n for i = start, finish do\n table.insert(t, source[i])\n end\n return t\nend\n")+"("+b+("FROM_END"===c||"FROM_START"===c?", "+e:"")+("FROM_END"===d||"FROM_START"===d?", "+a:"")+")",$.Blockly.Lua.ORDER_HIGH]};
|
||||
$.Blockly.Lua.lists_sort=function(a){var b=$.Blockly.Lua.valueToCode(a,"LIST",$.Blockly.Lua.ORDER_NONE)||"{}",c="1"===a.getFieldValue("DIRECTION")?1:-1;a=a.getFieldValue("TYPE");return[$.Blockly.Lua.provideFunction_("list_sort","\nfunction "+$.Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(list, typev, direction)\n local t = {}\n for n,v in pairs(list) do table.insert(t, v) end\n local compareFuncs = {\n NUMERIC = function(a, b)\n return (tonumber(tostring(a)) or 0)\n < (tonumber(tostring(b)) or 0) end,\n TEXT = function(a, b)\n return tostring(a) < tostring(b) end,\n IGNORE_CASE = function(a, b)\n return string.lower(tostring(a)) < string.lower(tostring(b)) end\n }\n local compareTemp = compareFuncs[typev]\n local compare = compareTemp\n if direction == -1\n then compare = function(a, b) return compareTemp(b, a) end\n end\n table.sort(t, compare)\n return t\nend\n")+
|
||||
"("+b+',"'+a+'", '+c+")",$.Blockly.Lua.ORDER_HIGH]};
|
||||
$.Blockly.Lua.lists_split=function(a){var b=$.Blockly.Lua.valueToCode(a,"INPUT",$.Blockly.Lua.ORDER_NONE),c=$.Blockly.Lua.valueToCode(a,"DELIM",$.Blockly.Lua.ORDER_NONE)||"''";a=a.getFieldValue("MODE");if("SPLIT"===a)b||(b="''"),a=$.Blockly.Lua.provideFunction_("list_string_split","\nfunction "+$.Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(input, delim)\n local t = {}\n local pos = 1\n while true do\n next_delim = string.find(input, delim, pos)\n if next_delim == nil then\n table.insert(t, string.sub(input, pos))\n break\n else\n table.insert(t, string.sub(input, pos, next_delim-1))\n pos = next_delim + #delim\n end\n end\n return t\nend\n");else if("JOIN"===
|
||||
a)b||(b="{}"),a="table.concat";else throw Error("Unknown mode: "+a);return[a+"("+b+", "+c+")",$.Blockly.Lua.ORDER_HIGH]};$.Blockly.Lua.lists_reverse=function(a){a=$.Blockly.Lua.valueToCode(a,"LIST",$.Blockly.Lua.ORDER_NONE)||"{}";return[$.Blockly.Lua.provideFunction_("list_reverse","\nfunction "+$.Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(input)\n local reversed = {}\n for i = #input, 1, -1 do\n table.insert(reversed, input[i])\n end\n return reversed\nend\n")+"("+a+")",$.Blockly.Lua.ORDER_HIGH]};var module$exports$Blockly$Lua$colour={};$.Blockly.Lua.colour_picker=function(a){return[$.Blockly.Lua.quote_(a.getFieldValue("COLOUR")),$.Blockly.Lua.ORDER_ATOMIC]};$.Blockly.Lua.colour_random=function(a){return['string.format("#%06x", math.random(0, 2^24 - 1))',$.Blockly.Lua.ORDER_HIGH]};
|
||||
$.Blockly.Lua.colour_rgb=function(a){var b=$.Blockly.Lua.provideFunction_("colour_rgb","\nfunction "+$.Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+'(r, g, b)\n r = math.floor(math.min(100, math.max(0, r)) * 2.55 + .5)\n g = math.floor(math.min(100, math.max(0, g)) * 2.55 + .5)\n b = math.floor(math.min(100, math.max(0, b)) * 2.55 + .5)\n return string.format("#%02x%02x%02x", r, g, b)\nend\n'),c=$.Blockly.Lua.valueToCode(a,"RED",$.Blockly.Lua.ORDER_NONE)||0,d=$.Blockly.Lua.valueToCode(a,"GREEN",$.Blockly.Lua.ORDER_NONE)||
|
||||
0;a=$.Blockly.Lua.valueToCode(a,"BLUE",$.Blockly.Lua.ORDER_NONE)||0;return[b+"("+c+", "+d+", "+a+")",$.Blockly.Lua.ORDER_HIGH]};
|
||||
$.Blockly.Lua.colour_blend=function(a){var b=$.Blockly.Lua.provideFunction_("colour_blend","\nfunction "+$.Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+'(colour1, colour2, ratio)\n local r1 = tonumber(string.sub(colour1, 2, 3), 16)\n local r2 = tonumber(string.sub(colour2, 2, 3), 16)\n local g1 = tonumber(string.sub(colour1, 4, 5), 16)\n local g2 = tonumber(string.sub(colour2, 4, 5), 16)\n local b1 = tonumber(string.sub(colour1, 6, 7), 16)\n local b2 = tonumber(string.sub(colour2, 6, 7), 16)\n local ratio = math.min(1, math.max(0, ratio))\n local r = math.floor(r1 * (1 - ratio) + r2 * ratio + .5)\n local g = math.floor(g1 * (1 - ratio) + g2 * ratio + .5)\n local b = math.floor(b1 * (1 - ratio) + b2 * ratio + .5)\n return string.format("#%02x%02x%02x", r, g, b)\nend\n'),c=
|
||||
$.Blockly.Lua.valueToCode(a,"COLOUR1",$.Blockly.Lua.ORDER_NONE)||"'#000000'",d=$.Blockly.Lua.valueToCode(a,"COLOUR2",$.Blockly.Lua.ORDER_NONE)||"'#000000'";a=$.Blockly.Lua.valueToCode(a,"RATIO",$.Blockly.Lua.ORDER_NONE)||0;return[b+"("+c+", "+d+", "+a+")",$.Blockly.Lua.ORDER_HIGH]};var module$exports$Blockly$Lua$all={};
|
||||
$.Blockly.Lua.__namespace__=$;
|
||||
return $.Blockly.Lua;
|
||||
var module$exports$Blockly$Lua={},module$contents$Blockly$Lua_objectUtils=$.module$build$src$core$utils$object,module$contents$Blockly$Lua_stringUtils=$.module$build$src$core$utils$string,module$contents$Blockly$Lua_Generator=$.Generator$$module$build$src$core$generator,module$contents$Blockly$Lua_inputTypes=$.module$build$src$core$input_types.inputTypes,module$contents$Blockly$Lua_Names=$.module$build$src$core$names.Names;module$exports$Blockly$Lua.luaGenerator=new $.Generator$$module$build$src$core$generator("Lua");
|
||||
module$exports$Blockly$Lua.luaGenerator.addReservedWords("_,__inext,assert,bit,colors,colours,coroutine,disk,dofile,error,fs,fetfenv,getmetatable,gps,help,io,ipairs,keys,loadfile,loadstring,math,native,next,os,paintutils,pairs,parallel,pcall,peripheral,print,printError,rawequal,rawget,rawset,read,rednet,redstone,rs,select,setfenv,setmetatable,sleep,string,table,term,textutils,tonumber,tostring,turtle,type,unpack,vector,write,xpcall,_VERSION,__indext,HTTP,and,break,do,else,elseif,end,false,for,function,if,in,local,nil,not,or,repeat,return,then,true,until,while,add,sub,mul,div,mod,pow,unm,concat,len,eq,lt,le,index,newindex,call,assert,collectgarbage,dofile,error,_G,getmetatable,inpairs,load,loadfile,next,pairs,pcall,print,rawequal,rawget,rawlen,rawset,select,setmetatable,tonumber,tostring,type,_VERSION,xpcall,require,package,string,table,math,bit32,io,file,os,debug");
|
||||
module$exports$Blockly$Lua.luaGenerator.ORDER_ATOMIC=0;module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH=1;module$exports$Blockly$Lua.luaGenerator.ORDER_EXPONENTIATION=2;module$exports$Blockly$Lua.luaGenerator.ORDER_UNARY=3;module$exports$Blockly$Lua.luaGenerator.ORDER_MULTIPLICATIVE=4;module$exports$Blockly$Lua.luaGenerator.ORDER_ADDITIVE=5;module$exports$Blockly$Lua.luaGenerator.ORDER_CONCATENATION=6;module$exports$Blockly$Lua.luaGenerator.ORDER_RELATIONAL=7;
|
||||
module$exports$Blockly$Lua.luaGenerator.ORDER_AND=8;module$exports$Blockly$Lua.luaGenerator.ORDER_OR=9;module$exports$Blockly$Lua.luaGenerator.ORDER_NONE=99;module$exports$Blockly$Lua.luaGenerator.isInitialized=!1;
|
||||
module$exports$Blockly$Lua.luaGenerator.init=function(a){Object.getPrototypeOf(this).init.call(this);this.nameDB_?this.nameDB_.reset():this.nameDB_=new $.module$build$src$core$names.Names(this.RESERVED_WORDS_);this.nameDB_.setVariableMap(a.getVariableMap());this.nameDB_.populateVariables(a);this.nameDB_.populateProcedures(a);this.isInitialized=!0};
|
||||
module$exports$Blockly$Lua.luaGenerator.finish=function(a){const b=$.module$build$src$core$utils$object.values(this.definitions_);a=Object.getPrototypeOf(this).finish.call(this,a);this.isInitialized=!1;this.nameDB_.reset();return b.join("\n\n")+"\n\n\n"+a};module$exports$Blockly$Lua.luaGenerator.scrubNakedValue=function(a){return"local _ = "+a+"\n"};module$exports$Blockly$Lua.luaGenerator.quote_=function(a){a=a.replace(/\\/g,"\\\\").replace(/\n/g,"\\\n").replace(/'/g,"\\'");return"'"+a+"'"};
|
||||
module$exports$Blockly$Lua.luaGenerator.multiline_quote_=function(a){return a.split(/\n/g).map(this.quote_).join(" .. '\\n' ..\n")};
|
||||
module$exports$Blockly$Lua.luaGenerator.scrub_=function(a,b,c){let d="";if(!a.outputConnection||!a.outputConnection.targetConnection){var e=a.getCommentText();e&&(e=$.module$build$src$core$utils$string.wrap(e,this.COMMENT_WRAP-3),d+=this.prefixLines(e,"-- ")+"\n");for(let f=0;f<a.inputList.length;f++)a.inputList[f].type===$.module$build$src$core$input_types.inputTypes.VALUE&&(e=a.inputList[f].connection.targetBlock())&&(e=this.allNestedComments(e))&&(d+=this.prefixLines(e,"-- "))}a=a.nextConnection&&
|
||||
a.nextConnection.targetBlock();c=c?"":this.blockToCode(a);return d+b+c};var module$exports$Blockly$Lua$variables={},module$contents$Blockly$Lua$variables_NameType=$.NameType$$module$build$src$core$names;module$exports$Blockly$Lua.luaGenerator.variables_get=function(a){return[module$exports$Blockly$Lua.luaGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE),module$exports$Blockly$Lua.luaGenerator.ORDER_ATOMIC]};
|
||||
module$exports$Blockly$Lua.luaGenerator.variables_set=function(a){const b=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"0";return module$exports$Blockly$Lua.luaGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE)+" = "+b+"\n"};var module$exports$Blockly$Lua$variablesDynamic={};module$exports$Blockly$Lua.luaGenerator.variables_get_dynamic=module$exports$Blockly$Lua.luaGenerator.variables_get;module$exports$Blockly$Lua.luaGenerator.variables_set_dynamic=module$exports$Blockly$Lua.luaGenerator.variables_set;var module$exports$Blockly$Lua$texts={},module$contents$Blockly$Lua$texts_NameType=$.NameType$$module$build$src$core$names;module$exports$Blockly$Lua.luaGenerator.text=function(a){return[module$exports$Blockly$Lua.luaGenerator.quote_(a.getFieldValue("TEXT")),module$exports$Blockly$Lua.luaGenerator.ORDER_ATOMIC]};
|
||||
module$exports$Blockly$Lua.luaGenerator.text_multiline=function(a){a=module$exports$Blockly$Lua.luaGenerator.multiline_quote_(a.getFieldValue("TEXT"));const b=-1!==a.indexOf("..")?module$exports$Blockly$Lua.luaGenerator.ORDER_CONCATENATION:module$exports$Blockly$Lua.luaGenerator.ORDER_ATOMIC;return[a,b]};
|
||||
module$exports$Blockly$Lua.luaGenerator.text_join=function(a){if(0===a.itemCount_)return["''",module$exports$Blockly$Lua.luaGenerator.ORDER_ATOMIC];if(1===a.itemCount_)return["tostring("+(module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"ADD0",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"''")+")",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH];if(2===a.itemCount_){var b=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"ADD0",module$exports$Blockly$Lua.luaGenerator.ORDER_CONCATENATION)||
|
||||
"''";a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"ADD1",module$exports$Blockly$Lua.luaGenerator.ORDER_CONCATENATION)||"''";return[b+" .. "+a,module$exports$Blockly$Lua.luaGenerator.ORDER_CONCATENATION]}b=[];for(let c=0;c<a.itemCount_;c++)b[c]=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"ADD"+c,module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"''";return["table.concat({"+b.join(", ")+"})",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};
|
||||
module$exports$Blockly$Lua.luaGenerator.text_append=function(a){const b=module$exports$Blockly$Lua.luaGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE);a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"TEXT",module$exports$Blockly$Lua.luaGenerator.ORDER_CONCATENATION)||"''";return b+" = "+b+" .. "+a+"\n"};
|
||||
module$exports$Blockly$Lua.luaGenerator.text_length=function(a){return["#"+(module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Lua.luaGenerator.ORDER_UNARY)||"''"),module$exports$Blockly$Lua.luaGenerator.ORDER_UNARY]};module$exports$Blockly$Lua.luaGenerator.text_isEmpty=function(a){return["#"+(module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Lua.luaGenerator.ORDER_UNARY)||"''")+" == 0",module$exports$Blockly$Lua.luaGenerator.ORDER_RELATIONAL]};
|
||||
module$exports$Blockly$Lua.luaGenerator.text_indexOf=function(a){const b=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"FIND",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"''",c=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"''";return[("FIRST"===a.getFieldValue("END")?module$exports$Blockly$Lua.luaGenerator.provideFunction_("firstIndexOf",`
|
||||
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(str, substr)
|
||||
local i = string.find(str, substr, 1, true)
|
||||
if i == nil then
|
||||
return 0
|
||||
end
|
||||
return i
|
||||
end
|
||||
`):module$exports$Blockly$Lua.luaGenerator.provideFunction_("lastIndexOf",`
|
||||
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(str, substr)
|
||||
local i = string.find(string.reverse(str), string.reverse(substr), 1, true)
|
||||
if i then
|
||||
return #str + 2 - i - #substr
|
||||
end
|
||||
return 0
|
||||
end
|
||||
`))+"("+c+", "+b+")",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};
|
||||
module$exports$Blockly$Lua.luaGenerator.text_charAt=function(a){var b=a.getFieldValue("WHERE")||"FROM_START";const c=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"AT","FROM_END"===b?module$exports$Blockly$Lua.luaGenerator.ORDER_UNARY:module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"1";a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"''";if("RANDOM"===b)b=module$exports$Blockly$Lua.luaGenerator.provideFunction_("text_random_letter",
|
||||
`
|
||||
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(str)
|
||||
local index = math.random(string.len(str))
|
||||
return string.sub(str, index, index)
|
||||
end
|
||||
`)+"("+a+")";else{if("FIRST"===b)b="1";else if("LAST"===b)b="-1";else if("FROM_START"===b)b=c;else if("FROM_END"===b)b="-"+c;else throw Error("Unhandled option (text_charAt).");b=b.match(/^-?\w*$/)?"string.sub("+a+", "+b+", "+b+")":module$exports$Blockly$Lua.luaGenerator.provideFunction_("text_char_at",`
|
||||
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(str, index)
|
||||
return string.sub(str, index, index)
|
||||
end
|
||||
`)+"("+a+", "+b+")"}return[b,module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};
|
||||
module$exports$Blockly$Lua.luaGenerator.text_getSubstring=function(a){const b=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"STRING",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"''";var c=a.getFieldValue("WHERE1"),d=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"AT1","FROM_END"===c?module$exports$Blockly$Lua.luaGenerator.ORDER_UNARY:module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"1";if("FIRST"===c)c=1;else if("FROM_START"===c)c=d;else if("FROM_END"===c)c="-"+d;else throw Error("Unhandled option (text_getSubstring)");
|
||||
d=a.getFieldValue("WHERE2");a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"AT2","FROM_END"===d?module$exports$Blockly$Lua.luaGenerator.ORDER_UNARY:module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"1";if("LAST"===d)a=-1;else if("FROM_START"!==d)if("FROM_END"===d)a="-"+a;else throw Error("Unhandled option (text_getSubstring)");return["string.sub("+b+", "+c+", "+a+")",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};
|
||||
module$exports$Blockly$Lua.luaGenerator.text_changeCase=function(a){const b=a.getFieldValue("CASE");a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"TEXT",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"''";let c;"UPPERCASE"===b?c="string.upper":"LOWERCASE"===b?c="string.lower":"TITLECASE"===b&&(c=module$exports$Blockly$Lua.luaGenerator.provideFunction_("text_titlecase",`
|
||||
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(str)
|
||||
local buf = {}
|
||||
local inWord = false
|
||||
for i = 1, #str do
|
||||
local c = string.sub(str, i, i)
|
||||
if inWord then
|
||||
table.insert(buf, string.lower(c))
|
||||
if string.find(c, "%s") then
|
||||
inWord = false
|
||||
end
|
||||
else
|
||||
table.insert(buf, string.upper(c))
|
||||
inWord = true
|
||||
end
|
||||
end
|
||||
return table.concat(buf)
|
||||
end
|
||||
`));return[c+"("+a+")",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};module$exports$Blockly$Lua.luaGenerator.text_trim=function(a){const b={LEFT:"^%s*(,-)",RIGHT:"(.-)%s*$",BOTH:"^%s*(.-)%s*$"}[a.getFieldValue("MODE")];return["string.gsub("+(module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"TEXT",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"''")+', "'+b+'", "%1")',module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};
|
||||
module$exports$Blockly$Lua.luaGenerator.text_print=function(a){return"print("+(module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"TEXT",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"''")+")\n"};
|
||||
module$exports$Blockly$Lua.luaGenerator.text_prompt_ext=function(a){var b=a.getField("TEXT")?module$exports$Blockly$Lua.luaGenerator.quote_(a.getFieldValue("TEXT")):module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"TEXT",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"''";b=module$exports$Blockly$Lua.luaGenerator.provideFunction_("text_prompt",`
|
||||
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(msg)
|
||||
io.write(msg)
|
||||
io.flush()
|
||||
return io.read()
|
||||
end
|
||||
`)+"("+b+")";"NUMBER"===a.getFieldValue("TYPE")&&(b="tonumber("+b+", 10)");return[b,module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};module$exports$Blockly$Lua.luaGenerator.text_prompt=module$exports$Blockly$Lua.luaGenerator.text_prompt_ext;
|
||||
module$exports$Blockly$Lua.luaGenerator.text_count=function(a){const b=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"TEXT",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"''";a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"SUB",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"''";return[module$exports$Blockly$Lua.luaGenerator.provideFunction_("text_count",`
|
||||
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle)
|
||||
if #needle == 0 then
|
||||
return #haystack + 1
|
||||
end
|
||||
local i = 1
|
||||
local count = 0
|
||||
while true do
|
||||
i = string.find(haystack, needle, i, true)
|
||||
if i == nil then
|
||||
break
|
||||
end
|
||||
count = count + 1
|
||||
i = i + #needle
|
||||
end
|
||||
return count
|
||||
end
|
||||
`)+"("+b+", "+a+")",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};
|
||||
module$exports$Blockly$Lua.luaGenerator.text_replace=function(a){const b=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"TEXT",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"''",c=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"FROM",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"''";a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"TO",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"''";return[module$exports$Blockly$Lua.luaGenerator.provideFunction_("text_replace",
|
||||
`
|
||||
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle, replacement)
|
||||
local buf = {}
|
||||
local i = 1
|
||||
while i <= #haystack do
|
||||
if string.sub(haystack, i, i + #needle - 1) == needle then
|
||||
for j = 1, #replacement do
|
||||
table.insert(buf, string.sub(replacement, j, j))
|
||||
end
|
||||
i = i + #needle
|
||||
else
|
||||
table.insert(buf, string.sub(haystack, i, i))
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
return table.concat(buf)
|
||||
end
|
||||
`)+"("+b+", "+c+", "+a+")",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};module$exports$Blockly$Lua.luaGenerator.text_reverse=function(a){return["string.reverse("+(module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"TEXT",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"''")+")",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};var module$exports$Blockly$Lua$procedures={},module$contents$Blockly$Lua$procedures_NameType=$.NameType$$module$build$src$core$names;
|
||||
module$exports$Blockly$Lua.luaGenerator.procedures_defreturn=function(a){const b=module$exports$Blockly$Lua.luaGenerator.nameDB_.getName(a.getFieldValue("NAME"),$.NameType$$module$build$src$core$names.PROCEDURE);var c="";module$exports$Blockly$Lua.luaGenerator.STATEMENT_PREFIX&&(c+=module$exports$Blockly$Lua.luaGenerator.injectId(module$exports$Blockly$Lua.luaGenerator.STATEMENT_PREFIX,a));module$exports$Blockly$Lua.luaGenerator.STATEMENT_SUFFIX&&(c+=module$exports$Blockly$Lua.luaGenerator.injectId(module$exports$Blockly$Lua.luaGenerator.STATEMENT_SUFFIX,
|
||||
a));c&&(c=module$exports$Blockly$Lua.luaGenerator.prefixLines(c,module$exports$Blockly$Lua.luaGenerator.INDENT));let d="";module$exports$Blockly$Lua.luaGenerator.INFINITE_LOOP_TRAP&&(d=module$exports$Blockly$Lua.luaGenerator.prefixLines(module$exports$Blockly$Lua.luaGenerator.injectId(module$exports$Blockly$Lua.luaGenerator.INFINITE_LOOP_TRAP,a),module$exports$Blockly$Lua.luaGenerator.INDENT));let e=module$exports$Blockly$Lua.luaGenerator.statementToCode(a,"STACK"),f=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,
|
||||
"RETURN",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"",g="";e&&f&&(g=c);f?f=module$exports$Blockly$Lua.luaGenerator.INDENT+"return "+f+"\n":e||(e="");const h=[],k=a.getVars();for(let l=0;l<k.length;l++)h[l]=module$exports$Blockly$Lua.luaGenerator.nameDB_.getName(k[l],$.NameType$$module$build$src$core$names.VARIABLE);c="function "+b+"("+h.join(", ")+")\n"+c+d+e+g+f+"end\n";c=module$exports$Blockly$Lua.luaGenerator.scrub_(a,c);module$exports$Blockly$Lua.luaGenerator.definitions_["%"+b]=c;
|
||||
return null};module$exports$Blockly$Lua.luaGenerator.procedures_defnoreturn=module$exports$Blockly$Lua.luaGenerator.procedures_defreturn;
|
||||
module$exports$Blockly$Lua.luaGenerator.procedures_callreturn=function(a){const b=module$exports$Blockly$Lua.luaGenerator.nameDB_.getName(a.getFieldValue("NAME"),$.NameType$$module$build$src$core$names.PROCEDURE),c=[],d=a.getVars();for(let e=0;e<d.length;e++)c[e]=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"ARG"+e,module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"nil";return[b+"("+c.join(", ")+")",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};
|
||||
module$exports$Blockly$Lua.luaGenerator.procedures_callnoreturn=function(a){return module$exports$Blockly$Lua.luaGenerator.procedures_callreturn(a)[0]+"\n"};
|
||||
module$exports$Blockly$Lua.luaGenerator.procedures_ifreturn=function(a){let b="if "+(module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"CONDITION",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"false")+" then\n";module$exports$Blockly$Lua.luaGenerator.STATEMENT_SUFFIX&&(b+=module$exports$Blockly$Lua.luaGenerator.prefixLines(module$exports$Blockly$Lua.luaGenerator.injectId(module$exports$Blockly$Lua.luaGenerator.STATEMENT_SUFFIX,a),module$exports$Blockly$Lua.luaGenerator.INDENT));a.hasReturnValue_?
|
||||
(a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"nil",b+=module$exports$Blockly$Lua.luaGenerator.INDENT+"return "+a+"\n"):b+=module$exports$Blockly$Lua.luaGenerator.INDENT+"return\n";return b+"end\n"};var module$exports$Blockly$Lua$math={},module$contents$Blockly$Lua$math_NameType=$.NameType$$module$build$src$core$names;module$exports$Blockly$Lua.luaGenerator.math_number=function(a){a=Number(a.getFieldValue("NUM"));return[a,0>a?module$exports$Blockly$Lua.luaGenerator.ORDER_UNARY:module$exports$Blockly$Lua.luaGenerator.ORDER_ATOMIC]};
|
||||
module$exports$Blockly$Lua.luaGenerator.math_arithmetic=function(a){var b={ADD:[" + ",module$exports$Blockly$Lua.luaGenerator.ORDER_ADDITIVE],MINUS:[" - ",module$exports$Blockly$Lua.luaGenerator.ORDER_ADDITIVE],MULTIPLY:[" * ",module$exports$Blockly$Lua.luaGenerator.ORDER_MULTIPLICATIVE],DIVIDE:[" / ",module$exports$Blockly$Lua.luaGenerator.ORDER_MULTIPLICATIVE],POWER:[" ^ ",module$exports$Blockly$Lua.luaGenerator.ORDER_EXPONENTIATION]}[a.getFieldValue("OP")];const c=b[0];b=b[1];const d=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,
|
||||
"A",b)||"0";a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"B",b)||"0";return[d+c+a,b]};
|
||||
module$exports$Blockly$Lua.luaGenerator.math_single=function(a){var b=a.getFieldValue("OP");if("NEG"===b)return a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"NUM",module$exports$Blockly$Lua.luaGenerator.ORDER_UNARY)||"0",["-"+a,module$exports$Blockly$Lua.luaGenerator.ORDER_UNARY];if("POW10"===b)return a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"NUM",module$exports$Blockly$Lua.luaGenerator.ORDER_EXPONENTIATION)||"0",["10 ^ "+a,module$exports$Blockly$Lua.luaGenerator.ORDER_EXPONENTIATION];
|
||||
a="ROUND"===b?module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"NUM",module$exports$Blockly$Lua.luaGenerator.ORDER_ADDITIVE)||"0":module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"NUM",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"0";switch(b){case "ABS":b="math.abs("+a+")";break;case "ROOT":b="math.sqrt("+a+")";break;case "LN":b="math.log("+a+")";break;case "LOG10":b="math.log("+a+", 10)";break;case "EXP":b="math.exp("+a+")";break;case "ROUND":b="math.floor("+a+" + .5)";break;case "ROUNDUP":b=
|
||||
"math.ceil("+a+")";break;case "ROUNDDOWN":b="math.floor("+a+")";break;case "SIN":b="math.sin(math.rad("+a+"))";break;case "COS":b="math.cos(math.rad("+a+"))";break;case "TAN":b="math.tan(math.rad("+a+"))";break;case "ASIN":b="math.deg(math.asin("+a+"))";break;case "ACOS":b="math.deg(math.acos("+a+"))";break;case "ATAN":b="math.deg(math.atan("+a+"))";break;default:throw Error("Unknown math operator: "+b);}return[b,module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};
|
||||
module$exports$Blockly$Lua.luaGenerator.math_constant=function(a){return{PI:["math.pi",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH],E:["math.exp(1)",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH],GOLDEN_RATIO:["(1 + math.sqrt(5)) / 2",module$exports$Blockly$Lua.luaGenerator.ORDER_MULTIPLICATIVE],SQRT2:["math.sqrt(2)",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH],SQRT1_2:["math.sqrt(1 / 2)",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH],INFINITY:["math.huge",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]}[a.getFieldValue("CONSTANT")]};
|
||||
module$exports$Blockly$Lua.luaGenerator.math_number_property=function(a){var b={EVEN:[" % 2 == 0",module$exports$Blockly$Lua.luaGenerator.ORDER_MULTIPLICATIVE,module$exports$Blockly$Lua.luaGenerator.ORDER_RELATIONAL],ODD:[" % 2 == 1",module$exports$Blockly$Lua.luaGenerator.ORDER_MULTIPLICATIVE,module$exports$Blockly$Lua.luaGenerator.ORDER_RELATIONAL],WHOLE:[" % 1 == 0",module$exports$Blockly$Lua.luaGenerator.ORDER_MULTIPLICATIVE,module$exports$Blockly$Lua.luaGenerator.ORDER_RELATIONAL],POSITIVE:[" > 0",
|
||||
module$exports$Blockly$Lua.luaGenerator.ORDER_RELATIONAL,module$exports$Blockly$Lua.luaGenerator.ORDER_RELATIONAL],NEGATIVE:[" < 0",module$exports$Blockly$Lua.luaGenerator.ORDER_RELATIONAL,module$exports$Blockly$Lua.luaGenerator.ORDER_RELATIONAL],DIVISIBLE_BY:[null,module$exports$Blockly$Lua.luaGenerator.ORDER_MULTIPLICATIVE,module$exports$Blockly$Lua.luaGenerator.ORDER_RELATIONAL],PRIME:[null,module$exports$Blockly$Lua.luaGenerator.ORDER_NONE,module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};
|
||||
const c=a.getFieldValue("PROPERTY"),[d,e,f]=b[c];b=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"NUMBER_TO_CHECK",e)||"0";if("PRIME"===c)a=module$exports$Blockly$Lua.luaGenerator.provideFunction_("math_isPrime",`
|
||||
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(n)
|
||||
-- https://en.wikipedia.org/wiki/Primality_test#Naive_methods
|
||||
if n == 2 or n == 3 then
|
||||
return true
|
||||
end
|
||||
-- False if n is NaN, negative, is 1, or not whole.
|
||||
-- And false if n is divisible by 2 or 3.
|
||||
if not(n > 1) or n % 1 ~= 0 or n % 2 == 0 or n % 3 == 0 then
|
||||
return false
|
||||
end
|
||||
-- Check all the numbers of form 6k +/- 1, up to sqrt(n).
|
||||
for x = 6, math.sqrt(n) + 1.5, 6 do
|
||||
if n % (x - 1) == 0 or n % (x + 1) == 0 then
|
||||
return false
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
`)+"("+b+")";else if("DIVISIBLE_BY"===c){a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"DIVISOR",module$exports$Blockly$Lua.luaGenerator.ORDER_MULTIPLICATIVE)||"0";if("0"===a)return["nil",module$exports$Blockly$Lua.luaGenerator.ORDER_ATOMIC];a=b+" % "+a+" == 0"}else a=b+d;return[a,f]};
|
||||
module$exports$Blockly$Lua.luaGenerator.math_change=function(a){const b=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"DELTA",module$exports$Blockly$Lua.luaGenerator.ORDER_ADDITIVE)||"0";a=module$exports$Blockly$Lua.luaGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE);return a+" = "+a+" + "+b+"\n"};module$exports$Blockly$Lua.luaGenerator.math_round=module$exports$Blockly$Lua.luaGenerator.math_single;
|
||||
module$exports$Blockly$Lua.luaGenerator.math_trig=module$exports$Blockly$Lua.luaGenerator.math_single;module$exports$Blockly$Lua.luaGenerator.math_on_list=function(a){function b(){return module$exports$Blockly$Lua.luaGenerator.provideFunction_("math_sum",`
|
||||
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(t)
|
||||
local result = 0
|
||||
for _, v in ipairs(t) do
|
||||
result = result + v
|
||||
end
|
||||
return result
|
||||
end
|
||||
`)}var c=a.getFieldValue("OP");a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"LIST",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"{}";switch(c){case "SUM":c=b();break;case "MIN":c=module$exports$Blockly$Lua.luaGenerator.provideFunction_("math_min",`
|
||||
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(t)
|
||||
if #t == 0 then
|
||||
return 0
|
||||
end
|
||||
local result = math.huge
|
||||
for _, v in ipairs(t) do
|
||||
if v < result then
|
||||
result = v
|
||||
end
|
||||
end
|
||||
return result
|
||||
end
|
||||
`);break;case "AVERAGE":c=module$exports$Blockly$Lua.luaGenerator.provideFunction_("math_average",`
|
||||
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(t)
|
||||
if #t == 0 then
|
||||
return 0
|
||||
end
|
||||
return ${b()}(t) / #t
|
||||
end
|
||||
`);break;case "MAX":c=module$exports$Blockly$Lua.luaGenerator.provideFunction_("math_max",`
|
||||
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(t)
|
||||
if #t == 0 then
|
||||
return 0
|
||||
end
|
||||
local result = -math.huge
|
||||
for _, v in ipairs(t) do
|
||||
if v > result then
|
||||
result = v
|
||||
end
|
||||
end
|
||||
return result
|
||||
end
|
||||
`);break;case "MEDIAN":c=module$exports$Blockly$Lua.luaGenerator.provideFunction_("math_median",`
|
||||
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(t)
|
||||
-- Source: http://lua-users.org/wiki/SimpleStats
|
||||
if #t == 0 then
|
||||
return 0
|
||||
end
|
||||
local temp = {}
|
||||
for _, v in ipairs(t) do
|
||||
if type(v) == 'number' then
|
||||
table.insert(temp, v)
|
||||
end
|
||||
end
|
||||
table.sort(temp)
|
||||
if #temp % 2 == 0 then
|
||||
return (temp[#temp / 2] + temp[(#temp / 2) + 1]) / 2
|
||||
else
|
||||
return temp[math.ceil(#temp / 2)]
|
||||
end
|
||||
end
|
||||
`);break;case "MODE":c=module$exports$Blockly$Lua.luaGenerator.provideFunction_("math_modes",`
|
||||
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(t)
|
||||
-- Source: http://lua-users.org/wiki/SimpleStats
|
||||
local counts = {}
|
||||
for _, v in ipairs(t) do
|
||||
if counts[v] == nil then
|
||||
counts[v] = 1
|
||||
else
|
||||
counts[v] = counts[v] + 1
|
||||
end
|
||||
end
|
||||
local biggestCount = 0
|
||||
for _, v in pairs(counts) do
|
||||
if v > biggestCount then
|
||||
biggestCount = v
|
||||
end
|
||||
end
|
||||
local temp = {}
|
||||
for k, v in pairs(counts) do
|
||||
if v == biggestCount then
|
||||
table.insert(temp, k)
|
||||
end
|
||||
end
|
||||
return temp
|
||||
end
|
||||
`);break;case "STD_DEV":c=module$exports$Blockly$Lua.luaGenerator.provideFunction_("math_standard_deviation",`
|
||||
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(t)
|
||||
local m
|
||||
local vm
|
||||
local total = 0
|
||||
local count = 0
|
||||
local result
|
||||
m = #t == 0 and 0 or ${b()}(t) / #t
|
||||
for _, v in ipairs(t) do
|
||||
if type(v) == 'number' then
|
||||
vm = v - m
|
||||
total = total + (vm * vm)
|
||||
count = count + 1
|
||||
end
|
||||
end
|
||||
result = math.sqrt(total / (count-1))
|
||||
return result
|
||||
end
|
||||
`);break;case "RANDOM":c=module$exports$Blockly$Lua.luaGenerator.provideFunction_("math_random_list",`
|
||||
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(t)
|
||||
if #t == 0 then
|
||||
return nil
|
||||
end
|
||||
return t[math.random(#t)]
|
||||
end
|
||||
`);break;default:throw Error("Unknown operator: "+c);}return[c+"("+a+")",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};module$exports$Blockly$Lua.luaGenerator.math_modulo=function(a){const b=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"DIVIDEND",module$exports$Blockly$Lua.luaGenerator.ORDER_MULTIPLICATIVE)||"0";a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"DIVISOR",module$exports$Blockly$Lua.luaGenerator.ORDER_MULTIPLICATIVE)||"0";return[b+" % "+a,module$exports$Blockly$Lua.luaGenerator.ORDER_MULTIPLICATIVE]};
|
||||
module$exports$Blockly$Lua.luaGenerator.math_constrain=function(a){const b=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"0",c=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"LOW",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"-math.huge";a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"HIGH",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"math.huge";return["math.min(math.max("+b+", "+c+"), "+a+")",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};
|
||||
module$exports$Blockly$Lua.luaGenerator.math_random_int=function(a){const b=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"FROM",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"0";a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"TO",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"0";return["math.random("+b+", "+a+")",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};module$exports$Blockly$Lua.luaGenerator.math_random_float=function(a){return["math.random()",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};
|
||||
module$exports$Blockly$Lua.luaGenerator.math_atan2=function(a){const b=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"X",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"0";return["math.deg(math.atan2("+(module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"Y",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"0")+", "+b+"))",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};var module$exports$Blockly$Lua$loops={},module$contents$Blockly$Lua$loops_stringUtils=$.module$build$src$core$utils$string,module$contents$Blockly$Lua$loops_NameType=$.NameType$$module$build$src$core$names,module$contents$Blockly$Lua$loops_CONTINUE_STATEMENT="goto continue\n",module$contents$Blockly$Lua$loops_addContinueLabel=function(a){return-1!==a.indexOf(module$contents$Blockly$Lua$loops_CONTINUE_STATEMENT)?a+module$exports$Blockly$Lua.luaGenerator.INDENT+"::continue::\n":a};
|
||||
module$exports$Blockly$Lua.luaGenerator.controls_repeat_ext=function(a){let b;b=a.getField("TIMES")?String(Number(a.getFieldValue("TIMES"))):module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"TIMES",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"0";b=$.module$build$src$core$utils$string.isNumber(b)?parseInt(b,10):"math.floor("+b+")";let c=module$exports$Blockly$Lua.luaGenerator.statementToCode(a,"DO");c=module$exports$Blockly$Lua.luaGenerator.addLoopTrap(c,a);c=module$contents$Blockly$Lua$loops_addContinueLabel(c);
|
||||
return"for "+module$exports$Blockly$Lua.luaGenerator.nameDB_.getDistinctName("count",$.NameType$$module$build$src$core$names.VARIABLE)+" = 1, "+b+" do\n"+c+"end\n"};module$exports$Blockly$Lua.luaGenerator.controls_repeat=module$exports$Blockly$Lua.luaGenerator.controls_repeat_ext;
|
||||
module$exports$Blockly$Lua.luaGenerator.controls_whileUntil=function(a){const b="UNTIL"===a.getFieldValue("MODE");let c=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"BOOL",b?module$exports$Blockly$Lua.luaGenerator.ORDER_UNARY:module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"false",d=module$exports$Blockly$Lua.luaGenerator.statementToCode(a,"DO");d=module$exports$Blockly$Lua.luaGenerator.addLoopTrap(d,a);d=module$contents$Blockly$Lua$loops_addContinueLabel(d);b&&(c="not "+c);return"while "+
|
||||
c+" do\n"+d+"end\n"};
|
||||
module$exports$Blockly$Lua.luaGenerator.controls_for=function(a){const b=module$exports$Blockly$Lua.luaGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE),c=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"FROM",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"0",d=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"TO",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"0",e=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"BY",
|
||||
module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"1";let f=module$exports$Blockly$Lua.luaGenerator.statementToCode(a,"DO");f=module$exports$Blockly$Lua.luaGenerator.addLoopTrap(f,a);f=module$contents$Blockly$Lua$loops_addContinueLabel(f);a="";let g;$.module$build$src$core$utils$string.isNumber(c)&&$.module$build$src$core$utils$string.isNumber(d)&&$.module$build$src$core$utils$string.isNumber(e)?g=(Number(c)<=Number(d)?"":"-")+Math.abs(Number(e)):(a="",g=module$exports$Blockly$Lua.luaGenerator.nameDB_.getDistinctName(b+
|
||||
"_inc",$.NameType$$module$build$src$core$names.VARIABLE),a+=g+" = ",a=$.module$build$src$core$utils$string.isNumber(e)?a+(Math.abs(e)+"\n"):a+("math.abs("+e+")\n"),a=a+("if ("+c+") > ("+d+") then\n")+(module$exports$Blockly$Lua.luaGenerator.INDENT+g+" = -"+g+"\n"),a+="end\n");return a+("for "+b+" = "+c+", "+d+", "+g)+(" do\n"+f+"end\n")};
|
||||
module$exports$Blockly$Lua.luaGenerator.controls_forEach=function(a){const b=module$exports$Blockly$Lua.luaGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE),c=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"LIST",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"{}";let d=module$exports$Blockly$Lua.luaGenerator.statementToCode(a,"DO");d=module$exports$Blockly$Lua.luaGenerator.addLoopTrap(d,a);d=module$contents$Blockly$Lua$loops_addContinueLabel(d);
|
||||
return"for _, "+b+" in ipairs("+c+") do \n"+d+"end\n"};
|
||||
module$exports$Blockly$Lua.luaGenerator.controls_flow_statements=function(a){let b="";module$exports$Blockly$Lua.luaGenerator.STATEMENT_PREFIX&&(b+=module$exports$Blockly$Lua.luaGenerator.injectId(module$exports$Blockly$Lua.luaGenerator.STATEMENT_PREFIX,a));module$exports$Blockly$Lua.luaGenerator.STATEMENT_SUFFIX&&(b+=module$exports$Blockly$Lua.luaGenerator.injectId(module$exports$Blockly$Lua.luaGenerator.STATEMENT_SUFFIX,a));if(module$exports$Blockly$Lua.luaGenerator.STATEMENT_PREFIX){const c=a.getSurroundLoop();
|
||||
c&&!c.suppressPrefixSuffix&&(b+=module$exports$Blockly$Lua.luaGenerator.injectId(module$exports$Blockly$Lua.luaGenerator.STATEMENT_PREFIX,c))}switch(a.getFieldValue("FLOW")){case "BREAK":return b+"break\n";case "CONTINUE":return b+module$contents$Blockly$Lua$loops_CONTINUE_STATEMENT}throw Error("Unknown flow statement.");};var module$exports$Blockly$Lua$logic={};
|
||||
module$exports$Blockly$Lua.luaGenerator.controls_if=function(a){var b=0;let c="";module$exports$Blockly$Lua.luaGenerator.STATEMENT_PREFIX&&(c+=module$exports$Blockly$Lua.luaGenerator.injectId(module$exports$Blockly$Lua.luaGenerator.STATEMENT_PREFIX,a));do{const d=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"IF"+b,module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"false";let e=module$exports$Blockly$Lua.luaGenerator.statementToCode(a,"DO"+b);module$exports$Blockly$Lua.luaGenerator.STATEMENT_SUFFIX&&(e=
|
||||
module$exports$Blockly$Lua.luaGenerator.prefixLines(module$exports$Blockly$Lua.luaGenerator.injectId(module$exports$Blockly$Lua.luaGenerator.STATEMENT_SUFFIX,a),module$exports$Blockly$Lua.luaGenerator.INDENT)+e);c+=(0<b?"else":"")+"if "+d+" then\n"+e;b++}while(a.getInput("IF"+b));if(a.getInput("ELSE")||module$exports$Blockly$Lua.luaGenerator.STATEMENT_SUFFIX)b=module$exports$Blockly$Lua.luaGenerator.statementToCode(a,"ELSE"),module$exports$Blockly$Lua.luaGenerator.STATEMENT_SUFFIX&&(b=module$exports$Blockly$Lua.luaGenerator.prefixLines(module$exports$Blockly$Lua.luaGenerator.injectId(module$exports$Blockly$Lua.luaGenerator.STATEMENT_SUFFIX,
|
||||
a),module$exports$Blockly$Lua.luaGenerator.INDENT)+b),c+="else\n"+b;return c+"end\n"};module$exports$Blockly$Lua.luaGenerator.controls_ifelse=module$exports$Blockly$Lua.luaGenerator.controls_if;
|
||||
module$exports$Blockly$Lua.luaGenerator.logic_compare=function(a){const b={EQ:"==",NEQ:"~=",LT:"<",LTE:"<=",GT:">",GTE:">="}[a.getFieldValue("OP")],c=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"A",module$exports$Blockly$Lua.luaGenerator.ORDER_RELATIONAL)||"0";a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"B",module$exports$Blockly$Lua.luaGenerator.ORDER_RELATIONAL)||"0";return[c+" "+b+" "+a,module$exports$Blockly$Lua.luaGenerator.ORDER_RELATIONAL]};
|
||||
module$exports$Blockly$Lua.luaGenerator.logic_operation=function(a){const b="AND"===a.getFieldValue("OP")?"and":"or",c="and"===b?module$exports$Blockly$Lua.luaGenerator.ORDER_AND:module$exports$Blockly$Lua.luaGenerator.ORDER_OR;let d=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"A",c);a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"B",c);if(d||a){const e="and"===b?"true":"false";d||(d=e);a||(a=e)}else a=d="false";return[d+" "+b+" "+a,c]};
|
||||
module$exports$Blockly$Lua.luaGenerator.logic_negate=function(a){return["not "+(module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"BOOL",module$exports$Blockly$Lua.luaGenerator.ORDER_UNARY)||"true"),module$exports$Blockly$Lua.luaGenerator.ORDER_UNARY]};module$exports$Blockly$Lua.luaGenerator.logic_boolean=function(a){return["TRUE"===a.getFieldValue("BOOL")?"true":"false",module$exports$Blockly$Lua.luaGenerator.ORDER_ATOMIC]};
|
||||
module$exports$Blockly$Lua.luaGenerator.logic_null=function(a){return["nil",module$exports$Blockly$Lua.luaGenerator.ORDER_ATOMIC]};
|
||||
module$exports$Blockly$Lua.luaGenerator.logic_ternary=function(a){const b=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"IF",module$exports$Blockly$Lua.luaGenerator.ORDER_AND)||"false",c=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"THEN",module$exports$Blockly$Lua.luaGenerator.ORDER_AND)||"nil";a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"ELSE",module$exports$Blockly$Lua.luaGenerator.ORDER_OR)||"nil";return[b+" and "+c+" or "+a,module$exports$Blockly$Lua.luaGenerator.ORDER_OR]};var module$exports$Blockly$Lua$lists={},module$contents$Blockly$Lua$lists_NameType=$.NameType$$module$build$src$core$names;module$exports$Blockly$Lua.luaGenerator.lists_create_empty=function(a){return["{}",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};
|
||||
module$exports$Blockly$Lua.luaGenerator.lists_create_with=function(a){const b=Array(a.itemCount_);for(let c=0;c<a.itemCount_;c++)b[c]=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"ADD"+c,module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"None";return["{"+b.join(", ")+"}",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};module$exports$Blockly$Lua.luaGenerator.lists_repeat=function(a){const b=module$exports$Blockly$Lua.luaGenerator.provideFunction_("create_list_repeated",`
|
||||
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(item, count)
|
||||
local t = {}
|
||||
for i = 1, count do
|
||||
table.insert(t, item)
|
||||
end
|
||||
return t
|
||||
end
|
||||
`),c=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"ITEM",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"None";a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"NUM",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"0";return[b+"("+c+", "+a+")",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};
|
||||
module$exports$Blockly$Lua.luaGenerator.lists_length=function(a){return["#"+(module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Lua.luaGenerator.ORDER_UNARY)||"{}"),module$exports$Blockly$Lua.luaGenerator.ORDER_UNARY]};module$exports$Blockly$Lua.luaGenerator.lists_isEmpty=function(a){return["#"+(module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Lua.luaGenerator.ORDER_UNARY)||"{}")+" == 0",module$exports$Blockly$Lua.luaGenerator.ORDER_RELATIONAL]};
|
||||
module$exports$Blockly$Lua.luaGenerator.lists_indexOf=function(a){const b=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"FIND",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"''",c=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"{}";return[("FIRST"===a.getFieldValue("END")?module$exports$Blockly$Lua.luaGenerator.provideFunction_("first_index",`
|
||||
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(t, elem)
|
||||
for k, v in ipairs(t) do
|
||||
if v == elem then
|
||||
return k
|
||||
end
|
||||
end
|
||||
return 0
|
||||
end
|
||||
`):module$exports$Blockly$Lua.luaGenerator.provideFunction_("last_index",`
|
||||
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(t, elem)
|
||||
for i = #t, 1, -1 do
|
||||
if t[i] == elem then
|
||||
return i
|
||||
end
|
||||
end
|
||||
return 0
|
||||
end
|
||||
`))+"("+c+", "+b+")",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};var module$contents$Blockly$Lua$lists_getListIndex=function(a,b,c){return"FIRST"===b?"1":"FROM_END"===b?"#"+a+" + 1 - "+c:"LAST"===b?"#"+a:"RANDOM"===b?"math.random(#"+a+")":c};
|
||||
module$exports$Blockly$Lua.luaGenerator.lists_getIndex=function(a){var b=a.getFieldValue("MODE")||"GET",c=a.getFieldValue("WHERE")||"FROM_START";const d=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH)||"({})";if("LAST"!==c&&"FROM_END"!==c&&"RANDOM"!==c||d.match(/^\w+$/)){a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"AT","GET"===b&&"FROM_END"===c?module$exports$Blockly$Lua.luaGenerator.ORDER_ADDITIVE:module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||
|
||||
"1";a=module$contents$Blockly$Lua$lists_getListIndex(d,c,a);if("GET"===b)return[d+"["+a+"]",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH];c="table.remove("+d+", "+a+")";return"GET_REMOVE"===b?[c,module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]:c+"\n"}if("REMOVE"===b)return b=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"AT","FROM_END"===c?module$exports$Blockly$Lua.luaGenerator.ORDER_ADDITIVE:module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"1",a=module$exports$Blockly$Lua.luaGenerator.nameDB_.getDistinctName("tmp_list",
|
||||
$.NameType$$module$build$src$core$names.VARIABLE),b=module$contents$Blockly$Lua$lists_getListIndex(a,c,b),a+" = "+d+"\ntable.remove("+a+", "+b+")\n";a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"AT",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"1";return[("GET"===b?module$exports$Blockly$Lua.luaGenerator.provideFunction_("list_get_"+c.toLowerCase(),["function "+module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_+"(t"+("FROM_END"===c||"FROM_START"===c?", at)":")"),
|
||||
" return t["+module$contents$Blockly$Lua$lists_getListIndex("t",c,"at")+"]","end"]):module$exports$Blockly$Lua.luaGenerator.provideFunction_("list_remove_"+c.toLowerCase(),["function "+module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_+"(t"+("FROM_END"===c||"FROM_START"===c?", at)":")")," return table.remove(t, "+module$contents$Blockly$Lua$lists_getListIndex("t",c,"at")+")","end"]))+"("+d+("FROM_END"===c||"FROM_START"===c?", "+a:"")+")",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};
|
||||
module$exports$Blockly$Lua.luaGenerator.lists_setIndex=function(a){let b=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"LIST",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH)||"{}";const c=a.getFieldValue("MODE")||"SET",d=a.getFieldValue("WHERE")||"FROM_START",e=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"AT",module$exports$Blockly$Lua.luaGenerator.ORDER_ADDITIVE)||"1";a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"TO",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||
|
||||
"None";let f="";if(("LAST"===d||"FROM_END"===d||"RANDOM"===d)&&!b.match(/^\w+$/)){const g=module$exports$Blockly$Lua.luaGenerator.nameDB_.getDistinctName("tmp_list",$.NameType$$module$build$src$core$names.VARIABLE);f=g+" = "+b+"\n";b=g}f="SET"===c?f+(b+"["+module$contents$Blockly$Lua$lists_getListIndex(b,d,e)+"] = "+a):f+("table.insert("+b+", "+(module$contents$Blockly$Lua$lists_getListIndex(b,d,e)+("LAST"===d?" + 1":""))+", "+a+")");return f+"\n"};
|
||||
module$exports$Blockly$Lua.luaGenerator.lists_getSublist=function(a){const b=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"LIST",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"{}",c=a.getFieldValue("WHERE1"),d=a.getFieldValue("WHERE2"),e=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"AT1",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"1";a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"AT2",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"1";const f="FROM_END"===
|
||||
c||"FROM_START"===c?", at1":"",g="FROM_END"===d||"FROM_START"===d?", at2":"";return[module$exports$Blockly$Lua.luaGenerator.provideFunction_("list_sublist_"+c.toLowerCase()+"_"+d.toLowerCase(),`
|
||||
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(source${f}${g})
|
||||
local t = {}
|
||||
local start = ${module$contents$Blockly$Lua$lists_getListIndex("source",c,"at1")}
|
||||
local finish = ${module$contents$Blockly$Lua$lists_getListIndex("source",d,"at2")}
|
||||
for i = start, finish do
|
||||
table.insert(t, source[i])
|
||||
end
|
||||
return t
|
||||
end
|
||||
`)+"("+b+("FROM_END"===c||"FROM_START"===c?", "+e:"")+("FROM_END"===d||"FROM_START"===d?", "+a:"")+")",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};module$exports$Blockly$Lua.luaGenerator.lists_sort=function(a){const b=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"LIST",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"{}",c="1"===a.getFieldValue("DIRECTION")?1:-1;a=a.getFieldValue("TYPE");return[module$exports$Blockly$Lua.luaGenerator.provideFunction_("list_sort",`
|
||||
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(list, typev, direction)
|
||||
local t = {}
|
||||
for n,v in pairs(list) do table.insert(t, v) end
|
||||
local compareFuncs = {
|
||||
NUMERIC = function(a, b)
|
||||
return (tonumber(tostring(a)) or 0)
|
||||
< (tonumber(tostring(b)) or 0) end,
|
||||
TEXT = function(a, b)
|
||||
return tostring(a) < tostring(b) end,
|
||||
IGNORE_CASE = function(a, b)
|
||||
return string.lower(tostring(a)) < string.lower(tostring(b)) end
|
||||
}
|
||||
local compareTemp = compareFuncs[typev]
|
||||
local compare = compareTemp
|
||||
if direction == -1
|
||||
then compare = function(a, b) return compareTemp(b, a) end
|
||||
end
|
||||
table.sort(t, compare)
|
||||
return t
|
||||
end
|
||||
`)+"("+b+',"'+a+'", '+c+")",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};
|
||||
module$exports$Blockly$Lua.luaGenerator.lists_split=function(a){let b=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"INPUT",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE);const c=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"DELIM",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"''";a=a.getFieldValue("MODE");if("SPLIT"===a)b||(b="''"),a=module$exports$Blockly$Lua.luaGenerator.provideFunction_("list_string_split",`
|
||||
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(input, delim)
|
||||
local t = {}
|
||||
local pos = 1
|
||||
while true do
|
||||
next_delim = string.find(input, delim, pos)
|
||||
if next_delim == nil then
|
||||
table.insert(t, string.sub(input, pos))
|
||||
break
|
||||
else
|
||||
table.insert(t, string.sub(input, pos, next_delim-1))
|
||||
pos = next_delim + #delim
|
||||
end
|
||||
end
|
||||
return t
|
||||
end
|
||||
`);else if("JOIN"===a)b||(b="{}"),a="table.concat";else throw Error("Unknown mode: "+a);return[a+"("+b+", "+c+")",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};module$exports$Blockly$Lua.luaGenerator.lists_reverse=function(a){a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"LIST",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"{}";return[module$exports$Blockly$Lua.luaGenerator.provideFunction_("list_reverse",`
|
||||
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(input)
|
||||
local reversed = {}
|
||||
for i = #input, 1, -1 do
|
||||
table.insert(reversed, input[i])
|
||||
end
|
||||
return reversed
|
||||
end
|
||||
`)+"("+a+")",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};var module$exports$Blockly$Lua$colour={};module$exports$Blockly$Lua.luaGenerator.colour_picker=function(a){return[module$exports$Blockly$Lua.luaGenerator.quote_(a.getFieldValue("COLOUR")),module$exports$Blockly$Lua.luaGenerator.ORDER_ATOMIC]};module$exports$Blockly$Lua.luaGenerator.colour_random=function(a){return['string.format("#%06x", math.random(0, 2^24 - 1))',module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};
|
||||
module$exports$Blockly$Lua.luaGenerator.colour_rgb=function(a){const b=module$exports$Blockly$Lua.luaGenerator.provideFunction_("colour_rgb",`
|
||||
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(r, g, b)
|
||||
r = math.floor(math.min(100, math.max(0, r)) * 2.55 + .5)
|
||||
g = math.floor(math.min(100, math.max(0, g)) * 2.55 + .5)
|
||||
b = math.floor(math.min(100, math.max(0, b)) * 2.55 + .5)
|
||||
return string.format("#%02x%02x%02x", r, g, b)
|
||||
end
|
||||
`),c=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"RED",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||0,d=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"GREEN",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||0;a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"BLUE",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||0;return[b+"("+c+", "+d+", "+a+")",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};
|
||||
module$exports$Blockly$Lua.luaGenerator.colour_blend=function(a){const b=module$exports$Blockly$Lua.luaGenerator.provideFunction_("colour_blend",`
|
||||
function ${module$exports$Blockly$Lua.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(colour1, colour2, ratio)
|
||||
local r1 = tonumber(string.sub(colour1, 2, 3), 16)
|
||||
local r2 = tonumber(string.sub(colour2, 2, 3), 16)
|
||||
local g1 = tonumber(string.sub(colour1, 4, 5), 16)
|
||||
local g2 = tonumber(string.sub(colour2, 4, 5), 16)
|
||||
local b1 = tonumber(string.sub(colour1, 6, 7), 16)
|
||||
local b2 = tonumber(string.sub(colour2, 6, 7), 16)
|
||||
local ratio = math.min(1, math.max(0, ratio))
|
||||
local r = math.floor(r1 * (1 - ratio) + r2 * ratio + .5)
|
||||
local g = math.floor(g1 * (1 - ratio) + g2 * ratio + .5)
|
||||
local b = math.floor(b1 * (1 - ratio) + b2 * ratio + .5)
|
||||
return string.format("#%02x%02x%02x", r, g, b)
|
||||
end
|
||||
`),c=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"COLOUR1",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"'#000000'",d=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"COLOUR2",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||"'#000000'";a=module$exports$Blockly$Lua.luaGenerator.valueToCode(a,"RATIO",module$exports$Blockly$Lua.luaGenerator.ORDER_NONE)||0;return[b+"("+c+", "+d+", "+a+")",module$exports$Blockly$Lua.luaGenerator.ORDER_HIGH]};var module$exports$Blockly$Lua$all=module$exports$Blockly$Lua;
|
||||
module$exports$Blockly$Lua.__namespace__=$;
|
||||
return module$exports$Blockly$Lua;
|
||||
}));
|
||||
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "blockly",
|
||||
"version": "8.0.0",
|
||||
"version": "9.0.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "blockly",
|
||||
"version": "8.0.0",
|
||||
"version": "9.0.0",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"jsdom": "15.2.1"
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "blockly",
|
||||
"version": "8.0.0",
|
||||
"version": "9.0.0",
|
||||
"description": "Blockly is a library for building visual programming editors.",
|
||||
"keywords": [
|
||||
"blockly"
|
||||
|
||||
+322
-93
@@ -8,103 +8,332 @@
|
||||
module.exports = factory(require("./blockly_compressed.js"));
|
||||
} else { // Browser
|
||||
var factoryExports = factory(root.Blockly);
|
||||
root.Blockly.PHP = factoryExports;
|
||||
root.Blockly.PHP = factoryExports.phpGenerator;
|
||||
root.Blockly.PHP.__namespace__ = factoryExports.__namespace__;
|
||||
}
|
||||
}(this, function(__parent__) {
|
||||
var $=__parent__.__namespace__;
|
||||
var module$contents$Blockly$PHP_PHP=new $.module$exports$Blockly$Generator.Generator("PHP");module$contents$Blockly$PHP_PHP.addReservedWords("__halt_compiler,abstract,and,array,as,break,callable,case,catch,class,clone,const,continue,declare,default,die,do,echo,else,elseif,empty,enddeclare,endfor,endforeach,endif,endswitch,endwhile,eval,exit,extends,final,for,foreach,function,global,goto,if,implements,include,include_once,instanceof,insteadof,interface,isset,list,namespace,new,or,print,private,protected,public,require,require_once,return,static,switch,throw,trait,try,unset,use,var,while,xor,PHP_VERSION,PHP_MAJOR_VERSION,PHP_MINOR_VERSION,PHP_RELEASE_VERSION,PHP_VERSION_ID,PHP_EXTRA_VERSION,PHP_ZTS,PHP_DEBUG,PHP_MAXPATHLEN,PHP_OS,PHP_SAPI,PHP_EOL,PHP_INT_MAX,PHP_INT_SIZE,DEFAULT_INCLUDE_PATH,PEAR_INSTALL_DIR,PEAR_EXTENSION_DIR,PHP_EXTENSION_DIR,PHP_PREFIX,PHP_BINDIR,PHP_BINARY,PHP_MANDIR,PHP_LIBDIR,PHP_DATADIR,PHP_SYSCONFDIR,PHP_LOCALSTATEDIR,PHP_CONFIG_FILE_PATH,PHP_CONFIG_FILE_SCAN_DIR,PHP_SHLIB_SUFFIX,E_ERROR,E_WARNING,E_PARSE,E_NOTICE,E_CORE_ERROR,E_CORE_WARNING,E_COMPILE_ERROR,E_COMPILE_WARNING,E_USER_ERROR,E_USER_WARNING,E_USER_NOTICE,E_DEPRECATED,E_USER_DEPRECATED,E_ALL,E_STRICT,__COMPILER_HALT_OFFSET__,TRUE,FALSE,NULL,__CLASS__,__DIR__,__FILE__,__FUNCTION__,__LINE__,__METHOD__,__NAMESPACE__,__TRAIT__");
|
||||
module$contents$Blockly$PHP_PHP.ORDER_ATOMIC=0;module$contents$Blockly$PHP_PHP.ORDER_CLONE=1;module$contents$Blockly$PHP_PHP.ORDER_NEW=1;module$contents$Blockly$PHP_PHP.ORDER_MEMBER=2.1;module$contents$Blockly$PHP_PHP.ORDER_FUNCTION_CALL=2.2;module$contents$Blockly$PHP_PHP.ORDER_POWER=3;module$contents$Blockly$PHP_PHP.ORDER_INCREMENT=4;module$contents$Blockly$PHP_PHP.ORDER_DECREMENT=4;module$contents$Blockly$PHP_PHP.ORDER_BITWISE_NOT=4;module$contents$Blockly$PHP_PHP.ORDER_CAST=4;
|
||||
module$contents$Blockly$PHP_PHP.ORDER_SUPPRESS_ERROR=4;module$contents$Blockly$PHP_PHP.ORDER_INSTANCEOF=5;module$contents$Blockly$PHP_PHP.ORDER_LOGICAL_NOT=6;module$contents$Blockly$PHP_PHP.ORDER_UNARY_PLUS=7.1;module$contents$Blockly$PHP_PHP.ORDER_UNARY_NEGATION=7.2;module$contents$Blockly$PHP_PHP.ORDER_MULTIPLICATION=8.1;module$contents$Blockly$PHP_PHP.ORDER_DIVISION=8.2;module$contents$Blockly$PHP_PHP.ORDER_MODULUS=8.3;module$contents$Blockly$PHP_PHP.ORDER_ADDITION=9.1;
|
||||
module$contents$Blockly$PHP_PHP.ORDER_SUBTRACTION=9.2;module$contents$Blockly$PHP_PHP.ORDER_STRING_CONCAT=9.3;module$contents$Blockly$PHP_PHP.ORDER_BITWISE_SHIFT=10;module$contents$Blockly$PHP_PHP.ORDER_RELATIONAL=11;module$contents$Blockly$PHP_PHP.ORDER_EQUALITY=12;module$contents$Blockly$PHP_PHP.ORDER_REFERENCE=13;module$contents$Blockly$PHP_PHP.ORDER_BITWISE_AND=13;module$contents$Blockly$PHP_PHP.ORDER_BITWISE_XOR=14;module$contents$Blockly$PHP_PHP.ORDER_BITWISE_OR=15;
|
||||
module$contents$Blockly$PHP_PHP.ORDER_LOGICAL_AND=16;module$contents$Blockly$PHP_PHP.ORDER_LOGICAL_OR=17;module$contents$Blockly$PHP_PHP.ORDER_IF_NULL=18;module$contents$Blockly$PHP_PHP.ORDER_CONDITIONAL=19;module$contents$Blockly$PHP_PHP.ORDER_ASSIGNMENT=20;module$contents$Blockly$PHP_PHP.ORDER_LOGICAL_AND_WEAK=21;module$contents$Blockly$PHP_PHP.ORDER_LOGICAL_XOR=22;module$contents$Blockly$PHP_PHP.ORDER_LOGICAL_OR_WEAK=23;module$contents$Blockly$PHP_PHP.ORDER_NONE=99;
|
||||
module$contents$Blockly$PHP_PHP.ORDER_OVERRIDES=[[module$contents$Blockly$PHP_PHP.ORDER_MEMBER,module$contents$Blockly$PHP_PHP.ORDER_FUNCTION_CALL],[module$contents$Blockly$PHP_PHP.ORDER_MEMBER,module$contents$Blockly$PHP_PHP.ORDER_MEMBER],[module$contents$Blockly$PHP_PHP.ORDER_LOGICAL_NOT,module$contents$Blockly$PHP_PHP.ORDER_LOGICAL_NOT],[module$contents$Blockly$PHP_PHP.ORDER_MULTIPLICATION,module$contents$Blockly$PHP_PHP.ORDER_MULTIPLICATION],[module$contents$Blockly$PHP_PHP.ORDER_ADDITION,module$contents$Blockly$PHP_PHP.ORDER_ADDITION],
|
||||
[module$contents$Blockly$PHP_PHP.ORDER_LOGICAL_AND,module$contents$Blockly$PHP_PHP.ORDER_LOGICAL_AND],[module$contents$Blockly$PHP_PHP.ORDER_LOGICAL_OR,module$contents$Blockly$PHP_PHP.ORDER_LOGICAL_OR]];module$contents$Blockly$PHP_PHP.isInitialized=!1;
|
||||
module$contents$Blockly$PHP_PHP.init=function(a){Object.getPrototypeOf(this).init.call(this);this.nameDB_?this.nameDB_.reset():this.nameDB_=new $.module$exports$Blockly$Names.Names(this.RESERVED_WORDS_,"$");this.nameDB_.setVariableMap(a.getVariableMap());this.nameDB_.populateVariables(a);this.nameDB_.populateProcedures(a);this.isInitialized=!0};
|
||||
module$contents$Blockly$PHP_PHP.finish=function(a){var b=(0,$.module$exports$Blockly$utils$object.values)(this.definitions_);a=Object.getPrototypeOf(this).finish.call(this,a);this.isInitialized=!1;this.nameDB_.reset();return b.join("\n\n")+"\n\n\n"+a};module$contents$Blockly$PHP_PHP.scrubNakedValue=function(a){return a+";\n"};module$contents$Blockly$PHP_PHP.quote_=function(a){a=a.replace(/\\/g,"\\\\").replace(/\n/g,"\\\n").replace(/'/g,"\\'");return"'"+a+"'"};
|
||||
module$contents$Blockly$PHP_PHP.multiline_quote_=function(a){return a.split(/\n/g).map(this.quote_).join(' . "\\n" .\n')};
|
||||
module$contents$Blockly$PHP_PHP.scrub_=function(a,b,c){var d="";if(!a.outputConnection||!a.outputConnection.targetConnection){var e=a.getCommentText();e&&(e=(0,$.module$exports$Blockly$utils$string.wrap)(e,this.COMMENT_WRAP-3),d+=this.prefixLines(e,"// ")+"\n");for(var f=0;f<a.inputList.length;f++)a.inputList[f].type===$.module$exports$Blockly$inputTypes.inputTypes.VALUE&&(e=a.inputList[f].connection.targetBlock())&&(e=this.allNestedComments(e))&&(d+=this.prefixLines(e,"// "))}a=a.nextConnection&&
|
||||
var module$exports$Blockly$PHP={},module$contents$Blockly$PHP_objectUtils=$.module$build$src$core$utils$object,module$contents$Blockly$PHP_stringUtils=$.module$build$src$core$utils$string,module$contents$Blockly$PHP_Generator=$.Generator$$module$build$src$core$generator,module$contents$Blockly$PHP_inputTypes=$.module$build$src$core$input_types.inputTypes,module$contents$Blockly$PHP_Names=$.module$build$src$core$names.Names;module$exports$Blockly$PHP.phpGenerator=new $.Generator$$module$build$src$core$generator("PHP");
|
||||
module$exports$Blockly$PHP.phpGenerator.addReservedWords("__halt_compiler,abstract,and,array,as,break,callable,case,catch,class,clone,const,continue,declare,default,die,do,echo,else,elseif,empty,enddeclare,endfor,endforeach,endif,endswitch,endwhile,eval,exit,extends,final,for,foreach,function,global,goto,if,implements,include,include_once,instanceof,insteadof,interface,isset,list,namespace,new,or,print,private,protected,public,require,require_once,return,static,switch,throw,trait,try,unset,use,var,while,xor,PHP_VERSION,PHP_MAJOR_VERSION,PHP_MINOR_VERSION,PHP_RELEASE_VERSION,PHP_VERSION_ID,PHP_EXTRA_VERSION,PHP_ZTS,PHP_DEBUG,PHP_MAXPATHLEN,PHP_OS,PHP_SAPI,PHP_EOL,PHP_INT_MAX,PHP_INT_SIZE,DEFAULT_INCLUDE_PATH,PEAR_INSTALL_DIR,PEAR_EXTENSION_DIR,PHP_EXTENSION_DIR,PHP_PREFIX,PHP_BINDIR,PHP_BINARY,PHP_MANDIR,PHP_LIBDIR,PHP_DATADIR,PHP_SYSCONFDIR,PHP_LOCALSTATEDIR,PHP_CONFIG_FILE_PATH,PHP_CONFIG_FILE_SCAN_DIR,PHP_SHLIB_SUFFIX,E_ERROR,E_WARNING,E_PARSE,E_NOTICE,E_CORE_ERROR,E_CORE_WARNING,E_COMPILE_ERROR,E_COMPILE_WARNING,E_USER_ERROR,E_USER_WARNING,E_USER_NOTICE,E_DEPRECATED,E_USER_DEPRECATED,E_ALL,E_STRICT,__COMPILER_HALT_OFFSET__,TRUE,FALSE,NULL,__CLASS__,__DIR__,__FILE__,__FUNCTION__,__LINE__,__METHOD__,__NAMESPACE__,__TRAIT__");
|
||||
module$exports$Blockly$PHP.phpGenerator.ORDER_ATOMIC=0;module$exports$Blockly$PHP.phpGenerator.ORDER_CLONE=1;module$exports$Blockly$PHP.phpGenerator.ORDER_NEW=1;module$exports$Blockly$PHP.phpGenerator.ORDER_MEMBER=2.1;module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL=2.2;module$exports$Blockly$PHP.phpGenerator.ORDER_POWER=3;module$exports$Blockly$PHP.phpGenerator.ORDER_INCREMENT=4;module$exports$Blockly$PHP.phpGenerator.ORDER_DECREMENT=4;
|
||||
module$exports$Blockly$PHP.phpGenerator.ORDER_BITWISE_NOT=4;module$exports$Blockly$PHP.phpGenerator.ORDER_CAST=4;module$exports$Blockly$PHP.phpGenerator.ORDER_SUPPRESS_ERROR=4;module$exports$Blockly$PHP.phpGenerator.ORDER_INSTANCEOF=5;module$exports$Blockly$PHP.phpGenerator.ORDER_LOGICAL_NOT=6;module$exports$Blockly$PHP.phpGenerator.ORDER_UNARY_PLUS=7.1;module$exports$Blockly$PHP.phpGenerator.ORDER_UNARY_NEGATION=7.2;module$exports$Blockly$PHP.phpGenerator.ORDER_MULTIPLICATION=8.1;
|
||||
module$exports$Blockly$PHP.phpGenerator.ORDER_DIVISION=8.2;module$exports$Blockly$PHP.phpGenerator.ORDER_MODULUS=8.3;module$exports$Blockly$PHP.phpGenerator.ORDER_ADDITION=9.1;module$exports$Blockly$PHP.phpGenerator.ORDER_SUBTRACTION=9.2;module$exports$Blockly$PHP.phpGenerator.ORDER_STRING_CONCAT=9.3;module$exports$Blockly$PHP.phpGenerator.ORDER_BITWISE_SHIFT=10;module$exports$Blockly$PHP.phpGenerator.ORDER_RELATIONAL=11;module$exports$Blockly$PHP.phpGenerator.ORDER_EQUALITY=12;
|
||||
module$exports$Blockly$PHP.phpGenerator.ORDER_REFERENCE=13;module$exports$Blockly$PHP.phpGenerator.ORDER_BITWISE_AND=13;module$exports$Blockly$PHP.phpGenerator.ORDER_BITWISE_XOR=14;module$exports$Blockly$PHP.phpGenerator.ORDER_BITWISE_OR=15;module$exports$Blockly$PHP.phpGenerator.ORDER_LOGICAL_AND=16;module$exports$Blockly$PHP.phpGenerator.ORDER_LOGICAL_OR=17;module$exports$Blockly$PHP.phpGenerator.ORDER_IF_NULL=18;module$exports$Blockly$PHP.phpGenerator.ORDER_CONDITIONAL=19;
|
||||
module$exports$Blockly$PHP.phpGenerator.ORDER_ASSIGNMENT=20;module$exports$Blockly$PHP.phpGenerator.ORDER_LOGICAL_AND_WEAK=21;module$exports$Blockly$PHP.phpGenerator.ORDER_LOGICAL_XOR=22;module$exports$Blockly$PHP.phpGenerator.ORDER_LOGICAL_OR_WEAK=23;module$exports$Blockly$PHP.phpGenerator.ORDER_NONE=99;
|
||||
module$exports$Blockly$PHP.phpGenerator.ORDER_OVERRIDES=[[module$exports$Blockly$PHP.phpGenerator.ORDER_MEMBER,module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL],[module$exports$Blockly$PHP.phpGenerator.ORDER_MEMBER,module$exports$Blockly$PHP.phpGenerator.ORDER_MEMBER],[module$exports$Blockly$PHP.phpGenerator.ORDER_LOGICAL_NOT,module$exports$Blockly$PHP.phpGenerator.ORDER_LOGICAL_NOT],[module$exports$Blockly$PHP.phpGenerator.ORDER_MULTIPLICATION,module$exports$Blockly$PHP.phpGenerator.ORDER_MULTIPLICATION],
|
||||
[module$exports$Blockly$PHP.phpGenerator.ORDER_ADDITION,module$exports$Blockly$PHP.phpGenerator.ORDER_ADDITION],[module$exports$Blockly$PHP.phpGenerator.ORDER_LOGICAL_AND,module$exports$Blockly$PHP.phpGenerator.ORDER_LOGICAL_AND],[module$exports$Blockly$PHP.phpGenerator.ORDER_LOGICAL_OR,module$exports$Blockly$PHP.phpGenerator.ORDER_LOGICAL_OR]];module$exports$Blockly$PHP.phpGenerator.isInitialized=!1;
|
||||
module$exports$Blockly$PHP.phpGenerator.init=function(a){Object.getPrototypeOf(this).init.call(this);this.nameDB_?this.nameDB_.reset():this.nameDB_=new $.module$build$src$core$names.Names(this.RESERVED_WORDS_,"$");this.nameDB_.setVariableMap(a.getVariableMap());this.nameDB_.populateVariables(a);this.nameDB_.populateProcedures(a);this.isInitialized=!0};
|
||||
module$exports$Blockly$PHP.phpGenerator.finish=function(a){const b=$.module$build$src$core$utils$object.values(this.definitions_);a=Object.getPrototypeOf(this).finish.call(this,a);this.isInitialized=!1;this.nameDB_.reset();return b.join("\n\n")+"\n\n\n"+a};module$exports$Blockly$PHP.phpGenerator.scrubNakedValue=function(a){return a+";\n"};module$exports$Blockly$PHP.phpGenerator.quote_=function(a){a=a.replace(/\\/g,"\\\\").replace(/\n/g,"\\\n").replace(/'/g,"\\'");return"'"+a+"'"};
|
||||
module$exports$Blockly$PHP.phpGenerator.multiline_quote_=function(a){return a.split(/\n/g).map(this.quote_).join(' . "\\n" .\n')};
|
||||
module$exports$Blockly$PHP.phpGenerator.scrub_=function(a,b,c){let d="";if(!a.outputConnection||!a.outputConnection.targetConnection){var e=a.getCommentText();e&&(e=$.module$build$src$core$utils$string.wrap(e,this.COMMENT_WRAP-3),d+=this.prefixLines(e,"// ")+"\n");for(let f=0;f<a.inputList.length;f++)a.inputList[f].type===$.module$build$src$core$input_types.inputTypes.VALUE&&(e=a.inputList[f].connection.targetBlock())&&(e=this.allNestedComments(e))&&(d+=this.prefixLines(e,"// "))}a=a.nextConnection&&
|
||||
a.nextConnection.targetBlock();c=c?"":this.blockToCode(a);return d+b+c};
|
||||
module$contents$Blockly$PHP_PHP.getAdjusted=function(a,b,c,d,e){c=c||0;e=e||this.ORDER_NONE;a.workspace.options.oneBasedIndex&&c--;var f=a.workspace.options.oneBasedIndex?"1":"0",g=e;if(0<c)var h=g=this.ORDER_ADDITION;else 0>c?h=g=this.ORDER_SUBTRACTION:d&&(h=g=this.ORDER_UNARY_NEGATION);a=this.valueToCode(a,b,g)||f;(0,$.module$exports$Blockly$utils$string.isNumber)(a)?(a=Number(a)+c,d&&(a=-a)):(0<c?a=a+" + "+c:0>c&&(a=a+" - "+-c),d&&(a=c?"-("+a+")":"-"+a),h=Math.floor(h),e=Math.floor(e),h&&e>=h&&
|
||||
(a="("+a+")"));return a};$.Blockly.PHP=module$contents$Blockly$PHP_PHP;var module$exports$Blockly$PHP$variables={};$.Blockly.PHP.variables_get=function(a){return[$.Blockly.PHP.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE),$.Blockly.PHP.ORDER_ATOMIC]};$.Blockly.PHP.variables_set=function(a){var b=$.Blockly.PHP.valueToCode(a,"VALUE",$.Blockly.PHP.ORDER_ASSIGNMENT)||"0";return $.Blockly.PHP.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE)+" = "+b+";\n"};var module$exports$Blockly$PHP$variablesDynamic={};$.Blockly.PHP.variables_get_dynamic=$.Blockly.PHP.variables_get;$.Blockly.PHP.variables_set_dynamic=$.Blockly.PHP.variables_set;var module$exports$Blockly$PHP$texts={};$.Blockly.PHP.text=function(a){return[$.Blockly.PHP.quote_(a.getFieldValue("TEXT")),$.Blockly.PHP.ORDER_ATOMIC]};$.Blockly.PHP.text_multiline=function(a){a=$.Blockly.PHP.multiline_quote_(a.getFieldValue("TEXT"));var b=-1!==a.indexOf(".")?$.Blockly.PHP.ORDER_STRING_CONCAT:$.Blockly.PHP.ORDER_ATOMIC;return[a,b]};
|
||||
$.Blockly.PHP.text_join=function(a){if(0===a.itemCount_)return["''",$.Blockly.PHP.ORDER_ATOMIC];if(1===a.itemCount_)return[$.Blockly.PHP.valueToCode(a,"ADD0",$.Blockly.PHP.ORDER_NONE)||"''",$.Blockly.PHP.ORDER_NONE];if(2===a.itemCount_){var b=$.Blockly.PHP.valueToCode(a,"ADD0",$.Blockly.PHP.ORDER_STRING_CONCAT)||"''";a=$.Blockly.PHP.valueToCode(a,"ADD1",$.Blockly.PHP.ORDER_STRING_CONCAT)||"''";return[b+" . "+a,$.Blockly.PHP.ORDER_STRING_CONCAT]}b=Array(a.itemCount_);for(var c=0;c<a.itemCount_;c++)b[c]=
|
||||
$.Blockly.PHP.valueToCode(a,"ADD"+c,$.Blockly.PHP.ORDER_NONE)||"''";return["implode('', array("+b.join(",")+"))",$.Blockly.PHP.ORDER_FUNCTION_CALL]};$.Blockly.PHP.text_append=function(a){var b=$.Blockly.PHP.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE);a=$.Blockly.PHP.valueToCode(a,"TEXT",$.Blockly.PHP.ORDER_ASSIGNMENT)||"''";return b+" .= "+a+";\n"};
|
||||
$.Blockly.PHP.text_length=function(a){var b=$.Blockly.PHP.provideFunction_("length","\nfunction "+$.Blockly.PHP.FUNCTION_NAME_PLACEHOLDER_+"($value) {\n if (is_string($value)) {\n return strlen($value);\n }\n return count($value);\n}\n");a=$.Blockly.PHP.valueToCode(a,"VALUE",$.Blockly.PHP.ORDER_NONE)||"''";return[b+"("+a+")",$.Blockly.PHP.ORDER_FUNCTION_CALL]};$.Blockly.PHP.text_isEmpty=function(a){return["empty("+($.Blockly.PHP.valueToCode(a,"VALUE",$.Blockly.PHP.ORDER_NONE)||"''")+")",$.Blockly.PHP.ORDER_FUNCTION_CALL]};
|
||||
$.Blockly.PHP.text_indexOf=function(a){var b="FIRST"===a.getFieldValue("END")?"strpos":"strrpos",c=$.Blockly.PHP.valueToCode(a,"FIND",$.Blockly.PHP.ORDER_NONE)||"''",d=$.Blockly.PHP.valueToCode(a,"VALUE",$.Blockly.PHP.ORDER_NONE)||"''",e=" -1",f="";a.workspace.options.oneBasedIndex&&(e=" 0",f=" + 1");return[$.Blockly.PHP.provideFunction_("FIRST"===a.getFieldValue("END")?"text_indexOf":"text_lastIndexOf","\nfunction "+$.Blockly.PHP.FUNCTION_NAME_PLACEHOLDER_+"($text, $search) {\n $pos = "+b+"($text, $search);\n return $pos === false ? "+
|
||||
e+" : $pos"+f+";\n}\n")+"("+d+", "+c+")",$.Blockly.PHP.ORDER_FUNCTION_CALL]};
|
||||
$.Blockly.PHP.text_charAt=function(a){var b=a.getFieldValue("WHERE")||"FROM_START",c=$.Blockly.PHP.valueToCode(a,"VALUE",$.Blockly.PHP.ORDER_NONE)||"''";switch(b){case "FIRST":return["substr("+c+", 0, 1)",$.Blockly.PHP.ORDER_FUNCTION_CALL];case "LAST":return["substr("+c+", -1)",$.Blockly.PHP.ORDER_FUNCTION_CALL];case "FROM_START":return a=$.Blockly.PHP.getAdjusted(a,"AT"),["substr("+c+", "+a+", 1)",$.Blockly.PHP.ORDER_FUNCTION_CALL];case "FROM_END":return a=$.Blockly.PHP.getAdjusted(a,"AT",1,!0),
|
||||
["substr("+c+", "+a+", 1)",$.Blockly.PHP.ORDER_FUNCTION_CALL];case "RANDOM":return[$.Blockly.PHP.provideFunction_("text_random_letter","\nfunction "+$.Blockly.PHP.FUNCTION_NAME_PLACEHOLDER_+"($text) {\n return $text[rand(0, strlen($text) - 1)];\n}\n")+"("+c+")",$.Blockly.PHP.ORDER_FUNCTION_CALL]}throw Error("Unhandled option (text_charAt).");};
|
||||
$.Blockly.PHP.text_getSubstring=function(a){var b=a.getFieldValue("WHERE1"),c=a.getFieldValue("WHERE2"),d=$.Blockly.PHP.valueToCode(a,"STRING",$.Blockly.PHP.ORDER_NONE)||"''";if("FIRST"===b&&"LAST"===c)return[d,$.Blockly.PHP.ORDER_NONE];var e=$.Blockly.PHP.getAdjusted(a,"AT1");a=$.Blockly.PHP.getAdjusted(a,"AT2");return[$.Blockly.PHP.provideFunction_("text_get_substring","\nfunction "+$.Blockly.PHP.FUNCTION_NAME_PLACEHOLDER_+"($text, $where1, $at1, $where2, $at2) {\n if ($where1 == 'FROM_END') {\n $at1 = strlen($text) - 1 - $at1;\n } else if ($where1 == 'FIRST') {\n $at1 = 0;\n } else if ($where1 != 'FROM_START') {\n throw new Exception('Unhandled option (text_get_substring).');\n }\n $length = 0;\n if ($where2 == 'FROM_START') {\n $length = $at2 - $at1 + 1;\n } else if ($where2 == 'FROM_END') {\n $length = strlen($text) - $at1 - $at2;\n } else if ($where2 == 'LAST') {\n $length = strlen($text) - $at1;\n } else {\n throw new Exception('Unhandled option (text_get_substring).');\n }\n return substr($text, $at1, $length);\n}\n")+
|
||||
"("+d+", '"+b+"', "+e+", '"+c+"', "+a+")",$.Blockly.PHP.ORDER_FUNCTION_CALL]};$.Blockly.PHP.text_changeCase=function(a){var b=$.Blockly.PHP.valueToCode(a,"TEXT",$.Blockly.PHP.ORDER_NONE)||"''",c;"UPPERCASE"===a.getFieldValue("CASE")?c="strtoupper("+b+")":"LOWERCASE"===a.getFieldValue("CASE")?c="strtolower("+b+")":"TITLECASE"===a.getFieldValue("CASE")&&(c="ucwords(strtolower("+b+"))");return[c,$.Blockly.PHP.ORDER_FUNCTION_CALL]};
|
||||
$.Blockly.PHP.text_trim=function(a){var b={LEFT:"ltrim",RIGHT:"rtrim",BOTH:"trim"}[a.getFieldValue("MODE")];a=$.Blockly.PHP.valueToCode(a,"TEXT",$.Blockly.PHP.ORDER_NONE)||"''";return[b+"("+a+")",$.Blockly.PHP.ORDER_FUNCTION_CALL]};$.Blockly.PHP.text_print=function(a){return"print("+($.Blockly.PHP.valueToCode(a,"TEXT",$.Blockly.PHP.ORDER_NONE)||"''")+");\n"};
|
||||
$.Blockly.PHP.text_prompt_ext=function(a){var b="readline("+(a.getField("TEXT")?$.Blockly.PHP.quote_(a.getFieldValue("TEXT")):$.Blockly.PHP.valueToCode(a,"TEXT",$.Blockly.PHP.ORDER_NONE)||"''")+")";"NUMBER"===a.getFieldValue("TYPE")&&(b="floatval("+b+")");return[b,$.Blockly.PHP.ORDER_FUNCTION_CALL]};$.Blockly.PHP.text_prompt=$.Blockly.PHP.text_prompt_ext;
|
||||
$.Blockly.PHP.text_count=function(a){var b=$.Blockly.PHP.valueToCode(a,"TEXT",$.Blockly.PHP.ORDER_NONE)||"''";a=$.Blockly.PHP.valueToCode(a,"SUB",$.Blockly.PHP.ORDER_NONE)||"''";return["strlen("+a+") === 0 ? strlen("+b+") + 1 : substr_count("+b+", "+a+")",$.Blockly.PHP.ORDER_CONDITIONAL]};
|
||||
$.Blockly.PHP.text_replace=function(a){var b=$.Blockly.PHP.valueToCode(a,"TEXT",$.Blockly.PHP.ORDER_NONE)||"''",c=$.Blockly.PHP.valueToCode(a,"FROM",$.Blockly.PHP.ORDER_NONE)||"''";a=$.Blockly.PHP.valueToCode(a,"TO",$.Blockly.PHP.ORDER_NONE)||"''";return["str_replace("+c+", "+a+", "+b+")",$.Blockly.PHP.ORDER_FUNCTION_CALL]};$.Blockly.PHP.text_reverse=function(a){return["strrev("+($.Blockly.PHP.valueToCode(a,"TEXT",$.Blockly.PHP.ORDER_NONE)||"''")+")",$.Blockly.PHP.ORDER_FUNCTION_CALL]};var module$exports$Blockly$PHP$procedures={};
|
||||
$.Blockly.PHP.procedures_defreturn=function(a){for(var b=[],c=a.workspace,d=(0,$.module$exports$Blockly$Variables.allUsedVarModels)(c)||[],e=0,f;f=d[e];e++)f=f.name,-1===a.getVars().indexOf(f)&&b.push($.Blockly.PHP.nameDB_.getName(f,$.module$exports$Blockly$Names.NameType.VARIABLE));c=(0,$.module$exports$Blockly$Variables.allDeveloperVariables)(c);for(d=0;d<c.length;d++)b.push($.Blockly.PHP.nameDB_.getName(c[d],$.module$exports$Blockly$Names.NameType.DEVELOPER_VARIABLE));c=b.length?$.Blockly.PHP.INDENT+
|
||||
"global "+b.join(", ")+";\n":"";b=$.Blockly.PHP.nameDB_.getName(a.getFieldValue("NAME"),$.module$exports$Blockly$Names.NameType.PROCEDURE);d="";$.Blockly.PHP.STATEMENT_PREFIX&&(d+=$.Blockly.PHP.injectId($.Blockly.PHP.STATEMENT_PREFIX,a));$.Blockly.PHP.STATEMENT_SUFFIX&&(d+=$.Blockly.PHP.injectId($.Blockly.PHP.STATEMENT_SUFFIX,a));d&&(d=$.Blockly.PHP.prefixLines(d,$.Blockly.PHP.INDENT));e="";$.Blockly.PHP.INFINITE_LOOP_TRAP&&(e=$.Blockly.PHP.prefixLines($.Blockly.PHP.injectId($.Blockly.PHP.INFINITE_LOOP_TRAP,
|
||||
a),$.Blockly.PHP.INDENT));f=$.Blockly.PHP.statementToCode(a,"STACK");var g=$.Blockly.PHP.valueToCode(a,"RETURN",$.Blockly.PHP.ORDER_NONE)||"",h="";f&&g&&(h=d);g&&(g=$.Blockly.PHP.INDENT+"return "+g+";\n");for(var k=[],l=a.getVars(),m=0;m<l.length;m++)k[m]=$.Blockly.PHP.nameDB_.getName(l[m],$.module$exports$Blockly$Names.NameType.VARIABLE);c="function "+b+"("+k.join(", ")+") {\n"+c+d+e+f+h+g+"}";c=$.Blockly.PHP.scrub_(a,c);$.Blockly.PHP.definitions_["%"+b]=c;return null};
|
||||
$.Blockly.PHP.procedures_defnoreturn=$.Blockly.PHP.procedures_defreturn;$.Blockly.PHP.procedures_callreturn=function(a){for(var b=$.Blockly.PHP.nameDB_.getName(a.getFieldValue("NAME"),$.module$exports$Blockly$Names.NameType.PROCEDURE),c=[],d=a.getVars(),e=0;e<d.length;e++)c[e]=$.Blockly.PHP.valueToCode(a,"ARG"+e,$.Blockly.PHP.ORDER_NONE)||"null";return[b+"("+c.join(", ")+")",$.Blockly.PHP.ORDER_FUNCTION_CALL]};
|
||||
$.Blockly.PHP.procedures_callnoreturn=function(a){return $.Blockly.PHP.procedures_callreturn(a)[0]+";\n"};
|
||||
$.Blockly.PHP.procedures_ifreturn=function(a){var b="if ("+($.Blockly.PHP.valueToCode(a,"CONDITION",$.Blockly.PHP.ORDER_NONE)||"false")+") {\n";$.Blockly.PHP.STATEMENT_SUFFIX&&(b+=$.Blockly.PHP.prefixLines($.Blockly.PHP.injectId($.Blockly.PHP.STATEMENT_SUFFIX,a),$.Blockly.PHP.INDENT));a.hasReturnValue_?(a=$.Blockly.PHP.valueToCode(a,"VALUE",$.Blockly.PHP.ORDER_NONE)||"null",b+=$.Blockly.PHP.INDENT+"return "+a+";\n"):b+=$.Blockly.PHP.INDENT+"return;\n";return b+"}\n"};var module$exports$Blockly$PHP$math={};$.Blockly.PHP.math_number=function(a){a=Number(a.getFieldValue("NUM"));var b=0<=a?$.Blockly.PHP.ORDER_ATOMIC:$.Blockly.PHP.ORDER_UNARY_NEGATION;Infinity===a?a="INF":-Infinity===a&&(a="-INF");return[a,b]};
|
||||
$.Blockly.PHP.math_arithmetic=function(a){var b={ADD:[" + ",$.Blockly.PHP.ORDER_ADDITION],MINUS:[" - ",$.Blockly.PHP.ORDER_SUBTRACTION],MULTIPLY:[" * ",$.Blockly.PHP.ORDER_MULTIPLICATION],DIVIDE:[" / ",$.Blockly.PHP.ORDER_DIVISION],POWER:[" ** ",$.Blockly.PHP.ORDER_POWER]}[a.getFieldValue("OP")],c=b[0];b=b[1];var d=$.Blockly.PHP.valueToCode(a,"A",b)||"0";a=$.Blockly.PHP.valueToCode(a,"B",b)||"0";return[d+c+a,b]};
|
||||
$.Blockly.PHP.math_single=function(a){var b=a.getFieldValue("OP");if("NEG"===b)return a=$.Blockly.PHP.valueToCode(a,"NUM",$.Blockly.PHP.ORDER_UNARY_NEGATION)||"0","-"===a[0]&&(a=" "+a),["-"+a,$.Blockly.PHP.ORDER_UNARY_NEGATION];a="SIN"===b||"COS"===b||"TAN"===b?$.Blockly.PHP.valueToCode(a,"NUM",$.Blockly.PHP.ORDER_DIVISION)||"0":$.Blockly.PHP.valueToCode(a,"NUM",$.Blockly.PHP.ORDER_NONE)||"0";switch(b){case "ABS":var c="abs("+a+")";break;case "ROOT":c="sqrt("+a+")";break;case "LN":c="log("+a+")";
|
||||
break;case "EXP":c="exp("+a+")";break;case "POW10":c="pow(10,"+a+")";break;case "ROUND":c="round("+a+")";break;case "ROUNDUP":c="ceil("+a+")";break;case "ROUNDDOWN":c="floor("+a+")";break;case "SIN":c="sin("+a+" / 180 * pi())";break;case "COS":c="cos("+a+" / 180 * pi())";break;case "TAN":c="tan("+a+" / 180 * pi())"}if(c)return[c,$.Blockly.PHP.ORDER_FUNCTION_CALL];switch(b){case "LOG10":c="log("+a+") / log(10)";break;case "ASIN":c="asin("+a+") / pi() * 180";break;case "ACOS":c="acos("+a+") / pi() * 180";
|
||||
break;case "ATAN":c="atan("+a+") / pi() * 180";break;default:throw Error("Unknown math operator: "+b);}return[c,$.Blockly.PHP.ORDER_DIVISION]};$.Blockly.PHP.math_constant=function(a){return{PI:["M_PI",$.Blockly.PHP.ORDER_ATOMIC],E:["M_E",$.Blockly.PHP.ORDER_ATOMIC],GOLDEN_RATIO:["(1 + sqrt(5)) / 2",$.Blockly.PHP.ORDER_DIVISION],SQRT2:["M_SQRT2",$.Blockly.PHP.ORDER_ATOMIC],SQRT1_2:["M_SQRT1_2",$.Blockly.PHP.ORDER_ATOMIC],INFINITY:["INF",$.Blockly.PHP.ORDER_ATOMIC]}[a.getFieldValue("CONSTANT")]};
|
||||
$.Blockly.PHP.math_number_property=function(a){var b={EVEN:[""," % 2 == 0",$.Blockly.PHP.ORDER_MODULUS,$.Blockly.PHP.ORDER_EQUALITY],ODD:[""," % 2 == 1",$.Blockly.PHP.ORDER_MODULUS,$.Blockly.PHP.ORDER_EQUALITY],WHOLE:["is_int(",")",$.Blockly.PHP.ORDER_NONE,$.Blockly.PHP.ORDER_FUNCTION_CALL],POSITIVE:[""," > 0",$.Blockly.PHP.ORDER_RELATIONAL,$.Blockly.PHP.ORDER_RELATIONAL],NEGATIVE:[""," < 0",$.Blockly.PHP.ORDER_RELATIONAL,$.Blockly.PHP.ORDER_RELATIONAL],DIVISIBLE_BY:[null,null,$.Blockly.PHP.ORDER_MODULUS,
|
||||
$.Blockly.PHP.ORDER_EQUALITY],PRIME:[null,null,$.Blockly.PHP.ORDER_NONE,$.Blockly.PHP.ORDER_FUNCTION_CALL]},c=a.getFieldValue("PROPERTY");b=$.$jscomp.makeIterator(b[c]);var d=b.next().value,e=b.next().value,f=b.next().value;b=b.next().value;f=$.Blockly.PHP.valueToCode(a,"NUMBER_TO_CHECK",f)||"0";if("PRIME"===c)a=$.Blockly.PHP.provideFunction_("math_isPrime","\nfunction "+$.Blockly.PHP.FUNCTION_NAME_PLACEHOLDER_+"($n) {\n // https://en.wikipedia.org/wiki/Primality_test#Naive_methods\n if ($n == 2 || $n == 3) {\n return true;\n }\n // False if n is NaN, negative, is 1, or not whole.\n // And false if n is divisible by 2 or 3.\n if (!is_numeric($n) || $n <= 1 || $n % 1 != 0 || $n % 2 == 0 || $n % 3 == 0) {\n return false;\n }\n // Check all the numbers of form 6k +/- 1, up to sqrt(n).\n for ($x = 6; $x <= sqrt($n) + 1; $x += 6) {\n if ($n % ($x - 1) == 0 || $n % ($x + 1) == 0) {\n return false;\n }\n }\n return true;\n}\n")+
|
||||
"("+f+")";else if("DIVISIBLE_BY"===c){a=$.Blockly.PHP.valueToCode(a,"DIVISOR",$.Blockly.PHP.ORDER_MODULUS)||"0";if("0"===a)return["false",$.Blockly.PHP.ORDER_ATOMIC];a=f+" % "+a+" == 0"}else a=d+f+e;return[a,b]};$.Blockly.PHP.math_change=function(a){var b=$.Blockly.PHP.valueToCode(a,"DELTA",$.Blockly.PHP.ORDER_ADDITION)||"0";return $.Blockly.PHP.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE)+" += "+b+";\n"};$.Blockly.PHP.math_round=$.Blockly.PHP.math_single;
|
||||
$.Blockly.PHP.math_trig=$.Blockly.PHP.math_single;
|
||||
$.Blockly.PHP.math_on_list=function(a){var b=a.getFieldValue("OP");switch(b){case "SUM":a=$.Blockly.PHP.valueToCode(a,"LIST",$.Blockly.PHP.ORDER_FUNCTION_CALL)||"array()";a="array_sum("+a+")";break;case "MIN":a=$.Blockly.PHP.valueToCode(a,"LIST",$.Blockly.PHP.ORDER_FUNCTION_CALL)||"array()";a="min("+a+")";break;case "MAX":a=$.Blockly.PHP.valueToCode(a,"LIST",$.Blockly.PHP.ORDER_FUNCTION_CALL)||"array()";a="max("+a+")";break;case "AVERAGE":b=$.Blockly.PHP.provideFunction_("math_mean","\nfunction "+
|
||||
$.Blockly.PHP.FUNCTION_NAME_PLACEHOLDER_+"($myList) {\n return array_sum($myList) / count($myList);\n}\n");a=$.Blockly.PHP.valueToCode(a,"LIST",$.Blockly.PHP.ORDER_NONE)||"array()";a=b+"("+a+")";break;case "MEDIAN":b=$.Blockly.PHP.provideFunction_("math_median","\nfunction "+$.Blockly.PHP.FUNCTION_NAME_PLACEHOLDER_+"($arr) {\n sort($arr,SORT_NUMERIC);\n return (count($arr) % 2) ? $arr[floor(count($arr) / 2)] :\n ($arr[floor(count($arr) / 2)] + $arr[floor(count($arr) / 2) - 1]) / 2;\n}\n");
|
||||
a=$.Blockly.PHP.valueToCode(a,"LIST",$.Blockly.PHP.ORDER_NONE)||"[]";a=b+"("+a+")";break;case "MODE":b=$.Blockly.PHP.provideFunction_("math_modes","\nfunction "+$.Blockly.PHP.FUNCTION_NAME_PLACEHOLDER_+"($values) {\n if (empty($values)) return array();\n $counts = array_count_values($values);\n arsort($counts); // Sort counts in descending order\n $modes = array_keys($counts, current($counts), true);\n return $modes;\n}\n");a=$.Blockly.PHP.valueToCode(a,"LIST",$.Blockly.PHP.ORDER_NONE)||"[]";
|
||||
a=b+"("+a+")";break;case "STD_DEV":b=$.Blockly.PHP.provideFunction_("math_standard_deviation","\nfunction "+$.Blockly.PHP.FUNCTION_NAME_PLACEHOLDER_+"($numbers) {\n $n = count($numbers);\n if (!$n) return null;\n $mean = array_sum($numbers) / count($numbers);\n foreach($numbers as $key => $num) $devs[$key] = pow($num - $mean, 2);\n return sqrt(array_sum($devs) / (count($devs) - 1));\n}\n");a=$.Blockly.PHP.valueToCode(a,"LIST",$.Blockly.PHP.ORDER_NONE)||"[]";a=b+"("+a+")";break;case "RANDOM":b=
|
||||
$.Blockly.PHP.provideFunction_("math_random_list","\nfunction "+$.Blockly.PHP.FUNCTION_NAME_PLACEHOLDER_+"($list) {\n $x = rand(0, count($list)-1);\n return $list[$x];\n}\n");a=$.Blockly.PHP.valueToCode(a,"LIST",$.Blockly.PHP.ORDER_NONE)||"[]";a=b+"("+a+")";break;default:throw Error("Unknown operator: "+b);}return[a,$.Blockly.PHP.ORDER_FUNCTION_CALL]};
|
||||
$.Blockly.PHP.math_modulo=function(a){var b=$.Blockly.PHP.valueToCode(a,"DIVIDEND",$.Blockly.PHP.ORDER_MODULUS)||"0";a=$.Blockly.PHP.valueToCode(a,"DIVISOR",$.Blockly.PHP.ORDER_MODULUS)||"0";return[b+" % "+a,$.Blockly.PHP.ORDER_MODULUS]};
|
||||
$.Blockly.PHP.math_constrain=function(a){var b=$.Blockly.PHP.valueToCode(a,"VALUE",$.Blockly.PHP.ORDER_NONE)||"0",c=$.Blockly.PHP.valueToCode(a,"LOW",$.Blockly.PHP.ORDER_NONE)||"0";a=$.Blockly.PHP.valueToCode(a,"HIGH",$.Blockly.PHP.ORDER_NONE)||"Infinity";return["min(max("+b+", "+c+"), "+a+")",$.Blockly.PHP.ORDER_FUNCTION_CALL]};
|
||||
$.Blockly.PHP.math_random_int=function(a){var b=$.Blockly.PHP.valueToCode(a,"FROM",$.Blockly.PHP.ORDER_NONE)||"0";a=$.Blockly.PHP.valueToCode(a,"TO",$.Blockly.PHP.ORDER_NONE)||"0";return[$.Blockly.PHP.provideFunction_("math_random_int","\nfunction "+$.Blockly.PHP.FUNCTION_NAME_PLACEHOLDER_+"($a, $b) {\n if ($a > $b) {\n return rand($b, $a);\n }\n return rand($a, $b);\n}\n")+"("+b+", "+a+")",$.Blockly.PHP.ORDER_FUNCTION_CALL]};
|
||||
$.Blockly.PHP.math_random_float=function(a){return["(float)rand()/(float)getrandmax()",$.Blockly.PHP.ORDER_FUNCTION_CALL]};$.Blockly.PHP.math_atan2=function(a){var b=$.Blockly.PHP.valueToCode(a,"X",$.Blockly.PHP.ORDER_NONE)||"0";return["atan2("+($.Blockly.PHP.valueToCode(a,"Y",$.Blockly.PHP.ORDER_NONE)||"0")+", "+b+") / pi() * 180",$.Blockly.PHP.ORDER_DIVISION]};var module$exports$Blockly$PHP$loops={};
|
||||
$.Blockly.PHP.controls_repeat_ext=function(a){var b=a.getField("TIMES")?String(Number(a.getFieldValue("TIMES"))):$.Blockly.PHP.valueToCode(a,"TIMES",$.Blockly.PHP.ORDER_ASSIGNMENT)||"0";var c=$.Blockly.PHP.statementToCode(a,"DO");c=$.Blockly.PHP.addLoopTrap(c,a);a="";var d=$.Blockly.PHP.nameDB_.getDistinctName("count",$.module$exports$Blockly$Names.NameType.VARIABLE),e=b;b.match(/^\w+$/)||(0,$.module$exports$Blockly$utils$string.isNumber)(b)||(e=$.Blockly.PHP.nameDB_.getDistinctName("repeat_end",$.module$exports$Blockly$Names.NameType.VARIABLE),
|
||||
a+=e+" = "+b+";\n");return a+("for ("+d+" = 0; "+d+" < "+e+"; "+d+"++) {\n"+c+"}\n")};$.Blockly.PHP.controls_repeat=$.Blockly.PHP.controls_repeat_ext;$.Blockly.PHP.controls_whileUntil=function(a){var b="UNTIL"===a.getFieldValue("MODE"),c=$.Blockly.PHP.valueToCode(a,"BOOL",b?$.Blockly.PHP.ORDER_LOGICAL_NOT:$.Blockly.PHP.ORDER_NONE)||"false",d=$.Blockly.PHP.statementToCode(a,"DO");d=$.Blockly.PHP.addLoopTrap(d,a);b&&(c="!"+c);return"while ("+c+") {\n"+d+"}\n"};
|
||||
$.Blockly.PHP.controls_for=function(a){var b=$.Blockly.PHP.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE),c=$.Blockly.PHP.valueToCode(a,"FROM",$.Blockly.PHP.ORDER_ASSIGNMENT)||"0",d=$.Blockly.PHP.valueToCode(a,"TO",$.Blockly.PHP.ORDER_ASSIGNMENT)||"0",e=$.Blockly.PHP.valueToCode(a,"BY",$.Blockly.PHP.ORDER_ASSIGNMENT)||"1",f=$.Blockly.PHP.statementToCode(a,"DO");f=$.Blockly.PHP.addLoopTrap(f,a);if((0,$.module$exports$Blockly$utils$string.isNumber)(c)&&(0,$.module$exports$Blockly$utils$string.isNumber)(d)&&
|
||||
(0,$.module$exports$Blockly$utils$string.isNumber)(e)){var g=Number(c)<=Number(d);a="for ("+b+" = "+c+"; "+b+(g?" <= ":" >= ")+d+"; "+b;b=Math.abs(Number(e));a=(1===b?a+(g?"++":"--"):a+((g?" += ":" -= ")+b))+(") {\n"+f+"}\n")}else a="",g=c,c.match(/^\w+$/)||(0,$.module$exports$Blockly$utils$string.isNumber)(c)||(g=$.Blockly.PHP.nameDB_.getDistinctName(b+"_start",$.module$exports$Blockly$Names.NameType.VARIABLE),a+=g+" = "+c+";\n"),c=d,d.match(/^\w+$/)||(0,$.module$exports$Blockly$utils$string.isNumber)(d)||
|
||||
(c=$.Blockly.PHP.nameDB_.getDistinctName(b+"_end",$.module$exports$Blockly$Names.NameType.VARIABLE),a+=c+" = "+d+";\n"),d=$.Blockly.PHP.nameDB_.getDistinctName(b+"_inc",$.module$exports$Blockly$Names.NameType.VARIABLE),a+=d+" = ",a=(0,$.module$exports$Blockly$utils$string.isNumber)(e)?a+(Math.abs(e)+";\n"):a+("abs("+e+");\n"),a=a+("if ("+g+" > "+c+") {\n")+($.Blockly.PHP.INDENT+d+" = -"+d+";\n"),a+="}\n",a+="for ("+b+" = "+g+"; "+d+" >= 0 ? "+b+" <= "+c+" : "+b+" >= "+c+"; "+b+" += "+d+") {\n"+f+
|
||||
"}\n";return a};$.Blockly.PHP.controls_forEach=function(a){var b=$.Blockly.PHP.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE),c=$.Blockly.PHP.valueToCode(a,"LIST",$.Blockly.PHP.ORDER_ASSIGNMENT)||"[]",d=$.Blockly.PHP.statementToCode(a,"DO");d=$.Blockly.PHP.addLoopTrap(d,a);return"foreach ("+c+" as "+b+") {\n"+d+"}\n"};
|
||||
$.Blockly.PHP.controls_flow_statements=function(a){var b="";$.Blockly.PHP.STATEMENT_PREFIX&&(b+=$.Blockly.PHP.injectId($.Blockly.PHP.STATEMENT_PREFIX,a));$.Blockly.PHP.STATEMENT_SUFFIX&&(b+=$.Blockly.PHP.injectId($.Blockly.PHP.STATEMENT_SUFFIX,a));if($.Blockly.PHP.STATEMENT_PREFIX){var c=a.getSurroundLoop();c&&!c.suppressPrefixSuffix&&(b+=$.Blockly.PHP.injectId($.Blockly.PHP.STATEMENT_PREFIX,c))}switch(a.getFieldValue("FLOW")){case "BREAK":return b+"break;\n";case "CONTINUE":return b+"continue;\n"}throw Error("Unknown flow statement.");
|
||||
};var module$exports$Blockly$PHP$logic={};
|
||||
$.Blockly.PHP.controls_if=function(a){var b=0,c="";$.Blockly.PHP.STATEMENT_PREFIX&&(c+=$.Blockly.PHP.injectId($.Blockly.PHP.STATEMENT_PREFIX,a));do{var d=$.Blockly.PHP.valueToCode(a,"IF"+b,$.Blockly.PHP.ORDER_NONE)||"false";var e=$.Blockly.PHP.statementToCode(a,"DO"+b);$.Blockly.PHP.STATEMENT_SUFFIX&&(e=$.Blockly.PHP.prefixLines($.Blockly.PHP.injectId($.Blockly.PHP.STATEMENT_SUFFIX,a),$.Blockly.PHP.INDENT)+e);c+=(0<b?" else ":"")+"if ("+d+") {\n"+e+"}";b++}while(a.getInput("IF"+b));if(a.getInput("ELSE")||
|
||||
$.Blockly.PHP.STATEMENT_SUFFIX)e=$.Blockly.PHP.statementToCode(a,"ELSE"),$.Blockly.PHP.STATEMENT_SUFFIX&&(e=$.Blockly.PHP.prefixLines($.Blockly.PHP.injectId($.Blockly.PHP.STATEMENT_SUFFIX,a),$.Blockly.PHP.INDENT)+e),c+=" else {\n"+e+"}";return c+"\n"};$.Blockly.PHP.controls_ifelse=$.Blockly.PHP.controls_if;
|
||||
$.Blockly.PHP.logic_compare=function(a){var b={EQ:"==",NEQ:"!=",LT:"<",LTE:"<=",GT:">",GTE:">="}[a.getFieldValue("OP")],c="=="===b||"!="===b?$.Blockly.PHP.ORDER_EQUALITY:$.Blockly.PHP.ORDER_RELATIONAL,d=$.Blockly.PHP.valueToCode(a,"A",c)||"0";a=$.Blockly.PHP.valueToCode(a,"B",c)||"0";return[d+" "+b+" "+a,c]};
|
||||
$.Blockly.PHP.logic_operation=function(a){var b="AND"===a.getFieldValue("OP")?"&&":"||",c="&&"===b?$.Blockly.PHP.ORDER_LOGICAL_AND:$.Blockly.PHP.ORDER_LOGICAL_OR,d=$.Blockly.PHP.valueToCode(a,"A",c);a=$.Blockly.PHP.valueToCode(a,"B",c);if(d||a){var e="&&"===b?"true":"false";d||(d=e);a||(a=e)}else a=d="false";return[d+" "+b+" "+a,c]};$.Blockly.PHP.logic_negate=function(a){var b=$.Blockly.PHP.ORDER_LOGICAL_NOT;return["!"+($.Blockly.PHP.valueToCode(a,"BOOL",b)||"true"),b]};
|
||||
$.Blockly.PHP.logic_boolean=function(a){return["TRUE"===a.getFieldValue("BOOL")?"true":"false",$.Blockly.PHP.ORDER_ATOMIC]};$.Blockly.PHP.logic_null=function(a){return["null",$.Blockly.PHP.ORDER_ATOMIC]};
|
||||
$.Blockly.PHP.logic_ternary=function(a){var b=$.Blockly.PHP.valueToCode(a,"IF",$.Blockly.PHP.ORDER_CONDITIONAL)||"false",c=$.Blockly.PHP.valueToCode(a,"THEN",$.Blockly.PHP.ORDER_CONDITIONAL)||"null";a=$.Blockly.PHP.valueToCode(a,"ELSE",$.Blockly.PHP.ORDER_CONDITIONAL)||"null";return[b+" ? "+c+" : "+a,$.Blockly.PHP.ORDER_CONDITIONAL]};var module$exports$Blockly$PHP$lists={};$.Blockly.PHP.lists_create_empty=function(a){return["array()",$.Blockly.PHP.ORDER_FUNCTION_CALL]};$.Blockly.PHP.lists_create_with=function(a){for(var b=Array(a.itemCount_),c=0;c<a.itemCount_;c++)b[c]=$.Blockly.PHP.valueToCode(a,"ADD"+c,$.Blockly.PHP.ORDER_NONE)||"null";b="array("+b.join(", ")+")";return[b,$.Blockly.PHP.ORDER_FUNCTION_CALL]};
|
||||
$.Blockly.PHP.lists_repeat=function(a){var b=$.Blockly.PHP.provideFunction_("lists_repeat","\nfunction "+$.Blockly.PHP.FUNCTION_NAME_PLACEHOLDER_+"($value, $count) {\n $array = array();\n for ($index = 0; $index < $count; $index++) {\n $array[] = $value;\n }\n return $array;\n}\n"),c=$.Blockly.PHP.valueToCode(a,"ITEM",$.Blockly.PHP.ORDER_NONE)||"null";a=$.Blockly.PHP.valueToCode(a,"NUM",$.Blockly.PHP.ORDER_NONE)||"0";return[b+"("+c+", "+a+")",$.Blockly.PHP.ORDER_FUNCTION_CALL]};
|
||||
$.Blockly.PHP.lists_length=function(a){var b=$.Blockly.PHP.provideFunction_("length","\nfunction "+$.Blockly.PHP.FUNCTION_NAME_PLACEHOLDER_+"($value) {\n if (is_string($value)) {\n return strlen($value);\n } else {\n return count($value);\n }\n}\n");a=$.Blockly.PHP.valueToCode(a,"VALUE",$.Blockly.PHP.ORDER_NONE)||"''";return[b+"("+a+")",$.Blockly.PHP.ORDER_FUNCTION_CALL]};
|
||||
$.Blockly.PHP.lists_isEmpty=function(a){return["empty("+($.Blockly.PHP.valueToCode(a,"VALUE",$.Blockly.PHP.ORDER_FUNCTION_CALL)||"array()")+")",$.Blockly.PHP.ORDER_FUNCTION_CALL]};
|
||||
$.Blockly.PHP.lists_indexOf=function(a){var b=$.Blockly.PHP.valueToCode(a,"FIND",$.Blockly.PHP.ORDER_NONE)||"''",c=$.Blockly.PHP.valueToCode(a,"VALUE",$.Blockly.PHP.ORDER_MEMBER)||"[]",d=" -1",e="";a.workspace.options.oneBasedIndex&&(d=" 0",e=" + 1");return[("FIRST"===a.getFieldValue("END")?$.Blockly.PHP.provideFunction_("indexOf","\nfunction "+$.Blockly.PHP.FUNCTION_NAME_PLACEHOLDER_+"($haystack, $needle) {\n for ($index = 0; $index < count($haystack); $index++) {\n if ($haystack[$index] == $needle) return $index"+
|
||||
e+";\n }\n return "+d+";\n}\n"):$.Blockly.PHP.provideFunction_("lastIndexOf","\nfunction "+$.Blockly.PHP.FUNCTION_NAME_PLACEHOLDER_+"($haystack, $needle) {\n $last = "+d+";\n for ($index = 0; $index < count($haystack); $index++) {\n if ($haystack[$index] == $needle) $last = $index"+e+";\n }\n return $last;\n}\n"))+"("+c+", "+b+")",$.Blockly.PHP.ORDER_FUNCTION_CALL]};
|
||||
$.Blockly.PHP.lists_getIndex=function(a){var b=a.getFieldValue("MODE")||"GET";switch(a.getFieldValue("WHERE")||"FROM_START"){case "FIRST":if("GET"===b)return[($.Blockly.PHP.valueToCode(a,"VALUE",$.Blockly.PHP.ORDER_MEMBER)||"array()")+"[0]",$.Blockly.PHP.ORDER_MEMBER];if("GET_REMOVE"===b)return["array_shift("+($.Blockly.PHP.valueToCode(a,"VALUE",$.Blockly.PHP.ORDER_NONE)||"array()")+")",$.Blockly.PHP.ORDER_FUNCTION_CALL];if("REMOVE"===b)return"array_shift("+($.Blockly.PHP.valueToCode(a,"VALUE",$.Blockly.PHP.ORDER_NONE)||
|
||||
"array()")+");\n";break;case "LAST":if("GET"===b)return["end("+($.Blockly.PHP.valueToCode(a,"VALUE",$.Blockly.PHP.ORDER_NONE)||"array()")+")",$.Blockly.PHP.ORDER_FUNCTION_CALL];if("GET_REMOVE"===b)return["array_pop("+($.Blockly.PHP.valueToCode(a,"VALUE",$.Blockly.PHP.ORDER_NONE)||"array()")+")",$.Blockly.PHP.ORDER_FUNCTION_CALL];if("REMOVE"===b)return"array_pop("+($.Blockly.PHP.valueToCode(a,"VALUE",$.Blockly.PHP.ORDER_NONE)||"array()")+");\n";break;case "FROM_START":var c=$.Blockly.PHP.getAdjusted(a,
|
||||
"AT");if("GET"===b)return[($.Blockly.PHP.valueToCode(a,"VALUE",$.Blockly.PHP.ORDER_MEMBER)||"array()")+"["+c+"]",$.Blockly.PHP.ORDER_MEMBER];if("GET_REMOVE"===b)return["array_splice("+($.Blockly.PHP.valueToCode(a,"VALUE",$.Blockly.PHP.ORDER_NONE)||"array()")+", "+c+", 1)[0]",$.Blockly.PHP.ORDER_FUNCTION_CALL];if("REMOVE"===b)return"array_splice("+($.Blockly.PHP.valueToCode(a,"VALUE",$.Blockly.PHP.ORDER_NONE)||"array()")+", "+c+", 1);\n";break;case "FROM_END":if("GET"===b)return b=$.Blockly.PHP.valueToCode(a,
|
||||
"VALUE",$.Blockly.PHP.ORDER_NONE)||"array()",a=$.Blockly.PHP.getAdjusted(a,"AT",1,!0),["array_slice("+b+", "+a+", 1)[0]",$.Blockly.PHP.ORDER_FUNCTION_CALL];if("GET_REMOVE"===b||"REMOVE"===b){c=$.Blockly.PHP.valueToCode(a,"VALUE",$.Blockly.PHP.ORDER_NONE)||"array()";a=$.Blockly.PHP.getAdjusted(a,"AT",1,!1,$.Blockly.PHP.ORDER_SUBTRACTION);a="array_splice("+c+", count("+c+") - "+a+", 1)[0]";if("GET_REMOVE"===b)return[a,$.Blockly.PHP.ORDER_FUNCTION_CALL];if("REMOVE"===b)return a+";\n"}break;case "RANDOM":a=
|
||||
$.Blockly.PHP.valueToCode(a,"VALUE",$.Blockly.PHP.ORDER_NONE)||"array()";if("GET"===b)return[$.Blockly.PHP.provideFunction_("lists_get_random_item","\nfunction "+$.Blockly.PHP.FUNCTION_NAME_PLACEHOLDER_+"($list) {\n return $list[rand(0,count($list)-1)];\n}\n")+"("+a+")",$.Blockly.PHP.ORDER_FUNCTION_CALL];if("GET_REMOVE"===b)return[$.Blockly.PHP.provideFunction_("lists_get_remove_random_item","\nfunction "+$.Blockly.PHP.FUNCTION_NAME_PLACEHOLDER_+"(&$list) {\n $x = rand(0,count($list)-1);\n unset($list[$x]);\n return array_values($list);\n}\n")+
|
||||
"("+a+")",$.Blockly.PHP.ORDER_FUNCTION_CALL];if("REMOVE"===b)return $.Blockly.PHP.provideFunction_("lists_remove_random_item","\nfunction "+$.Blockly.PHP.FUNCTION_NAME_PLACEHOLDER_+"(&$list) {\n unset($list[rand(0,count($list)-1)]);\n}\n")+"("+a+");\n"}throw Error("Unhandled combination (lists_getIndex).");};
|
||||
$.Blockly.PHP.lists_setIndex=function(a){var b=a.getFieldValue("MODE")||"GET",c=a.getFieldValue("WHERE")||"FROM_START",d=$.Blockly.PHP.valueToCode(a,"TO",$.Blockly.PHP.ORDER_ASSIGNMENT)||"null";switch(c){case "FIRST":if("SET"===b)return($.Blockly.PHP.valueToCode(a,"LIST",$.Blockly.PHP.ORDER_MEMBER)||"array()")+"[0] = "+d+";\n";if("INSERT"===b)return"array_unshift("+($.Blockly.PHP.valueToCode(a,"LIST",$.Blockly.PHP.ORDER_NONE)||"array()")+", "+d+");\n";break;case "LAST":a=$.Blockly.PHP.valueToCode(a,
|
||||
"LIST",$.Blockly.PHP.ORDER_NONE)||"array()";if("SET"===b)return $.Blockly.PHP.provideFunction_("lists_set_last_item","\nfunction "+$.Blockly.PHP.FUNCTION_NAME_PLACEHOLDER_+"(&$list, $value) {\n $list[count($list) - 1] = $value;\n}\n")+"("+a+", "+d+");\n";if("INSERT"===b)return"array_push("+a+", "+d+");\n";break;case "FROM_START":c=$.Blockly.PHP.getAdjusted(a,"AT");if("SET"===b)return($.Blockly.PHP.valueToCode(a,"LIST",$.Blockly.PHP.ORDER_MEMBER)||"array()")+"["+c+"] = "+d+";\n";if("INSERT"===b)return"array_splice("+
|
||||
($.Blockly.PHP.valueToCode(a,"LIST",$.Blockly.PHP.ORDER_NONE)||"array()")+", "+c+", 0, "+d+");\n";break;case "FROM_END":c=$.Blockly.PHP.valueToCode(a,"LIST",$.Blockly.PHP.ORDER_NONE)||"array()";a=$.Blockly.PHP.getAdjusted(a,"AT",1);if("SET"===b)return $.Blockly.PHP.provideFunction_("lists_set_from_end","\nfunction "+$.Blockly.PHP.FUNCTION_NAME_PLACEHOLDER_+"(&$list, $at, $value) {\n $list[count($list) - $at] = $value;\n}\n")+"("+c+", "+a+", "+d+");\n";if("INSERT"===b)return $.Blockly.PHP.provideFunction_("lists_insert_from_end",
|
||||
"\nfunction "+$.Blockly.PHP.FUNCTION_NAME_PLACEHOLDER_+"(&$list, $at, $value) {\n return array_splice($list, count($list) - $at, 0, $value);\n}\n")+"("+c+", "+a+", "+d+");\n";break;case "RANDOM":a=$.Blockly.PHP.valueToCode(a,"LIST",$.Blockly.PHP.ORDER_REFERENCE)||"array()";if(a.match(/^\$\w+$/))c="";else{c=$.Blockly.PHP.nameDB_.getDistinctName("tmp_list",$.module$exports$Blockly$Names.NameType.VARIABLE);var e=c+" = &"+a+";\n";a=c;c=e}e=$.Blockly.PHP.nameDB_.getDistinctName("tmp_x",$.module$exports$Blockly$Names.NameType.VARIABLE);
|
||||
c+=e+" = rand(0, count("+a+")-1);\n";if("SET"===b)return c+(a+"["+e+"] = "+d+";\n");if("INSERT"===b)return c+("array_splice("+a+", "+e+", 0, "+d+");\n")}throw Error("Unhandled combination (lists_setIndex).");};
|
||||
$.Blockly.PHP.lists_getSublist=function(a){var b=$.Blockly.PHP.valueToCode(a,"LIST",$.Blockly.PHP.ORDER_NONE)||"array()",c=a.getFieldValue("WHERE1"),d=a.getFieldValue("WHERE2");if("FIRST"!==c||"LAST"!==d)if(b.match(/^\$\w+$/)||"FROM_END"!==c&&"FROM_START"===d){switch(c){case "FROM_START":c=$.Blockly.PHP.getAdjusted(a,"AT1");break;case "FROM_END":c=$.Blockly.PHP.getAdjusted(a,"AT1",1,!1,$.Blockly.PHP.ORDER_SUBTRACTION);c="count("+b+") - "+c;break;case "FIRST":c="0";break;default:throw Error("Unhandled option (lists_getSublist).");
|
||||
}switch(d){case "FROM_START":d=$.Blockly.PHP.getAdjusted(a,"AT2",0,!1,$.Blockly.PHP.ORDER_SUBTRACTION);d+=" - ";d=(0,$.module$exports$Blockly$utils$string.isNumber)(String(c))||String(c).match(/^\(.+\)$/)?d+c:d+("("+c+")");d+=" + 1";break;case "FROM_END":d=$.Blockly.PHP.getAdjusted(a,"AT2",0,!1,$.Blockly.PHP.ORDER_SUBTRACTION);d="count("+b+") - "+d+" - ";d=(0,$.module$exports$Blockly$utils$string.isNumber)(String(c))||String(c).match(/^\(.+\)$/)?d+c:d+("("+c+")");break;case "LAST":d="count("+b+") - ";
|
||||
d=(0,$.module$exports$Blockly$utils$string.isNumber)(String(c))||String(c).match(/^\(.+\)$/)?d+c:d+("("+c+")");break;default:throw Error("Unhandled option (lists_getSublist).");}b="array_slice("+b+", "+c+", "+d+")"}else{var e=$.Blockly.PHP.getAdjusted(a,"AT1");a=$.Blockly.PHP.getAdjusted(a,"AT2");b=$.Blockly.PHP.provideFunction_("lists_get_sublist","\nfunction "+$.Blockly.PHP.FUNCTION_NAME_PLACEHOLDER_+"($list, $where1, $at1, $where2, $at2) {\n if ($where1 == 'FROM_END') {\n $at1 = count($list) - 1 - $at1;\n } else if ($where1 == 'FIRST') {\n $at1 = 0;\n } else if ($where1 != 'FROM_START') {\n throw new Exception('Unhandled option (lists_get_sublist).');\n }\n $length = 0;\n if ($where2 == 'FROM_START') {\n $length = $at2 - $at1 + 1;\n } else if ($where2 == 'FROM_END') {\n $length = count($list) - $at1 - $at2;\n } else if ($where2 == 'LAST') {\n $length = count($list) - $at1;\n } else {\n throw new Exception('Unhandled option (lists_get_sublist).');\n }\n return array_slice($list, $at1, $length);\n}\n")+
|
||||
"("+b+", '"+c+"', "+e+", '"+d+"', "+a+")"}return[b,$.Blockly.PHP.ORDER_FUNCTION_CALL]};
|
||||
$.Blockly.PHP.lists_sort=function(a){var b=$.Blockly.PHP.valueToCode(a,"LIST",$.Blockly.PHP.ORDER_NONE)||"array()",c="1"===a.getFieldValue("DIRECTION")?1:-1;a=a.getFieldValue("TYPE");return[$.Blockly.PHP.provideFunction_("lists_sort","\nfunction "+$.Blockly.PHP.FUNCTION_NAME_PLACEHOLDER_+"($list, $type, $direction) {\n $sortCmpFuncs = array(\n 'NUMERIC' => 'strnatcasecmp',\n 'TEXT' => 'strcmp',\n 'IGNORE_CASE' => 'strcasecmp'\n );\n $sortCmp = $sortCmpFuncs[$type];\n $list2 = $list;\n usort($list2, $sortCmp);\n if ($direction == -1) {\n $list2 = array_reverse($list2);\n }\n return $list2;\n}\n")+"("+
|
||||
b+', "'+a+'", '+c+")",$.Blockly.PHP.ORDER_FUNCTION_CALL]};$.Blockly.PHP.lists_split=function(a){var b=$.Blockly.PHP.valueToCode(a,"INPUT",$.Blockly.PHP.ORDER_NONE),c=$.Blockly.PHP.valueToCode(a,"DELIM",$.Blockly.PHP.ORDER_NONE)||"''";a=a.getFieldValue("MODE");if("SPLIT"===a)b||(b="''"),a="explode";else if("JOIN"===a)b||(b="array()"),a="implode";else throw Error("Unknown mode: "+a);return[a+"("+c+", "+b+")",$.Blockly.PHP.ORDER_FUNCTION_CALL]};
|
||||
$.Blockly.PHP.lists_reverse=function(a){return["array_reverse("+($.Blockly.PHP.valueToCode(a,"LIST",$.Blockly.PHP.ORDER_NONE)||"[]")+")",$.Blockly.PHP.ORDER_FUNCTION_CALL]};var module$exports$Blockly$PHP$colour={};$.Blockly.PHP.colour_picker=function(a){return[$.Blockly.PHP.quote_(a.getFieldValue("COLOUR")),$.Blockly.PHP.ORDER_ATOMIC]};$.Blockly.PHP.colour_random=function(a){return[$.Blockly.PHP.provideFunction_("colour_random","\nfunction "+$.Blockly.PHP.FUNCTION_NAME_PLACEHOLDER_+"() {\n return '#' . str_pad(dechex(mt_rand(0, 0xFFFFFF)), 6, '0', STR_PAD_LEFT);\n}\n")+"()",$.Blockly.PHP.ORDER_FUNCTION_CALL]};
|
||||
$.Blockly.PHP.colour_rgb=function(a){var b=$.Blockly.PHP.valueToCode(a,"RED",$.Blockly.PHP.ORDER_NONE)||0,c=$.Blockly.PHP.valueToCode(a,"GREEN",$.Blockly.PHP.ORDER_NONE)||0;a=$.Blockly.PHP.valueToCode(a,"BLUE",$.Blockly.PHP.ORDER_NONE)||0;return[$.Blockly.PHP.provideFunction_("colour_rgb","\nfunction "+$.Blockly.PHP.FUNCTION_NAME_PLACEHOLDER_+"($r, $g, $b) {\n $r = round(max(min($r, 100), 0) * 2.55);\n $g = round(max(min($g, 100), 0) * 2.55);\n $b = round(max(min($b, 100), 0) * 2.55);\n $hex = '#';\n $hex .= str_pad(dechex($r), 2, '0', STR_PAD_LEFT);\n $hex .= str_pad(dechex($g), 2, '0', STR_PAD_LEFT);\n $hex .= str_pad(dechex($b), 2, '0', STR_PAD_LEFT);\n return $hex;\n}\n")+
|
||||
"("+b+", "+c+", "+a+")",$.Blockly.PHP.ORDER_FUNCTION_CALL]};
|
||||
$.Blockly.PHP.colour_blend=function(a){var b=$.Blockly.PHP.valueToCode(a,"COLOUR1",$.Blockly.PHP.ORDER_NONE)||"'#000000'",c=$.Blockly.PHP.valueToCode(a,"COLOUR2",$.Blockly.PHP.ORDER_NONE)||"'#000000'";a=$.Blockly.PHP.valueToCode(a,"RATIO",$.Blockly.PHP.ORDER_NONE)||.5;return[$.Blockly.PHP.provideFunction_("colour_blend","\nfunction "+$.Blockly.PHP.FUNCTION_NAME_PLACEHOLDER_+"($c1, $c2, $ratio) {\n $ratio = max(min($ratio, 1), 0);\n $r1 = hexdec(substr($c1, 1, 2));\n $g1 = hexdec(substr($c1, 3, 2));\n $b1 = hexdec(substr($c1, 5, 2));\n $r2 = hexdec(substr($c2, 1, 2));\n $g2 = hexdec(substr($c2, 3, 2));\n $b2 = hexdec(substr($c2, 5, 2));\n $r = round($r1 * (1 - $ratio) + $r2 * $ratio);\n $g = round($g1 * (1 - $ratio) + $g2 * $ratio);\n $b = round($b1 * (1 - $ratio) + $b2 * $ratio);\n $hex = '#';\n $hex .= str_pad(dechex($r), 2, '0', STR_PAD_LEFT);\n $hex .= str_pad(dechex($g), 2, '0', STR_PAD_LEFT);\n $hex .= str_pad(dechex($b), 2, '0', STR_PAD_LEFT);\n return $hex;\n}\n")+"("+
|
||||
b+", "+c+", "+a+")",$.Blockly.PHP.ORDER_FUNCTION_CALL]};var module$exports$Blockly$PHP$all={};
|
||||
$.Blockly.PHP.__namespace__=$;
|
||||
return $.Blockly.PHP;
|
||||
module$exports$Blockly$PHP.phpGenerator.getAdjusted=function(a,b,c,d,e){c=c||0;e=e||this.ORDER_NONE;a.workspace.options.oneBasedIndex&&c--;let f=a.workspace.options.oneBasedIndex?"1":"0",g=e,h;0<c?h=g=this.ORDER_ADDITION:0>c?h=g=this.ORDER_SUBTRACTION:d&&(h=g=this.ORDER_UNARY_NEGATION);a=this.valueToCode(a,b,g)||f;$.module$build$src$core$utils$string.isNumber(a)?(a=Number(a)+c,d&&(a=-a)):(0<c?a=a+" + "+c:0>c&&(a=a+" - "+-c),d&&(a=c?"-("+a+")":"-"+a),h=Math.floor(h),e=Math.floor(e),h&&e>=h&&(a="("+
|
||||
a+")"));return a};var module$exports$Blockly$PHP$variables={},module$contents$Blockly$PHP$variables_NameType=$.NameType$$module$build$src$core$names;module$exports$Blockly$PHP.phpGenerator.variables_get=function(a){return[module$exports$Blockly$PHP.phpGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE),module$exports$Blockly$PHP.phpGenerator.ORDER_ATOMIC]};
|
||||
module$exports$Blockly$PHP.phpGenerator.variables_set=function(a){const b=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"VALUE",module$exports$Blockly$PHP.phpGenerator.ORDER_ASSIGNMENT)||"0";return module$exports$Blockly$PHP.phpGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE)+" = "+b+";\n"};var module$exports$Blockly$PHP$variablesDynamic={};module$exports$Blockly$PHP.phpGenerator.variables_get_dynamic=module$exports$Blockly$PHP.phpGenerator.variables_get;module$exports$Blockly$PHP.phpGenerator.variables_set_dynamic=module$exports$Blockly$PHP.phpGenerator.variables_set;var module$exports$Blockly$PHP$texts={},module$contents$Blockly$PHP$texts_NameType=$.NameType$$module$build$src$core$names;module$exports$Blockly$PHP.phpGenerator.text=function(a){return[module$exports$Blockly$PHP.phpGenerator.quote_(a.getFieldValue("TEXT")),module$exports$Blockly$PHP.phpGenerator.ORDER_ATOMIC]};
|
||||
module$exports$Blockly$PHP.phpGenerator.text_multiline=function(a){a=module$exports$Blockly$PHP.phpGenerator.multiline_quote_(a.getFieldValue("TEXT"));const b=-1!==a.indexOf(".")?module$exports$Blockly$PHP.phpGenerator.ORDER_STRING_CONCAT:module$exports$Blockly$PHP.phpGenerator.ORDER_ATOMIC;return[a,b]};
|
||||
module$exports$Blockly$PHP.phpGenerator.text_join=function(a){if(0===a.itemCount_)return["''",module$exports$Blockly$PHP.phpGenerator.ORDER_ATOMIC];if(1===a.itemCount_)return[module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"ADD0",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"''",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE];if(2===a.itemCount_){var b=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"ADD0",module$exports$Blockly$PHP.phpGenerator.ORDER_STRING_CONCAT)||"''";
|
||||
a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"ADD1",module$exports$Blockly$PHP.phpGenerator.ORDER_STRING_CONCAT)||"''";return[b+" . "+a,module$exports$Blockly$PHP.phpGenerator.ORDER_STRING_CONCAT]}b=Array(a.itemCount_);for(let c=0;c<a.itemCount_;c++)b[c]=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"ADD"+c,module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"''";return["implode('', array("+b.join(",")+"))",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$PHP.phpGenerator.text_append=function(a){const b=module$exports$Blockly$PHP.phpGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE);a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"TEXT",module$exports$Blockly$PHP.phpGenerator.ORDER_ASSIGNMENT)||"''";return b+" .= "+a+";\n"};module$exports$Blockly$PHP.phpGenerator.text_length=function(a){const b=module$exports$Blockly$PHP.phpGenerator.provideFunction_("length",`
|
||||
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($value) {
|
||||
if (is_string($value)) {
|
||||
return strlen($value);
|
||||
}
|
||||
return count($value);
|
||||
}
|
||||
`);a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"VALUE",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"''";return[b+"("+a+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};module$exports$Blockly$PHP.phpGenerator.text_isEmpty=function(a){return["empty("+(module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"VALUE",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"''")+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$PHP.phpGenerator.text_indexOf=function(a){const b="FIRST"===a.getFieldValue("END")?"strpos":"strrpos",c=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"FIND",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"''",d=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"VALUE",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"''";let e=" -1",f="";a.workspace.options.oneBasedIndex&&(e=" 0",f=" + 1");return[module$exports$Blockly$PHP.phpGenerator.provideFunction_("FIRST"===
|
||||
a.getFieldValue("END")?"text_indexOf":"text_lastIndexOf",`
|
||||
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($text, $search) {
|
||||
$pos = ${b}($text, $search);
|
||||
return $pos === false ? ${e} : $pos${f};
|
||||
}
|
||||
`)+"("+d+", "+c+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$PHP.phpGenerator.text_charAt=function(a){const b=a.getFieldValue("WHERE")||"FROM_START",c=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"VALUE",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"''";switch(b){case "FIRST":return["substr("+c+", 0, 1)",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL];case "LAST":return["substr("+c+", -1)",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL];case "FROM_START":return a=module$exports$Blockly$PHP.phpGenerator.getAdjusted(a,
|
||||
"AT"),["substr("+c+", "+a+", 1)",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL];case "FROM_END":return a=module$exports$Blockly$PHP.phpGenerator.getAdjusted(a,"AT",1,!0),["substr("+c+", "+a+", 1)",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL];case "RANDOM":return[module$exports$Blockly$PHP.phpGenerator.provideFunction_("text_random_letter",`
|
||||
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($text) {
|
||||
return $text[rand(0, strlen($text) - 1)];
|
||||
}
|
||||
`)+"("+c+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]}throw Error("Unhandled option (text_charAt).");};
|
||||
module$exports$Blockly$PHP.phpGenerator.text_getSubstring=function(a){const b=a.getFieldValue("WHERE1"),c=a.getFieldValue("WHERE2"),d=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"STRING",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"''";if("FIRST"===b&&"LAST"===c)return[d,module$exports$Blockly$PHP.phpGenerator.ORDER_NONE];const e=module$exports$Blockly$PHP.phpGenerator.getAdjusted(a,"AT1");a=module$exports$Blockly$PHP.phpGenerator.getAdjusted(a,"AT2");return[module$exports$Blockly$PHP.phpGenerator.provideFunction_("text_get_substring",
|
||||
`
|
||||
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($text, $where1, $at1, $where2, $at2) {
|
||||
if ($where1 == 'FROM_END') {
|
||||
$at1 = strlen($text) - 1 - $at1;
|
||||
} else if ($where1 == 'FIRST') {
|
||||
$at1 = 0;
|
||||
} else if ($where1 != 'FROM_START') {
|
||||
throw new Exception('Unhandled option (text_get_substring).');
|
||||
}
|
||||
$length = 0;
|
||||
if ($where2 == 'FROM_START') {
|
||||
$length = $at2 - $at1 + 1;
|
||||
} else if ($where2 == 'FROM_END') {
|
||||
$length = strlen($text) - $at1 - $at2;
|
||||
} else if ($where2 == 'LAST') {
|
||||
$length = strlen($text) - $at1;
|
||||
} else {
|
||||
throw new Exception('Unhandled option (text_get_substring).');
|
||||
}
|
||||
return substr($text, $at1, $length);
|
||||
}
|
||||
`)+"("+d+", '"+b+"', "+e+", '"+c+"', "+a+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$PHP.phpGenerator.text_changeCase=function(a){const b=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"TEXT",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"''";let c;"UPPERCASE"===a.getFieldValue("CASE")?c="strtoupper("+b+")":"LOWERCASE"===a.getFieldValue("CASE")?c="strtolower("+b+")":"TITLECASE"===a.getFieldValue("CASE")&&(c="ucwords(strtolower("+b+"))");return[c,module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$PHP.phpGenerator.text_trim=function(a){const b={LEFT:"ltrim",RIGHT:"rtrim",BOTH:"trim"}[a.getFieldValue("MODE")];a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"TEXT",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"''";return[b+"("+a+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$PHP.phpGenerator.text_print=function(a){return"print("+(module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"TEXT",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"''")+");\n"};
|
||||
module$exports$Blockly$PHP.phpGenerator.text_prompt_ext=function(a){let b="readline("+(a.getField("TEXT")?module$exports$Blockly$PHP.phpGenerator.quote_(a.getFieldValue("TEXT")):module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"TEXT",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"''")+")";"NUMBER"===a.getFieldValue("TYPE")&&(b="floatval("+b+")");return[b,module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};module$exports$Blockly$PHP.phpGenerator.text_prompt=module$exports$Blockly$PHP.phpGenerator.text_prompt_ext;
|
||||
module$exports$Blockly$PHP.phpGenerator.text_count=function(a){const b=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"TEXT",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"''";a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"SUB",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"''";return["strlen("+a+") === 0 ? strlen("+b+") + 1 : substr_count("+b+", "+a+")",module$exports$Blockly$PHP.phpGenerator.ORDER_CONDITIONAL]};
|
||||
module$exports$Blockly$PHP.phpGenerator.text_replace=function(a){const b=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"TEXT",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"''",c=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"FROM",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"''";a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"TO",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"''";return["str_replace("+c+", "+a+", "+b+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$PHP.phpGenerator.text_reverse=function(a){return["strrev("+(module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"TEXT",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"''")+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};var module$exports$Blockly$PHP$procedures={},module$contents$Blockly$PHP$procedures_Variables=$.module$build$src$core$variables,module$contents$Blockly$PHP$procedures_NameType=$.NameType$$module$build$src$core$names;
|
||||
module$exports$Blockly$PHP.phpGenerator.procedures_defreturn=function(a){var b=[],c=a.workspace,d=$.module$build$src$core$variables.allUsedVarModels(c)||[];for(let m=0,n;n=d[m];m++){var e=n.name;-1===a.getVars().indexOf(e)&&b.push(module$exports$Blockly$PHP.phpGenerator.nameDB_.getName(e,$.NameType$$module$build$src$core$names.VARIABLE))}c=$.module$build$src$core$variables.allDeveloperVariables(c);for(d=0;d<c.length;d++)b.push(module$exports$Blockly$PHP.phpGenerator.nameDB_.getName(c[d],$.NameType$$module$build$src$core$names.DEVELOPER_VARIABLE));
|
||||
c=b.length?module$exports$Blockly$PHP.phpGenerator.INDENT+"global "+b.join(", ")+";\n":"";b=module$exports$Blockly$PHP.phpGenerator.nameDB_.getName(a.getFieldValue("NAME"),$.NameType$$module$build$src$core$names.PROCEDURE);d="";module$exports$Blockly$PHP.phpGenerator.STATEMENT_PREFIX&&(d+=module$exports$Blockly$PHP.phpGenerator.injectId(module$exports$Blockly$PHP.phpGenerator.STATEMENT_PREFIX,a));module$exports$Blockly$PHP.phpGenerator.STATEMENT_SUFFIX&&(d+=module$exports$Blockly$PHP.phpGenerator.injectId(module$exports$Blockly$PHP.phpGenerator.STATEMENT_SUFFIX,
|
||||
a));d&&(d=module$exports$Blockly$PHP.phpGenerator.prefixLines(d,module$exports$Blockly$PHP.phpGenerator.INDENT));e="";module$exports$Blockly$PHP.phpGenerator.INFINITE_LOOP_TRAP&&(e=module$exports$Blockly$PHP.phpGenerator.prefixLines(module$exports$Blockly$PHP.phpGenerator.injectId(module$exports$Blockly$PHP.phpGenerator.INFINITE_LOOP_TRAP,a),module$exports$Blockly$PHP.phpGenerator.INDENT));const f=module$exports$Blockly$PHP.phpGenerator.statementToCode(a,"STACK");let g=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,
|
||||
"RETURN",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"",h="";f&&g&&(h=d);g&&(g=module$exports$Blockly$PHP.phpGenerator.INDENT+"return "+g+";\n");const k=[],l=a.getVars();for(let m=0;m<l.length;m++)k[m]=module$exports$Blockly$PHP.phpGenerator.nameDB_.getName(l[m],$.NameType$$module$build$src$core$names.VARIABLE);c="function "+b+"("+k.join(", ")+") {\n"+c+d+e+f+h+g+"}";c=module$exports$Blockly$PHP.phpGenerator.scrub_(a,c);module$exports$Blockly$PHP.phpGenerator.definitions_["%"+b]=c;return null};
|
||||
module$exports$Blockly$PHP.phpGenerator.procedures_defnoreturn=module$exports$Blockly$PHP.phpGenerator.procedures_defreturn;
|
||||
module$exports$Blockly$PHP.phpGenerator.procedures_callreturn=function(a){const b=module$exports$Blockly$PHP.phpGenerator.nameDB_.getName(a.getFieldValue("NAME"),$.NameType$$module$build$src$core$names.PROCEDURE),c=[],d=a.getVars();for(let e=0;e<d.length;e++)c[e]=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"ARG"+e,module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"null";return[b+"("+c.join(", ")+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$PHP.phpGenerator.procedures_callnoreturn=function(a){return module$exports$Blockly$PHP.phpGenerator.procedures_callreturn(a)[0]+";\n"};
|
||||
module$exports$Blockly$PHP.phpGenerator.procedures_ifreturn=function(a){let b="if ("+(module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"CONDITION",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"false")+") {\n";module$exports$Blockly$PHP.phpGenerator.STATEMENT_SUFFIX&&(b+=module$exports$Blockly$PHP.phpGenerator.prefixLines(module$exports$Blockly$PHP.phpGenerator.injectId(module$exports$Blockly$PHP.phpGenerator.STATEMENT_SUFFIX,a),module$exports$Blockly$PHP.phpGenerator.INDENT));a.hasReturnValue_?
|
||||
(a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"VALUE",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"null",b+=module$exports$Blockly$PHP.phpGenerator.INDENT+"return "+a+";\n"):b+=module$exports$Blockly$PHP.phpGenerator.INDENT+"return;\n";return b+"}\n"};var module$exports$Blockly$PHP$math={},module$contents$Blockly$PHP$math_NameType=$.NameType$$module$build$src$core$names;module$exports$Blockly$PHP.phpGenerator.math_number=function(a){a=Number(a.getFieldValue("NUM"));const b=0<=a?module$exports$Blockly$PHP.phpGenerator.ORDER_ATOMIC:module$exports$Blockly$PHP.phpGenerator.ORDER_UNARY_NEGATION;Infinity===a?a="INF":-Infinity===a&&(a="-INF");return[a,b]};
|
||||
module$exports$Blockly$PHP.phpGenerator.math_arithmetic=function(a){var b={ADD:[" + ",module$exports$Blockly$PHP.phpGenerator.ORDER_ADDITION],MINUS:[" - ",module$exports$Blockly$PHP.phpGenerator.ORDER_SUBTRACTION],MULTIPLY:[" * ",module$exports$Blockly$PHP.phpGenerator.ORDER_MULTIPLICATION],DIVIDE:[" / ",module$exports$Blockly$PHP.phpGenerator.ORDER_DIVISION],POWER:[" ** ",module$exports$Blockly$PHP.phpGenerator.ORDER_POWER]}[a.getFieldValue("OP")];const c=b[0];b=b[1];const d=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,
|
||||
"A",b)||"0";a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"B",b)||"0";return[d+c+a,b]};
|
||||
module$exports$Blockly$PHP.phpGenerator.math_single=function(a){const b=a.getFieldValue("OP");let c;if("NEG"===b)return a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"NUM",module$exports$Blockly$PHP.phpGenerator.ORDER_UNARY_NEGATION)||"0","-"===a[0]&&(a=" "+a),["-"+a,module$exports$Blockly$PHP.phpGenerator.ORDER_UNARY_NEGATION];a="SIN"===b||"COS"===b||"TAN"===b?module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"NUM",module$exports$Blockly$PHP.phpGenerator.ORDER_DIVISION)||"0":module$exports$Blockly$PHP.phpGenerator.valueToCode(a,
|
||||
"NUM",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"0";switch(b){case "ABS":c="abs("+a+")";break;case "ROOT":c="sqrt("+a+")";break;case "LN":c="log("+a+")";break;case "EXP":c="exp("+a+")";break;case "POW10":c="pow(10,"+a+")";break;case "ROUND":c="round("+a+")";break;case "ROUNDUP":c="ceil("+a+")";break;case "ROUNDDOWN":c="floor("+a+")";break;case "SIN":c="sin("+a+" / 180 * pi())";break;case "COS":c="cos("+a+" / 180 * pi())";break;case "TAN":c="tan("+a+" / 180 * pi())"}if(c)return[c,module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL];
|
||||
switch(b){case "LOG10":c="log("+a+") / log(10)";break;case "ASIN":c="asin("+a+") / pi() * 180";break;case "ACOS":c="acos("+a+") / pi() * 180";break;case "ATAN":c="atan("+a+") / pi() * 180";break;default:throw Error("Unknown math operator: "+b);}return[c,module$exports$Blockly$PHP.phpGenerator.ORDER_DIVISION]};
|
||||
module$exports$Blockly$PHP.phpGenerator.math_constant=function(a){return{PI:["M_PI",module$exports$Blockly$PHP.phpGenerator.ORDER_ATOMIC],E:["M_E",module$exports$Blockly$PHP.phpGenerator.ORDER_ATOMIC],GOLDEN_RATIO:["(1 + sqrt(5)) / 2",module$exports$Blockly$PHP.phpGenerator.ORDER_DIVISION],SQRT2:["M_SQRT2",module$exports$Blockly$PHP.phpGenerator.ORDER_ATOMIC],SQRT1_2:["M_SQRT1_2",module$exports$Blockly$PHP.phpGenerator.ORDER_ATOMIC],INFINITY:["INF",module$exports$Blockly$PHP.phpGenerator.ORDER_ATOMIC]}[a.getFieldValue("CONSTANT")]};
|
||||
module$exports$Blockly$PHP.phpGenerator.math_number_property=function(a){var b={EVEN:[""," % 2 == 0",module$exports$Blockly$PHP.phpGenerator.ORDER_MODULUS,module$exports$Blockly$PHP.phpGenerator.ORDER_EQUALITY],ODD:[""," % 2 == 1",module$exports$Blockly$PHP.phpGenerator.ORDER_MODULUS,module$exports$Blockly$PHP.phpGenerator.ORDER_EQUALITY],WHOLE:["is_int(",")",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE,module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL],POSITIVE:[""," > 0",module$exports$Blockly$PHP.phpGenerator.ORDER_RELATIONAL,
|
||||
module$exports$Blockly$PHP.phpGenerator.ORDER_RELATIONAL],NEGATIVE:[""," < 0",module$exports$Blockly$PHP.phpGenerator.ORDER_RELATIONAL,module$exports$Blockly$PHP.phpGenerator.ORDER_RELATIONAL],DIVISIBLE_BY:[null,null,module$exports$Blockly$PHP.phpGenerator.ORDER_MODULUS,module$exports$Blockly$PHP.phpGenerator.ORDER_EQUALITY],PRIME:[null,null,module$exports$Blockly$PHP.phpGenerator.ORDER_NONE,module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};const c=a.getFieldValue("PROPERTY"),[d,e,f,g]=
|
||||
b[c];b=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"NUMBER_TO_CHECK",f)||"0";if("PRIME"===c)a=module$exports$Blockly$PHP.phpGenerator.provideFunction_("math_isPrime",`
|
||||
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($n) {
|
||||
// https://en.wikipedia.org/wiki/Primality_test#Naive_methods
|
||||
if ($n == 2 || $n == 3) {
|
||||
return true;
|
||||
}
|
||||
// False if n is NaN, negative, is 1, or not whole.
|
||||
// And false if n is divisible by 2 or 3.
|
||||
if (!is_numeric($n) || $n <= 1 || $n % 1 != 0 || $n % 2 == 0 || $n % 3 == 0) {
|
||||
return false;
|
||||
}
|
||||
// Check all the numbers of form 6k +/- 1, up to sqrt(n).
|
||||
for ($x = 6; $x <= sqrt($n) + 1; $x += 6) {
|
||||
if ($n % ($x - 1) == 0 || $n % ($x + 1) == 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
`)+"("+b+")";else if("DIVISIBLE_BY"===c){a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"DIVISOR",module$exports$Blockly$PHP.phpGenerator.ORDER_MODULUS)||"0";if("0"===a)return["false",module$exports$Blockly$PHP.phpGenerator.ORDER_ATOMIC];a=b+" % "+a+" == 0"}else a=d+b+e;return[a,g]};
|
||||
module$exports$Blockly$PHP.phpGenerator.math_change=function(a){const b=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"DELTA",module$exports$Blockly$PHP.phpGenerator.ORDER_ADDITION)||"0";return module$exports$Blockly$PHP.phpGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE)+" += "+b+";\n"};module$exports$Blockly$PHP.phpGenerator.math_round=module$exports$Blockly$PHP.phpGenerator.math_single;module$exports$Blockly$PHP.phpGenerator.math_trig=module$exports$Blockly$PHP.phpGenerator.math_single;
|
||||
module$exports$Blockly$PHP.phpGenerator.math_on_list=function(a){var b=a.getFieldValue("OP");switch(b){case "SUM":a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"LIST",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL)||"array()";a="array_sum("+a+")";break;case "MIN":a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"LIST",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL)||"array()";a="min("+a+")";break;case "MAX":a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,
|
||||
"LIST",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL)||"array()";a="max("+a+")";break;case "AVERAGE":b=module$exports$Blockly$PHP.phpGenerator.provideFunction_("math_mean",`
|
||||
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($myList) {
|
||||
return array_sum($myList) / count($myList);
|
||||
}
|
||||
`);a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"LIST",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"array()";a=b+"("+a+")";break;case "MEDIAN":b=module$exports$Blockly$PHP.phpGenerator.provideFunction_("math_median",`
|
||||
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($arr) {
|
||||
sort($arr,SORT_NUMERIC);
|
||||
return (count($arr) % 2) ? $arr[floor(count($arr) / 2)] :
|
||||
($arr[floor(count($arr) / 2)] + $arr[floor(count($arr) / 2) - 1]) / 2;
|
||||
}
|
||||
`);a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"LIST",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"[]";a=b+"("+a+")";break;case "MODE":b=module$exports$Blockly$PHP.phpGenerator.provideFunction_("math_modes",`
|
||||
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($values) {
|
||||
if (empty($values)) return array();
|
||||
$counts = array_count_values($values);
|
||||
arsort($counts); // Sort counts in descending order
|
||||
$modes = array_keys($counts, current($counts), true);
|
||||
return $modes;
|
||||
}
|
||||
`);a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"LIST",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"[]";a=b+"("+a+")";break;case "STD_DEV":b=module$exports$Blockly$PHP.phpGenerator.provideFunction_("math_standard_deviation",`
|
||||
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($numbers) {
|
||||
$n = count($numbers);
|
||||
if (!$n) return null;
|
||||
$mean = array_sum($numbers) / count($numbers);
|
||||
foreach($numbers as $key => $num) $devs[$key] = pow($num - $mean, 2);
|
||||
return sqrt(array_sum($devs) / (count($devs) - 1));
|
||||
}
|
||||
`);a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"LIST",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"[]";a=b+"("+a+")";break;case "RANDOM":b=module$exports$Blockly$PHP.phpGenerator.provideFunction_("math_random_list",`
|
||||
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($list) {
|
||||
$x = rand(0, count($list)-1);
|
||||
return $list[$x];
|
||||
}
|
||||
`);a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"LIST",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"[]";a=b+"("+a+")";break;default:throw Error("Unknown operator: "+b);}return[a,module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$PHP.phpGenerator.math_modulo=function(a){const b=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"DIVIDEND",module$exports$Blockly$PHP.phpGenerator.ORDER_MODULUS)||"0";a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"DIVISOR",module$exports$Blockly$PHP.phpGenerator.ORDER_MODULUS)||"0";return[b+" % "+a,module$exports$Blockly$PHP.phpGenerator.ORDER_MODULUS]};
|
||||
module$exports$Blockly$PHP.phpGenerator.math_constrain=function(a){const b=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"VALUE",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"0",c=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"LOW",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"0";a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"HIGH",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"Infinity";return["min(max("+b+", "+c+"), "+a+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$PHP.phpGenerator.math_random_int=function(a){const b=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"FROM",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"0";a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"TO",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"0";return[module$exports$Blockly$PHP.phpGenerator.provideFunction_("math_random_int",`
|
||||
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($a, $b) {
|
||||
if ($a > $b) {
|
||||
return rand($b, $a);
|
||||
}
|
||||
return rand($a, $b);
|
||||
}
|
||||
`)+"("+b+", "+a+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};module$exports$Blockly$PHP.phpGenerator.math_random_float=function(a){return["(float)rand()/(float)getrandmax()",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$PHP.phpGenerator.math_atan2=function(a){const b=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"X",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"0";return["atan2("+(module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"Y",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"0")+", "+b+") / pi() * 180",module$exports$Blockly$PHP.phpGenerator.ORDER_DIVISION]};var module$exports$Blockly$PHP$loops={},module$contents$Blockly$PHP$loops_stringUtils=$.module$build$src$core$utils$string,module$contents$Blockly$PHP$loops_NameType=$.NameType$$module$build$src$core$names;
|
||||
module$exports$Blockly$PHP.phpGenerator.controls_repeat_ext=function(a){let b;b=a.getField("TIMES")?String(Number(a.getFieldValue("TIMES"))):module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"TIMES",module$exports$Blockly$PHP.phpGenerator.ORDER_ASSIGNMENT)||"0";let c=module$exports$Blockly$PHP.phpGenerator.statementToCode(a,"DO");c=module$exports$Blockly$PHP.phpGenerator.addLoopTrap(c,a);a="";const d=module$exports$Blockly$PHP.phpGenerator.nameDB_.getDistinctName("count",$.NameType$$module$build$src$core$names.VARIABLE);
|
||||
let e=b;b.match(/^\w+$/)||$.module$build$src$core$utils$string.isNumber(b)||(e=module$exports$Blockly$PHP.phpGenerator.nameDB_.getDistinctName("repeat_end",$.NameType$$module$build$src$core$names.VARIABLE),a+=e+" = "+b+";\n");return a+("for ("+d+" = 0; "+d+" < "+e+"; "+d+"++) {\n"+c+"}\n")};module$exports$Blockly$PHP.phpGenerator.controls_repeat=module$exports$Blockly$PHP.phpGenerator.controls_repeat_ext;
|
||||
module$exports$Blockly$PHP.phpGenerator.controls_whileUntil=function(a){const b="UNTIL"===a.getFieldValue("MODE");let c=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"BOOL",b?module$exports$Blockly$PHP.phpGenerator.ORDER_LOGICAL_NOT:module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"false",d=module$exports$Blockly$PHP.phpGenerator.statementToCode(a,"DO");d=module$exports$Blockly$PHP.phpGenerator.addLoopTrap(d,a);b&&(c="!"+c);return"while ("+c+") {\n"+d+"}\n"};
|
||||
module$exports$Blockly$PHP.phpGenerator.controls_for=function(a){var b=module$exports$Blockly$PHP.phpGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE),c=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"FROM",module$exports$Blockly$PHP.phpGenerator.ORDER_ASSIGNMENT)||"0",d=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"TO",module$exports$Blockly$PHP.phpGenerator.ORDER_ASSIGNMENT)||"0";const e=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,
|
||||
"BY",module$exports$Blockly$PHP.phpGenerator.ORDER_ASSIGNMENT)||"1";let f=module$exports$Blockly$PHP.phpGenerator.statementToCode(a,"DO");f=module$exports$Blockly$PHP.phpGenerator.addLoopTrap(f,a);if($.module$build$src$core$utils$string.isNumber(c)&&$.module$build$src$core$utils$string.isNumber(d)&&$.module$build$src$core$utils$string.isNumber(e)){var g=Number(c)<=Number(d);a="for ("+b+" = "+c+"; "+b+(g?" <= ":" >= ")+d+"; "+b;b=Math.abs(Number(e));a=1===b?a+(g?"++":"--"):a+((g?" += ":" -= ")+b);
|
||||
a+=") {\n"+f+"}\n"}else a="",g=c,c.match(/^\w+$/)||$.module$build$src$core$utils$string.isNumber(c)||(g=module$exports$Blockly$PHP.phpGenerator.nameDB_.getDistinctName(b+"_start",$.NameType$$module$build$src$core$names.VARIABLE),a+=g+" = "+c+";\n"),c=d,d.match(/^\w+$/)||$.module$build$src$core$utils$string.isNumber(d)||(c=module$exports$Blockly$PHP.phpGenerator.nameDB_.getDistinctName(b+"_end",$.NameType$$module$build$src$core$names.VARIABLE),a+=c+" = "+d+";\n"),d=module$exports$Blockly$PHP.phpGenerator.nameDB_.getDistinctName(b+
|
||||
"_inc",$.NameType$$module$build$src$core$names.VARIABLE),a+=d+" = ",a=$.module$build$src$core$utils$string.isNumber(e)?a+(Math.abs(e)+";\n"):a+("abs("+e+");\n"),a+="if ("+g+" > "+c+") {\n",a+=module$exports$Blockly$PHP.phpGenerator.INDENT+d+" = -"+d+";\n",a=a+"}\nfor ("+(b+" = "+g+"; "+d+" >= 0 ? "+b+" <= "+c+" : "+b+" >= "+c+"; "+b+" += "+d+") {\n"+f+"}\n");return a};
|
||||
module$exports$Blockly$PHP.phpGenerator.controls_forEach=function(a){const b=module$exports$Blockly$PHP.phpGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE),c=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"LIST",module$exports$Blockly$PHP.phpGenerator.ORDER_ASSIGNMENT)||"[]";let d=module$exports$Blockly$PHP.phpGenerator.statementToCode(a,"DO");d=module$exports$Blockly$PHP.phpGenerator.addLoopTrap(d,a);return"foreach ("+c+" as "+b+") {\n"+d+
|
||||
"}\n"};
|
||||
module$exports$Blockly$PHP.phpGenerator.controls_flow_statements=function(a){let b="";module$exports$Blockly$PHP.phpGenerator.STATEMENT_PREFIX&&(b+=module$exports$Blockly$PHP.phpGenerator.injectId(module$exports$Blockly$PHP.phpGenerator.STATEMENT_PREFIX,a));module$exports$Blockly$PHP.phpGenerator.STATEMENT_SUFFIX&&(b+=module$exports$Blockly$PHP.phpGenerator.injectId(module$exports$Blockly$PHP.phpGenerator.STATEMENT_SUFFIX,a));if(module$exports$Blockly$PHP.phpGenerator.STATEMENT_PREFIX){const c=a.getSurroundLoop();
|
||||
c&&!c.suppressPrefixSuffix&&(b+=module$exports$Blockly$PHP.phpGenerator.injectId(module$exports$Blockly$PHP.phpGenerator.STATEMENT_PREFIX,c))}switch(a.getFieldValue("FLOW")){case "BREAK":return b+"break;\n";case "CONTINUE":return b+"continue;\n"}throw Error("Unknown flow statement.");};var module$exports$Blockly$PHP$logic={};
|
||||
module$exports$Blockly$PHP.phpGenerator.controls_if=function(a){let b=0,c="",d,e;module$exports$Blockly$PHP.phpGenerator.STATEMENT_PREFIX&&(c+=module$exports$Blockly$PHP.phpGenerator.injectId(module$exports$Blockly$PHP.phpGenerator.STATEMENT_PREFIX,a));do e=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"IF"+b,module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"false",d=module$exports$Blockly$PHP.phpGenerator.statementToCode(a,"DO"+b),module$exports$Blockly$PHP.phpGenerator.STATEMENT_SUFFIX&&(d=
|
||||
module$exports$Blockly$PHP.phpGenerator.prefixLines(module$exports$Blockly$PHP.phpGenerator.injectId(module$exports$Blockly$PHP.phpGenerator.STATEMENT_SUFFIX,a),module$exports$Blockly$PHP.phpGenerator.INDENT)+d),c+=(0<b?" else ":"")+"if ("+e+") {\n"+d+"}",b++;while(a.getInput("IF"+b));if(a.getInput("ELSE")||module$exports$Blockly$PHP.phpGenerator.STATEMENT_SUFFIX)d=module$exports$Blockly$PHP.phpGenerator.statementToCode(a,"ELSE"),module$exports$Blockly$PHP.phpGenerator.STATEMENT_SUFFIX&&(d=module$exports$Blockly$PHP.phpGenerator.prefixLines(module$exports$Blockly$PHP.phpGenerator.injectId(module$exports$Blockly$PHP.phpGenerator.STATEMENT_SUFFIX,
|
||||
a),module$exports$Blockly$PHP.phpGenerator.INDENT)+d),c+=" else {\n"+d+"}";return c+"\n"};module$exports$Blockly$PHP.phpGenerator.controls_ifelse=module$exports$Blockly$PHP.phpGenerator.controls_if;
|
||||
module$exports$Blockly$PHP.phpGenerator.logic_compare=function(a){const b={EQ:"==",NEQ:"!=",LT:"<",LTE:"<=",GT:">",GTE:">="}[a.getFieldValue("OP")],c="=="===b||"!="===b?module$exports$Blockly$PHP.phpGenerator.ORDER_EQUALITY:module$exports$Blockly$PHP.phpGenerator.ORDER_RELATIONAL,d=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"A",c)||"0";a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"B",c)||"0";return[d+" "+b+" "+a,c]};
|
||||
module$exports$Blockly$PHP.phpGenerator.logic_operation=function(a){const b="AND"===a.getFieldValue("OP")?"&&":"||",c="&&"===b?module$exports$Blockly$PHP.phpGenerator.ORDER_LOGICAL_AND:module$exports$Blockly$PHP.phpGenerator.ORDER_LOGICAL_OR;let d=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"A",c);a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"B",c);if(d||a){const e="&&"===b?"true":"false";d||(d=e);a||(a=e)}else a=d="false";return[d+" "+b+" "+a,c]};
|
||||
module$exports$Blockly$PHP.phpGenerator.logic_negate=function(a){const b=module$exports$Blockly$PHP.phpGenerator.ORDER_LOGICAL_NOT;return["!"+(module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"BOOL",b)||"true"),b]};module$exports$Blockly$PHP.phpGenerator.logic_boolean=function(a){return["TRUE"===a.getFieldValue("BOOL")?"true":"false",module$exports$Blockly$PHP.phpGenerator.ORDER_ATOMIC]};module$exports$Blockly$PHP.phpGenerator.logic_null=function(a){return["null",module$exports$Blockly$PHP.phpGenerator.ORDER_ATOMIC]};
|
||||
module$exports$Blockly$PHP.phpGenerator.logic_ternary=function(a){const b=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"IF",module$exports$Blockly$PHP.phpGenerator.ORDER_CONDITIONAL)||"false",c=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"THEN",module$exports$Blockly$PHP.phpGenerator.ORDER_CONDITIONAL)||"null";a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"ELSE",module$exports$Blockly$PHP.phpGenerator.ORDER_CONDITIONAL)||"null";return[b+" ? "+c+" : "+a,module$exports$Blockly$PHP.phpGenerator.ORDER_CONDITIONAL]};var module$exports$Blockly$PHP$lists={},module$contents$Blockly$PHP$lists_stringUtils=$.module$build$src$core$utils$string,module$contents$Blockly$PHP$lists_NameType=$.NameType$$module$build$src$core$names;module$exports$Blockly$PHP.phpGenerator.lists_create_empty=function(a){return["array()",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$PHP.phpGenerator.lists_create_with=function(a){let b=Array(a.itemCount_);for(let c=0;c<a.itemCount_;c++)b[c]=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"ADD"+c,module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"null";b="array("+b.join(", ")+")";return[b,module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};module$exports$Blockly$PHP.phpGenerator.lists_repeat=function(a){const b=module$exports$Blockly$PHP.phpGenerator.provideFunction_("lists_repeat",`
|
||||
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($value, $count) {
|
||||
$array = array();
|
||||
for ($index = 0; $index < $count; $index++) {
|
||||
$array[] = $value;
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
`),c=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"ITEM",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"null";a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"NUM",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"0";return[b+"("+c+", "+a+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};module$exports$Blockly$PHP.phpGenerator.lists_length=function(a){const b=module$exports$Blockly$PHP.phpGenerator.provideFunction_("length",`
|
||||
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($value) {
|
||||
if (is_string($value)) {
|
||||
return strlen($value);
|
||||
} else {
|
||||
return count($value);
|
||||
}
|
||||
}
|
||||
`);a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"VALUE",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"''";return[b+"("+a+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};module$exports$Blockly$PHP.phpGenerator.lists_isEmpty=function(a){return["empty("+(module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"VALUE",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL)||"array()")+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$PHP.phpGenerator.lists_indexOf=function(a){const b=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"FIND",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"''",c=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"VALUE",module$exports$Blockly$PHP.phpGenerator.ORDER_MEMBER)||"[]";let d=" -1",e="";a.workspace.options.oneBasedIndex&&(d=" 0",e=" + 1");return[("FIRST"===a.getFieldValue("END")?module$exports$Blockly$PHP.phpGenerator.provideFunction_("indexOf",`
|
||||
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($haystack, $needle) {
|
||||
for ($index = 0; $index < count($haystack); $index++) {
|
||||
if ($haystack[$index] == $needle) return $index${e};
|
||||
}
|
||||
return ${d};
|
||||
}
|
||||
`):module$exports$Blockly$PHP.phpGenerator.provideFunction_("lastIndexOf",`
|
||||
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($haystack, $needle) {
|
||||
$last = ${d};
|
||||
for ($index = 0; $index < count($haystack); $index++) {
|
||||
if ($haystack[$index] == $needle) $last = $index${e};
|
||||
}
|
||||
return $last;
|
||||
}
|
||||
`))+"("+c+", "+b+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$PHP.phpGenerator.lists_getIndex=function(a){var b=a.getFieldValue("MODE")||"GET";switch(a.getFieldValue("WHERE")||"FROM_START"){case "FIRST":if("GET"===b)return[(module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"VALUE",module$exports$Blockly$PHP.phpGenerator.ORDER_MEMBER)||"array()")+"[0]",module$exports$Blockly$PHP.phpGenerator.ORDER_MEMBER];if("GET_REMOVE"===b)return["array_shift("+(module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"VALUE",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||
|
||||
"array()")+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL];if("REMOVE"===b)return"array_shift("+(module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"VALUE",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"array()")+");\n";break;case "LAST":if("GET"===b)return["end("+(module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"VALUE",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"array()")+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL];if("GET_REMOVE"===
|
||||
b)return["array_pop("+(module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"VALUE",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"array()")+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL];if("REMOVE"===b)return"array_pop("+(module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"VALUE",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"array()")+");\n";break;case "FROM_START":var c=module$exports$Blockly$PHP.phpGenerator.getAdjusted(a,"AT");if("GET"===b)return[(module$exports$Blockly$PHP.phpGenerator.valueToCode(a,
|
||||
"VALUE",module$exports$Blockly$PHP.phpGenerator.ORDER_MEMBER)||"array()")+"["+c+"]",module$exports$Blockly$PHP.phpGenerator.ORDER_MEMBER];if("GET_REMOVE"===b)return["array_splice("+(module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"VALUE",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"array()")+", "+c+", 1)[0]",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL];if("REMOVE"===b)return"array_splice("+(module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"VALUE",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||
|
||||
"array()")+", "+c+", 1);\n";break;case "FROM_END":if("GET"===b)return b=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"VALUE",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"array()",a=module$exports$Blockly$PHP.phpGenerator.getAdjusted(a,"AT",1,!0),["array_slice("+b+", "+a+", 1)[0]",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL];if("GET_REMOVE"===b||"REMOVE"===b){c=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"VALUE",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||
|
||||
"array()";a=module$exports$Blockly$PHP.phpGenerator.getAdjusted(a,"AT",1,!1,module$exports$Blockly$PHP.phpGenerator.ORDER_SUBTRACTION);a="array_splice("+c+", count("+c+") - "+a+", 1)[0]";if("GET_REMOVE"===b)return[a,module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL];if("REMOVE"===b)return a+";\n"}break;case "RANDOM":a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"VALUE",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"array()";if("GET"===b)return[module$exports$Blockly$PHP.phpGenerator.provideFunction_("lists_get_random_item",
|
||||
`
|
||||
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($list) {
|
||||
return $list[rand(0,count($list)-1)];
|
||||
}
|
||||
`)+"("+a+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL];if("GET_REMOVE"===b)return[module$exports$Blockly$PHP.phpGenerator.provideFunction_("lists_get_remove_random_item",`
|
||||
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}(&$list) {
|
||||
$x = rand(0,count($list)-1);
|
||||
unset($list[$x]);
|
||||
return array_values($list);
|
||||
}
|
||||
`)+"("+a+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL];if("REMOVE"===b)return module$exports$Blockly$PHP.phpGenerator.provideFunction_("lists_remove_random_item",`
|
||||
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}(&$list) {
|
||||
unset($list[rand(0,count($list)-1)]);
|
||||
}
|
||||
`)+"("+a+");\n"}throw Error("Unhandled combination (lists_getIndex).");};
|
||||
module$exports$Blockly$PHP.phpGenerator.lists_setIndex=function(a){const b=a.getFieldValue("MODE")||"GET";var c=a.getFieldValue("WHERE")||"FROM_START";const d=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"TO",module$exports$Blockly$PHP.phpGenerator.ORDER_ASSIGNMENT)||"null";switch(c){case "FIRST":if("SET"===b)return(module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"LIST",module$exports$Blockly$PHP.phpGenerator.ORDER_MEMBER)||"array()")+"[0] = "+d+";\n";if("INSERT"===b)return"array_unshift("+
|
||||
(module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"LIST",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"array()")+", "+d+");\n";break;case "LAST":a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"LIST",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"array()";if("SET"===b)return module$exports$Blockly$PHP.phpGenerator.provideFunction_("lists_set_last_item",`
|
||||
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}(&$list, $value) {
|
||||
$list[count($list) - 1] = $value;
|
||||
}
|
||||
`)+"("+a+", "+d+");\n";if("INSERT"===b)return"array_push("+a+", "+d+");\n";break;case "FROM_START":c=module$exports$Blockly$PHP.phpGenerator.getAdjusted(a,"AT");if("SET"===b)return(module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"LIST",module$exports$Blockly$PHP.phpGenerator.ORDER_MEMBER)||"array()")+"["+c+"] = "+d+";\n";if("INSERT"===b)return"array_splice("+(module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"LIST",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"array()")+", "+c+", 0, "+
|
||||
d+");\n";break;case "FROM_END":c=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"LIST",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"array()";a=module$exports$Blockly$PHP.phpGenerator.getAdjusted(a,"AT",1);if("SET"===b)return module$exports$Blockly$PHP.phpGenerator.provideFunction_("lists_set_from_end",`
|
||||
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}(&$list, $at, $value) {
|
||||
$list[count($list) - $at] = $value;
|
||||
}
|
||||
`)+"("+c+", "+a+", "+d+");\n";if("INSERT"===b)return module$exports$Blockly$PHP.phpGenerator.provideFunction_("lists_insert_from_end",`
|
||||
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}(&$list, $at, $value) {
|
||||
return array_splice($list, count($list) - $at, 0, $value);
|
||||
}
|
||||
`)+"("+c+", "+a+", "+d+");\n";break;case "RANDOM":a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"LIST",module$exports$Blockly$PHP.phpGenerator.ORDER_REFERENCE)||"array()";if(a.match(/^\$\w+$/))c="";else{c=module$exports$Blockly$PHP.phpGenerator.nameDB_.getDistinctName("tmp_list",$.NameType$$module$build$src$core$names.VARIABLE);var e=c+" = &"+a+";\n";a=c;c=e}e=module$exports$Blockly$PHP.phpGenerator.nameDB_.getDistinctName("tmp_x",$.NameType$$module$build$src$core$names.VARIABLE);c+=e+" = rand(0, count("+
|
||||
a+")-1);\n";if("SET"===b)return c+(a+"["+e+"] = "+d+";\n");if("INSERT"===b)return c+("array_splice("+a+", "+e+", 0, "+d+");\n")}throw Error("Unhandled combination (lists_setIndex).");};
|
||||
module$exports$Blockly$PHP.phpGenerator.lists_getSublist=function(a){var b=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"LIST",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"array()",c=a.getFieldValue("WHERE1"),d=a.getFieldValue("WHERE2");if("FIRST"!==c||"LAST"!==d)if(b.match(/^\$\w+$/)||"FROM_END"!==c&&"FROM_START"===d){switch(c){case "FROM_START":c=module$exports$Blockly$PHP.phpGenerator.getAdjusted(a,"AT1");break;case "FROM_END":c=module$exports$Blockly$PHP.phpGenerator.getAdjusted(a,
|
||||
"AT1",1,!1,module$exports$Blockly$PHP.phpGenerator.ORDER_SUBTRACTION);c="count("+b+") - "+c;break;case "FIRST":c="0";break;default:throw Error("Unhandled option (lists_getSublist).");}switch(d){case "FROM_START":d=module$exports$Blockly$PHP.phpGenerator.getAdjusted(a,"AT2",0,!1,module$exports$Blockly$PHP.phpGenerator.ORDER_SUBTRACTION);d+=" - ";d=$.module$build$src$core$utils$string.isNumber(String(c))||String(c).match(/^\(.+\)$/)?d+c:d+("("+c+")");d+=" + 1";break;case "FROM_END":d=module$exports$Blockly$PHP.phpGenerator.getAdjusted(a,
|
||||
"AT2",0,!1,module$exports$Blockly$PHP.phpGenerator.ORDER_SUBTRACTION);d="count("+b+") - "+d+" - ";d=$.module$build$src$core$utils$string.isNumber(String(c))||String(c).match(/^\(.+\)$/)?d+c:d+("("+c+")");break;case "LAST":d="count("+b+") - ";d=$.module$build$src$core$utils$string.isNumber(String(c))||String(c).match(/^\(.+\)$/)?d+c:d+("("+c+")");break;default:throw Error("Unhandled option (lists_getSublist).");}b="array_slice("+b+", "+c+", "+d+")"}else{const e=module$exports$Blockly$PHP.phpGenerator.getAdjusted(a,
|
||||
"AT1");a=module$exports$Blockly$PHP.phpGenerator.getAdjusted(a,"AT2");b=module$exports$Blockly$PHP.phpGenerator.provideFunction_("lists_get_sublist",`
|
||||
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($list, $where1, $at1, $where2, $at2) {
|
||||
if ($where1 == 'FROM_END') {
|
||||
$at1 = count($list) - 1 - $at1;
|
||||
} else if ($where1 == 'FIRST') {
|
||||
$at1 = 0;
|
||||
} else if ($where1 != 'FROM_START') {
|
||||
throw new Exception('Unhandled option (lists_get_sublist).');
|
||||
}
|
||||
$length = 0;
|
||||
if ($where2 == 'FROM_START') {
|
||||
$length = $at2 - $at1 + 1;
|
||||
} else if ($where2 == 'FROM_END') {
|
||||
$length = count($list) - $at1 - $at2;
|
||||
} else if ($where2 == 'LAST') {
|
||||
$length = count($list) - $at1;
|
||||
} else {
|
||||
throw new Exception('Unhandled option (lists_get_sublist).');
|
||||
}
|
||||
return array_slice($list, $at1, $length);
|
||||
}
|
||||
`)+"("+b+", '"+c+"', "+e+", '"+d+"', "+a+")"}return[b,module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};module$exports$Blockly$PHP.phpGenerator.lists_sort=function(a){const b=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"LIST",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"array()",c="1"===a.getFieldValue("DIRECTION")?1:-1;a=a.getFieldValue("TYPE");return[module$exports$Blockly$PHP.phpGenerator.provideFunction_("lists_sort",`
|
||||
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($list, $type, $direction) {
|
||||
$sortCmpFuncs = array(
|
||||
'NUMERIC' => 'strnatcasecmp',
|
||||
'TEXT' => 'strcmp',
|
||||
'IGNORE_CASE' => 'strcasecmp'
|
||||
);
|
||||
$sortCmp = $sortCmpFuncs[$type];
|
||||
$list2 = $list;
|
||||
usort($list2, $sortCmp);
|
||||
if ($direction == -1) {
|
||||
$list2 = array_reverse($list2);
|
||||
}
|
||||
return $list2;
|
||||
}
|
||||
`)+"("+b+', "'+a+'", '+c+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$PHP.phpGenerator.lists_split=function(a){let b=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"INPUT",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE);const c=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"DELIM",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"''";a=a.getFieldValue("MODE");if("SPLIT"===a)b||(b="''"),a="explode";else if("JOIN"===a)b||(b="array()"),a="implode";else throw Error("Unknown mode: "+a);return[a+"("+c+", "+b+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$PHP.phpGenerator.lists_reverse=function(a){return["array_reverse("+(module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"LIST",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"[]")+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};var module$exports$Blockly$PHP$colour={};module$exports$Blockly$PHP.phpGenerator.colour_picker=function(a){return[module$exports$Blockly$PHP.phpGenerator.quote_(a.getFieldValue("COLOUR")),module$exports$Blockly$PHP.phpGenerator.ORDER_ATOMIC]};module$exports$Blockly$PHP.phpGenerator.colour_random=function(a){return[module$exports$Blockly$PHP.phpGenerator.provideFunction_("colour_random",`
|
||||
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}() {
|
||||
return '#' . str_pad(dechex(mt_rand(0, 0xFFFFFF)), 6, '0', STR_PAD_LEFT);
|
||||
}
|
||||
`)+"()",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$PHP.phpGenerator.colour_rgb=function(a){const b=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"RED",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||0,c=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"GREEN",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||0;a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"BLUE",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||0;return[module$exports$Blockly$PHP.phpGenerator.provideFunction_("colour_rgb",`
|
||||
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($r, $g, $b) {
|
||||
$r = round(max(min($r, 100), 0) * 2.55);
|
||||
$g = round(max(min($g, 100), 0) * 2.55);
|
||||
$b = round(max(min($b, 100), 0) * 2.55);
|
||||
$hex = '#';
|
||||
$hex .= str_pad(dechex($r), 2, '0', STR_PAD_LEFT);
|
||||
$hex .= str_pad(dechex($g), 2, '0', STR_PAD_LEFT);
|
||||
$hex .= str_pad(dechex($b), 2, '0', STR_PAD_LEFT);
|
||||
return $hex;
|
||||
}
|
||||
`)+"("+b+", "+c+", "+a+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$PHP.phpGenerator.colour_blend=function(a){const b=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"COLOUR1",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"'#000000'",c=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"COLOUR2",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||"'#000000'";a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"RATIO",module$exports$Blockly$PHP.phpGenerator.ORDER_NONE)||.5;return[module$exports$Blockly$PHP.phpGenerator.provideFunction_("colour_blend",
|
||||
`
|
||||
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($c1, $c2, $ratio) {
|
||||
$ratio = max(min($ratio, 1), 0);
|
||||
$r1 = hexdec(substr($c1, 1, 2));
|
||||
$g1 = hexdec(substr($c1, 3, 2));
|
||||
$b1 = hexdec(substr($c1, 5, 2));
|
||||
$r2 = hexdec(substr($c2, 1, 2));
|
||||
$g2 = hexdec(substr($c2, 3, 2));
|
||||
$b2 = hexdec(substr($c2, 5, 2));
|
||||
$r = round($r1 * (1 - $ratio) + $r2 * $ratio);
|
||||
$g = round($g1 * (1 - $ratio) + $g2 * $ratio);
|
||||
$b = round($b1 * (1 - $ratio) + $b2 * $ratio);
|
||||
$hex = '#';
|
||||
$hex .= str_pad(dechex($r), 2, '0', STR_PAD_LEFT);
|
||||
$hex .= str_pad(dechex($g), 2, '0', STR_PAD_LEFT);
|
||||
$hex .= str_pad(dechex($b), 2, '0', STR_PAD_LEFT);
|
||||
return $hex;
|
||||
}
|
||||
`)+"("+b+", "+c+", "+a+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};var module$exports$Blockly$PHP$all=module$exports$Blockly$PHP;
|
||||
module$exports$Blockly$PHP.__namespace__=$;
|
||||
return module$exports$Blockly$PHP;
|
||||
}));
|
||||
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
+237
-90
@@ -8,99 +8,246 @@
|
||||
module.exports = factory(require("./blockly_compressed.js"));
|
||||
} else { // Browser
|
||||
var factoryExports = factory(root.Blockly);
|
||||
root.Blockly.Python = factoryExports;
|
||||
root.Blockly.Python = factoryExports.pythonGenerator;
|
||||
root.Blockly.Python.__namespace__ = factoryExports.__namespace__;
|
||||
}
|
||||
}(this, function(__parent__) {
|
||||
var $=__parent__.__namespace__;
|
||||
var module$contents$Blockly$Python_Python=new $.module$exports$Blockly$Generator.Generator("Python");module$contents$Blockly$Python_Python.addReservedWords("False,None,True,and,as,assert,break,class,continue,def,del,elif,else,except,exec,finally,for,from,global,if,import,in,is,lambda,nonlocal,not,or,pass,print,raise,return,try,while,with,yield,NotImplemented,Ellipsis,__debug__,quit,exit,copyright,license,credits,ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EnvironmentError,Exception,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StandardError,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,ZeroDivisionError,_,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,all,any,apply,ascii,basestring,bin,bool,buffer,bytearray,bytes,callable,chr,classmethod,cmp,coerce,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,execfile,exit,file,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,intern,isinstance,issubclass,iter,len,license,list,locals,long,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,raw_input,reduce,reload,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,unichr,unicode,vars,xrange,zip");
|
||||
module$contents$Blockly$Python_Python.ORDER_ATOMIC=0;module$contents$Blockly$Python_Python.ORDER_COLLECTION=1;module$contents$Blockly$Python_Python.ORDER_STRING_CONVERSION=1;module$contents$Blockly$Python_Python.ORDER_MEMBER=2.1;module$contents$Blockly$Python_Python.ORDER_FUNCTION_CALL=2.2;module$contents$Blockly$Python_Python.ORDER_EXPONENTIATION=3;module$contents$Blockly$Python_Python.ORDER_UNARY_SIGN=4;module$contents$Blockly$Python_Python.ORDER_BITWISE_NOT=4;
|
||||
module$contents$Blockly$Python_Python.ORDER_MULTIPLICATIVE=5;module$contents$Blockly$Python_Python.ORDER_ADDITIVE=6;module$contents$Blockly$Python_Python.ORDER_BITWISE_SHIFT=7;module$contents$Blockly$Python_Python.ORDER_BITWISE_AND=8;module$contents$Blockly$Python_Python.ORDER_BITWISE_XOR=9;module$contents$Blockly$Python_Python.ORDER_BITWISE_OR=10;module$contents$Blockly$Python_Python.ORDER_RELATIONAL=11;module$contents$Blockly$Python_Python.ORDER_LOGICAL_NOT=12;
|
||||
module$contents$Blockly$Python_Python.ORDER_LOGICAL_AND=13;module$contents$Blockly$Python_Python.ORDER_LOGICAL_OR=14;module$contents$Blockly$Python_Python.ORDER_CONDITIONAL=15;module$contents$Blockly$Python_Python.ORDER_LAMBDA=16;module$contents$Blockly$Python_Python.ORDER_NONE=99;
|
||||
module$contents$Blockly$Python_Python.ORDER_OVERRIDES=[[module$contents$Blockly$Python_Python.ORDER_FUNCTION_CALL,module$contents$Blockly$Python_Python.ORDER_MEMBER],[module$contents$Blockly$Python_Python.ORDER_FUNCTION_CALL,module$contents$Blockly$Python_Python.ORDER_FUNCTION_CALL],[module$contents$Blockly$Python_Python.ORDER_MEMBER,module$contents$Blockly$Python_Python.ORDER_MEMBER],[module$contents$Blockly$Python_Python.ORDER_MEMBER,module$contents$Blockly$Python_Python.ORDER_FUNCTION_CALL],[module$contents$Blockly$Python_Python.ORDER_LOGICAL_NOT,
|
||||
module$contents$Blockly$Python_Python.ORDER_LOGICAL_NOT],[module$contents$Blockly$Python_Python.ORDER_LOGICAL_AND,module$contents$Blockly$Python_Python.ORDER_LOGICAL_AND],[module$contents$Blockly$Python_Python.ORDER_LOGICAL_OR,module$contents$Blockly$Python_Python.ORDER_LOGICAL_OR]];module$contents$Blockly$Python_Python.isInitialized=!1;
|
||||
module$contents$Blockly$Python_Python.init=function(a){Object.getPrototypeOf(this).init.call(this);this.PASS=this.INDENT+"pass\n";this.nameDB_?this.nameDB_.reset():this.nameDB_=new $.module$exports$Blockly$Names.Names(this.RESERVED_WORDS_);this.nameDB_.setVariableMap(a.getVariableMap());this.nameDB_.populateVariables(a);this.nameDB_.populateProcedures(a);for(var b=[],c=(0,$.module$exports$Blockly$Variables.allDeveloperVariables)(a),d=0;d<c.length;d++)b.push(this.nameDB_.getName(c[d],$.module$exports$Blockly$Names.Names.DEVELOPER_VARIABLE_TYPE)+
|
||||
" = None");a=(0,$.module$exports$Blockly$Variables.allUsedVarModels)(a);for(c=0;c<a.length;c++)b.push(this.nameDB_.getName(a[c].getId(),$.module$exports$Blockly$Names.NameType.VARIABLE)+" = None");this.definitions_.variables=b.join("\n");this.isInitialized=!0};
|
||||
module$contents$Blockly$Python_Python.finish=function(a){var b=[],c=[],d;for(d in this.definitions_){var e=this.definitions_[d];e.match(/^(from\s+\S+\s+)?import\s+\S+/)?b.push(e):c.push(e)}a=Object.getPrototypeOf(this).finish.call(this,a);this.isInitialized=!1;this.nameDB_.reset();return(b.join("\n")+"\n\n"+c.join("\n\n")).replace(/\n\n+/g,"\n\n").replace(/\n*$/,"\n\n\n")+a};module$contents$Blockly$Python_Python.scrubNakedValue=function(a){return a+"\n"};
|
||||
module$contents$Blockly$Python_Python.quote_=function(a){a=a.replace(/\\/g,"\\\\").replace(/\n/g,"\\\n");var b="'";-1!==a.indexOf("'")&&(-1===a.indexOf('"')?b='"':a=a.replace(/'/g,"\\'"));return b+a+b};module$contents$Blockly$Python_Python.multiline_quote_=function(a){return a.split(/\n/g).map(this.quote_).join(" + '\\n' + \n")};
|
||||
module$contents$Blockly$Python_Python.scrub_=function(a,b,c){var d="";if(!a.outputConnection||!a.outputConnection.targetConnection){var e=a.getCommentText();e&&(e=(0,$.module$exports$Blockly$utils$string.wrap)(e,this.COMMENT_WRAP-3),d+=this.prefixLines(e+"\n","# "));for(var f=0;f<a.inputList.length;f++)a.inputList[f].type===$.module$exports$Blockly$inputTypes.inputTypes.VALUE&&(e=a.inputList[f].connection.targetBlock())&&(e=this.allNestedComments(e))&&(d+=this.prefixLines(e,"# "))}a=a.nextConnection&&
|
||||
a.nextConnection.targetBlock();c=c?"":this.blockToCode(a);return d+b+c};module$contents$Blockly$Python_Python.getAdjustedInt=function(a,b,c,d){c=c||0;a.workspace.options.oneBasedIndex&&c--;var e=a.workspace.options.oneBasedIndex?"1":"0";a=this.valueToCode(a,b,c?this.ORDER_ADDITIVE:this.ORDER_NONE)||e;(0,$.module$exports$Blockly$utils$string.isNumber)(a)?(a=parseInt(a,10)+c,d&&(a=-a)):(a=0<c?"int("+a+" + "+c+")":0>c?"int("+a+" - "+-c+")":"int("+a+")",d&&(a="-"+a));return a};$.Blockly.Python=module$contents$Blockly$Python_Python;var module$exports$Blockly$Python$variables={};$.Blockly.Python.variables_get=function(a){return[$.Blockly.Python.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE),$.Blockly.Python.ORDER_ATOMIC]};$.Blockly.Python.variables_set=function(a){var b=$.Blockly.Python.valueToCode(a,"VALUE",$.Blockly.Python.ORDER_NONE)||"0";return $.Blockly.Python.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE)+" = "+b+"\n"};var module$exports$Blockly$Python$variablesDynamic={};$.Blockly.Python.variables_get_dynamic=$.Blockly.Python.variables_get;$.Blockly.Python.variables_set_dynamic=$.Blockly.Python.variables_set;var module$exports$Blockly$Python$texts={};$.Blockly.Python.text=function(a){return[$.Blockly.Python.quote_(a.getFieldValue("TEXT")),$.Blockly.Python.ORDER_ATOMIC]};$.Blockly.Python.text_multiline=function(a){a=$.Blockly.Python.multiline_quote_(a.getFieldValue("TEXT"));var b=-1!==a.indexOf("+")?$.Blockly.Python.ORDER_ADDITIVE:$.Blockly.Python.ORDER_ATOMIC;return[a,b]};
|
||||
var module$contents$Blockly$Python$texts_strRegExp=/^\s*'([^']|\\')*'\s*$/,module$contents$Blockly$Python$texts_forceString=function(a){return module$contents$Blockly$Python$texts_strRegExp.test(a)?[a,$.Blockly.Python.ORDER_ATOMIC]:["str("+a+")",$.Blockly.Python.ORDER_FUNCTION_CALL]};
|
||||
$.Blockly.Python.text_join=function(a){switch(a.itemCount_){case 0:return["''",$.Blockly.Python.ORDER_ATOMIC];case 1:return a=$.Blockly.Python.valueToCode(a,"ADD0",$.Blockly.Python.ORDER_NONE)||"''",module$contents$Blockly$Python$texts_forceString(a);case 2:var b=$.Blockly.Python.valueToCode(a,"ADD0",$.Blockly.Python.ORDER_NONE)||"''";a=$.Blockly.Python.valueToCode(a,"ADD1",$.Blockly.Python.ORDER_NONE)||"''";return[module$contents$Blockly$Python$texts_forceString(b)[0]+" + "+module$contents$Blockly$Python$texts_forceString(a)[0],
|
||||
$.Blockly.Python.ORDER_ADDITIVE];default:b=[];for(var c=0;c<a.itemCount_;c++)b[c]=$.Blockly.Python.valueToCode(a,"ADD"+c,$.Blockly.Python.ORDER_NONE)||"''";a=$.Blockly.Python.nameDB_.getDistinctName("x",$.module$exports$Blockly$Names.NameType.VARIABLE);return["''.join([str("+a+") for "+a+" in ["+b.join(", ")+"]])",$.Blockly.Python.ORDER_FUNCTION_CALL]}};
|
||||
$.Blockly.Python.text_append=function(a){var b=$.Blockly.Python.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE);a=$.Blockly.Python.valueToCode(a,"TEXT",$.Blockly.Python.ORDER_NONE)||"''";return b+" = str("+b+") + "+module$contents$Blockly$Python$texts_forceString(a)[0]+"\n"};$.Blockly.Python.text_length=function(a){return["len("+($.Blockly.Python.valueToCode(a,"VALUE",$.Blockly.Python.ORDER_NONE)||"''")+")",$.Blockly.Python.ORDER_FUNCTION_CALL]};
|
||||
$.Blockly.Python.text_isEmpty=function(a){return["not len("+($.Blockly.Python.valueToCode(a,"VALUE",$.Blockly.Python.ORDER_NONE)||"''")+")",$.Blockly.Python.ORDER_LOGICAL_NOT]};
|
||||
$.Blockly.Python.text_indexOf=function(a){var b="FIRST"===a.getFieldValue("END")?"find":"rfind",c=$.Blockly.Python.valueToCode(a,"FIND",$.Blockly.Python.ORDER_NONE)||"''";b=($.Blockly.Python.valueToCode(a,"VALUE",$.Blockly.Python.ORDER_MEMBER)||"''")+"."+b+"("+c+")";return a.workspace.options.oneBasedIndex?[b+" + 1",$.Blockly.Python.ORDER_ADDITIVE]:[b,$.Blockly.Python.ORDER_FUNCTION_CALL]};
|
||||
$.Blockly.Python.text_charAt=function(a){var b=a.getFieldValue("WHERE")||"FROM_START",c=$.Blockly.Python.valueToCode(a,"VALUE","RANDOM"===b?$.Blockly.Python.ORDER_NONE:$.Blockly.Python.ORDER_MEMBER)||"''";switch(b){case "FIRST":return[c+"[0]",$.Blockly.Python.ORDER_MEMBER];case "LAST":return[c+"[-1]",$.Blockly.Python.ORDER_MEMBER];case "FROM_START":return a=$.Blockly.Python.getAdjustedInt(a,"AT"),[c+"["+a+"]",$.Blockly.Python.ORDER_MEMBER];case "FROM_END":return a=$.Blockly.Python.getAdjustedInt(a,
|
||||
"AT",1,!0),[c+"["+a+"]",$.Blockly.Python.ORDER_MEMBER];case "RANDOM":return $.Blockly.Python.definitions_.import_random="import random",[$.Blockly.Python.provideFunction_("text_random_letter","\ndef "+$.Blockly.Python.FUNCTION_NAME_PLACEHOLDER_+"(text):\n x = int(random.random() * len(text))\n return text[x]\n")+"("+c+")",$.Blockly.Python.ORDER_FUNCTION_CALL]}throw Error("Unhandled option (text_charAt).");};
|
||||
$.Blockly.Python.text_getSubstring=function(a){var b=a.getFieldValue("WHERE1"),c=a.getFieldValue("WHERE2"),d=$.Blockly.Python.valueToCode(a,"STRING",$.Blockly.Python.ORDER_MEMBER)||"''";switch(b){case "FROM_START":b=$.Blockly.Python.getAdjustedInt(a,"AT1");0===b&&(b="");break;case "FROM_END":b=$.Blockly.Python.getAdjustedInt(a,"AT1",1,!0);break;case "FIRST":b="";break;default:throw Error("Unhandled option (text_getSubstring)");}switch(c){case "FROM_START":a=$.Blockly.Python.getAdjustedInt(a,"AT2",
|
||||
1);break;case "FROM_END":a=$.Blockly.Python.getAdjustedInt(a,"AT2",0,!0);(0,$.module$exports$Blockly$utils$string.isNumber)(String(a))?0===a&&(a=""):($.Blockly.Python.definitions_.import_sys="import sys",a+=" or sys.maxsize");break;case "LAST":a="";break;default:throw Error("Unhandled option (text_getSubstring)");}return[d+"["+b+" : "+a+"]",$.Blockly.Python.ORDER_MEMBER]};
|
||||
$.Blockly.Python.text_changeCase=function(a){var b={UPPERCASE:".upper()",LOWERCASE:".lower()",TITLECASE:".title()"}[a.getFieldValue("CASE")];return[($.Blockly.Python.valueToCode(a,"TEXT",$.Blockly.Python.ORDER_MEMBER)||"''")+b,$.Blockly.Python.ORDER_FUNCTION_CALL]};$.Blockly.Python.text_trim=function(a){var b={LEFT:".lstrip()",RIGHT:".rstrip()",BOTH:".strip()"}[a.getFieldValue("MODE")];return[($.Blockly.Python.valueToCode(a,"TEXT",$.Blockly.Python.ORDER_MEMBER)||"''")+b,$.Blockly.Python.ORDER_FUNCTION_CALL]};
|
||||
$.Blockly.Python.text_print=function(a){return"print("+($.Blockly.Python.valueToCode(a,"TEXT",$.Blockly.Python.ORDER_NONE)||"''")+")\n"};
|
||||
$.Blockly.Python.text_prompt_ext=function(a){var b=$.Blockly.Python.provideFunction_("text_prompt","\ndef "+$.Blockly.Python.FUNCTION_NAME_PLACEHOLDER_+"(msg):\n try:\n return raw_input(msg)\n except NameError:\n return input(msg)\n");var c=a.getField("TEXT")?$.Blockly.Python.quote_(a.getFieldValue("TEXT")):$.Blockly.Python.valueToCode(a,"TEXT",$.Blockly.Python.ORDER_NONE)||"''";b=b+"("+c+")";"NUMBER"===a.getFieldValue("TYPE")&&(b="float("+b+")");return[b,$.Blockly.Python.ORDER_FUNCTION_CALL]};
|
||||
$.Blockly.Python.text_prompt=$.Blockly.Python.text_prompt_ext;$.Blockly.Python.text_count=function(a){var b=$.Blockly.Python.valueToCode(a,"TEXT",$.Blockly.Python.ORDER_MEMBER)||"''";a=$.Blockly.Python.valueToCode(a,"SUB",$.Blockly.Python.ORDER_NONE)||"''";return[b+".count("+a+")",$.Blockly.Python.ORDER_FUNCTION_CALL]};
|
||||
$.Blockly.Python.text_replace=function(a){var b=$.Blockly.Python.valueToCode(a,"TEXT",$.Blockly.Python.ORDER_MEMBER)||"''",c=$.Blockly.Python.valueToCode(a,"FROM",$.Blockly.Python.ORDER_NONE)||"''";a=$.Blockly.Python.valueToCode(a,"TO",$.Blockly.Python.ORDER_NONE)||"''";return[b+".replace("+c+", "+a+")",$.Blockly.Python.ORDER_MEMBER]};$.Blockly.Python.text_reverse=function(a){return[($.Blockly.Python.valueToCode(a,"TEXT",$.Blockly.Python.ORDER_MEMBER)||"''")+"[::-1]",$.Blockly.Python.ORDER_MEMBER]};var module$exports$Blockly$Python$procedures={};
|
||||
$.Blockly.Python.procedures_defreturn=function(a){for(var b=[],c=a.workspace,d=(0,$.module$exports$Blockly$Variables.allUsedVarModels)(c)||[],e=0,f;f=d[e];e++)f=f.name,-1===a.getVars().indexOf(f)&&b.push($.Blockly.Python.nameDB_.getName(f,$.module$exports$Blockly$Names.NameType.VARIABLE));c=(0,$.module$exports$Blockly$Variables.allDeveloperVariables)(c);for(d=0;d<c.length;d++)b.push($.Blockly.Python.nameDB_.getName(c[d],$.module$exports$Blockly$Names.NameType.DEVELOPER_VARIABLE));c=b.length?$.Blockly.Python.INDENT+
|
||||
"global "+b.join(", ")+"\n":"";b=$.Blockly.Python.nameDB_.getName(a.getFieldValue("NAME"),$.module$exports$Blockly$Names.NameType.PROCEDURE);d="";$.Blockly.Python.STATEMENT_PREFIX&&(d+=$.Blockly.Python.injectId($.Blockly.Python.STATEMENT_PREFIX,a));$.Blockly.Python.STATEMENT_SUFFIX&&(d+=$.Blockly.Python.injectId($.Blockly.Python.STATEMENT_SUFFIX,a));d&&(d=$.Blockly.Python.prefixLines(d,$.Blockly.Python.INDENT));e="";$.Blockly.Python.INFINITE_LOOP_TRAP&&(e=$.Blockly.Python.prefixLines($.Blockly.Python.injectId($.Blockly.Python.INFINITE_LOOP_TRAP,
|
||||
a),$.Blockly.Python.INDENT));f=$.Blockly.Python.statementToCode(a,"STACK");var g=$.Blockly.Python.valueToCode(a,"RETURN",$.Blockly.Python.ORDER_NONE)||"",h="";f&&g&&(h=d);g?g=$.Blockly.Python.INDENT+"return "+g+"\n":f||(f=$.Blockly.Python.PASS);for(var k=[],l=a.getVars(),m=0;m<l.length;m++)k[m]=$.Blockly.Python.nameDB_.getName(l[m],$.module$exports$Blockly$Names.NameType.VARIABLE);c="def "+b+"("+k.join(", ")+"):\n"+c+d+e+f+h+g;c=$.Blockly.Python.scrub_(a,c);$.Blockly.Python.definitions_["%"+b]=c;
|
||||
return null};$.Blockly.Python.procedures_defnoreturn=$.Blockly.Python.procedures_defreturn;$.Blockly.Python.procedures_callreturn=function(a){for(var b=$.Blockly.Python.nameDB_.getName(a.getFieldValue("NAME"),$.module$exports$Blockly$Names.NameType.PROCEDURE),c=[],d=a.getVars(),e=0;e<d.length;e++)c[e]=$.Blockly.Python.valueToCode(a,"ARG"+e,$.Blockly.Python.ORDER_NONE)||"None";return[b+"("+c.join(", ")+")",$.Blockly.Python.ORDER_FUNCTION_CALL]};
|
||||
$.Blockly.Python.procedures_callnoreturn=function(a){return $.Blockly.Python.procedures_callreturn(a)[0]+"\n"};
|
||||
$.Blockly.Python.procedures_ifreturn=function(a){var b="if "+($.Blockly.Python.valueToCode(a,"CONDITION",$.Blockly.Python.ORDER_NONE)||"False")+":\n";$.Blockly.Python.STATEMENT_SUFFIX&&(b+=$.Blockly.Python.prefixLines($.Blockly.Python.injectId($.Blockly.Python.STATEMENT_SUFFIX,a),$.Blockly.Python.INDENT));a.hasReturnValue_?(a=$.Blockly.Python.valueToCode(a,"VALUE",$.Blockly.Python.ORDER_NONE)||"None",b+=$.Blockly.Python.INDENT+"return "+a+"\n"):b+=$.Blockly.Python.INDENT+"return\n";return b};var module$exports$Blockly$Python$math={};$.Blockly.Python.addReservedWords("math,random,Number");$.Blockly.Python.math_number=function(a){a=Number(a.getFieldValue("NUM"));if(Infinity===a){a='float("inf")';var b=$.Blockly.Python.ORDER_FUNCTION_CALL}else-Infinity===a?(a='-float("inf")',b=$.Blockly.Python.ORDER_UNARY_SIGN):b=0>a?$.Blockly.Python.ORDER_UNARY_SIGN:$.Blockly.Python.ORDER_ATOMIC;return[a,b]};
|
||||
$.Blockly.Python.math_arithmetic=function(a){var b={ADD:[" + ",$.Blockly.Python.ORDER_ADDITIVE],MINUS:[" - ",$.Blockly.Python.ORDER_ADDITIVE],MULTIPLY:[" * ",$.Blockly.Python.ORDER_MULTIPLICATIVE],DIVIDE:[" / ",$.Blockly.Python.ORDER_MULTIPLICATIVE],POWER:[" ** ",$.Blockly.Python.ORDER_EXPONENTIATION]}[a.getFieldValue("OP")],c=b[0];b=b[1];var d=$.Blockly.Python.valueToCode(a,"A",b)||"0";a=$.Blockly.Python.valueToCode(a,"B",b)||"0";return[d+c+a,b]};
|
||||
$.Blockly.Python.math_single=function(a){var b=a.getFieldValue("OP");if("NEG"===b){var c=$.Blockly.Python.valueToCode(a,"NUM",$.Blockly.Python.ORDER_UNARY_SIGN)||"0";return["-"+c,$.Blockly.Python.ORDER_UNARY_SIGN]}$.Blockly.Python.definitions_.import_math="import math";a="SIN"===b||"COS"===b||"TAN"===b?$.Blockly.Python.valueToCode(a,"NUM",$.Blockly.Python.ORDER_MULTIPLICATIVE)||"0":$.Blockly.Python.valueToCode(a,"NUM",$.Blockly.Python.ORDER_NONE)||"0";switch(b){case "ABS":c="math.fabs("+a+")";break;
|
||||
case "ROOT":c="math.sqrt("+a+")";break;case "LN":c="math.log("+a+")";break;case "LOG10":c="math.log10("+a+")";break;case "EXP":c="math.exp("+a+")";break;case "POW10":c="math.pow(10,"+a+")";break;case "ROUND":c="round("+a+")";break;case "ROUNDUP":c="math.ceil("+a+")";break;case "ROUNDDOWN":c="math.floor("+a+")";break;case "SIN":c="math.sin("+a+" / 180.0 * math.pi)";break;case "COS":c="math.cos("+a+" / 180.0 * math.pi)";break;case "TAN":c="math.tan("+a+" / 180.0 * math.pi)"}if(c)return[c,$.Blockly.Python.ORDER_FUNCTION_CALL];
|
||||
switch(b){case "ASIN":c="math.asin("+a+") / math.pi * 180";break;case "ACOS":c="math.acos("+a+") / math.pi * 180";break;case "ATAN":c="math.atan("+a+") / math.pi * 180";break;default:throw Error("Unknown math operator: "+b);}return[c,$.Blockly.Python.ORDER_MULTIPLICATIVE]};
|
||||
$.Blockly.Python.math_constant=function(a){var b={PI:["math.pi",$.Blockly.Python.ORDER_MEMBER],E:["math.e",$.Blockly.Python.ORDER_MEMBER],GOLDEN_RATIO:["(1 + math.sqrt(5)) / 2",$.Blockly.Python.ORDER_MULTIPLICATIVE],SQRT2:["math.sqrt(2)",$.Blockly.Python.ORDER_MEMBER],SQRT1_2:["math.sqrt(1.0 / 2)",$.Blockly.Python.ORDER_MEMBER],INFINITY:["float('inf')",$.Blockly.Python.ORDER_ATOMIC]};a=a.getFieldValue("CONSTANT");"INFINITY"!==a&&($.Blockly.Python.definitions_.import_math="import math");return b[a]};
|
||||
$.Blockly.Python.math_number_property=function(a){var b={EVEN:[" % 2 == 0",$.Blockly.Python.ORDER_MULTIPLICATIVE,$.Blockly.Python.ORDER_RELATIONAL],ODD:[" % 2 == 1",$.Blockly.Python.ORDER_MULTIPLICATIVE,$.Blockly.Python.ORDER_RELATIONAL],WHOLE:[" % 1 == 0",$.Blockly.Python.ORDER_MULTIPLICATIVE,$.Blockly.Python.ORDER_RELATIONAL],POSITIVE:[" > 0",$.Blockly.Python.ORDER_RELATIONAL,$.Blockly.Python.ORDER_RELATIONAL],NEGATIVE:[" < 0",$.Blockly.Python.ORDER_RELATIONAL,$.Blockly.Python.ORDER_RELATIONAL],
|
||||
DIVISIBLE_BY:[null,$.Blockly.Python.ORDER_MULTIPLICATIVE,$.Blockly.Python.ORDER_RELATIONAL],PRIME:[null,$.Blockly.Python.ORDER_NONE,$.Blockly.Python.ORDER_FUNCTION_CALL]},c=a.getFieldValue("PROPERTY");b=$.$jscomp.makeIterator(b[c]);var d=b.next().value,e=b.next().value;b=b.next().value;e=$.Blockly.Python.valueToCode(a,"NUMBER_TO_CHECK",e)||"0";if("PRIME"===c)$.Blockly.Python.definitions_.import_math="import math",$.Blockly.Python.definitions_.from_numbers_import_Number="from numbers import Number",
|
||||
a=$.Blockly.Python.provideFunction_("math_isPrime","\ndef "+$.Blockly.Python.FUNCTION_NAME_PLACEHOLDER_+"(n):\n # https://en.wikipedia.org/wiki/Primality_test#Naive_methods\n # If n is not a number but a string, try parsing it.\n if not isinstance(n, Number):\n try:\n n = float(n)\n except:\n return False\n if n == 2 or n == 3:\n return True\n # False if n is negative, is 1, or not whole, or if n is divisible by 2 or 3.\n if n <= 1 or n % 1 != 0 or n % 2 == 0 or n % 3 == 0:\n return False\n # Check all the numbers of form 6k +/- 1, up to sqrt(n).\n for x in range(6, int(math.sqrt(n)) + 2, 6):\n if n % (x - 1) == 0 or n % (x + 1) == 0:\n return False\n return True\n")+
|
||||
"("+e+")";else if("DIVISIBLE_BY"===c){a=$.Blockly.Python.valueToCode(a,"DIVISOR",$.Blockly.Python.ORDER_MULTIPLICATIVE)||"0";if("0"===a)return["False",$.Blockly.Python.ORDER_ATOMIC];a=e+" % "+a+" == 0"}else a=e+d;return[a,b]};
|
||||
$.Blockly.Python.math_change=function(a){$.Blockly.Python.definitions_.from_numbers_import_Number="from numbers import Number";var b=$.Blockly.Python.valueToCode(a,"DELTA",$.Blockly.Python.ORDER_ADDITIVE)||"0";a=$.Blockly.Python.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE);return a+" = ("+a+" if isinstance("+a+", Number) else 0) + "+b+"\n"};$.Blockly.Python.math_round=$.Blockly.Python.math_single;$.Blockly.Python.math_trig=$.Blockly.Python.math_single;
|
||||
$.Blockly.Python.math_on_list=function(a){var b=a.getFieldValue("OP");a=$.Blockly.Python.valueToCode(a,"LIST",$.Blockly.Python.ORDER_NONE)||"[]";switch(b){case "SUM":b="sum("+a+")";break;case "MIN":b="min("+a+")";break;case "MAX":b="max("+a+")";break;case "AVERAGE":$.Blockly.Python.definitions_.from_numbers_import_Number="from numbers import Number";b=$.Blockly.Python.provideFunction_("math_mean","\ndef "+$.Blockly.Python.FUNCTION_NAME_PLACEHOLDER_+"(myList):\n localList = [e for e in myList if isinstance(e, Number)]\n if not localList: return\n return float(sum(localList)) / len(localList)\n")+
|
||||
"("+a+")";break;case "MEDIAN":$.Blockly.Python.definitions_.from_numbers_import_Number="from numbers import Number";b=$.Blockly.Python.provideFunction_("math_median","\ndef "+$.Blockly.Python.FUNCTION_NAME_PLACEHOLDER_+"(myList):\n localList = sorted([e for e in myList if isinstance(e, Number)])\n if not localList: return\n if len(localList) % 2 == 0:\n return (localList[len(localList) // 2 - 1] + localList[len(localList) // 2]) / 2.0\n else:\n return localList[(len(localList) - 1) // 2]\n")+
|
||||
"("+a+")";break;case "MODE":b=$.Blockly.Python.provideFunction_("math_modes","\ndef "+$.Blockly.Python.FUNCTION_NAME_PLACEHOLDER_+'(some_list):\n modes = []\n # Using a lists of [item, count] to keep count rather than dict\n # to avoid "unhashable" errors when the counted item is itself a list or dict.\n counts = []\n maxCount = 1\n for item in some_list:\n found = False\n for count in counts:\n if count[0] == item:\n count[1] += 1\n maxCount = max(maxCount, count[1])\n found = True\n if not found:\n counts.append([item, 1])\n for counted_item, item_count in counts:\n if item_count == maxCount:\n modes.append(counted_item)\n return modes\n')+
|
||||
"("+a+")";break;case "STD_DEV":$.Blockly.Python.definitions_.import_math="import math";b=$.Blockly.Python.provideFunction_("math_standard_deviation","\ndef "+$.Blockly.Python.FUNCTION_NAME_PLACEHOLDER_+"(numbers):\n n = len(numbers)\n if n == 0: return\n mean = float(sum(numbers)) / n\n variance = sum((x - mean) ** 2 for x in numbers) / n\n return math.sqrt(variance)\n")+"("+a+")";break;case "RANDOM":$.Blockly.Python.definitions_.import_random="import random";b="random.choice("+a+")";break;default:throw Error("Unknown operator: "+
|
||||
b);}return[b,$.Blockly.Python.ORDER_FUNCTION_CALL]};$.Blockly.Python.math_modulo=function(a){var b=$.Blockly.Python.valueToCode(a,"DIVIDEND",$.Blockly.Python.ORDER_MULTIPLICATIVE)||"0";a=$.Blockly.Python.valueToCode(a,"DIVISOR",$.Blockly.Python.ORDER_MULTIPLICATIVE)||"0";return[b+" % "+a,$.Blockly.Python.ORDER_MULTIPLICATIVE]};
|
||||
$.Blockly.Python.math_constrain=function(a){var b=$.Blockly.Python.valueToCode(a,"VALUE",$.Blockly.Python.ORDER_NONE)||"0",c=$.Blockly.Python.valueToCode(a,"LOW",$.Blockly.Python.ORDER_NONE)||"0";a=$.Blockly.Python.valueToCode(a,"HIGH",$.Blockly.Python.ORDER_NONE)||"float('inf')";return["min(max("+b+", "+c+"), "+a+")",$.Blockly.Python.ORDER_FUNCTION_CALL]};
|
||||
$.Blockly.Python.math_random_int=function(a){$.Blockly.Python.definitions_.import_random="import random";var b=$.Blockly.Python.valueToCode(a,"FROM",$.Blockly.Python.ORDER_NONE)||"0";a=$.Blockly.Python.valueToCode(a,"TO",$.Blockly.Python.ORDER_NONE)||"0";return["random.randint("+b+", "+a+")",$.Blockly.Python.ORDER_FUNCTION_CALL]};$.Blockly.Python.math_random_float=function(a){$.Blockly.Python.definitions_.import_random="import random";return["random.random()",$.Blockly.Python.ORDER_FUNCTION_CALL]};
|
||||
$.Blockly.Python.math_atan2=function(a){$.Blockly.Python.definitions_.import_math="import math";var b=$.Blockly.Python.valueToCode(a,"X",$.Blockly.Python.ORDER_NONE)||"0";return["math.atan2("+($.Blockly.Python.valueToCode(a,"Y",$.Blockly.Python.ORDER_NONE)||"0")+", "+b+") / math.pi * 180",$.Blockly.Python.ORDER_MULTIPLICATIVE]};var module$exports$Blockly$Python$loops={};
|
||||
$.Blockly.Python.controls_repeat_ext=function(a){var b=a.getField("TIMES")?String(parseInt(a.getFieldValue("TIMES"),10)):$.Blockly.Python.valueToCode(a,"TIMES",$.Blockly.Python.ORDER_NONE)||"0";b=(0,$.module$exports$Blockly$utils$string.isNumber)(b)?parseInt(b,10):"int("+b+")";var c=$.Blockly.Python.statementToCode(a,"DO");c=$.Blockly.Python.addLoopTrap(c,a)||$.Blockly.Python.PASS;return"for "+$.Blockly.Python.nameDB_.getDistinctName("count",$.module$exports$Blockly$Names.NameType.VARIABLE)+" in range("+
|
||||
b+"):\n"+c};$.Blockly.Python.controls_repeat=$.Blockly.Python.controls_repeat_ext;$.Blockly.Python.controls_whileUntil=function(a){var b="UNTIL"===a.getFieldValue("MODE"),c=$.Blockly.Python.valueToCode(a,"BOOL",b?$.Blockly.Python.ORDER_LOGICAL_NOT:$.Blockly.Python.ORDER_NONE)||"False",d=$.Blockly.Python.statementToCode(a,"DO");d=$.Blockly.Python.addLoopTrap(d,a)||$.Blockly.Python.PASS;b&&(c="not "+c);return"while "+c+":\n"+d};
|
||||
$.Blockly.Python.controls_for=function(a){var b=$.Blockly.Python.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE),c=$.Blockly.Python.valueToCode(a,"FROM",$.Blockly.Python.ORDER_NONE)||"0",d=$.Blockly.Python.valueToCode(a,"TO",$.Blockly.Python.ORDER_NONE)||"0",e=$.Blockly.Python.valueToCode(a,"BY",$.Blockly.Python.ORDER_NONE)||"1",f=$.Blockly.Python.statementToCode(a,"DO");f=$.Blockly.Python.addLoopTrap(f,a)||$.Blockly.Python.PASS;var g="";a=function(){return $.Blockly.Python.provideFunction_("upRange",
|
||||
"\ndef "+$.Blockly.Python.FUNCTION_NAME_PLACEHOLDER_+"(start, stop, step):\n while start <= stop:\n yield start\n start += abs(step)\n")};var h=function(){return $.Blockly.Python.provideFunction_("downRange","\ndef "+$.Blockly.Python.FUNCTION_NAME_PLACEHOLDER_+"(start, stop, step):\n while start >= stop:\n yield start\n start -= abs(step)\n")};if((0,$.module$exports$Blockly$utils$string.isNumber)(c)&&(0,$.module$exports$Blockly$utils$string.isNumber)(d)&&(0,$.module$exports$Blockly$utils$string.isNumber)(e))c=
|
||||
Number(c),d=Number(d),e=Math.abs(Number(e)),0===c%1&&0===d%1&&0===e%1?(c<=d?(d++,a=0===c&&1===e?d:c+", "+d,1!==e&&(a+=", "+e)):(d--,a=c+", "+d+", -"+e),a="range("+a+")"):(a=c<d?a():h(),a+="("+c+", "+d+", "+e+")");else{var k=function(l,m){(0,$.module$exports$Blockly$utils$string.isNumber)(l)?l=Number(l):l.match(/^\w+$/)?l="float("+l+")":(m=$.Blockly.Python.nameDB_.getDistinctName(b+m,$.module$exports$Blockly$Names.NameType.VARIABLE),g+=m+" = float("+l+")\n",l=m);return l};c=k(c,"_start");d=k(d,"_end");
|
||||
e=k(e,"_inc");"number"===typeof c&&"number"===typeof d?(a=c<d?a():h(),a+="("+c+", "+d+", "+e+")"):a="("+c+" <= "+d+") and "+a()+"("+c+", "+d+", "+e+") or "+h()+"("+c+", "+d+", "+e+")"}return g+="for "+b+" in "+a+":\n"+f};
|
||||
$.Blockly.Python.controls_forEach=function(a){var b=$.Blockly.Python.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE),c=$.Blockly.Python.valueToCode(a,"LIST",$.Blockly.Python.ORDER_RELATIONAL)||"[]",d=$.Blockly.Python.statementToCode(a,"DO");d=$.Blockly.Python.addLoopTrap(d,a)||$.Blockly.Python.PASS;return"for "+b+" in "+c+":\n"+d};
|
||||
$.Blockly.Python.controls_flow_statements=function(a){var b="";$.Blockly.Python.STATEMENT_PREFIX&&(b+=$.Blockly.Python.injectId($.Blockly.Python.STATEMENT_PREFIX,a));$.Blockly.Python.STATEMENT_SUFFIX&&(b+=$.Blockly.Python.injectId($.Blockly.Python.STATEMENT_SUFFIX,a));if($.Blockly.Python.STATEMENT_PREFIX){var c=a.getSurroundLoop();c&&!c.suppressPrefixSuffix&&(b+=$.Blockly.Python.injectId($.Blockly.Python.STATEMENT_PREFIX,c))}switch(a.getFieldValue("FLOW")){case "BREAK":return b+"break\n";case "CONTINUE":return b+
|
||||
"continue\n"}throw Error("Unknown flow statement.");};var module$exports$Blockly$Python$logic={};
|
||||
$.Blockly.Python.controls_if=function(a){var b=0,c="";$.Blockly.Python.STATEMENT_PREFIX&&(c+=$.Blockly.Python.injectId($.Blockly.Python.STATEMENT_PREFIX,a));do{var d=$.Blockly.Python.valueToCode(a,"IF"+b,$.Blockly.Python.ORDER_NONE)||"False";var e=$.Blockly.Python.statementToCode(a,"DO"+b)||$.Blockly.Python.PASS;$.Blockly.Python.STATEMENT_SUFFIX&&(e=$.Blockly.Python.prefixLines($.Blockly.Python.injectId($.Blockly.Python.STATEMENT_SUFFIX,a),$.Blockly.Python.INDENT)+e);c+=(0===b?"if ":"elif ")+d+":\n"+
|
||||
e;b++}while(a.getInput("IF"+b));if(a.getInput("ELSE")||$.Blockly.Python.STATEMENT_SUFFIX)e=$.Blockly.Python.statementToCode(a,"ELSE")||$.Blockly.Python.PASS,$.Blockly.Python.STATEMENT_SUFFIX&&(e=$.Blockly.Python.prefixLines($.Blockly.Python.injectId($.Blockly.Python.STATEMENT_SUFFIX,a),$.Blockly.Python.INDENT)+e),c+="else:\n"+e;return c};$.Blockly.Python.controls_ifelse=$.Blockly.Python.controls_if;
|
||||
$.Blockly.Python.logic_compare=function(a){var b={EQ:"==",NEQ:"!=",LT:"<",LTE:"<=",GT:">",GTE:">="}[a.getFieldValue("OP")],c=$.Blockly.Python.ORDER_RELATIONAL,d=$.Blockly.Python.valueToCode(a,"A",c)||"0";a=$.Blockly.Python.valueToCode(a,"B",c)||"0";return[d+" "+b+" "+a,c]};
|
||||
$.Blockly.Python.logic_operation=function(a){var b="AND"===a.getFieldValue("OP")?"and":"or",c="and"===b?$.Blockly.Python.ORDER_LOGICAL_AND:$.Blockly.Python.ORDER_LOGICAL_OR,d=$.Blockly.Python.valueToCode(a,"A",c);a=$.Blockly.Python.valueToCode(a,"B",c);if(d||a){var e="and"===b?"True":"False";d||(d=e);a||(a=e)}else a=d="False";return[d+" "+b+" "+a,c]};$.Blockly.Python.logic_negate=function(a){return["not "+($.Blockly.Python.valueToCode(a,"BOOL",$.Blockly.Python.ORDER_LOGICAL_NOT)||"True"),$.Blockly.Python.ORDER_LOGICAL_NOT]};
|
||||
$.Blockly.Python.logic_boolean=function(a){return["TRUE"===a.getFieldValue("BOOL")?"True":"False",$.Blockly.Python.ORDER_ATOMIC]};$.Blockly.Python.logic_null=function(a){return["None",$.Blockly.Python.ORDER_ATOMIC]};
|
||||
$.Blockly.Python.logic_ternary=function(a){var b=$.Blockly.Python.valueToCode(a,"IF",$.Blockly.Python.ORDER_CONDITIONAL)||"False",c=$.Blockly.Python.valueToCode(a,"THEN",$.Blockly.Python.ORDER_CONDITIONAL)||"None";a=$.Blockly.Python.valueToCode(a,"ELSE",$.Blockly.Python.ORDER_CONDITIONAL)||"None";return[c+" if "+b+" else "+a,$.Blockly.Python.ORDER_CONDITIONAL]};var module$exports$Blockly$Python$lists={};$.Blockly.Python.lists_create_empty=function(a){return["[]",$.Blockly.Python.ORDER_ATOMIC]};$.Blockly.Python.lists_create_with=function(a){for(var b=Array(a.itemCount_),c=0;c<a.itemCount_;c++)b[c]=$.Blockly.Python.valueToCode(a,"ADD"+c,$.Blockly.Python.ORDER_NONE)||"None";return["["+b.join(", ")+"]",$.Blockly.Python.ORDER_ATOMIC]};
|
||||
$.Blockly.Python.lists_repeat=function(a){var b=$.Blockly.Python.valueToCode(a,"ITEM",$.Blockly.Python.ORDER_NONE)||"None";a=$.Blockly.Python.valueToCode(a,"NUM",$.Blockly.Python.ORDER_MULTIPLICATIVE)||"0";return["["+b+"] * "+a,$.Blockly.Python.ORDER_MULTIPLICATIVE]};$.Blockly.Python.lists_length=function(a){return["len("+($.Blockly.Python.valueToCode(a,"VALUE",$.Blockly.Python.ORDER_NONE)||"[]")+")",$.Blockly.Python.ORDER_FUNCTION_CALL]};
|
||||
$.Blockly.Python.lists_isEmpty=function(a){return["not len("+($.Blockly.Python.valueToCode(a,"VALUE",$.Blockly.Python.ORDER_NONE)||"[]")+")",$.Blockly.Python.ORDER_LOGICAL_NOT]};
|
||||
$.Blockly.Python.lists_indexOf=function(a){var b=$.Blockly.Python.valueToCode(a,"FIND",$.Blockly.Python.ORDER_NONE)||"[]",c=$.Blockly.Python.valueToCode(a,"VALUE",$.Blockly.Python.ORDER_NONE)||"''",d=" -1",e="",f=" - 1";a.workspace.options.oneBasedIndex&&(d=" 0",e=" + 1",f="");return[("FIRST"===a.getFieldValue("END")?$.Blockly.Python.provideFunction_("first_index","\ndef "+$.Blockly.Python.FUNCTION_NAME_PLACEHOLDER_+"(my_list, elem):\n try: index = my_list.index(elem)"+e+"\n except: index ="+d+
|
||||
"\n return index\n"):$.Blockly.Python.provideFunction_("last_index","\ndef "+$.Blockly.Python.FUNCTION_NAME_PLACEHOLDER_+"(my_list, elem):\n try: index = len(my_list) - my_list[::-1].index(elem)"+f+"\n except: index ="+d+"\n return index\n"))+"("+c+", "+b+")",$.Blockly.Python.ORDER_FUNCTION_CALL]};
|
||||
$.Blockly.Python.lists_getIndex=function(a){var b=a.getFieldValue("MODE")||"GET",c=a.getFieldValue("WHERE")||"FROM_START",d=$.Blockly.Python.valueToCode(a,"VALUE","RANDOM"===c?$.Blockly.Python.ORDER_NONE:$.Blockly.Python.ORDER_MEMBER)||"[]";switch(c){case "FIRST":if("GET"===b)return[d+"[0]",$.Blockly.Python.ORDER_MEMBER];if("GET_REMOVE"===b)return[d+".pop(0)",$.Blockly.Python.ORDER_FUNCTION_CALL];if("REMOVE"===b)return d+".pop(0)\n";break;case "LAST":if("GET"===b)return[d+"[-1]",$.Blockly.Python.ORDER_MEMBER];
|
||||
if("GET_REMOVE"===b)return[d+".pop()",$.Blockly.Python.ORDER_FUNCTION_CALL];if("REMOVE"===b)return d+".pop()\n";break;case "FROM_START":a=$.Blockly.Python.getAdjustedInt(a,"AT");if("GET"===b)return[d+"["+a+"]",$.Blockly.Python.ORDER_MEMBER];if("GET_REMOVE"===b)return[d+".pop("+a+")",$.Blockly.Python.ORDER_FUNCTION_CALL];if("REMOVE"===b)return d+".pop("+a+")\n";break;case "FROM_END":a=$.Blockly.Python.getAdjustedInt(a,"AT",1,!0);if("GET"===b)return[d+"["+a+"]",$.Blockly.Python.ORDER_MEMBER];if("GET_REMOVE"===
|
||||
b)return[d+".pop("+a+")",$.Blockly.Python.ORDER_FUNCTION_CALL];if("REMOVE"===b)return d+".pop("+a+")\n";break;case "RANDOM":$.Blockly.Python.definitions_.import_random="import random";if("GET"===b)return["random.choice("+d+")",$.Blockly.Python.ORDER_FUNCTION_CALL];d=$.Blockly.Python.provideFunction_("lists_remove_random_item","\ndef "+$.Blockly.Python.FUNCTION_NAME_PLACEHOLDER_+"(myList):\n x = int(random.random() * len(myList))\n return myList.pop(x)\n")+"("+d+")";if("GET_REMOVE"===b)return[d,
|
||||
$.Blockly.Python.ORDER_FUNCTION_CALL];if("REMOVE"===b)return d+"\n"}throw Error("Unhandled combination (lists_getIndex).");};
|
||||
$.Blockly.Python.lists_setIndex=function(a){var b=$.Blockly.Python.valueToCode(a,"LIST",$.Blockly.Python.ORDER_MEMBER)||"[]",c=a.getFieldValue("MODE")||"GET",d=a.getFieldValue("WHERE")||"FROM_START",e=$.Blockly.Python.valueToCode(a,"TO",$.Blockly.Python.ORDER_NONE)||"None";switch(d){case "FIRST":if("SET"===c)return b+"[0] = "+e+"\n";if("INSERT"===c)return b+".insert(0, "+e+")\n";break;case "LAST":if("SET"===c)return b+"[-1] = "+e+"\n";if("INSERT"===c)return b+".append("+e+")\n";break;case "FROM_START":a=
|
||||
$.Blockly.Python.getAdjustedInt(a,"AT");if("SET"===c)return b+"["+a+"] = "+e+"\n";if("INSERT"===c)return b+".insert("+a+", "+e+")\n";break;case "FROM_END":a=$.Blockly.Python.getAdjustedInt(a,"AT",1,!0);if("SET"===c)return b+"["+a+"] = "+e+"\n";if("INSERT"===c)return b+".insert("+a+", "+e+")\n";break;case "RANDOM":$.Blockly.Python.definitions_.import_random="import random";b.match(/^\w+$/)?a="":(a=$.Blockly.Python.nameDB_.getDistinctName("tmp_list",$.module$exports$Blockly$Names.NameType.VARIABLE),
|
||||
d=a+" = "+b+"\n",b=a,a=d);d=$.Blockly.Python.nameDB_.getDistinctName("tmp_x",$.module$exports$Blockly$Names.NameType.VARIABLE);a+=d+" = int(random.random() * len("+b+"))\n";if("SET"===c)return a+(b+"["+d+"] = "+e+"\n");if("INSERT"===c)return a+(b+".insert("+d+", "+e+")\n")}throw Error("Unhandled combination (lists_setIndex).");};
|
||||
$.Blockly.Python.lists_getSublist=function(a){var b=$.Blockly.Python.valueToCode(a,"LIST",$.Blockly.Python.ORDER_MEMBER)||"[]",c=a.getFieldValue("WHERE1"),d=a.getFieldValue("WHERE2");switch(c){case "FROM_START":c=$.Blockly.Python.getAdjustedInt(a,"AT1");0===c&&(c="");break;case "FROM_END":c=$.Blockly.Python.getAdjustedInt(a,"AT1",1,!0);break;case "FIRST":c="";break;default:throw Error("Unhandled option (lists_getSublist)");}switch(d){case "FROM_START":a=$.Blockly.Python.getAdjustedInt(a,"AT2",1);
|
||||
break;case "FROM_END":a=$.Blockly.Python.getAdjustedInt(a,"AT2",0,!0);(0,$.module$exports$Blockly$utils$string.isNumber)(String(a))?0===a&&(a=""):($.Blockly.Python.definitions_.import_sys="import sys",a+=" or sys.maxsize");break;case "LAST":a="";break;default:throw Error("Unhandled option (lists_getSublist)");}return[b+"["+c+" : "+a+"]",$.Blockly.Python.ORDER_MEMBER]};
|
||||
$.Blockly.Python.lists_sort=function(a){var b=$.Blockly.Python.valueToCode(a,"LIST",$.Blockly.Python.ORDER_NONE)||"[]",c=a.getFieldValue("TYPE");a="1"===a.getFieldValue("DIRECTION")?"False":"True";return[$.Blockly.Python.provideFunction_("lists_sort","\ndef "+$.Blockly.Python.FUNCTION_NAME_PLACEHOLDER_+'(my_list, type, reverse):\n def try_float(s):\n try:\n return float(s)\n except:\n return 0\n key_funcs = {\n "NUMERIC": try_float,\n "TEXT": str,\n "IGNORE_CASE": lambda s: str(s).lower()\n }\n key_func = key_funcs[type]\n list_cpy = list(my_list)\n return sorted(list_cpy, key=key_func, reverse=reverse)\n')+
|
||||
"("+b+', "'+c+'", '+a+")",$.Blockly.Python.ORDER_FUNCTION_CALL]};
|
||||
$.Blockly.Python.lists_split=function(a){var b=a.getFieldValue("MODE");if("SPLIT"===b)b=$.Blockly.Python.valueToCode(a,"INPUT",$.Blockly.Python.ORDER_MEMBER)||"''",a=$.Blockly.Python.valueToCode(a,"DELIM",$.Blockly.Python.ORDER_NONE),a=b+".split("+a+")";else if("JOIN"===b)b=$.Blockly.Python.valueToCode(a,"INPUT",$.Blockly.Python.ORDER_NONE)||"[]",a=($.Blockly.Python.valueToCode(a,"DELIM",$.Blockly.Python.ORDER_MEMBER)||"''")+".join("+b+")";else throw Error("Unknown mode: "+b);return[a,$.Blockly.Python.ORDER_FUNCTION_CALL]};
|
||||
$.Blockly.Python.lists_reverse=function(a){return["list(reversed("+($.Blockly.Python.valueToCode(a,"LIST",$.Blockly.Python.ORDER_NONE)||"[]")+"))",$.Blockly.Python.ORDER_FUNCTION_CALL]};var module$exports$Blockly$Python$colour={};$.Blockly.Python.colour_picker=function(a){return[$.Blockly.Python.quote_(a.getFieldValue("COLOUR")),$.Blockly.Python.ORDER_ATOMIC]};$.Blockly.Python.colour_random=function(a){$.Blockly.Python.definitions_.import_random="import random";return["'#%06x' % random.randint(0, 2**24 - 1)",$.Blockly.Python.ORDER_FUNCTION_CALL]};
|
||||
$.Blockly.Python.colour_rgb=function(a){var b=$.Blockly.Python.provideFunction_("colour_rgb","\ndef "+$.Blockly.Python.FUNCTION_NAME_PLACEHOLDER_+"(r, g, b):\n r = round(min(100, max(0, r)) * 2.55)\n g = round(min(100, max(0, g)) * 2.55)\n b = round(min(100, max(0, b)) * 2.55)\n return '#%02x%02x%02x' % (r, g, b)\n"),c=$.Blockly.Python.valueToCode(a,"RED",$.Blockly.Python.ORDER_NONE)||0,d=$.Blockly.Python.valueToCode(a,"GREEN",$.Blockly.Python.ORDER_NONE)||0;a=$.Blockly.Python.valueToCode(a,"BLUE",
|
||||
$.Blockly.Python.ORDER_NONE)||0;return[b+"("+c+", "+d+", "+a+")",$.Blockly.Python.ORDER_FUNCTION_CALL]};
|
||||
$.Blockly.Python.colour_blend=function(a){var b=$.Blockly.Python.provideFunction_("colour_blend","\ndef "+$.Blockly.Python.FUNCTION_NAME_PLACEHOLDER_+"(colour1, colour2, ratio):\n r1, r2 = int(colour1[1:3], 16), int(colour2[1:3], 16)\n g1, g2 = int(colour1[3:5], 16), int(colour2[3:5], 16)\n b1, b2 = int(colour1[5:7], 16), int(colour2[5:7], 16)\n ratio = min(1, max(0, ratio))\n r = round(r1 * (1 - ratio) + r2 * ratio)\n g = round(g1 * (1 - ratio) + g2 * ratio)\n b = round(b1 * (1 - ratio) + b2 * ratio)\n return '#%02x%02x%02x' % (r, g, b)\n"),c=
|
||||
$.Blockly.Python.valueToCode(a,"COLOUR1",$.Blockly.Python.ORDER_NONE)||"'#000000'",d=$.Blockly.Python.valueToCode(a,"COLOUR2",$.Blockly.Python.ORDER_NONE)||"'#000000'";a=$.Blockly.Python.valueToCode(a,"RATIO",$.Blockly.Python.ORDER_NONE)||0;return[b+"("+c+", "+d+", "+a+")",$.Blockly.Python.ORDER_FUNCTION_CALL]};var module$exports$Blockly$Python$all={};
|
||||
$.Blockly.Python.__namespace__=$;
|
||||
return $.Blockly.Python;
|
||||
var module$exports$Blockly$Python={},module$contents$Blockly$Python_stringUtils=$.module$build$src$core$utils$string,module$contents$Blockly$Python_Variables=$.module$build$src$core$variables,module$contents$Blockly$Python_Generator=$.Generator$$module$build$src$core$generator,module$contents$Blockly$Python_inputTypes=$.module$build$src$core$input_types.inputTypes,module$contents$Blockly$Python_Names=$.module$build$src$core$names.Names,module$contents$Blockly$Python_NameType=$.NameType$$module$build$src$core$names;
|
||||
module$exports$Blockly$Python.pythonGenerator=new $.Generator$$module$build$src$core$generator("Python");module$exports$Blockly$Python.pythonGenerator.addReservedWords("False,None,True,and,as,assert,break,class,continue,def,del,elif,else,except,exec,finally,for,from,global,if,import,in,is,lambda,nonlocal,not,or,pass,print,raise,return,try,while,with,yield,NotImplemented,Ellipsis,__debug__,quit,exit,copyright,license,credits,ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EnvironmentError,Exception,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StandardError,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,ZeroDivisionError,_,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,all,any,apply,ascii,basestring,bin,bool,buffer,bytearray,bytes,callable,chr,classmethod,cmp,coerce,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,execfile,exit,file,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,intern,isinstance,issubclass,iter,len,license,list,locals,long,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,raw_input,reduce,reload,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,unichr,unicode,vars,xrange,zip");
|
||||
module$exports$Blockly$Python.pythonGenerator.ORDER_ATOMIC=0;module$exports$Blockly$Python.pythonGenerator.ORDER_COLLECTION=1;module$exports$Blockly$Python.pythonGenerator.ORDER_STRING_CONVERSION=1;module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER=2.1;module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL=2.2;module$exports$Blockly$Python.pythonGenerator.ORDER_EXPONENTIATION=3;module$exports$Blockly$Python.pythonGenerator.ORDER_UNARY_SIGN=4;
|
||||
module$exports$Blockly$Python.pythonGenerator.ORDER_BITWISE_NOT=4;module$exports$Blockly$Python.pythonGenerator.ORDER_MULTIPLICATIVE=5;module$exports$Blockly$Python.pythonGenerator.ORDER_ADDITIVE=6;module$exports$Blockly$Python.pythonGenerator.ORDER_BITWISE_SHIFT=7;module$exports$Blockly$Python.pythonGenerator.ORDER_BITWISE_AND=8;module$exports$Blockly$Python.pythonGenerator.ORDER_BITWISE_XOR=9;module$exports$Blockly$Python.pythonGenerator.ORDER_BITWISE_OR=10;
|
||||
module$exports$Blockly$Python.pythonGenerator.ORDER_RELATIONAL=11;module$exports$Blockly$Python.pythonGenerator.ORDER_LOGICAL_NOT=12;module$exports$Blockly$Python.pythonGenerator.ORDER_LOGICAL_AND=13;module$exports$Blockly$Python.pythonGenerator.ORDER_LOGICAL_OR=14;module$exports$Blockly$Python.pythonGenerator.ORDER_CONDITIONAL=15;module$exports$Blockly$Python.pythonGenerator.ORDER_LAMBDA=16;module$exports$Blockly$Python.pythonGenerator.ORDER_NONE=99;
|
||||
module$exports$Blockly$Python.pythonGenerator.ORDER_OVERRIDES=[[module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL,module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER],[module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL,module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL],[module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER,module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER],[module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER,
|
||||
module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL],[module$exports$Blockly$Python.pythonGenerator.ORDER_LOGICAL_NOT,module$exports$Blockly$Python.pythonGenerator.ORDER_LOGICAL_NOT],[module$exports$Blockly$Python.pythonGenerator.ORDER_LOGICAL_AND,module$exports$Blockly$Python.pythonGenerator.ORDER_LOGICAL_AND],[module$exports$Blockly$Python.pythonGenerator.ORDER_LOGICAL_OR,module$exports$Blockly$Python.pythonGenerator.ORDER_LOGICAL_OR]];
|
||||
module$exports$Blockly$Python.pythonGenerator.isInitialized=!1;
|
||||
module$exports$Blockly$Python.pythonGenerator.init=function(a){Object.getPrototypeOf(this).init.call(this);this.PASS=this.INDENT+"pass\n";this.nameDB_?this.nameDB_.reset():this.nameDB_=new $.module$build$src$core$names.Names(this.RESERVED_WORDS_);this.nameDB_.setVariableMap(a.getVariableMap());this.nameDB_.populateVariables(a);this.nameDB_.populateProcedures(a);const b=[];var c=$.module$build$src$core$variables.allDeveloperVariables(a);for(let d=0;d<c.length;d++)b.push(this.nameDB_.getName(c[d],$.module$build$src$core$names.Names.DEVELOPER_VARIABLE_TYPE)+
|
||||
" = None");a=$.module$build$src$core$variables.allUsedVarModels(a);for(c=0;c<a.length;c++)b.push(this.nameDB_.getName(a[c].getId(),$.NameType$$module$build$src$core$names.VARIABLE)+" = None");this.definitions_.variables=b.join("\n");this.isInitialized=!0};
|
||||
module$exports$Blockly$Python.pythonGenerator.finish=function(a){const b=[],c=[];for(let d in this.definitions_){const e=this.definitions_[d];e.match(/^(from\s+\S+\s+)?import\s+\S+/)?b.push(e):c.push(e)}a=Object.getPrototypeOf(this).finish.call(this,a);this.isInitialized=!1;this.nameDB_.reset();return(b.join("\n")+"\n\n"+c.join("\n\n")).replace(/\n\n+/g,"\n\n").replace(/\n*$/,"\n\n\n")+a};module$exports$Blockly$Python.pythonGenerator.scrubNakedValue=function(a){return a+"\n"};
|
||||
module$exports$Blockly$Python.pythonGenerator.quote_=function(a){a=a.replace(/\\/g,"\\\\").replace(/\n/g,"\\\n");let b="'";-1!==a.indexOf("'")&&(-1===a.indexOf('"')?b='"':a=a.replace(/'/g,"\\'"));return b+a+b};module$exports$Blockly$Python.pythonGenerator.multiline_quote_=function(a){return a.split(/\n/g).map(this.quote_).join(" + '\\n' + \n")};
|
||||
module$exports$Blockly$Python.pythonGenerator.scrub_=function(a,b,c){let d="";if(!a.outputConnection||!a.outputConnection.targetConnection){var e=a.getCommentText();e&&(e=$.module$build$src$core$utils$string.wrap(e,this.COMMENT_WRAP-3),d+=this.prefixLines(e+"\n","# "));for(let f=0;f<a.inputList.length;f++)a.inputList[f].type===$.module$build$src$core$input_types.inputTypes.VALUE&&(e=a.inputList[f].connection.targetBlock())&&(e=this.allNestedComments(e))&&(d+=this.prefixLines(e,"# "))}a=a.nextConnection&&
|
||||
a.nextConnection.targetBlock();c=c?"":this.blockToCode(a);return d+b+c};module$exports$Blockly$Python.pythonGenerator.getAdjustedInt=function(a,b,c,d){c=c||0;a.workspace.options.oneBasedIndex&&c--;const e=a.workspace.options.oneBasedIndex?"1":"0";a=this.valueToCode(a,b,c?this.ORDER_ADDITIVE:this.ORDER_NONE)||e;$.module$build$src$core$utils$string.isNumber(a)?(a=parseInt(a,10)+c,d&&(a=-a)):(a=0<c?"int("+a+" + "+c+")":0>c?"int("+a+" - "+-c+")":"int("+a+")",d&&(a="-"+a));return a};var module$exports$Blockly$Python$variables={},module$contents$Blockly$Python$variables_NameType=$.NameType$$module$build$src$core$names;module$exports$Blockly$Python.pythonGenerator.variables_get=function(a){return[module$exports$Blockly$Python.pythonGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE),module$exports$Blockly$Python.pythonGenerator.ORDER_ATOMIC]};
|
||||
module$exports$Blockly$Python.pythonGenerator.variables_set=function(a){const b=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"0";return module$exports$Blockly$Python.pythonGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE)+" = "+b+"\n"};var module$exports$Blockly$Python$variablesDynamic={};module$exports$Blockly$Python.pythonGenerator.variables_get_dynamic=module$exports$Blockly$Python.pythonGenerator.variables_get;module$exports$Blockly$Python.pythonGenerator.variables_set_dynamic=module$exports$Blockly$Python.pythonGenerator.variables_set;var module$exports$Blockly$Python$texts={},module$contents$Blockly$Python$texts_stringUtils=$.module$build$src$core$utils$string,module$contents$Blockly$Python$texts_NameType=$.NameType$$module$build$src$core$names;module$exports$Blockly$Python.pythonGenerator.text=function(a){return[module$exports$Blockly$Python.pythonGenerator.quote_(a.getFieldValue("TEXT")),module$exports$Blockly$Python.pythonGenerator.ORDER_ATOMIC]};
|
||||
module$exports$Blockly$Python.pythonGenerator.text_multiline=function(a){a=module$exports$Blockly$Python.pythonGenerator.multiline_quote_(a.getFieldValue("TEXT"));const b=-1!==a.indexOf("+")?module$exports$Blockly$Python.pythonGenerator.ORDER_ADDITIVE:module$exports$Blockly$Python.pythonGenerator.ORDER_ATOMIC;return[a,b]};
|
||||
var module$contents$Blockly$Python$texts_strRegExp=/^\s*'([^']|\\')*'\s*$/,module$contents$Blockly$Python$texts_forceString=function(a){return module$contents$Blockly$Python$texts_strRegExp.test(a)?[a,module$exports$Blockly$Python.pythonGenerator.ORDER_ATOMIC]:["str("+a+")",module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$Python.pythonGenerator.text_join=function(a){switch(a.itemCount_){case 0:return["''",module$exports$Blockly$Python.pythonGenerator.ORDER_ATOMIC];case 1:return a=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"ADD0",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"''",module$contents$Blockly$Python$texts_forceString(a);case 2:var b=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"ADD0",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||
|
||||
"''";a=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"ADD1",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"''";return[module$contents$Blockly$Python$texts_forceString(b)[0]+" + "+module$contents$Blockly$Python$texts_forceString(a)[0],module$exports$Blockly$Python.pythonGenerator.ORDER_ADDITIVE];default:b=[];for(let c=0;c<a.itemCount_;c++)b[c]=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"ADD"+c,module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"''";
|
||||
a=module$exports$Blockly$Python.pythonGenerator.nameDB_.getDistinctName("x",$.NameType$$module$build$src$core$names.VARIABLE);return["''.join([str("+a+") for "+a+" in ["+b.join(", ")+"]])",module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]}};
|
||||
module$exports$Blockly$Python.pythonGenerator.text_append=function(a){const b=module$exports$Blockly$Python.pythonGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE);a=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"TEXT",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"''";return b+" = str("+b+") + "+module$contents$Blockly$Python$texts_forceString(a)[0]+"\n"};
|
||||
module$exports$Blockly$Python.pythonGenerator.text_length=function(a){return["len("+(module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"''")+")",module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$Python.pythonGenerator.text_isEmpty=function(a){return["not len("+(module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"''")+")",module$exports$Blockly$Python.pythonGenerator.ORDER_LOGICAL_NOT]};
|
||||
module$exports$Blockly$Python.pythonGenerator.text_indexOf=function(a){var b="FIRST"===a.getFieldValue("END")?"find":"rfind";const c=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"FIND",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"''";b=(module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER)||"''")+"."+b+"("+c+")";return a.workspace.options.oneBasedIndex?[b+" + 1",module$exports$Blockly$Python.pythonGenerator.ORDER_ADDITIVE]:
|
||||
[b,module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$Python.pythonGenerator.text_charAt=function(a){const b=a.getFieldValue("WHERE")||"FROM_START",c=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"VALUE","RANDOM"===b?module$exports$Blockly$Python.pythonGenerator.ORDER_NONE:module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER)||"''";switch(b){case "FIRST":return[c+"[0]",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER];case "LAST":return[c+"[-1]",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER];
|
||||
case "FROM_START":return a=module$exports$Blockly$Python.pythonGenerator.getAdjustedInt(a,"AT"),[c+"["+a+"]",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER];case "FROM_END":return a=module$exports$Blockly$Python.pythonGenerator.getAdjustedInt(a,"AT",1,!0),[c+"["+a+"]",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER];case "RANDOM":return module$exports$Blockly$Python.pythonGenerator.definitions_.import_random="import random",[module$exports$Blockly$Python.pythonGenerator.provideFunction_("text_random_letter",
|
||||
`
|
||||
def ${module$exports$Blockly$Python.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(text):
|
||||
x = int(random.random() * len(text))
|
||||
return text[x]
|
||||
`)+"("+c+")",module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]}throw Error("Unhandled option (text_charAt).");};
|
||||
module$exports$Blockly$Python.pythonGenerator.text_getSubstring=function(a){var b=a.getFieldValue("WHERE1");const c=a.getFieldValue("WHERE2"),d=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"STRING",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER)||"''";switch(b){case "FROM_START":b=module$exports$Blockly$Python.pythonGenerator.getAdjustedInt(a,"AT1");0===b&&(b="");break;case "FROM_END":b=module$exports$Blockly$Python.pythonGenerator.getAdjustedInt(a,"AT1",1,!0);break;case "FIRST":b=
|
||||
"";break;default:throw Error("Unhandled option (text_getSubstring)");}switch(c){case "FROM_START":a=module$exports$Blockly$Python.pythonGenerator.getAdjustedInt(a,"AT2",1);break;case "FROM_END":a=module$exports$Blockly$Python.pythonGenerator.getAdjustedInt(a,"AT2",0,!0);$.module$build$src$core$utils$string.isNumber(String(a))?0===a&&(a=""):(module$exports$Blockly$Python.pythonGenerator.definitions_.import_sys="import sys",a+=" or sys.maxsize");break;case "LAST":a="";break;default:throw Error("Unhandled option (text_getSubstring)");
|
||||
}return[d+"["+b+" : "+a+"]",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER]};module$exports$Blockly$Python.pythonGenerator.text_changeCase=function(a){const b={UPPERCASE:".upper()",LOWERCASE:".lower()",TITLECASE:".title()"}[a.getFieldValue("CASE")];return[(module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"TEXT",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER)||"''")+b,module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$Python.pythonGenerator.text_trim=function(a){const b={LEFT:".lstrip()",RIGHT:".rstrip()",BOTH:".strip()"}[a.getFieldValue("MODE")];return[(module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"TEXT",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER)||"''")+b,module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$Python.pythonGenerator.text_print=function(a){return"print("+(module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"TEXT",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"''")+")\n"};module$exports$Blockly$Python.pythonGenerator.text_prompt_ext=function(a){var b=module$exports$Blockly$Python.pythonGenerator.provideFunction_("text_prompt",`
|
||||
def ${module$exports$Blockly$Python.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(msg):
|
||||
try:
|
||||
return raw_input(msg)
|
||||
except NameError:
|
||||
return input(msg)
|
||||
`);let c;c=a.getField("TEXT")?module$exports$Blockly$Python.pythonGenerator.quote_(a.getFieldValue("TEXT")):module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"TEXT",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"''";b=b+"("+c+")";"NUMBER"===a.getFieldValue("TYPE")&&(b="float("+b+")");return[b,module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]};module$exports$Blockly$Python.pythonGenerator.text_prompt=module$exports$Blockly$Python.pythonGenerator.text_prompt_ext;
|
||||
module$exports$Blockly$Python.pythonGenerator.text_count=function(a){const b=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"TEXT",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER)||"''";a=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"SUB",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"''";return[b+".count("+a+")",module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$Python.pythonGenerator.text_replace=function(a){const b=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"TEXT",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER)||"''",c=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"FROM",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"''";a=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"TO",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"''";return[b+".replace("+c+", "+
|
||||
a+")",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER]};module$exports$Blockly$Python.pythonGenerator.text_reverse=function(a){return[(module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"TEXT",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER)||"''")+"[::-1]",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER]};var module$exports$Blockly$Python$procedures={},module$contents$Blockly$Python$procedures_Variables=$.module$build$src$core$variables,module$contents$Blockly$Python$procedures_NameType=$.NameType$$module$build$src$core$names;
|
||||
module$exports$Blockly$Python.pythonGenerator.procedures_defreturn=function(a){var b=[],c=a.workspace,d=$.module$build$src$core$variables.allUsedVarModels(c)||[];for(let m=0,n;n=d[m];m++){var e=n.name;-1===a.getVars().indexOf(e)&&b.push(module$exports$Blockly$Python.pythonGenerator.nameDB_.getName(e,$.NameType$$module$build$src$core$names.VARIABLE))}c=$.module$build$src$core$variables.allDeveloperVariables(c);for(d=0;d<c.length;d++)b.push(module$exports$Blockly$Python.pythonGenerator.nameDB_.getName(c[d],
|
||||
$.NameType$$module$build$src$core$names.DEVELOPER_VARIABLE));c=b.length?module$exports$Blockly$Python.pythonGenerator.INDENT+"global "+b.join(", ")+"\n":"";b=module$exports$Blockly$Python.pythonGenerator.nameDB_.getName(a.getFieldValue("NAME"),$.NameType$$module$build$src$core$names.PROCEDURE);d="";module$exports$Blockly$Python.pythonGenerator.STATEMENT_PREFIX&&(d+=module$exports$Blockly$Python.pythonGenerator.injectId(module$exports$Blockly$Python.pythonGenerator.STATEMENT_PREFIX,a));module$exports$Blockly$Python.pythonGenerator.STATEMENT_SUFFIX&&
|
||||
(d+=module$exports$Blockly$Python.pythonGenerator.injectId(module$exports$Blockly$Python.pythonGenerator.STATEMENT_SUFFIX,a));d&&(d=module$exports$Blockly$Python.pythonGenerator.prefixLines(d,module$exports$Blockly$Python.pythonGenerator.INDENT));e="";module$exports$Blockly$Python.pythonGenerator.INFINITE_LOOP_TRAP&&(e=module$exports$Blockly$Python.pythonGenerator.prefixLines(module$exports$Blockly$Python.pythonGenerator.injectId(module$exports$Blockly$Python.pythonGenerator.INFINITE_LOOP_TRAP,a),
|
||||
module$exports$Blockly$Python.pythonGenerator.INDENT));let f=module$exports$Blockly$Python.pythonGenerator.statementToCode(a,"STACK"),g=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"RETURN",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"",h="";f&&g&&(h=d);g?g=module$exports$Blockly$Python.pythonGenerator.INDENT+"return "+g+"\n":f||(f=module$exports$Blockly$Python.pythonGenerator.PASS);const k=[],l=a.getVars();for(let m=0;m<l.length;m++)k[m]=module$exports$Blockly$Python.pythonGenerator.nameDB_.getName(l[m],
|
||||
$.NameType$$module$build$src$core$names.VARIABLE);c="def "+b+"("+k.join(", ")+"):\n"+c+d+e+f+h+g;c=module$exports$Blockly$Python.pythonGenerator.scrub_(a,c);module$exports$Blockly$Python.pythonGenerator.definitions_["%"+b]=c;return null};module$exports$Blockly$Python.pythonGenerator.procedures_defnoreturn=module$exports$Blockly$Python.pythonGenerator.procedures_defreturn;
|
||||
module$exports$Blockly$Python.pythonGenerator.procedures_callreturn=function(a){const b=module$exports$Blockly$Python.pythonGenerator.nameDB_.getName(a.getFieldValue("NAME"),$.NameType$$module$build$src$core$names.PROCEDURE),c=[],d=a.getVars();for(let e=0;e<d.length;e++)c[e]=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"ARG"+e,module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"None";return[b+"("+c.join(", ")+")",module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$Python.pythonGenerator.procedures_callnoreturn=function(a){return module$exports$Blockly$Python.pythonGenerator.procedures_callreturn(a)[0]+"\n"};
|
||||
module$exports$Blockly$Python.pythonGenerator.procedures_ifreturn=function(a){let b="if "+(module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"CONDITION",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"False")+":\n";module$exports$Blockly$Python.pythonGenerator.STATEMENT_SUFFIX&&(b+=module$exports$Blockly$Python.pythonGenerator.prefixLines(module$exports$Blockly$Python.pythonGenerator.injectId(module$exports$Blockly$Python.pythonGenerator.STATEMENT_SUFFIX,a),module$exports$Blockly$Python.pythonGenerator.INDENT));
|
||||
a.hasReturnValue_?(a=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"None",b+=module$exports$Blockly$Python.pythonGenerator.INDENT+"return "+a+"\n"):b+=module$exports$Blockly$Python.pythonGenerator.INDENT+"return\n";return b};var module$exports$Blockly$Python$math={},module$contents$Blockly$Python$math_NameType=$.NameType$$module$build$src$core$names;module$exports$Blockly$Python.pythonGenerator.addReservedWords("math,random,Number");
|
||||
module$exports$Blockly$Python.pythonGenerator.math_number=function(a){a=Number(a.getFieldValue("NUM"));let b;Infinity===a?(a='float("inf")',b=module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL):-Infinity===a?(a='-float("inf")',b=module$exports$Blockly$Python.pythonGenerator.ORDER_UNARY_SIGN):b=0>a?module$exports$Blockly$Python.pythonGenerator.ORDER_UNARY_SIGN:module$exports$Blockly$Python.pythonGenerator.ORDER_ATOMIC;return[a,b]};
|
||||
module$exports$Blockly$Python.pythonGenerator.math_arithmetic=function(a){var b={ADD:[" + ",module$exports$Blockly$Python.pythonGenerator.ORDER_ADDITIVE],MINUS:[" - ",module$exports$Blockly$Python.pythonGenerator.ORDER_ADDITIVE],MULTIPLY:[" * ",module$exports$Blockly$Python.pythonGenerator.ORDER_MULTIPLICATIVE],DIVIDE:[" / ",module$exports$Blockly$Python.pythonGenerator.ORDER_MULTIPLICATIVE],POWER:[" ** ",module$exports$Blockly$Python.pythonGenerator.ORDER_EXPONENTIATION]}[a.getFieldValue("OP")];
|
||||
const c=b[0];b=b[1];const d=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"A",b)||"0";a=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"B",b)||"0";return[d+c+a,b]};
|
||||
module$exports$Blockly$Python.pythonGenerator.math_single=function(a){const b=a.getFieldValue("OP");let c;if("NEG"===b)return c=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"NUM",module$exports$Blockly$Python.pythonGenerator.ORDER_UNARY_SIGN)||"0",["-"+c,module$exports$Blockly$Python.pythonGenerator.ORDER_UNARY_SIGN];module$exports$Blockly$Python.pythonGenerator.definitions_.import_math="import math";a="SIN"===b||"COS"===b||"TAN"===b?module$exports$Blockly$Python.pythonGenerator.valueToCode(a,
|
||||
"NUM",module$exports$Blockly$Python.pythonGenerator.ORDER_MULTIPLICATIVE)||"0":module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"NUM",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"0";switch(b){case "ABS":c="math.fabs("+a+")";break;case "ROOT":c="math.sqrt("+a+")";break;case "LN":c="math.log("+a+")";break;case "LOG10":c="math.log10("+a+")";break;case "EXP":c="math.exp("+a+")";break;case "POW10":c="math.pow(10,"+a+")";break;case "ROUND":c="round("+a+")";break;case "ROUNDUP":c=
|
||||
"math.ceil("+a+")";break;case "ROUNDDOWN":c="math.floor("+a+")";break;case "SIN":c="math.sin("+a+" / 180.0 * math.pi)";break;case "COS":c="math.cos("+a+" / 180.0 * math.pi)";break;case "TAN":c="math.tan("+a+" / 180.0 * math.pi)"}if(c)return[c,module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL];switch(b){case "ASIN":c="math.asin("+a+") / math.pi * 180";break;case "ACOS":c="math.acos("+a+") / math.pi * 180";break;case "ATAN":c="math.atan("+a+") / math.pi * 180";break;default:throw Error("Unknown math operator: "+
|
||||
b);}return[c,module$exports$Blockly$Python.pythonGenerator.ORDER_MULTIPLICATIVE]};
|
||||
module$exports$Blockly$Python.pythonGenerator.math_constant=function(a){const b={PI:["math.pi",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER],E:["math.e",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER],GOLDEN_RATIO:["(1 + math.sqrt(5)) / 2",module$exports$Blockly$Python.pythonGenerator.ORDER_MULTIPLICATIVE],SQRT2:["math.sqrt(2)",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER],SQRT1_2:["math.sqrt(1.0 / 2)",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER],
|
||||
INFINITY:["float('inf')",module$exports$Blockly$Python.pythonGenerator.ORDER_ATOMIC]};a=a.getFieldValue("CONSTANT");"INFINITY"!==a&&(module$exports$Blockly$Python.pythonGenerator.definitions_.import_math="import math");return b[a]};
|
||||
module$exports$Blockly$Python.pythonGenerator.math_number_property=function(a){var b={EVEN:[" % 2 == 0",module$exports$Blockly$Python.pythonGenerator.ORDER_MULTIPLICATIVE,module$exports$Blockly$Python.pythonGenerator.ORDER_RELATIONAL],ODD:[" % 2 == 1",module$exports$Blockly$Python.pythonGenerator.ORDER_MULTIPLICATIVE,module$exports$Blockly$Python.pythonGenerator.ORDER_RELATIONAL],WHOLE:[" % 1 == 0",module$exports$Blockly$Python.pythonGenerator.ORDER_MULTIPLICATIVE,module$exports$Blockly$Python.pythonGenerator.ORDER_RELATIONAL],
|
||||
POSITIVE:[" > 0",module$exports$Blockly$Python.pythonGenerator.ORDER_RELATIONAL,module$exports$Blockly$Python.pythonGenerator.ORDER_RELATIONAL],NEGATIVE:[" < 0",module$exports$Blockly$Python.pythonGenerator.ORDER_RELATIONAL,module$exports$Blockly$Python.pythonGenerator.ORDER_RELATIONAL],DIVISIBLE_BY:[null,module$exports$Blockly$Python.pythonGenerator.ORDER_MULTIPLICATIVE,module$exports$Blockly$Python.pythonGenerator.ORDER_RELATIONAL],PRIME:[null,module$exports$Blockly$Python.pythonGenerator.ORDER_NONE,
|
||||
module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]};const c=a.getFieldValue("PROPERTY"),[d,e,f]=b[c];b=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"NUMBER_TO_CHECK",e)||"0";if("PRIME"===c)module$exports$Blockly$Python.pythonGenerator.definitions_.import_math="import math",module$exports$Blockly$Python.pythonGenerator.definitions_.from_numbers_import_Number="from numbers import Number",a=module$exports$Blockly$Python.pythonGenerator.provideFunction_("math_isPrime",`
|
||||
def ${module$exports$Blockly$Python.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(n):
|
||||
# https://en.wikipedia.org/wiki/Primality_test#Naive_methods
|
||||
# If n is not a number but a string, try parsing it.
|
||||
if not isinstance(n, Number):
|
||||
try:
|
||||
n = float(n)
|
||||
except:
|
||||
return False
|
||||
if n == 2 or n == 3:
|
||||
return True
|
||||
# False if n is negative, is 1, or not whole, or if n is divisible by 2 or 3.
|
||||
if n <= 1 or n % 1 != 0 or n % 2 == 0 or n % 3 == 0:
|
||||
return False
|
||||
# Check all the numbers of form 6k +/- 1, up to sqrt(n).
|
||||
for x in range(6, int(math.sqrt(n)) + 2, 6):
|
||||
if n % (x - 1) == 0 or n % (x + 1) == 0:
|
||||
return False
|
||||
return True
|
||||
`)+"("+b+")";else if("DIVISIBLE_BY"===c){a=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"DIVISOR",module$exports$Blockly$Python.pythonGenerator.ORDER_MULTIPLICATIVE)||"0";if("0"===a)return["False",module$exports$Blockly$Python.pythonGenerator.ORDER_ATOMIC];a=b+" % "+a+" == 0"}else a=b+d;return[a,f]};
|
||||
module$exports$Blockly$Python.pythonGenerator.math_change=function(a){module$exports$Blockly$Python.pythonGenerator.definitions_.from_numbers_import_Number="from numbers import Number";const b=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"DELTA",module$exports$Blockly$Python.pythonGenerator.ORDER_ADDITIVE)||"0";a=module$exports$Blockly$Python.pythonGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE);return a+" = ("+a+" if isinstance("+
|
||||
a+", Number) else 0) + "+b+"\n"};module$exports$Blockly$Python.pythonGenerator.math_round=module$exports$Blockly$Python.pythonGenerator.math_single;module$exports$Blockly$Python.pythonGenerator.math_trig=module$exports$Blockly$Python.pythonGenerator.math_single;
|
||||
module$exports$Blockly$Python.pythonGenerator.math_on_list=function(a){var b=a.getFieldValue("OP");a=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"LIST",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"[]";switch(b){case "SUM":b="sum("+a+")";break;case "MIN":b="min("+a+")";break;case "MAX":b="max("+a+")";break;case "AVERAGE":module$exports$Blockly$Python.pythonGenerator.definitions_.from_numbers_import_Number="from numbers import Number";b=module$exports$Blockly$Python.pythonGenerator.provideFunction_("math_mean",
|
||||
`
|
||||
def ${module$exports$Blockly$Python.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(myList):
|
||||
localList = [e for e in myList if isinstance(e, Number)]
|
||||
if not localList: return
|
||||
return float(sum(localList)) / len(localList)
|
||||
`)+"("+a+")";break;case "MEDIAN":module$exports$Blockly$Python.pythonGenerator.definitions_.from_numbers_import_Number="from numbers import Number";b=module$exports$Blockly$Python.pythonGenerator.provideFunction_("math_median",`
|
||||
def ${module$exports$Blockly$Python.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(myList):
|
||||
localList = sorted([e for e in myList if isinstance(e, Number)])
|
||||
if not localList: return
|
||||
if len(localList) % 2 == 0:
|
||||
return (localList[len(localList) // 2 - 1] + localList[len(localList) // 2]) / 2.0
|
||||
else:
|
||||
return localList[(len(localList) - 1) // 2]
|
||||
`)+"("+a+")";break;case "MODE":b=module$exports$Blockly$Python.pythonGenerator.provideFunction_("math_modes",`
|
||||
def ${module$exports$Blockly$Python.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(some_list):
|
||||
modes = []
|
||||
# Using a lists of [item, count] to keep count rather than dict
|
||||
# to avoid "unhashable" errors when the counted item is itself a list or dict.
|
||||
counts = []
|
||||
maxCount = 1
|
||||
for item in some_list:
|
||||
found = False
|
||||
for count in counts:
|
||||
if count[0] == item:
|
||||
count[1] += 1
|
||||
maxCount = max(maxCount, count[1])
|
||||
found = True
|
||||
if not found:
|
||||
counts.append([item, 1])
|
||||
for counted_item, item_count in counts:
|
||||
if item_count == maxCount:
|
||||
modes.append(counted_item)
|
||||
return modes
|
||||
`)+"("+a+")";break;case "STD_DEV":module$exports$Blockly$Python.pythonGenerator.definitions_.import_math="import math";b=module$exports$Blockly$Python.pythonGenerator.provideFunction_("math_standard_deviation",`
|
||||
def ${module$exports$Blockly$Python.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(numbers):
|
||||
n = len(numbers)
|
||||
if n == 0: return
|
||||
mean = float(sum(numbers)) / n
|
||||
variance = sum((x - mean) ** 2 for x in numbers) / n
|
||||
return math.sqrt(variance)
|
||||
`)+"("+a+")";break;case "RANDOM":module$exports$Blockly$Python.pythonGenerator.definitions_.import_random="import random";b="random.choice("+a+")";break;default:throw Error("Unknown operator: "+b);}return[b,module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$Python.pythonGenerator.math_modulo=function(a){const b=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"DIVIDEND",module$exports$Blockly$Python.pythonGenerator.ORDER_MULTIPLICATIVE)||"0";a=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"DIVISOR",module$exports$Blockly$Python.pythonGenerator.ORDER_MULTIPLICATIVE)||"0";return[b+" % "+a,module$exports$Blockly$Python.pythonGenerator.ORDER_MULTIPLICATIVE]};
|
||||
module$exports$Blockly$Python.pythonGenerator.math_constrain=function(a){const b=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"0",c=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"LOW",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"0";a=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"HIGH",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"float('inf')";return["min(max("+
|
||||
b+", "+c+"), "+a+")",module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$Python.pythonGenerator.math_random_int=function(a){module$exports$Blockly$Python.pythonGenerator.definitions_.import_random="import random";const b=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"FROM",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"0";a=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"TO",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"0";return["random.randint("+b+", "+a+")",module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$Python.pythonGenerator.math_random_float=function(a){module$exports$Blockly$Python.pythonGenerator.definitions_.import_random="import random";return["random.random()",module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$Python.pythonGenerator.math_atan2=function(a){module$exports$Blockly$Python.pythonGenerator.definitions_.import_math="import math";const b=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"X",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"0";return["math.atan2("+(module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"Y",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"0")+", "+b+") / math.pi * 180",module$exports$Blockly$Python.pythonGenerator.ORDER_MULTIPLICATIVE]};var module$exports$Blockly$Python$loops={},module$contents$Blockly$Python$loops_stringUtils=$.module$build$src$core$utils$string,module$contents$Blockly$Python$loops_NameType=$.NameType$$module$build$src$core$names;
|
||||
module$exports$Blockly$Python.pythonGenerator.controls_repeat_ext=function(a){let b;b=a.getField("TIMES")?String(parseInt(a.getFieldValue("TIMES"),10)):module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"TIMES",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"0";b=$.module$build$src$core$utils$string.isNumber(b)?parseInt(b,10):"int("+b+")";let c=module$exports$Blockly$Python.pythonGenerator.statementToCode(a,"DO");c=module$exports$Blockly$Python.pythonGenerator.addLoopTrap(c,a)||
|
||||
module$exports$Blockly$Python.pythonGenerator.PASS;return"for "+module$exports$Blockly$Python.pythonGenerator.nameDB_.getDistinctName("count",$.NameType$$module$build$src$core$names.VARIABLE)+" in range("+b+"):\n"+c};module$exports$Blockly$Python.pythonGenerator.controls_repeat=module$exports$Blockly$Python.pythonGenerator.controls_repeat_ext;
|
||||
module$exports$Blockly$Python.pythonGenerator.controls_whileUntil=function(a){const b="UNTIL"===a.getFieldValue("MODE");let c=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"BOOL",b?module$exports$Blockly$Python.pythonGenerator.ORDER_LOGICAL_NOT:module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"False",d=module$exports$Blockly$Python.pythonGenerator.statementToCode(a,"DO");d=module$exports$Blockly$Python.pythonGenerator.addLoopTrap(d,a)||module$exports$Blockly$Python.pythonGenerator.PASS;
|
||||
b&&(c="not "+c);return"while "+c+":\n"+d};
|
||||
module$exports$Blockly$Python.pythonGenerator.controls_for=function(a){const b=module$exports$Blockly$Python.pythonGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE);var c=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"FROM",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"0",d=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"TO",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"0",e=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,
|
||||
"BY",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"1";let f=module$exports$Blockly$Python.pythonGenerator.statementToCode(a,"DO");f=module$exports$Blockly$Python.pythonGenerator.addLoopTrap(f,a)||module$exports$Blockly$Python.pythonGenerator.PASS;let g="";const h=function(){return module$exports$Blockly$Python.pythonGenerator.provideFunction_("upRange",`
|
||||
def ${module$exports$Blockly$Python.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(start, stop, step):
|
||||
while start <= stop:
|
||||
yield start
|
||||
start += abs(step)
|
||||
`)},k=function(){return module$exports$Blockly$Python.pythonGenerator.provideFunction_("downRange",`
|
||||
def ${module$exports$Blockly$Python.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(start, stop, step):
|
||||
while start >= stop:
|
||||
yield start
|
||||
start -= abs(step)
|
||||
`)};a=function(l,m,n){return"("+l+" <= "+m+") and "+h()+"("+l+", "+m+", "+n+") or "+k()+"("+l+", "+m+", "+n+")"};if($.module$build$src$core$utils$string.isNumber(c)&&$.module$build$src$core$utils$string.isNumber(d)&&$.module$build$src$core$utils$string.isNumber(e))c=Number(c),d=Number(d),e=Math.abs(Number(e)),0===c%1&&0===d%1&&0===e%1?(c<=d?(d++,a=0===c&&1===e?d:c+", "+d,1!==e&&(a+=", "+e)):(d--,a=c+", "+d+", -"+e),a="range("+a+")"):(a=c<d?h():k(),a+="("+c+", "+d+", "+e+")");else{const l=function(m,
|
||||
n){$.module$build$src$core$utils$string.isNumber(m)?m=Number(m):m.match(/^\w+$/)||(n=module$exports$Blockly$Python.pythonGenerator.nameDB_.getDistinctName(b+n,$.NameType$$module$build$src$core$names.VARIABLE),g+=n+" = "+m+"\n",m=n);return m};c=l(c,"_start");d=l(d,"_end");e=l(e,"_inc");"number"===typeof c&&"number"===typeof d?(a=c<d?h():k(),a+="("+c+", "+d+", "+e+")"):a=a(c,d,e)}return g+="for "+b+" in "+a+":\n"+f};
|
||||
module$exports$Blockly$Python.pythonGenerator.controls_forEach=function(a){const b=module$exports$Blockly$Python.pythonGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE),c=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"LIST",module$exports$Blockly$Python.pythonGenerator.ORDER_RELATIONAL)||"[]";let d=module$exports$Blockly$Python.pythonGenerator.statementToCode(a,"DO");d=module$exports$Blockly$Python.pythonGenerator.addLoopTrap(d,a)||module$exports$Blockly$Python.pythonGenerator.PASS;
|
||||
return"for "+b+" in "+c+":\n"+d};
|
||||
module$exports$Blockly$Python.pythonGenerator.controls_flow_statements=function(a){let b="";module$exports$Blockly$Python.pythonGenerator.STATEMENT_PREFIX&&(b+=module$exports$Blockly$Python.pythonGenerator.injectId(module$exports$Blockly$Python.pythonGenerator.STATEMENT_PREFIX,a));module$exports$Blockly$Python.pythonGenerator.STATEMENT_SUFFIX&&(b+=module$exports$Blockly$Python.pythonGenerator.injectId(module$exports$Blockly$Python.pythonGenerator.STATEMENT_SUFFIX,a));if(module$exports$Blockly$Python.pythonGenerator.STATEMENT_PREFIX){const c=
|
||||
a.getSurroundLoop();c&&!c.suppressPrefixSuffix&&(b+=module$exports$Blockly$Python.pythonGenerator.injectId(module$exports$Blockly$Python.pythonGenerator.STATEMENT_PREFIX,c))}switch(a.getFieldValue("FLOW")){case "BREAK":return b+"break\n";case "CONTINUE":return b+"continue\n"}throw Error("Unknown flow statement.");};var module$exports$Blockly$Python$logic={};
|
||||
module$exports$Blockly$Python.pythonGenerator.controls_if=function(a){let b=0,c="",d,e;module$exports$Blockly$Python.pythonGenerator.STATEMENT_PREFIX&&(c+=module$exports$Blockly$Python.pythonGenerator.injectId(module$exports$Blockly$Python.pythonGenerator.STATEMENT_PREFIX,a));do e=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"IF"+b,module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"False",d=module$exports$Blockly$Python.pythonGenerator.statementToCode(a,"DO"+b)||module$exports$Blockly$Python.pythonGenerator.PASS,
|
||||
module$exports$Blockly$Python.pythonGenerator.STATEMENT_SUFFIX&&(d=module$exports$Blockly$Python.pythonGenerator.prefixLines(module$exports$Blockly$Python.pythonGenerator.injectId(module$exports$Blockly$Python.pythonGenerator.STATEMENT_SUFFIX,a),module$exports$Blockly$Python.pythonGenerator.INDENT)+d),c+=(0===b?"if ":"elif ")+e+":\n"+d,b++;while(a.getInput("IF"+b));if(a.getInput("ELSE")||module$exports$Blockly$Python.pythonGenerator.STATEMENT_SUFFIX)d=module$exports$Blockly$Python.pythonGenerator.statementToCode(a,
|
||||
"ELSE")||module$exports$Blockly$Python.pythonGenerator.PASS,module$exports$Blockly$Python.pythonGenerator.STATEMENT_SUFFIX&&(d=module$exports$Blockly$Python.pythonGenerator.prefixLines(module$exports$Blockly$Python.pythonGenerator.injectId(module$exports$Blockly$Python.pythonGenerator.STATEMENT_SUFFIX,a),module$exports$Blockly$Python.pythonGenerator.INDENT)+d),c+="else:\n"+d;return c};module$exports$Blockly$Python.pythonGenerator.controls_ifelse=module$exports$Blockly$Python.pythonGenerator.controls_if;
|
||||
module$exports$Blockly$Python.pythonGenerator.logic_compare=function(a){const b={EQ:"==",NEQ:"!=",LT:"<",LTE:"<=",GT:">",GTE:">="}[a.getFieldValue("OP")],c=module$exports$Blockly$Python.pythonGenerator.ORDER_RELATIONAL,d=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"A",c)||"0";a=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"B",c)||"0";return[d+" "+b+" "+a,c]};
|
||||
module$exports$Blockly$Python.pythonGenerator.logic_operation=function(a){const b="AND"===a.getFieldValue("OP")?"and":"or",c="and"===b?module$exports$Blockly$Python.pythonGenerator.ORDER_LOGICAL_AND:module$exports$Blockly$Python.pythonGenerator.ORDER_LOGICAL_OR;let d=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"A",c);a=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"B",c);if(d||a){const e="and"===b?"True":"False";d||(d=e);a||(a=e)}else a=d="False";return[d+" "+b+" "+a,
|
||||
c]};module$exports$Blockly$Python.pythonGenerator.logic_negate=function(a){return["not "+(module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"BOOL",module$exports$Blockly$Python.pythonGenerator.ORDER_LOGICAL_NOT)||"True"),module$exports$Blockly$Python.pythonGenerator.ORDER_LOGICAL_NOT]};module$exports$Blockly$Python.pythonGenerator.logic_boolean=function(a){return["TRUE"===a.getFieldValue("BOOL")?"True":"False",module$exports$Blockly$Python.pythonGenerator.ORDER_ATOMIC]};
|
||||
module$exports$Blockly$Python.pythonGenerator.logic_null=function(a){return["None",module$exports$Blockly$Python.pythonGenerator.ORDER_ATOMIC]};
|
||||
module$exports$Blockly$Python.pythonGenerator.logic_ternary=function(a){const b=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"IF",module$exports$Blockly$Python.pythonGenerator.ORDER_CONDITIONAL)||"False",c=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"THEN",module$exports$Blockly$Python.pythonGenerator.ORDER_CONDITIONAL)||"None";a=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"ELSE",module$exports$Blockly$Python.pythonGenerator.ORDER_CONDITIONAL)||"None";
|
||||
return[c+" if "+b+" else "+a,module$exports$Blockly$Python.pythonGenerator.ORDER_CONDITIONAL]};var module$exports$Blockly$Python$lists={},module$contents$Blockly$Python$lists_stringUtils=$.module$build$src$core$utils$string,module$contents$Blockly$Python$lists_NameType=$.NameType$$module$build$src$core$names;module$exports$Blockly$Python.pythonGenerator.lists_create_empty=function(a){return["[]",module$exports$Blockly$Python.pythonGenerator.ORDER_ATOMIC]};
|
||||
module$exports$Blockly$Python.pythonGenerator.lists_create_with=function(a){const b=Array(a.itemCount_);for(let c=0;c<a.itemCount_;c++)b[c]=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"ADD"+c,module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"None";return["["+b.join(", ")+"]",module$exports$Blockly$Python.pythonGenerator.ORDER_ATOMIC]};
|
||||
module$exports$Blockly$Python.pythonGenerator.lists_repeat=function(a){const b=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"ITEM",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"None";a=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"NUM",module$exports$Blockly$Python.pythonGenerator.ORDER_MULTIPLICATIVE)||"0";return["["+b+"] * "+a,module$exports$Blockly$Python.pythonGenerator.ORDER_MULTIPLICATIVE]};
|
||||
module$exports$Blockly$Python.pythonGenerator.lists_length=function(a){return["len("+(module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"[]")+")",module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$Python.pythonGenerator.lists_isEmpty=function(a){return["not len("+(module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"[]")+")",module$exports$Blockly$Python.pythonGenerator.ORDER_LOGICAL_NOT]};
|
||||
module$exports$Blockly$Python.pythonGenerator.lists_indexOf=function(a){const b=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"FIND",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"[]",c=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"''";let d=" -1",e="",f=" - 1";a.workspace.options.oneBasedIndex&&(d=" 0",e=" + 1",f="");return[("FIRST"===a.getFieldValue("END")?module$exports$Blockly$Python.pythonGenerator.provideFunction_("first_index",
|
||||
`
|
||||
def ${module$exports$Blockly$Python.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(my_list, elem):
|
||||
try: index = my_list.index(elem)${e}
|
||||
except: index =${d}
|
||||
return index
|
||||
`):module$exports$Blockly$Python.pythonGenerator.provideFunction_("last_index",`
|
||||
def ${module$exports$Blockly$Python.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(my_list, elem):
|
||||
try: index = len(my_list) - my_list[::-1].index(elem)${f}
|
||||
except: index =${d}
|
||||
return index
|
||||
`))+"("+c+", "+b+")",module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$Python.pythonGenerator.lists_getIndex=function(a){const b=a.getFieldValue("MODE")||"GET",c=a.getFieldValue("WHERE")||"FROM_START";var d=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"VALUE","RANDOM"===c?module$exports$Blockly$Python.pythonGenerator.ORDER_NONE:module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER)||"[]";switch(c){case "FIRST":if("GET"===b)return[d+"[0]",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER];if("GET_REMOVE"===b)return[d+
|
||||
".pop(0)",module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL];if("REMOVE"===b)return d+".pop(0)\n";break;case "LAST":if("GET"===b)return[d+"[-1]",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER];if("GET_REMOVE"===b)return[d+".pop()",module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL];if("REMOVE"===b)return d+".pop()\n";break;case "FROM_START":a=module$exports$Blockly$Python.pythonGenerator.getAdjustedInt(a,"AT");if("GET"===b)return[d+"["+a+"]",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER];
|
||||
if("GET_REMOVE"===b)return[d+".pop("+a+")",module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL];if("REMOVE"===b)return d+".pop("+a+")\n";break;case "FROM_END":a=module$exports$Blockly$Python.pythonGenerator.getAdjustedInt(a,"AT",1,!0);if("GET"===b)return[d+"["+a+"]",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER];if("GET_REMOVE"===b)return[d+".pop("+a+")",module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL];if("REMOVE"===b)return d+".pop("+a+")\n";break;case "RANDOM":module$exports$Blockly$Python.pythonGenerator.definitions_.import_random=
|
||||
"import random";if("GET"===b)return["random.choice("+d+")",module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL];d=module$exports$Blockly$Python.pythonGenerator.provideFunction_("lists_remove_random_item",`
|
||||
def ${module$exports$Blockly$Python.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(myList):
|
||||
x = int(random.random() * len(myList))
|
||||
return myList.pop(x)
|
||||
`)+"("+d+")";if("GET_REMOVE"===b)return[d,module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL];if("REMOVE"===b)return d+"\n"}throw Error("Unhandled combination (lists_getIndex).");};
|
||||
module$exports$Blockly$Python.pythonGenerator.lists_setIndex=function(a){let b=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"LIST",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER)||"[]";const c=a.getFieldValue("MODE")||"GET";var d=a.getFieldValue("WHERE")||"FROM_START";const e=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"TO",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"None";switch(d){case "FIRST":if("SET"===c)return b+"[0] = "+e+"\n";if("INSERT"===
|
||||
c)return b+".insert(0, "+e+")\n";break;case "LAST":if("SET"===c)return b+"[-1] = "+e+"\n";if("INSERT"===c)return b+".append("+e+")\n";break;case "FROM_START":a=module$exports$Blockly$Python.pythonGenerator.getAdjustedInt(a,"AT");if("SET"===c)return b+"["+a+"] = "+e+"\n";if("INSERT"===c)return b+".insert("+a+", "+e+")\n";break;case "FROM_END":a=module$exports$Blockly$Python.pythonGenerator.getAdjustedInt(a,"AT",1,!0);if("SET"===c)return b+"["+a+"] = "+e+"\n";if("INSERT"===c)return b+".insert("+a+", "+
|
||||
e+")\n";break;case "RANDOM":module$exports$Blockly$Python.pythonGenerator.definitions_.import_random="import random";b.match(/^\w+$/)?a="":(a=module$exports$Blockly$Python.pythonGenerator.nameDB_.getDistinctName("tmp_list",$.NameType$$module$build$src$core$names.VARIABLE),d=a+" = "+b+"\n",b=a,a=d);d=module$exports$Blockly$Python.pythonGenerator.nameDB_.getDistinctName("tmp_x",$.NameType$$module$build$src$core$names.VARIABLE);a+=d+" = int(random.random() * len("+b+"))\n";if("SET"===c)return a+(b+"["+
|
||||
d+"] = "+e+"\n");if("INSERT"===c)return a+(b+".insert("+d+", "+e+")\n")}throw Error("Unhandled combination (lists_setIndex).");};
|
||||
module$exports$Blockly$Python.pythonGenerator.lists_getSublist=function(a){const b=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"LIST",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER)||"[]";var c=a.getFieldValue("WHERE1");const d=a.getFieldValue("WHERE2");switch(c){case "FROM_START":c=module$exports$Blockly$Python.pythonGenerator.getAdjustedInt(a,"AT1");0===c&&(c="");break;case "FROM_END":c=module$exports$Blockly$Python.pythonGenerator.getAdjustedInt(a,"AT1",1,!0);break;
|
||||
case "FIRST":c="";break;default:throw Error("Unhandled option (lists_getSublist)");}switch(d){case "FROM_START":a=module$exports$Blockly$Python.pythonGenerator.getAdjustedInt(a,"AT2",1);break;case "FROM_END":a=module$exports$Blockly$Python.pythonGenerator.getAdjustedInt(a,"AT2",0,!0);$.module$build$src$core$utils$string.isNumber(String(a))?0===a&&(a=""):(module$exports$Blockly$Python.pythonGenerator.definitions_.import_sys="import sys",a+=" or sys.maxsize");break;case "LAST":a="";break;default:throw Error("Unhandled option (lists_getSublist)");
|
||||
}return[b+"["+c+" : "+a+"]",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER]};module$exports$Blockly$Python.pythonGenerator.lists_sort=function(a){const b=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"LIST",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"[]",c=a.getFieldValue("TYPE");a="1"===a.getFieldValue("DIRECTION")?"False":"True";return[module$exports$Blockly$Python.pythonGenerator.provideFunction_("lists_sort",`
|
||||
def ${module$exports$Blockly$Python.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(my_list, type, reverse):
|
||||
def try_float(s):
|
||||
try:
|
||||
return float(s)
|
||||
except:
|
||||
return 0
|
||||
key_funcs = {
|
||||
"NUMERIC": try_float,
|
||||
"TEXT": str,
|
||||
"IGNORE_CASE": lambda s: str(s).lower()
|
||||
}
|
||||
key_func = key_funcs[type]
|
||||
list_cpy = list(my_list)
|
||||
return sorted(list_cpy, key=key_func, reverse=reverse)
|
||||
`)+"("+b+', "'+c+'", '+a+")",module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$Python.pythonGenerator.lists_split=function(a){var b=a.getFieldValue("MODE");if("SPLIT"===b)b=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"INPUT",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER)||"''",a=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"DELIM",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE),a=b+".split("+a+")";else if("JOIN"===b)b=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"INPUT",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||
|
||||
"[]",a=(module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"DELIM",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER)||"''")+".join("+b+")";else throw Error("Unknown mode: "+b);return[a,module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$Python.pythonGenerator.lists_reverse=function(a){return["list(reversed("+(module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"LIST",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"[]")+"))",module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]};var module$exports$Blockly$Python$colour={};module$exports$Blockly$Python.pythonGenerator.colour_picker=function(a){return[module$exports$Blockly$Python.pythonGenerator.quote_(a.getFieldValue("COLOUR")),module$exports$Blockly$Python.pythonGenerator.ORDER_ATOMIC]};module$exports$Blockly$Python.pythonGenerator.colour_random=function(a){module$exports$Blockly$Python.pythonGenerator.definitions_.import_random="import random";return["'#%06x' % random.randint(0, 2**24 - 1)",module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$Python.pythonGenerator.colour_rgb=function(a){const b=module$exports$Blockly$Python.pythonGenerator.provideFunction_("colour_rgb",`
|
||||
def ${module$exports$Blockly$Python.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(r, g, b):
|
||||
r = round(min(100, max(0, r)) * 2.55)
|
||||
g = round(min(100, max(0, g)) * 2.55)
|
||||
b = round(min(100, max(0, b)) * 2.55)
|
||||
return '#%02x%02x%02x' % (r, g, b)
|
||||
`),c=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"RED",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||0,d=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"GREEN",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||0;a=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"BLUE",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||0;return[b+"("+c+", "+d+", "+a+")",module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]};
|
||||
module$exports$Blockly$Python.pythonGenerator.colour_blend=function(a){const b=module$exports$Blockly$Python.pythonGenerator.provideFunction_("colour_blend",`
|
||||
def ${module$exports$Blockly$Python.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(colour1, colour2, ratio):
|
||||
r1, r2 = int(colour1[1:3], 16), int(colour2[1:3], 16)
|
||||
g1, g2 = int(colour1[3:5], 16), int(colour2[3:5], 16)
|
||||
b1, b2 = int(colour1[5:7], 16), int(colour2[5:7], 16)
|
||||
ratio = min(1, max(0, ratio))
|
||||
r = round(r1 * (1 - ratio) + r2 * ratio)
|
||||
g = round(g1 * (1 - ratio) + g2 * ratio)
|
||||
b = round(b1 * (1 - ratio) + b2 * ratio)
|
||||
return '#%02x%02x%02x' % (r, g, b)
|
||||
`),c=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"COLOUR1",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"'#000000'",d=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"COLOUR2",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"'#000000'";a=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"RATIO",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||0;return[b+"("+c+", "+d+", "+a+")",module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]};var module$exports$Blockly$Python$all=module$exports$Blockly$Python;
|
||||
module$exports$Blockly$Python.__namespace__=$;
|
||||
return module$exports$Blockly$Python;
|
||||
}));
|
||||
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user