blockly 9.3.0-beta.0 → 9.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/blockly.min.js +1674 -1520
- package/blockly_compressed.js +1313 -1152
- package/blockly_compressed.js.map +1 -1
- package/blocks_compressed.js +166 -173
- package/blocks_compressed.js.map +1 -1
- package/core/any_aliases.d.ts +5 -0
- package/core/block.d.ts +49 -17
- package/core/block_animations.d.ts +0 -4
- package/core/block_drag_surface.d.ts +135 -0
- package/core/block_dragger.d.ts +2 -7
- package/core/block_svg.d.ts +72 -9
- package/core/blockly.d.ts +29 -58
- package/core/blockly_options.d.ts +0 -2
- package/core/blocks.d.ts +0 -2
- package/core/browser_events.d.ts +0 -9
- package/core/bubble.d.ts +6 -4
- package/core/bubble_dragger.d.ts +2 -3
- package/core/bump_objects.d.ts +0 -3
- package/core/clipboard.d.ts +0 -3
- package/core/comment.d.ts +6 -10
- package/core/common.d.ts +0 -12
- package/core/component_manager.d.ts +0 -2
- package/core/connection.d.ts +19 -6
- package/core/connection_checker.d.ts +1 -3
- package/core/connection_db.d.ts +0 -2
- package/core/connection_type.d.ts +0 -2
- package/core/constants.d.ts +0 -4
- package/core/contextmenu.d.ts +0 -11
- package/core/contextmenu_items.d.ts +0 -27
- package/core/contextmenu_registry.d.ts +0 -2
- package/core/css.d.ts +0 -2
- package/core/delete_area.d.ts +0 -2
- package/core/dialog.d.ts +0 -6
- package/core/drag_target.d.ts +0 -2
- package/core/events/events_abstract.d.ts +0 -3
- package/core/events/events_block_base.d.ts +0 -2
- package/core/events/events_block_change.d.ts +0 -2
- package/core/events/events_block_create.d.ts +0 -2
- package/core/events/events_block_delete.d.ts +0 -2
- package/core/events/events_block_drag.d.ts +0 -2
- package/core/events/events_block_move.d.ts +0 -2
- package/core/events/events_bubble_open.d.ts +0 -2
- package/core/events/events_click.d.ts +0 -2
- package/core/events/events_comment_base.d.ts +0 -2
- package/core/events/events_comment_change.d.ts +0 -2
- package/core/events/events_comment_create.d.ts +0 -2
- package/core/events/events_comment_delete.d.ts +0 -2
- package/core/events/events_comment_move.d.ts +0 -2
- package/core/events/events_marker_move.d.ts +0 -2
- package/core/events/events_selected.d.ts +0 -2
- package/core/events/events_theme_change.d.ts +0 -2
- package/core/events/events_toolbox_item_select.d.ts +0 -2
- package/core/events/events_trashcan_open.d.ts +0 -2
- package/core/events/events_ui.d.ts +0 -1
- package/core/events/events_ui_base.d.ts +0 -2
- package/core/events/events_var_base.d.ts +0 -2
- package/core/events/events_var_create.d.ts +0 -2
- package/core/events/events_viewport.d.ts +0 -2
- package/core/events/utils.d.ts +0 -73
- package/core/events/workspace_events.d.ts +0 -2
- package/core/extensions.d.ts +0 -8
- package/core/field.d.ts +16 -15
- package/core/field_angle.d.ts +60 -50
- package/core/field_checkbox.d.ts +22 -10
- package/core/field_colour.d.ts +55 -42
- package/core/field_dropdown.d.ts +34 -18
- package/core/field_image.d.ts +9 -12
- package/core/field_input.d.ts +34 -11
- package/core/field_label.d.ts +7 -10
- package/core/field_label_serializable.d.ts +4 -6
- package/core/field_multilineinput.d.ts +34 -12
- package/core/field_number.d.ts +27 -19
- package/core/field_registry.d.ts +0 -3
- package/core/field_textinput.d.ts +28 -12
- package/core/field_variable.d.ts +28 -16
- package/core/flyout_base.d.ts +5 -6
- package/core/flyout_button.d.ts +2 -2
- package/core/flyout_horizontal.d.ts +0 -2
- package/core/flyout_metrics_manager.d.ts +0 -2
- package/core/flyout_vertical.d.ts +0 -2
- package/core/generator.d.ts +0 -1
- package/core/gesture.d.ts +4 -17
- package/core/grid.d.ts +0 -2
- package/core/icon.d.ts +0 -2
- package/core/inject.d.ts +0 -1
- package/core/input.d.ts +0 -3
- package/core/input_types.d.ts +0 -2
- package/core/insertion_marker_manager.d.ts +6 -6
- package/core/interfaces/i_ast_node_location.d.ts +0 -2
- package/core/interfaces/i_ast_node_location_svg.d.ts +0 -2
- package/core/interfaces/i_ast_node_location_with_block.d.ts +0 -2
- package/core/interfaces/i_autohideable.d.ts +0 -2
- package/core/interfaces/i_block_dragger.d.ts +1 -3
- package/core/interfaces/i_bounded_element.d.ts +0 -2
- package/core/interfaces/i_bubble.d.ts +6 -4
- package/core/interfaces/i_collapsible_toolbox_item.d.ts +0 -2
- package/core/interfaces/i_component.d.ts +0 -2
- package/core/interfaces/i_connection_checker.d.ts +0 -2
- package/core/interfaces/i_contextmenu.d.ts +0 -1
- package/core/interfaces/i_copyable.d.ts +3 -2
- package/core/interfaces/i_deletable.d.ts +0 -2
- package/core/interfaces/i_delete_area.d.ts +0 -2
- package/core/interfaces/i_drag_target.d.ts +0 -2
- package/core/interfaces/i_draggable.d.ts +0 -2
- package/core/interfaces/i_flyout.d.ts +0 -2
- package/core/interfaces/i_keyboard_accessible.d.ts +0 -2
- package/core/interfaces/i_legacy_procedure_blocks.d.ts +34 -0
- package/core/interfaces/i_metrics_manager.d.ts +0 -2
- package/core/interfaces/i_movable.d.ts +0 -2
- package/core/interfaces/i_positionable.d.ts +0 -2
- package/core/interfaces/i_procedure_model.d.ts +0 -5
- package/core/interfaces/i_registrable.d.ts +0 -2
- package/core/interfaces/i_selectable.d.ts +0 -2
- package/core/interfaces/i_selectable_toolbox_item.d.ts +4 -2
- package/core/interfaces/i_serializer.d.ts +0 -2
- package/core/interfaces/i_styleable.d.ts +0 -2
- package/core/interfaces/i_toolbox.d.ts +0 -2
- package/core/interfaces/i_toolbox_item.d.ts +0 -2
- package/core/interfaces/i_variable_backed_parameter_model.d.ts +17 -0
- package/core/internal_constants.d.ts +0 -5
- package/core/keyboard_nav/ast_node.d.ts +0 -3
- package/core/keyboard_nav/basic_cursor.d.ts +0 -3
- package/core/keyboard_nav/cursor.d.ts +0 -3
- package/core/keyboard_nav/marker.d.ts +0 -2
- package/core/keyboard_nav/tab_navigate_cursor.d.ts +0 -2
- package/core/marker_manager.d.ts +0 -2
- package/core/menu.d.ts +0 -2
- package/core/menuitem.d.ts +0 -2
- package/core/metrics_manager.d.ts +0 -2
- package/core/mutator.d.ts +0 -2
- package/core/names.d.ts +0 -3
- package/core/options.d.ts +0 -2
- package/core/positionable_helpers.d.ts +0 -7
- package/core/procedures.d.ts +2 -25
- package/core/registry.d.ts +0 -11
- package/core/render_management.d.ts +15 -0
- package/core/rendered_connection.d.ts +22 -9
- package/core/renderers/common/block_rendering.d.ts +0 -3
- package/core/renderers/common/constants.d.ts +6 -51
- package/core/renderers/common/debug.d.ts +0 -3
- package/core/renderers/common/debugger.d.ts +9 -23
- package/core/renderers/common/drawer.d.ts +0 -5
- package/core/renderers/common/i_path_object.d.ts +0 -17
- package/core/renderers/common/info.d.ts +2 -12
- package/core/renderers/common/marker_svg.d.ts +2 -4
- package/core/renderers/common/path_object.d.ts +0 -24
- package/core/renderers/common/renderer.d.ts +5 -20
- package/core/renderers/geras/constants.d.ts +0 -5
- package/core/renderers/geras/drawer.d.ts +2 -4
- package/core/renderers/geras/highlight_constants.d.ts +6 -17
- package/core/renderers/geras/highlighter.d.ts +0 -13
- package/core/renderers/geras/info.d.ts +2 -5
- package/core/renderers/geras/measurables/inline_input.d.ts +0 -3
- package/core/renderers/geras/measurables/statement_input.d.ts +0 -3
- package/core/renderers/geras/path_object.d.ts +0 -8
- package/core/renderers/geras/renderer.d.ts +5 -7
- package/core/renderers/measurables/base.d.ts +0 -3
- package/core/renderers/measurables/bottom_row.d.ts +0 -9
- package/core/renderers/measurables/connection.d.ts +0 -3
- package/core/renderers/measurables/external_value_input.d.ts +0 -3
- package/core/renderers/measurables/field.d.ts +0 -3
- package/core/renderers/measurables/hat.d.ts +0 -3
- package/core/renderers/measurables/icon.d.ts +2 -5
- package/core/renderers/measurables/in_row_spacer.d.ts +0 -3
- package/core/renderers/measurables/inline_input.d.ts +1 -4
- package/core/renderers/measurables/input_connection.d.ts +1 -4
- package/core/renderers/measurables/input_row.d.ts +0 -7
- package/core/renderers/measurables/jagged_edge.d.ts +2 -5
- package/core/renderers/measurables/next_connection.d.ts +0 -3
- package/core/renderers/measurables/output_connection.d.ts +0 -3
- package/core/renderers/measurables/previous_connection.d.ts +0 -3
- package/core/renderers/measurables/round_corner.d.ts +0 -3
- package/core/renderers/measurables/row.d.ts +0 -39
- package/core/renderers/measurables/spacer_row.d.ts +0 -3
- package/core/renderers/measurables/square_corner.d.ts +0 -3
- package/core/renderers/measurables/statement_input.d.ts +0 -3
- package/core/renderers/measurables/top_row.d.ts +0 -6
- package/core/renderers/measurables/types.d.ts +0 -31
- package/core/renderers/minimalist/constants.d.ts +2 -4
- package/core/renderers/minimalist/drawer.d.ts +0 -3
- package/core/renderers/minimalist/info.d.ts +0 -4
- package/core/renderers/minimalist/renderer.d.ts +0 -3
- package/core/renderers/thrasos/info.d.ts +0 -4
- package/core/renderers/thrasos/renderer.d.ts +3 -3
- package/core/renderers/zelos/constants.d.ts +3 -17
- package/core/renderers/zelos/drawer.d.ts +0 -3
- package/core/renderers/zelos/info.d.ts +0 -4
- package/core/renderers/zelos/marker_svg.d.ts +0 -2
- package/core/renderers/zelos/measurables/bottom_row.d.ts +0 -3
- package/core/renderers/zelos/measurables/inputs.d.ts +0 -3
- package/core/renderers/zelos/measurables/row_elements.d.ts +0 -3
- package/core/renderers/zelos/measurables/top_row.d.ts +0 -3
- package/core/renderers/zelos/path_object.d.ts +0 -9
- package/core/renderers/zelos/renderer.d.ts +3 -5
- package/core/scrollbar.d.ts +0 -2
- package/core/scrollbar_pair.d.ts +0 -2
- package/core/serialization/blocks.d.ts +3 -9
- package/core/serialization/exceptions.d.ts +0 -8
- package/core/serialization/priorities.d.ts +0 -4
- package/core/serialization/registry.d.ts +0 -2
- package/core/serialization/variables.d.ts +0 -4
- package/core/serialization/workspaces.d.ts +0 -2
- package/core/shortcut_items.d.ts +0 -17
- package/core/shortcut_registry.d.ts +0 -2
- package/core/sprites.d.ts +0 -2
- package/core/theme/classic.d.ts +0 -2
- package/core/theme/zelos.d.ts +0 -2
- package/core/theme.d.ts +0 -2
- package/core/theme_manager.d.ts +3 -6
- package/core/toolbox/category.d.ts +5 -7
- package/core/toolbox/collapsible_category.d.ts +0 -4
- package/core/toolbox/separator.d.ts +0 -2
- package/core/toolbox/toolbox.d.ts +2 -5
- package/core/toolbox/toolbox_item.d.ts +0 -2
- package/core/tooltip.d.ts +0 -29
- package/core/touch.d.ts +0 -13
- package/core/trashcan.d.ts +0 -2
- package/core/utils/aria.d.ts +0 -6
- package/core/utils/array.d.ts +0 -1
- package/core/utils/colour.d.ts +0 -12
- package/core/utils/coordinate.d.ts +0 -2
- package/core/utils/deprecation.d.ts +0 -1
- package/core/utils/dom.d.ts +0 -25
- package/core/utils/idgenerator.d.ts +0 -2
- package/core/utils/keycodes.d.ts +0 -2
- package/core/utils/math.d.ts +0 -3
- package/core/utils/metrics.d.ts +0 -1
- package/core/utils/object.d.ts +0 -4
- package/core/utils/parsing.d.ts +0 -4
- package/core/utils/rect.d.ts +0 -2
- package/core/utils/size.d.ts +0 -2
- package/core/utils/string.d.ts +0 -6
- package/core/utils/style.d.ts +0 -8
- package/core/utils/svg.d.ts +0 -2
- package/core/utils/svg_math.d.ts +0 -6
- package/core/utils/svg_paths.d.ts +0 -8
- package/core/utils/toolbox.d.ts +2 -35
- package/core/utils/useragent.d.ts +0 -8
- package/core/utils/xml.d.ts +9 -8
- package/core/utils.d.ts +0 -12
- package/core/variable_map.d.ts +1 -3
- package/core/variable_model.d.ts +0 -1
- package/core/variables.d.ts +13 -17
- package/core/variables_dynamic.d.ts +0 -4
- package/core/warning.d.ts +0 -2
- package/core/widgetdiv.d.ts +0 -10
- package/core/workspace.d.ts +3 -3
- package/core/workspace_audio.d.ts +0 -2
- package/core/workspace_comment.d.ts +1 -3
- package/core/workspace_comment_svg.d.ts +16 -5
- package/core/workspace_drag_surface_svg.d.ts +74 -0
- package/core/workspace_dragger.d.ts +3 -2
- package/core/workspace_svg.d.ts +48 -8
- package/core/xml.d.ts +1 -13
- package/core/zoom_controls.d.ts +4 -15
- package/dart_compressed.js +199 -199
- package/dart_compressed.js.map +1 -1
- package/javascript_compressed.js +168 -168
- package/javascript_compressed.js.map +1 -1
- package/lua_compressed.js +211 -211
- package/lua_compressed.js.map +1 -1
- package/msg/bn.js +2 -2
- package/msg/bs.js +7 -7
- package/msg/de.js +1 -1
- package/msg/fi.js +1 -1
- package/msg/fr.js +3 -3
- package/msg/ia.js +5 -5
- package/msg/kn.js +5 -5
- package/msg/ko.js +1 -1
- package/msg/lb.js +22 -22
- package/msg/sd.js +9 -9
- package/msg/skr-arab.js +2 -2
- package/msg/sl.js +18 -18
- package/msg/sw.js +1 -1
- package/msg/zh-hans.js +6 -6
- package/msg/zh-hant.js +2 -2
- package/package.json +6 -6
- package/php_compressed.js +185 -185
- package/php_compressed.js.map +1 -1
- package/python_compressed.js +138 -138
- package/python_compressed.js.map +1 -1
- package/core/utils/sentinel.d.ts +0 -18
package/php_compressed.js
CHANGED
|
@@ -27,162 +27,43 @@ module$exports$Blockly$PHP.phpGenerator.multiline_quote_=function(a){return a.sp
|
|
|
27
27
|
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&&
|
|
28
28
|
a.nextConnection.targetBlock();c=c?"":this.blockToCode(a);return d+b+c};
|
|
29
29
|
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="("+
|
|
30
|
-
a+")"));return a};var module$exports$Blockly$PHP$
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
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)||"''";
|
|
34
|
-
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]};
|
|
35
|
-
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",`
|
|
36
|
-
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($value) {
|
|
37
|
-
if (is_string($value)) {
|
|
38
|
-
return strlen($value);
|
|
39
|
-
}
|
|
40
|
-
return count($value);
|
|
41
|
-
}
|
|
42
|
-
`);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]};
|
|
43
|
-
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"===
|
|
44
|
-
a.getFieldValue("END")?"text_indexOf":"text_lastIndexOf",`
|
|
45
|
-
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($text, $search) {
|
|
46
|
-
$pos = ${b}($text, $search);
|
|
47
|
-
return $pos === false ? ${e} : $pos${f};
|
|
30
|
+
a+")"));return a};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",`
|
|
31
|
+
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}() {
|
|
32
|
+
return '#' . str_pad(dechex(mt_rand(0, 0xFFFFFF)), 6, '0', STR_PAD_LEFT);
|
|
48
33
|
}
|
|
49
|
-
`)+"(
|
|
50
|
-
module$exports$Blockly$PHP.phpGenerator.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
34
|
+
`)+"()",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};
|
|
35
|
+
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",`
|
|
36
|
+
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($r, $g, $b) {
|
|
37
|
+
$r = round(max(min($r, 100), 0) * 2.55);
|
|
38
|
+
$g = round(max(min($g, 100), 0) * 2.55);
|
|
39
|
+
$b = round(max(min($b, 100), 0) * 2.55);
|
|
40
|
+
$hex = '#';
|
|
41
|
+
$hex .= str_pad(dechex($r), 2, '0', STR_PAD_LEFT);
|
|
42
|
+
$hex .= str_pad(dechex($g), 2, '0', STR_PAD_LEFT);
|
|
43
|
+
$hex .= str_pad(dechex($b), 2, '0', STR_PAD_LEFT);
|
|
44
|
+
return $hex;
|
|
54
45
|
}
|
|
55
|
-
`)+"("+c+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]}
|
|
56
|
-
module$exports$Blockly$PHP.phpGenerator.
|
|
46
|
+
`)+"("+b+", "+c+", "+a+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};
|
|
47
|
+
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",
|
|
57
48
|
`
|
|
58
|
-
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
$
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
throw new Exception('Unhandled option (text_get_substring).');
|
|
75
|
-
}
|
|
76
|
-
return substr($text, $at1, $length);
|
|
77
|
-
}
|
|
78
|
-
`)+"("+d+", '"+b+"', "+e+", '"+c+"', "+a+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};
|
|
79
|
-
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]};
|
|
80
|
-
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]};
|
|
81
|
-
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"};
|
|
82
|
-
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;
|
|
83
|
-
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]};
|
|
84
|
-
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]};
|
|
85
|
-
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;
|
|
86
|
-
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));
|
|
87
|
-
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,
|
|
88
|
-
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,
|
|
89
|
-
"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};
|
|
90
|
-
module$exports$Blockly$PHP.phpGenerator.procedures_defnoreturn=module$exports$Blockly$PHP.phpGenerator.procedures_defreturn;
|
|
91
|
-
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]};
|
|
92
|
-
module$exports$Blockly$PHP.phpGenerator.procedures_callnoreturn=function(a){return module$exports$Blockly$PHP.phpGenerator.procedures_callreturn(a)[0]+";\n"};
|
|
93
|
-
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_?
|
|
94
|
-
(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]};
|
|
95
|
-
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,
|
|
96
|
-
"A",b)||"0";a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"B",b)||"0";return[d+c+a,b]};
|
|
97
|
-
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,
|
|
98
|
-
"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];
|
|
99
|
-
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]};
|
|
100
|
-
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")]};
|
|
101
|
-
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,
|
|
102
|
-
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]=
|
|
103
|
-
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",`
|
|
104
|
-
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($n) {
|
|
105
|
-
// https://en.wikipedia.org/wiki/Primality_test#Naive_methods
|
|
106
|
-
if ($n == 2 || $n == 3) {
|
|
107
|
-
return true;
|
|
108
|
-
}
|
|
109
|
-
// False if n is NaN, negative, is 1, or not whole.
|
|
110
|
-
// And false if n is divisible by 2 or 3.
|
|
111
|
-
if (!is_numeric($n) || $n <= 1 || $n % 1 != 0 || $n % 2 == 0 || $n % 3 == 0) {
|
|
112
|
-
return false;
|
|
113
|
-
}
|
|
114
|
-
// Check all the numbers of form 6k +/- 1, up to sqrt(n).
|
|
115
|
-
for ($x = 6; $x <= sqrt($n) + 1; $x += 6) {
|
|
116
|
-
if ($n % ($x - 1) == 0 || $n % ($x + 1) == 0) {
|
|
117
|
-
return false;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
return true;
|
|
121
|
-
}
|
|
122
|
-
`)+"("+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]};
|
|
123
|
-
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;
|
|
124
|
-
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,
|
|
125
|
-
"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",`
|
|
126
|
-
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($myList) {
|
|
127
|
-
return array_sum($myList) / count($myList);
|
|
128
|
-
}
|
|
129
|
-
`);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",`
|
|
130
|
-
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($arr) {
|
|
131
|
-
sort($arr,SORT_NUMERIC);
|
|
132
|
-
return (count($arr) % 2) ? $arr[floor(count($arr) / 2)] :
|
|
133
|
-
($arr[floor(count($arr) / 2)] + $arr[floor(count($arr) / 2) - 1]) / 2;
|
|
134
|
-
}
|
|
135
|
-
`);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",`
|
|
136
|
-
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($values) {
|
|
137
|
-
if (empty($values)) return array();
|
|
138
|
-
$counts = array_count_values($values);
|
|
139
|
-
arsort($counts); // Sort counts in descending order
|
|
140
|
-
$modes = array_keys($counts, current($counts), true);
|
|
141
|
-
return $modes;
|
|
142
|
-
}
|
|
143
|
-
`);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",`
|
|
144
|
-
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($numbers) {
|
|
145
|
-
$n = count($numbers);
|
|
146
|
-
if (!$n) return null;
|
|
147
|
-
$mean = array_sum($numbers) / count($numbers);
|
|
148
|
-
foreach($numbers as $key => $num) $devs[$key] = pow($num - $mean, 2);
|
|
149
|
-
return sqrt(array_sum($devs) / (count($devs) - 1));
|
|
150
|
-
}
|
|
151
|
-
`);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",`
|
|
152
|
-
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($list) {
|
|
153
|
-
$x = rand(0, count($list)-1);
|
|
154
|
-
return $list[$x];
|
|
155
|
-
}
|
|
156
|
-
`);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]};
|
|
157
|
-
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]};
|
|
158
|
-
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]};
|
|
159
|
-
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",`
|
|
160
|
-
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($a, $b) {
|
|
161
|
-
if ($a > $b) {
|
|
162
|
-
return rand($b, $a);
|
|
163
|
-
}
|
|
164
|
-
return rand($a, $b);
|
|
49
|
+
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($c1, $c2, $ratio) {
|
|
50
|
+
$ratio = max(min($ratio, 1), 0);
|
|
51
|
+
$r1 = hexdec(substr($c1, 1, 2));
|
|
52
|
+
$g1 = hexdec(substr($c1, 3, 2));
|
|
53
|
+
$b1 = hexdec(substr($c1, 5, 2));
|
|
54
|
+
$r2 = hexdec(substr($c2, 1, 2));
|
|
55
|
+
$g2 = hexdec(substr($c2, 3, 2));
|
|
56
|
+
$b2 = hexdec(substr($c2, 5, 2));
|
|
57
|
+
$r = round($r1 * (1 - $ratio) + $r2 * $ratio);
|
|
58
|
+
$g = round($g1 * (1 - $ratio) + $g2 * $ratio);
|
|
59
|
+
$b = round($b1 * (1 - $ratio) + $b2 * $ratio);
|
|
60
|
+
$hex = '#';
|
|
61
|
+
$hex .= str_pad(dechex($r), 2, '0', STR_PAD_LEFT);
|
|
62
|
+
$hex .= str_pad(dechex($g), 2, '0', STR_PAD_LEFT);
|
|
63
|
+
$hex .= str_pad(dechex($b), 2, '0', STR_PAD_LEFT);
|
|
64
|
+
return $hex;
|
|
165
65
|
}
|
|
166
|
-
`)+"("+b+", "+a+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};module$exports$Blockly$PHP.phpGenerator.
|
|
167
|
-
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;
|
|
168
|
-
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);
|
|
169
|
-
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;
|
|
170
|
-
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"};
|
|
171
|
-
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,
|
|
172
|
-
"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);
|
|
173
|
-
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+
|
|
174
|
-
"_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};
|
|
175
|
-
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+
|
|
176
|
-
"}\n"};
|
|
177
|
-
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();
|
|
178
|
-
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={};
|
|
179
|
-
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=
|
|
180
|
-
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,
|
|
181
|
-
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;
|
|
182
|
-
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]};
|
|
183
|
-
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]};
|
|
184
|
-
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]};
|
|
185
|
-
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]};
|
|
66
|
+
`)+"("+b+", "+c+", "+a+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};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]};
|
|
186
67
|
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",`
|
|
187
68
|
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($value, $count) {
|
|
188
69
|
$array = array();
|
|
@@ -294,43 +175,162 @@ function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($
|
|
|
294
175
|
}
|
|
295
176
|
`)+"("+b+', "'+a+'", '+c+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};
|
|
296
177
|
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]};
|
|
297
|
-
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$
|
|
298
|
-
function $
|
|
299
|
-
|
|
178
|
+
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$logic={};
|
|
179
|
+
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=
|
|
180
|
+
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,
|
|
181
|
+
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;
|
|
182
|
+
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]};
|
|
183
|
+
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]};
|
|
184
|
+
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]};
|
|
185
|
+
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$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;
|
|
186
|
+
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);
|
|
187
|
+
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;
|
|
188
|
+
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"};
|
|
189
|
+
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,
|
|
190
|
+
"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);
|
|
191
|
+
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+
|
|
192
|
+
"_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};
|
|
193
|
+
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+
|
|
194
|
+
"}\n"};
|
|
195
|
+
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();
|
|
196
|
+
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$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]};
|
|
197
|
+
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,
|
|
198
|
+
"A",b)||"0";a=module$exports$Blockly$PHP.phpGenerator.valueToCode(a,"B",b)||"0";return[d+c+a,b]};
|
|
199
|
+
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,
|
|
200
|
+
"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];
|
|
201
|
+
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]};
|
|
202
|
+
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")]};
|
|
203
|
+
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,
|
|
204
|
+
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]=
|
|
205
|
+
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",`
|
|
206
|
+
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($n) {
|
|
207
|
+
// https://en.wikipedia.org/wiki/Primality_test#Naive_methods
|
|
208
|
+
if ($n == 2 || $n == 3) {
|
|
209
|
+
return true;
|
|
210
|
+
}
|
|
211
|
+
// False if n is NaN, negative, is 1, or not whole.
|
|
212
|
+
// And false if n is divisible by 2 or 3.
|
|
213
|
+
if (!is_numeric($n) || $n <= 1 || $n % 1 != 0 || $n % 2 == 0 || $n % 3 == 0) {
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
// Check all the numbers of form 6k +/- 1, up to sqrt(n).
|
|
217
|
+
for ($x = 6; $x <= sqrt($n) + 1; $x += 6) {
|
|
218
|
+
if ($n % ($x - 1) == 0 || $n % ($x + 1) == 0) {
|
|
219
|
+
return false;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return true;
|
|
300
223
|
}
|
|
301
|
-
`)+"()",module$exports$Blockly$PHP.phpGenerator.
|
|
302
|
-
module$exports$Blockly$PHP.phpGenerator.
|
|
303
|
-
function
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
$hex = '#';
|
|
308
|
-
$hex .= str_pad(dechex($r), 2, '0', STR_PAD_LEFT);
|
|
309
|
-
$hex .= str_pad(dechex($g), 2, '0', STR_PAD_LEFT);
|
|
310
|
-
$hex .= str_pad(dechex($b), 2, '0', STR_PAD_LEFT);
|
|
311
|
-
return $hex;
|
|
224
|
+
`)+"("+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]};
|
|
225
|
+
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;
|
|
226
|
+
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,
|
|
227
|
+
"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",`
|
|
228
|
+
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($myList) {
|
|
229
|
+
return array_sum($myList) / count($myList);
|
|
312
230
|
}
|
|
313
|
-
`)
|
|
314
|
-
|
|
231
|
+
`);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",`
|
|
232
|
+
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($arr) {
|
|
233
|
+
sort($arr,SORT_NUMERIC);
|
|
234
|
+
return (count($arr) % 2) ? $arr[floor(count($arr) / 2)] :
|
|
235
|
+
($arr[floor(count($arr) / 2)] + $arr[floor(count($arr) / 2) - 1]) / 2;
|
|
236
|
+
}
|
|
237
|
+
`);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",`
|
|
238
|
+
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($values) {
|
|
239
|
+
if (empty($values)) return array();
|
|
240
|
+
$counts = array_count_values($values);
|
|
241
|
+
arsort($counts); // Sort counts in descending order
|
|
242
|
+
$modes = array_keys($counts, current($counts), true);
|
|
243
|
+
return $modes;
|
|
244
|
+
}
|
|
245
|
+
`);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",`
|
|
246
|
+
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($numbers) {
|
|
247
|
+
$n = count($numbers);
|
|
248
|
+
if (!$n) return null;
|
|
249
|
+
$mean = array_sum($numbers) / count($numbers);
|
|
250
|
+
foreach($numbers as $key => $num) $devs[$key] = pow($num - $mean, 2);
|
|
251
|
+
return sqrt(array_sum($devs) / (count($devs) - 1));
|
|
252
|
+
}
|
|
253
|
+
`);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",`
|
|
254
|
+
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($list) {
|
|
255
|
+
$x = rand(0, count($list)-1);
|
|
256
|
+
return $list[$x];
|
|
257
|
+
}
|
|
258
|
+
`);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]};
|
|
259
|
+
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]};
|
|
260
|
+
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]};
|
|
261
|
+
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",`
|
|
262
|
+
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($a, $b) {
|
|
263
|
+
if ($a > $b) {
|
|
264
|
+
return rand($b, $a);
|
|
265
|
+
}
|
|
266
|
+
return rand($a, $b);
|
|
267
|
+
}
|
|
268
|
+
`)+"("+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]};
|
|
269
|
+
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$procedures={},module$contents$Blockly$PHP$procedures_Variables=$.module$build$src$core$variables,module$contents$Blockly$PHP$procedures_NameType=$.NameType$$module$build$src$core$names;
|
|
270
|
+
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));
|
|
271
|
+
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,
|
|
272
|
+
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,
|
|
273
|
+
"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};
|
|
274
|
+
module$exports$Blockly$PHP.phpGenerator.procedures_defnoreturn=module$exports$Blockly$PHP.phpGenerator.procedures_defreturn;
|
|
275
|
+
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]};
|
|
276
|
+
module$exports$Blockly$PHP.phpGenerator.procedures_callnoreturn=function(a){return module$exports$Blockly$PHP.phpGenerator.procedures_callreturn(a)[0]+";\n"};
|
|
277
|
+
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_?
|
|
278
|
+
(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$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]};
|
|
279
|
+
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]};
|
|
280
|
+
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)||"''";
|
|
281
|
+
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]};
|
|
282
|
+
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",`
|
|
283
|
+
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($value) {
|
|
284
|
+
if (is_string($value)) {
|
|
285
|
+
return strlen($value);
|
|
286
|
+
}
|
|
287
|
+
return count($value);
|
|
288
|
+
}
|
|
289
|
+
`);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]};
|
|
290
|
+
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"===
|
|
291
|
+
a.getFieldValue("END")?"text_indexOf":"text_lastIndexOf",`
|
|
292
|
+
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($text, $search) {
|
|
293
|
+
$pos = ${b}($text, $search);
|
|
294
|
+
return $pos === false ? ${e} : $pos${f};
|
|
295
|
+
}
|
|
296
|
+
`)+"("+d+", "+c+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};
|
|
297
|
+
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,
|
|
298
|
+
"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",`
|
|
299
|
+
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($text) {
|
|
300
|
+
return $text[rand(0, strlen($text) - 1)];
|
|
301
|
+
}
|
|
302
|
+
`)+"("+c+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]}throw Error("Unhandled option (text_charAt).");};
|
|
303
|
+
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",
|
|
315
304
|
`
|
|
316
|
-
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
$
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
$
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
305
|
+
function ${module$exports$Blockly$PHP.phpGenerator.FUNCTION_NAME_PLACEHOLDER_}($text, $where1, $at1, $where2, $at2) {
|
|
306
|
+
if ($where1 == 'FROM_END') {
|
|
307
|
+
$at1 = strlen($text) - 1 - $at1;
|
|
308
|
+
} else if ($where1 == 'FIRST') {
|
|
309
|
+
$at1 = 0;
|
|
310
|
+
} else if ($where1 != 'FROM_START') {
|
|
311
|
+
throw new Exception('Unhandled option (text_get_substring).');
|
|
312
|
+
}
|
|
313
|
+
$length = 0;
|
|
314
|
+
if ($where2 == 'FROM_START') {
|
|
315
|
+
$length = $at2 - $at1 + 1;
|
|
316
|
+
} else if ($where2 == 'FROM_END') {
|
|
317
|
+
$length = strlen($text) - $at1 - $at2;
|
|
318
|
+
} else if ($where2 == 'LAST') {
|
|
319
|
+
$length = strlen($text) - $at1;
|
|
320
|
+
} else {
|
|
321
|
+
throw new Exception('Unhandled option (text_get_substring).');
|
|
322
|
+
}
|
|
323
|
+
return substr($text, $at1, $length);
|
|
332
324
|
}
|
|
333
|
-
`)+"("+b+", "+c+", "+a+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};
|
|
325
|
+
`)+"("+d+", '"+b+"', "+e+", '"+c+"', "+a+")",module$exports$Blockly$PHP.phpGenerator.ORDER_FUNCTION_CALL]};
|
|
326
|
+
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]};
|
|
327
|
+
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]};
|
|
328
|
+
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"};
|
|
329
|
+
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;
|
|
330
|
+
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]};
|
|
331
|
+
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]};
|
|
332
|
+
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$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]};
|
|
333
|
+
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$all=module$exports$Blockly$PHP;
|
|
334
334
|
module$exports$Blockly$PHP.__namespace__=$;
|
|
335
335
|
return module$exports$Blockly$PHP;
|
|
336
336
|
}));
|