nodeskini 1.0.1 → 1.0.3

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.
Files changed (534) hide show
  1. package/blocklySkini/archive/blocklyControleur.js +87 -0
  2. package/blocklySkini/archive/blocklySkini.js +84 -0
  3. package/blocklySkini/archive/blocklyhop.js +75 -0
  4. package/blocklySkini/archive/clientControleurBlocly.js +170 -0
  5. package/blocklySkini/archive/index.html +76 -0
  6. package/blocklySkini/archive/testHHsuspend.txt +89 -0
  7. package/blocklySkini/archive/testHHtrap.txt +262 -0
  8. package/blocklySkini/archive/testOrchestration.txt +177 -0
  9. package/blocklySkini/archive/testOrchestration.xml +447 -0
  10. package/blocklySkini/archive/testOrchestration2.xml +456 -0
  11. package/blocklySkini/blockly/README.md +77 -0
  12. package/blocklySkini/blockly/blockly.d.ts +21480 -0
  13. package/blocklySkini/blockly/blockly.js +25 -0
  14. package/blocklySkini/blockly/blockly.min.js +2188 -0
  15. package/blocklySkini/blockly/blockly_compressed.js +1455 -0
  16. package/blocklySkini/blockly/blockly_compressed.js.map +1 -0
  17. package/blocklySkini/blockly/blocks/colour.js +122 -0
  18. package/blocklySkini/blockly/blocks/lists.js +862 -0
  19. package/blocklySkini/blockly/blocks/logic.js +635 -0
  20. package/blocklySkini/blockly/blocks/loops.js +357 -0
  21. package/blocklySkini/blockly/blocks/math.js +566 -0
  22. package/blocklySkini/blockly/blocks/procedures.js +1072 -0
  23. package/blocklySkini/blockly/blocks/text.js +923 -0
  24. package/blocklySkini/blockly/blocks/variables.js +163 -0
  25. package/blocklySkini/blockly/blocks/variables_dynamic.js +180 -0
  26. package/blocklySkini/blockly/blocks.d.ts +15 -0
  27. package/blocklySkini/blockly/blocks.js +27 -0
  28. package/blocklySkini/blockly/blocks_compressed.js +182 -0
  29. package/blocklySkini/blockly/blocks_compressed.js.map +1 -0
  30. package/blocklySkini/blockly/browser.js +36 -0
  31. package/blocklySkini/blockly/core/block.js +2010 -0
  32. package/blocklySkini/blockly/core/block_animations.js +203 -0
  33. package/blocklySkini/blockly/core/block_drag_surface.js +212 -0
  34. package/blocklySkini/blockly/core/block_dragger.js +378 -0
  35. package/blocklySkini/blockly/core/block_events.js +548 -0
  36. package/blocklySkini/blockly/core/block_svg.js +1763 -0
  37. package/blocklySkini/blockly/core/blockly.js +674 -0
  38. package/blocklySkini/blockly/core/blocks.js +23 -0
  39. package/blocklySkini/blockly/core/bubble.js +880 -0
  40. package/blocklySkini/blockly/core/bubble_dragger.js +274 -0
  41. package/blocklySkini/blockly/core/comment.js +439 -0
  42. package/blocklySkini/blockly/core/components/component.js +554 -0
  43. package/blocklySkini/blockly/core/components/tree/basenode.js +895 -0
  44. package/blocklySkini/blockly/core/components/tree/treecontrol.js +332 -0
  45. package/blocklySkini/blockly/core/components/tree/treenode.js +172 -0
  46. package/blocklySkini/blockly/core/connection.js +682 -0
  47. package/blocklySkini/blockly/core/connection_checker.js +285 -0
  48. package/blocklySkini/blockly/core/connection_db.js +295 -0
  49. package/blocklySkini/blockly/core/constants.js +277 -0
  50. package/blocklySkini/blockly/core/contextmenu.js +307 -0
  51. package/blocklySkini/blockly/core/contextmenu_items.js +534 -0
  52. package/blocklySkini/blockly/core/contextmenu_registry.js +165 -0
  53. package/blocklySkini/blockly/core/css.js +549 -0
  54. package/blocklySkini/blockly/core/dropdowndiv.js +776 -0
  55. package/blocklySkini/blockly/core/events.js +387 -0
  56. package/blocklySkini/blockly/core/events_abstract.js +106 -0
  57. package/blocklySkini/blockly/core/extensions.js +450 -0
  58. package/blocklySkini/blockly/core/field.js +1162 -0
  59. package/blocklySkini/blockly/core/field_angle.js +562 -0
  60. package/blocklySkini/blockly/core/field_checkbox.js +220 -0
  61. package/blocklySkini/blockly/core/field_colour.js +664 -0
  62. package/blocklySkini/blockly/core/field_dropdown.js +760 -0
  63. package/blocklySkini/blockly/core/field_image.js +286 -0
  64. package/blocklySkini/blockly/core/field_label.js +130 -0
  65. package/blocklySkini/blockly/core/field_label_serializable.js +69 -0
  66. package/blocklySkini/blockly/core/field_multilineinput.js +299 -0
  67. package/blocklySkini/blockly/core/field_number.js +317 -0
  68. package/blocklySkini/blockly/core/field_registry.js +66 -0
  69. package/blocklySkini/blockly/core/field_textinput.js +616 -0
  70. package/blocklySkini/blockly/core/field_variable.js +463 -0
  71. package/blocklySkini/blockly/core/flyout_base.js +1071 -0
  72. package/blocklySkini/blockly/core/flyout_button.js +325 -0
  73. package/blocklySkini/blockly/core/flyout_dragger.js +76 -0
  74. package/blocklySkini/blockly/core/flyout_horizontal.js +388 -0
  75. package/blocklySkini/blockly/core/flyout_vertical.js +397 -0
  76. package/blocklySkini/blockly/core/generator.js +482 -0
  77. package/blocklySkini/blockly/core/gesture.js +993 -0
  78. package/blocklySkini/blockly/core/grid.js +222 -0
  79. package/blocklySkini/blockly/core/icon.js +206 -0
  80. package/blocklySkini/blockly/core/inject.js +487 -0
  81. package/blocklySkini/blockly/core/input.js +296 -0
  82. package/blocklySkini/blockly/core/insertion_marker_manager.js +700 -0
  83. package/blocklySkini/blockly/core/interfaces/i_accessibility.js +72 -0
  84. package/blocklySkini/blockly/core/interfaces/i_bounded_element.js +31 -0
  85. package/blocklySkini/blockly/core/interfaces/i_bubble.js +83 -0
  86. package/blocklySkini/blockly/core/interfaces/i_connection_checker.js +94 -0
  87. package/blocklySkini/blockly/core/interfaces/i_contextmenu.js +26 -0
  88. package/blocklySkini/blockly/core/interfaces/i_copyable.js +40 -0
  89. package/blocklySkini/blockly/core/interfaces/i_deletable.js +27 -0
  90. package/blocklySkini/blockly/core/interfaces/i_deletearea.js +28 -0
  91. package/blocklySkini/blockly/core/interfaces/i_flyout.js +178 -0
  92. package/blocklySkini/blockly/core/interfaces/i_movable.js +27 -0
  93. package/blocklySkini/blockly/core/interfaces/i_registrable.js +22 -0
  94. package/blocklySkini/blockly/core/interfaces/i_registrable_field.js +31 -0
  95. package/blocklySkini/blockly/core/interfaces/i_selectable.js +43 -0
  96. package/blocklySkini/blockly/core/interfaces/i_styleable.js +33 -0
  97. package/blocklySkini/blockly/core/interfaces/i_toolbox.js +131 -0
  98. package/blocklySkini/blockly/core/interfaces/i_toolbox_item.js +148 -0
  99. package/blocklySkini/blockly/core/keyboard_nav/action.js +26 -0
  100. package/blocklySkini/blockly/core/keyboard_nav/ast_node.js +684 -0
  101. package/blocklySkini/blockly/core/keyboard_nav/basic_cursor.js +208 -0
  102. package/blocklySkini/blockly/core/keyboard_nav/cursor.js +170 -0
  103. package/blocklySkini/blockly/core/keyboard_nav/flyout_cursor.js +106 -0
  104. package/blocklySkini/blockly/core/keyboard_nav/key_map.js +190 -0
  105. package/blocklySkini/blockly/core/keyboard_nav/marker.js +120 -0
  106. package/blocklySkini/blockly/core/keyboard_nav/navigation.js +1084 -0
  107. package/blocklySkini/blockly/core/keyboard_nav/tab_navigate_cursor.js +48 -0
  108. package/blocklySkini/blockly/core/marker_manager.js +183 -0
  109. package/blocklySkini/blockly/core/menu.js +465 -0
  110. package/blocklySkini/blockly/core/menuitem.js +280 -0
  111. package/blocklySkini/blockly/core/msg.js +31 -0
  112. package/blocklySkini/blockly/core/mutator.js +555 -0
  113. package/blocklySkini/blockly/core/names.js +186 -0
  114. package/blocklySkini/blockly/core/options.js +365 -0
  115. package/blocklySkini/blockly/core/procedures.js +404 -0
  116. package/blocklySkini/blockly/core/registry.js +265 -0
  117. package/blocklySkini/blockly/core/rendered_connection.js +565 -0
  118. package/blocklySkini/blockly/core/renderers/common/block_rendering.js +81 -0
  119. package/blocklySkini/blockly/core/renderers/common/constants.js +1256 -0
  120. package/blocklySkini/blockly/core/renderers/common/debugger.js +431 -0
  121. package/blocklySkini/blockly/core/renderers/common/drawer.js +468 -0
  122. package/blocklySkini/blockly/core/renderers/common/i_path_object.js +151 -0
  123. package/blocklySkini/blockly/core/renderers/common/info.js +775 -0
  124. package/blocklySkini/blockly/core/renderers/common/marker_svg.js +687 -0
  125. package/blocklySkini/blockly/core/renderers/common/path_object.js +279 -0
  126. package/blocklySkini/blockly/core/renderers/common/renderer.js +301 -0
  127. package/blocklySkini/blockly/core/renderers/geras/constants.js +64 -0
  128. package/blocklySkini/blockly/core/renderers/geras/drawer.js +205 -0
  129. package/blocklySkini/blockly/core/renderers/geras/highlight_constants.js +311 -0
  130. package/blocklySkini/blockly/core/renderers/geras/highlighter.js +256 -0
  131. package/blocklySkini/blockly/core/renderers/geras/info.js +483 -0
  132. package/blocklySkini/blockly/core/renderers/geras/measurables/inputs.js +67 -0
  133. package/blocklySkini/blockly/core/renderers/geras/path_object.js +177 -0
  134. package/blocklySkini/blockly/core/renderers/geras/renderer.js +138 -0
  135. package/blocklySkini/blockly/core/renderers/measurables/base.js +44 -0
  136. package/blocklySkini/blockly/core/renderers/measurables/connections.js +114 -0
  137. package/blocklySkini/blockly/core/renderers/measurables/inputs.js +160 -0
  138. package/blocklySkini/blockly/core/renderers/measurables/row_elements.js +185 -0
  139. package/blocklySkini/blockly/core/renderers/measurables/rows.js +532 -0
  140. package/blocklySkini/blockly/core/renderers/measurables/types.js +349 -0
  141. package/blocklySkini/blockly/core/renderers/minimalist/constants.js +29 -0
  142. package/blocklySkini/blockly/core/renderers/minimalist/drawer.js +32 -0
  143. package/blocklySkini/blockly/core/renderers/minimalist/info.js +45 -0
  144. package/blocklySkini/blockly/core/renderers/minimalist/renderer.js +70 -0
  145. package/blocklySkini/blockly/core/renderers/thrasos/info.js +338 -0
  146. package/blocklySkini/blockly/core/renderers/thrasos/renderer.js +45 -0
  147. package/blocklySkini/blockly/core/renderers/zelos/constants.js +1002 -0
  148. package/blocklySkini/blockly/core/renderers/zelos/drawer.js +233 -0
  149. package/blocklySkini/blockly/core/renderers/zelos/info.js +587 -0
  150. package/blocklySkini/blockly/core/renderers/zelos/marker_svg.js +148 -0
  151. package/blocklySkini/blockly/core/renderers/zelos/measurables/inputs.js +47 -0
  152. package/blocklySkini/blockly/core/renderers/zelos/measurables/row_elements.js +37 -0
  153. package/blocklySkini/blockly/core/renderers/zelos/measurables/rows.js +108 -0
  154. package/blocklySkini/blockly/core/renderers/zelos/path_object.js +244 -0
  155. package/blocklySkini/blockly/core/renderers/zelos/renderer.js +130 -0
  156. package/blocklySkini/blockly/core/requires.js +84 -0
  157. package/blocklySkini/blockly/core/scrollbar.js +880 -0
  158. package/blocklySkini/blockly/core/theme/classic.js +87 -0
  159. package/blocklySkini/blockly/core/theme/dark.js +33 -0
  160. package/blocklySkini/blockly/core/theme/deuteranopia.js +104 -0
  161. package/blocklySkini/blockly/core/theme/highcontrast.js +119 -0
  162. package/blocklySkini/blockly/core/theme/modern.js +108 -0
  163. package/blocklySkini/blockly/core/theme/tritanopia.js +103 -0
  164. package/blocklySkini/blockly/core/theme/zelos.js +106 -0
  165. package/blocklySkini/blockly/core/theme.js +236 -0
  166. package/blocklySkini/blockly/core/theme_manager.js +197 -0
  167. package/blocklySkini/blockly/core/toolbox/category.js +690 -0
  168. package/blocklySkini/blockly/core/toolbox/collapsible_category.js +294 -0
  169. package/blocklySkini/blockly/core/toolbox/separator.js +123 -0
  170. package/blocklySkini/blockly/core/toolbox/toolbox.js +984 -0
  171. package/blocklySkini/blockly/core/toolbox/toolbox_item.js +145 -0
  172. package/blocklySkini/blockly/core/toolbox.js +943 -0
  173. package/blocklySkini/blockly/core/tooltip.js +387 -0
  174. package/blocklySkini/blockly/core/touch.js +255 -0
  175. package/blocklySkini/blockly/core/touch_gesture.js +325 -0
  176. package/blocklySkini/blockly/core/trashcan.js +661 -0
  177. package/blocklySkini/blockly/core/ui_events.js +85 -0
  178. package/blocklySkini/blockly/core/utils/aria.js +167 -0
  179. package/blocklySkini/blockly/core/utils/colour.js +208 -0
  180. package/blocklySkini/blockly/core/utils/coordinate.js +125 -0
  181. package/blocklySkini/blockly/core/utils/deprecation.js +34 -0
  182. package/blocklySkini/blockly/core/utils/dom.js +391 -0
  183. package/blocklySkini/blockly/core/utils/global.js +37 -0
  184. package/blocklySkini/blockly/core/utils/idgenerator.js +33 -0
  185. package/blocklySkini/blockly/core/utils/keycodes.js +164 -0
  186. package/blocklySkini/blockly/core/utils/math.js +56 -0
  187. package/blocklySkini/blockly/core/utils/metrics.js +124 -0
  188. package/blocklySkini/blockly/core/utils/object.js +73 -0
  189. package/blocklySkini/blockly/core/utils/rect.js +54 -0
  190. package/blocklySkini/blockly/core/utils/size.js +58 -0
  191. package/blocklySkini/blockly/core/utils/string.js +284 -0
  192. package/blocklySkini/blockly/core/utils/style.js +281 -0
  193. package/blocklySkini/blockly/core/utils/svg.js +181 -0
  194. package/blocklySkini/blockly/core/utils/svg_paths.js +142 -0
  195. package/blocklySkini/blockly/core/utils/toolbox.js +401 -0
  196. package/blocklySkini/blockly/core/utils/useragent.js +110 -0
  197. package/blocklySkini/blockly/core/utils/xml.js +79 -0
  198. package/blocklySkini/blockly/core/utils.js +652 -0
  199. package/blocklySkini/blockly/core/variable_events.js +248 -0
  200. package/blocklySkini/blockly/core/variable_map.js +414 -0
  201. package/blocklySkini/blockly/core/variable_model.js +95 -0
  202. package/blocklySkini/blockly/core/variables.js +571 -0
  203. package/blocklySkini/blockly/core/variables_dynamic.js +100 -0
  204. package/blocklySkini/blockly/core/warning.js +200 -0
  205. package/blocklySkini/blockly/core/widgetdiv.js +241 -0
  206. package/blocklySkini/blockly/core/workspace.js +786 -0
  207. package/blocklySkini/blockly/core/workspace_audio.js +153 -0
  208. package/blocklySkini/blockly/core/workspace_comment.js +373 -0
  209. package/blocklySkini/blockly/core/workspace_comment_render_svg.js +461 -0
  210. package/blocklySkini/blockly/core/workspace_comment_svg.js +701 -0
  211. package/blocklySkini/blockly/core/workspace_drag_surface_svg.js +176 -0
  212. package/blocklySkini/blockly/core/workspace_dragger.js +85 -0
  213. package/blocklySkini/blockly/core/workspace_events.js +93 -0
  214. package/blocklySkini/blockly/core/workspace_svg.js +2661 -0
  215. package/blocklySkini/blockly/core/ws_comment_events.js +417 -0
  216. package/blocklySkini/blockly/core/xml.js +827 -0
  217. package/blocklySkini/blockly/core/zoom_controls.js +449 -0
  218. package/blocklySkini/blockly/core-browser.js +34 -0
  219. package/blocklySkini/blockly/core.d.ts +15 -0
  220. package/blocklySkini/blockly/core.js +38 -0
  221. package/blocklySkini/blockly/dart.d.ts +15 -0
  222. package/blocklySkini/blockly/dart.js +27 -0
  223. package/blocklySkini/blockly/dart_compressed.js +114 -0
  224. package/blocklySkini/blockly/dart_compressed.js.map +1 -0
  225. package/blocklySkini/blockly/generators/dart/colour.js +114 -0
  226. package/blocklySkini/blockly/generators/dart/lists.js +447 -0
  227. package/blocklySkini/blockly/generators/dart/logic.js +127 -0
  228. package/blocklySkini/blockly/generators/dart/loops.js +169 -0
  229. package/blocklySkini/blockly/generators/dart/math.js +485 -0
  230. package/blocklySkini/blockly/generators/dart/procedures.js +111 -0
  231. package/blocklySkini/blockly/generators/dart/text.js +339 -0
  232. package/blocklySkini/blockly/generators/dart/variables.js +32 -0
  233. package/blocklySkini/blockly/generators/dart/variables_dynamic.js +21 -0
  234. package/blocklySkini/blockly/generators/dart.js +290 -0
  235. package/blocklySkini/blockly/generators/javascript/colour.js +89 -0
  236. package/blocklySkini/blockly/generators/javascript/lists.js +388 -0
  237. package/blocklySkini/blockly/generators/javascript/logic.js +129 -0
  238. package/blocklySkini/blockly/generators/javascript/loops.js +184 -0
  239. package/blocklySkini/blockly/generators/javascript/math.js +409 -0
  240. package/blocklySkini/blockly/generators/javascript/procedures.js +113 -0
  241. package/blocklySkini/blockly/generators/javascript/text.js +367 -0
  242. package/blocklySkini/blockly/generators/javascript/variables.js +32 -0
  243. package/blocklySkini/blockly/generators/javascript/variables_dynamic.js +23 -0
  244. package/blocklySkini/blockly/generators/javascript.js +317 -0
  245. package/blocklySkini/blockly/generators/lua/colour.js +76 -0
  246. package/blocklySkini/blockly/generators/lua/lists.js +368 -0
  247. package/blocklySkini/blockly/generators/lua/logic.js +127 -0
  248. package/blocklySkini/blockly/generators/lua/loops.js +173 -0
  249. package/blocklySkini/blockly/generators/lua/math.js +423 -0
  250. package/blocklySkini/blockly/generators/lua/procedures.js +113 -0
  251. package/blocklySkini/blockly/generators/lua/text.js +353 -0
  252. package/blocklySkini/blockly/generators/lua/variables.js +32 -0
  253. package/blocklySkini/blockly/generators/lua/variables_dynamic.js +21 -0
  254. package/blocklySkini/blockly/generators/lua.js +198 -0
  255. package/blocklySkini/blockly/generators/php/colour.js +91 -0
  256. package/blocklySkini/blockly/generators/php/lists.js +498 -0
  257. package/blocklySkini/blockly/generators/php/logic.js +128 -0
  258. package/blocklySkini/blockly/generators/php/loops.js +170 -0
  259. package/blocklySkini/blockly/generators/php/math.js +370 -0
  260. package/blocklySkini/blockly/generators/php/procedures.js +132 -0
  261. package/blocklySkini/blockly/generators/php/text.js +271 -0
  262. package/blocklySkini/blockly/generators/php/variables.js +32 -0
  263. package/blocklySkini/blockly/generators/php/variables_dynamic.js +21 -0
  264. package/blocklySkini/blockly/generators/php.js +318 -0
  265. package/blocklySkini/blockly/generators/python/colour.js +72 -0
  266. package/blocklySkini/blockly/generators/python/lists.js +349 -0
  267. package/blocklySkini/blockly/generators/python/logic.js +127 -0
  268. package/blocklySkini/blockly/generators/python/loops.js +214 -0
  269. package/blocklySkini/blockly/generators/python/math.js +385 -0
  270. package/blocklySkini/blockly/generators/python/procedures.js +134 -0
  271. package/blocklySkini/blockly/generators/python/text.js +293 -0
  272. package/blocklySkini/blockly/generators/python/variables.js +32 -0
  273. package/blocklySkini/blockly/generators/python/variables_dynamic.js +21 -0
  274. package/blocklySkini/blockly/generators/python.js +322 -0
  275. package/blocklySkini/blockly/index.d.ts +22 -0
  276. package/blocklySkini/blockly/index.js +24 -0
  277. package/blocklySkini/blockly/javascript.d.ts +15 -0
  278. package/blocklySkini/blockly/javascript.js +27 -0
  279. package/blocklySkini/blockly/javascript_compressed.js +115 -0
  280. package/blocklySkini/blockly/javascript_compressed.js.map +1 -0
  281. package/blocklySkini/blockly/lua.d.ts +15 -0
  282. package/blocklySkini/blockly/lua.js +27 -0
  283. package/blocklySkini/blockly/lua_compressed.js +94 -0
  284. package/blocklySkini/blockly/lua_compressed.js.map +1 -0
  285. package/blocklySkini/blockly/media/1x1.gif +0 -0
  286. package/blocklySkini/blockly/media/click.mp3 +0 -0
  287. package/blocklySkini/blockly/media/click.ogg +0 -0
  288. package/blocklySkini/blockly/media/click.wav +0 -0
  289. package/blocklySkini/blockly/media/delete.mp3 +0 -0
  290. package/blocklySkini/blockly/media/delete.ogg +0 -0
  291. package/blocklySkini/blockly/media/delete.wav +0 -0
  292. package/blocklySkini/blockly/media/disconnect.mp3 +0 -0
  293. package/blocklySkini/blockly/media/disconnect.ogg +0 -0
  294. package/blocklySkini/blockly/media/disconnect.wav +0 -0
  295. package/blocklySkini/blockly/media/dropdown-arrow.svg +1 -0
  296. package/blocklySkini/blockly/media/handclosed.cur +0 -0
  297. package/blocklySkini/blockly/media/handdelete.cur +0 -0
  298. package/blocklySkini/blockly/media/handopen.cur +0 -0
  299. package/blocklySkini/blockly/media/pilcrow.png +0 -0
  300. package/blocklySkini/blockly/media/quote0.png +0 -0
  301. package/blocklySkini/blockly/media/quote1.png +0 -0
  302. package/blocklySkini/blockly/media/sprites.png +0 -0
  303. package/blocklySkini/blockly/media/sprites.svg +74 -0
  304. package/blocklySkini/blockly/msg/ab.d.ts +16 -0
  305. package/blocklySkini/blockly/msg/ab.js +447 -0
  306. package/blocklySkini/blockly/msg/ar.d.ts +16 -0
  307. package/blocklySkini/blockly/msg/ar.js +447 -0
  308. package/blocklySkini/blockly/msg/az.d.ts +16 -0
  309. package/blocklySkini/blockly/msg/az.js +447 -0
  310. package/blocklySkini/blockly/msg/ba.d.ts +16 -0
  311. package/blocklySkini/blockly/msg/ba.js +447 -0
  312. package/blocklySkini/blockly/msg/bcc.d.ts +16 -0
  313. package/blocklySkini/blockly/msg/bcc.js +447 -0
  314. package/blocklySkini/blockly/msg/be-tarask.d.ts +16 -0
  315. package/blocklySkini/blockly/msg/be-tarask.js +447 -0
  316. package/blocklySkini/blockly/msg/be.d.ts +16 -0
  317. package/blocklySkini/blockly/msg/be.js +447 -0
  318. package/blocklySkini/blockly/msg/bg.d.ts +16 -0
  319. package/blocklySkini/blockly/msg/bg.js +447 -0
  320. package/blocklySkini/blockly/msg/bn.d.ts +16 -0
  321. package/blocklySkini/blockly/msg/bn.js +447 -0
  322. package/blocklySkini/blockly/msg/br.d.ts +16 -0
  323. package/blocklySkini/blockly/msg/br.js +447 -0
  324. package/blocklySkini/blockly/msg/ca.d.ts +16 -0
  325. package/blocklySkini/blockly/msg/ca.js +447 -0
  326. package/blocklySkini/blockly/msg/constants.d.ts +16 -0
  327. package/blocklySkini/blockly/msg/cs.d.ts +16 -0
  328. package/blocklySkini/blockly/msg/cs.js +447 -0
  329. package/blocklySkini/blockly/msg/da.d.ts +16 -0
  330. package/blocklySkini/blockly/msg/da.js +447 -0
  331. package/blocklySkini/blockly/msg/de.d.ts +16 -0
  332. package/blocklySkini/blockly/msg/de.js +447 -0
  333. package/blocklySkini/blockly/msg/diq.d.ts +16 -0
  334. package/blocklySkini/blockly/msg/diq.js +447 -0
  335. package/blocklySkini/blockly/msg/dty.d.ts +16 -0
  336. package/blocklySkini/blockly/msg/dty.js +447 -0
  337. package/blocklySkini/blockly/msg/ee.d.ts +16 -0
  338. package/blocklySkini/blockly/msg/ee.js +447 -0
  339. package/blocklySkini/blockly/msg/el.d.ts +16 -0
  340. package/blocklySkini/blockly/msg/el.js +447 -0
  341. package/blocklySkini/blockly/msg/en-gb.d.ts +16 -0
  342. package/blocklySkini/blockly/msg/en-gb.js +447 -0
  343. package/blocklySkini/blockly/msg/en.d.ts +16 -0
  344. package/blocklySkini/blockly/msg/en.js +447 -0
  345. package/blocklySkini/blockly/msg/eo.d.ts +16 -0
  346. package/blocklySkini/blockly/msg/eo.js +447 -0
  347. package/blocklySkini/blockly/msg/es.d.ts +16 -0
  348. package/blocklySkini/blockly/msg/es.js +447 -0
  349. package/blocklySkini/blockly/msg/et.d.ts +16 -0
  350. package/blocklySkini/blockly/msg/et.js +447 -0
  351. package/blocklySkini/blockly/msg/eu.d.ts +16 -0
  352. package/blocklySkini/blockly/msg/eu.js +447 -0
  353. package/blocklySkini/blockly/msg/fa.d.ts +16 -0
  354. package/blocklySkini/blockly/msg/fa.js +447 -0
  355. package/blocklySkini/blockly/msg/fi.d.ts +16 -0
  356. package/blocklySkini/blockly/msg/fi.js +447 -0
  357. package/blocklySkini/blockly/msg/fr.d.ts +16 -0
  358. package/blocklySkini/blockly/msg/fr.js +447 -0
  359. package/blocklySkini/blockly/msg/gl.d.ts +16 -0
  360. package/blocklySkini/blockly/msg/gl.js +447 -0
  361. package/blocklySkini/blockly/msg/gor.d.ts +16 -0
  362. package/blocklySkini/blockly/msg/gor.js +447 -0
  363. package/blocklySkini/blockly/msg/ha.d.ts +16 -0
  364. package/blocklySkini/blockly/msg/ha.js +447 -0
  365. package/blocklySkini/blockly/msg/he.d.ts +16 -0
  366. package/blocklySkini/blockly/msg/he.js +447 -0
  367. package/blocklySkini/blockly/msg/hi.d.ts +16 -0
  368. package/blocklySkini/blockly/msg/hi.js +447 -0
  369. package/blocklySkini/blockly/msg/hrx.d.ts +16 -0
  370. package/blocklySkini/blockly/msg/hrx.js +447 -0
  371. package/blocklySkini/blockly/msg/hu.d.ts +16 -0
  372. package/blocklySkini/blockly/msg/hu.js +447 -0
  373. package/blocklySkini/blockly/msg/hy.d.ts +16 -0
  374. package/blocklySkini/blockly/msg/hy.js +447 -0
  375. package/blocklySkini/blockly/msg/ia.d.ts +16 -0
  376. package/blocklySkini/blockly/msg/ia.js +447 -0
  377. package/blocklySkini/blockly/msg/id.d.ts +16 -0
  378. package/blocklySkini/blockly/msg/id.js +447 -0
  379. package/blocklySkini/blockly/msg/ig.d.ts +16 -0
  380. package/blocklySkini/blockly/msg/ig.js +447 -0
  381. package/blocklySkini/blockly/msg/is.d.ts +16 -0
  382. package/blocklySkini/blockly/msg/is.js +447 -0
  383. package/blocklySkini/blockly/msg/it.d.ts +16 -0
  384. package/blocklySkini/blockly/msg/it.js +447 -0
  385. package/blocklySkini/blockly/msg/ja.d.ts +16 -0
  386. package/blocklySkini/blockly/msg/ja.js +447 -0
  387. package/blocklySkini/blockly/msg/kab.d.ts +16 -0
  388. package/blocklySkini/blockly/msg/kab.js +447 -0
  389. package/blocklySkini/blockly/msg/kn.d.ts +16 -0
  390. package/blocklySkini/blockly/msg/kn.js +447 -0
  391. package/blocklySkini/blockly/msg/ko.d.ts +16 -0
  392. package/blocklySkini/blockly/msg/ko.js +447 -0
  393. package/blocklySkini/blockly/msg/lb.d.ts +16 -0
  394. package/blocklySkini/blockly/msg/lb.js +447 -0
  395. package/blocklySkini/blockly/msg/lki.d.ts +16 -0
  396. package/blocklySkini/blockly/msg/lki.js +447 -0
  397. package/blocklySkini/blockly/msg/lo.d.ts +16 -0
  398. package/blocklySkini/blockly/msg/lo.js +447 -0
  399. package/blocklySkini/blockly/msg/lrc.d.ts +16 -0
  400. package/blocklySkini/blockly/msg/lrc.js +447 -0
  401. package/blocklySkini/blockly/msg/lt.d.ts +16 -0
  402. package/blocklySkini/blockly/msg/lt.js +447 -0
  403. package/blocklySkini/blockly/msg/lv.d.ts +16 -0
  404. package/blocklySkini/blockly/msg/lv.js +447 -0
  405. package/blocklySkini/blockly/msg/mk.d.ts +16 -0
  406. package/blocklySkini/blockly/msg/mk.js +447 -0
  407. package/blocklySkini/blockly/msg/mnw.d.ts +16 -0
  408. package/blocklySkini/blockly/msg/mnw.js +447 -0
  409. package/blocklySkini/blockly/msg/ms.d.ts +16 -0
  410. package/blocklySkini/blockly/msg/ms.js +447 -0
  411. package/blocklySkini/blockly/msg/msg.d.ts +444 -0
  412. package/blocklySkini/blockly/msg/nb.d.ts +16 -0
  413. package/blocklySkini/blockly/msg/nb.js +447 -0
  414. package/blocklySkini/blockly/msg/nl.d.ts +16 -0
  415. package/blocklySkini/blockly/msg/nl.js +447 -0
  416. package/blocklySkini/blockly/msg/oc.d.ts +16 -0
  417. package/blocklySkini/blockly/msg/oc.js +447 -0
  418. package/blocklySkini/blockly/msg/pl.d.ts +16 -0
  419. package/blocklySkini/blockly/msg/pl.js +447 -0
  420. package/blocklySkini/blockly/msg/pms.d.ts +16 -0
  421. package/blocklySkini/blockly/msg/pms.js +447 -0
  422. package/blocklySkini/blockly/msg/pt-br.d.ts +16 -0
  423. package/blocklySkini/blockly/msg/pt-br.js +447 -0
  424. package/blocklySkini/blockly/msg/pt.d.ts +16 -0
  425. package/blocklySkini/blockly/msg/pt.js +447 -0
  426. package/blocklySkini/blockly/msg/qqq.d.ts +16 -0
  427. package/blocklySkini/blockly/msg/ro.d.ts +16 -0
  428. package/blocklySkini/blockly/msg/ro.js +447 -0
  429. package/blocklySkini/blockly/msg/ru.d.ts +16 -0
  430. package/blocklySkini/blockly/msg/ru.js +447 -0
  431. package/blocklySkini/blockly/msg/sc.d.ts +16 -0
  432. package/blocklySkini/blockly/msg/sc.js +447 -0
  433. package/blocklySkini/blockly/msg/sd.d.ts +16 -0
  434. package/blocklySkini/blockly/msg/sd.js +447 -0
  435. package/blocklySkini/blockly/msg/shn.d.ts +16 -0
  436. package/blocklySkini/blockly/msg/shn.js +447 -0
  437. package/blocklySkini/blockly/msg/sk.d.ts +16 -0
  438. package/blocklySkini/blockly/msg/sk.js +447 -0
  439. package/blocklySkini/blockly/msg/skr-arab.d.ts +16 -0
  440. package/blocklySkini/blockly/msg/skr-arab.js +447 -0
  441. package/blocklySkini/blockly/msg/sl.d.ts +16 -0
  442. package/blocklySkini/blockly/msg/sl.js +447 -0
  443. package/blocklySkini/blockly/msg/sq.d.ts +16 -0
  444. package/blocklySkini/blockly/msg/sq.js +447 -0
  445. package/blocklySkini/blockly/msg/sr-latn.d.ts +16 -0
  446. package/blocklySkini/blockly/msg/sr-latn.js +447 -0
  447. package/blocklySkini/blockly/msg/sr.d.ts +16 -0
  448. package/blocklySkini/blockly/msg/sr.js +447 -0
  449. package/blocklySkini/blockly/msg/sv.d.ts +16 -0
  450. package/blocklySkini/blockly/msg/sv.js +447 -0
  451. package/blocklySkini/blockly/msg/synonyms.d.ts +16 -0
  452. package/blocklySkini/blockly/msg/ta.d.ts +16 -0
  453. package/blocklySkini/blockly/msg/ta.js +447 -0
  454. package/blocklySkini/blockly/msg/tcy.d.ts +16 -0
  455. package/blocklySkini/blockly/msg/tcy.js +447 -0
  456. package/blocklySkini/blockly/msg/te.d.ts +16 -0
  457. package/blocklySkini/blockly/msg/te.js +447 -0
  458. package/blocklySkini/blockly/msg/th.d.ts +16 -0
  459. package/blocklySkini/blockly/msg/th.js +447 -0
  460. package/blocklySkini/blockly/msg/tl.d.ts +16 -0
  461. package/blocklySkini/blockly/msg/tl.js +447 -0
  462. package/blocklySkini/blockly/msg/tlh.d.ts +16 -0
  463. package/blocklySkini/blockly/msg/tlh.js +447 -0
  464. package/blocklySkini/blockly/msg/tr.d.ts +16 -0
  465. package/blocklySkini/blockly/msg/tr.js +447 -0
  466. package/blocklySkini/blockly/msg/ug-arab.d.ts +16 -0
  467. package/blocklySkini/blockly/msg/ug-arab.js +447 -0
  468. package/blocklySkini/blockly/msg/uk.d.ts +16 -0
  469. package/blocklySkini/blockly/msg/uk.js +447 -0
  470. package/blocklySkini/blockly/msg/ur.d.ts +16 -0
  471. package/blocklySkini/blockly/msg/ur.js +447 -0
  472. package/blocklySkini/blockly/msg/vi.d.ts +16 -0
  473. package/blocklySkini/blockly/msg/vi.js +447 -0
  474. package/blocklySkini/blockly/msg/xmf.d.ts +16 -0
  475. package/blocklySkini/blockly/msg/xmf.js +447 -0
  476. package/blocklySkini/blockly/msg/yo.d.ts +16 -0
  477. package/blocklySkini/blockly/msg/yo.js +447 -0
  478. package/blocklySkini/blockly/msg/zh-hans.d.ts +16 -0
  479. package/blocklySkini/blockly/msg/zh-hans.js +447 -0
  480. package/blocklySkini/blockly/msg/zh-hant.d.ts +16 -0
  481. package/blocklySkini/blockly/msg/zh-hant.js +447 -0
  482. package/blocklySkini/blockly/node.js +35 -0
  483. package/blocklySkini/blockly/package.json +84 -0
  484. package/blocklySkini/blockly/php.d.ts +15 -0
  485. package/blocklySkini/blockly/php.js +27 -0
  486. package/blocklySkini/blockly/php_compressed.js +103 -0
  487. package/blocklySkini/blockly/php_compressed.js.map +1 -0
  488. package/blocklySkini/blockly/python.d.ts +15 -0
  489. package/blocklySkini/blockly/python.js +27 -0
  490. package/blocklySkini/blockly/python_compressed.js +98 -0
  491. package/blocklySkini/blockly/python_compressed.js.map +1 -0
  492. package/blocklySkini/blocklySkini.html +81 -0
  493. package/blocklySkini/orchestrations/.xml +1 -0
  494. package/blocklySkini/orchestrations/BluesSkini-1.xml +231 -0
  495. package/blocklySkini/orchestrations/BluesSkini-2.xml +741 -0
  496. package/blocklySkini/orchestrations/BluesSkini-3.xml +731 -0
  497. package/blocklySkini/orchestrations/BluesSkini-4.xml +695 -0
  498. package/blocklySkini/orchestrations/BluesSkini-5.xml +731 -0
  499. package/blocklySkini/orchestrations/BluesSkini.xml +704 -0
  500. package/blocklySkini/orchestrations/FunkBitwig-1.xml +778 -0
  501. package/blocklySkini/orchestrations/FunkBitwig-2.xml +471 -0
  502. package/blocklySkini/orchestrations/JouerLeBonInstrument1-1.xml +784 -0
  503. package/blocklySkini/orchestrations/MajeurMineur-1.xml +638 -0
  504. package/blocklySkini/orchestrations/Opus5-3 - Copie.xml +1041 -0
  505. package/blocklySkini/orchestrations/Opus5-3.xml +1128 -0
  506. package/blocklySkini/orchestrations/Quatuor1-1.xml +357 -0
  507. package/blocklySkini/orchestrations/TechnoBitwig-1.xml +221 -0
  508. package/blocklySkini/orchestrations/TestBlockly.xml +497 -0
  509. package/blocklySkini/orchestrations/TestBlockly1.xml +500 -0
  510. package/blocklySkini/orchestrations/TestBlockly2.xml +792 -0
  511. package/blocklySkini/orchestrations/TestBlockly3-1.xml +1182 -0
  512. package/blocklySkini/orchestrations/TestBlockly3.xml +1251 -0
  513. package/blocklySkini/orchestrations/TestFunction.xml +143 -0
  514. package/blocklySkini/orchestrations/TestIf.xml +80 -0
  515. package/blocklySkini/orchestrations/TestLoop.xml +127 -0
  516. package/blocklySkini/orchestrations/TestOrchestration2.xml +460 -0
  517. package/blocklySkini/orchestrations/TestPrint.xml +70 -0
  518. package/blocklySkini/orchestrations/TestSubMod.xml +81 -0
  519. package/blocklySkini/orchestrations/Testlogic.xml +113 -0
  520. package/blocklySkini/orchestrations/TrouveLaPercu-1.xml +813 -0
  521. package/blocklySkini/orchestrations/TrouveLaPercu-2.xml +813 -0
  522. package/blocklySkini/orchestrations/bar.xml +496 -0
  523. package/blocklySkini/orchestrations/bar2.xml +496 -0
  524. package/blocklySkini/orchestrations/foo.xml +500 -0
  525. package/blocklySkini/orchestrations/opus5Blockly - Copie.xml +496 -0
  526. package/blocklySkini/orchestrations/opus5Blockly-3.xml +868 -0
  527. package/blocklySkini/orchestrations/opus5Blockly.xml +496 -0
  528. package/blocklySkini/orchestrations/testOrchestration3.xml +483 -0
  529. package/blocklySkini/orchestrations/testOrchestration4.xml +487 -0
  530. package/blocklySkini/scripts/hiphop_blocks.js +6104 -0
  531. package/blocklySkini/scripts/main2.js +801 -0
  532. package/blocklySkini/styles/index.css +320 -0
  533. package/blocklySkini/styles/material.css +11552 -0
  534. package/package.json +5 -5
@@ -0,0 +1,1072 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2012 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ /**
8
+ * @fileoverview Procedure blocks for Blockly.
9
+ * @author fraser@google.com (Neil Fraser)
10
+ */
11
+ 'use strict';
12
+
13
+ goog.provide('Blockly.Blocks.procedures');
14
+
15
+ goog.require('Blockly');
16
+ goog.require('Blockly.Blocks');
17
+ goog.require('Blockly.Comment');
18
+ goog.require('Blockly.FieldCheckbox');
19
+ goog.require('Blockly.FieldLabel');
20
+ goog.require('Blockly.FieldTextInput');
21
+ goog.require('Blockly.Mutator');
22
+ goog.require('Blockly.Warning');
23
+
24
+
25
+ Blockly.Blocks['procedures_defnoreturn'] = {
26
+ /**
27
+ * Block for defining a procedure with no return value.
28
+ * @this {Blockly.Block}
29
+ */
30
+ init: function() {
31
+ var nameField = new Blockly.FieldTextInput('',
32
+ Blockly.Procedures.rename);
33
+ nameField.setSpellcheck(false);
34
+ this.appendDummyInput()
35
+ .appendField(Blockly.Msg['PROCEDURES_DEFNORETURN_TITLE'])
36
+ .appendField(nameField, 'NAME')
37
+ .appendField('', 'PARAMS');
38
+ this.setMutator(new Blockly.Mutator(['procedures_mutatorarg']));
39
+ if ((this.workspace.options.comments ||
40
+ (this.workspace.options.parentWorkspace &&
41
+ this.workspace.options.parentWorkspace.options.comments)) &&
42
+ Blockly.Msg['PROCEDURES_DEFNORETURN_COMMENT']) {
43
+ this.setCommentText(Blockly.Msg['PROCEDURES_DEFNORETURN_COMMENT']);
44
+ }
45
+ this.setStyle('procedure_blocks');
46
+ this.setTooltip(Blockly.Msg['PROCEDURES_DEFNORETURN_TOOLTIP']);
47
+ this.setHelpUrl(Blockly.Msg['PROCEDURES_DEFNORETURN_HELPURL']);
48
+ this.arguments_ = [];
49
+ this.argumentVarModels_ = [];
50
+ this.setStatements_(true);
51
+ this.statementConnection_ = null;
52
+ },
53
+ /**
54
+ * Add or remove the statement block from this function definition.
55
+ * @param {boolean} hasStatements True if a statement block is needed.
56
+ * @this {Blockly.Block}
57
+ */
58
+ setStatements_: function(hasStatements) {
59
+ if (this.hasStatements_ === hasStatements) {
60
+ return;
61
+ }
62
+ if (hasStatements) {
63
+ this.appendStatementInput('STACK')
64
+ .appendField(Blockly.Msg['PROCEDURES_DEFNORETURN_DO']);
65
+ if (this.getInput('RETURN')) {
66
+ this.moveInputBefore('STACK', 'RETURN');
67
+ }
68
+ } else {
69
+ this.removeInput('STACK', true);
70
+ }
71
+ this.hasStatements_ = hasStatements;
72
+ },
73
+ /**
74
+ * Update the display of parameters for this procedure definition block.
75
+ * @private
76
+ * @this {Blockly.Block}
77
+ */
78
+ updateParams_: function() {
79
+
80
+ // Merge the arguments into a human-readable list.
81
+ var paramString = '';
82
+ if (this.arguments_.length) {
83
+ paramString = Blockly.Msg['PROCEDURES_BEFORE_PARAMS'] +
84
+ ' ' + this.arguments_.join(', ');
85
+ }
86
+ // The params field is deterministic based on the mutation,
87
+ // no need to fire a change event.
88
+ Blockly.Events.disable();
89
+ try {
90
+ this.setFieldValue(paramString, 'PARAMS');
91
+ } finally {
92
+ Blockly.Events.enable();
93
+ }
94
+ },
95
+ /**
96
+ * Create XML to represent the argument inputs.
97
+ * @param {boolean=} opt_paramIds If true include the IDs of the parameter
98
+ * quarks. Used by Blockly.Procedures.mutateCallers for reconnection.
99
+ * @return {!Element} XML storage element.
100
+ * @this {Blockly.Block}
101
+ */
102
+ mutationToDom: function(opt_paramIds) {
103
+ var container = Blockly.utils.xml.createElement('mutation');
104
+ if (opt_paramIds) {
105
+ container.setAttribute('name', this.getFieldValue('NAME'));
106
+ }
107
+ for (var i = 0; i < this.argumentVarModels_.length; i++) {
108
+ var parameter = Blockly.utils.xml.createElement('arg');
109
+ var argModel = this.argumentVarModels_[i];
110
+ parameter.setAttribute('name', argModel.name);
111
+ parameter.setAttribute('varid', argModel.getId());
112
+ if (opt_paramIds && this.paramIds_) {
113
+ parameter.setAttribute('paramId', this.paramIds_[i]);
114
+ }
115
+ container.appendChild(parameter);
116
+ }
117
+
118
+ // Save whether the statement input is visible.
119
+ if (!this.hasStatements_) {
120
+ container.setAttribute('statements', 'false');
121
+ }
122
+ return container;
123
+ },
124
+ /**
125
+ * Parse XML to restore the argument inputs.
126
+ * @param {!Element} xmlElement XML storage element.
127
+ * @this {Blockly.Block}
128
+ */
129
+ domToMutation: function(xmlElement) {
130
+ this.arguments_ = [];
131
+ this.argumentVarModels_ = [];
132
+ for (var i = 0, childNode; (childNode = xmlElement.childNodes[i]); i++) {
133
+ if (childNode.nodeName.toLowerCase() == 'arg') {
134
+ var varName = childNode.getAttribute('name');
135
+ var varId = childNode.getAttribute('varid') || childNode.getAttribute('varId');
136
+ this.arguments_.push(varName);
137
+ var variable = Blockly.Variables.getOrCreateVariablePackage(
138
+ this.workspace, varId, varName, '');
139
+ if (variable != null) {
140
+ this.argumentVarModels_.push(variable);
141
+ } else {
142
+ console.log('Failed to create a variable with name ' + varName + ', ignoring.');
143
+ }
144
+ }
145
+ }
146
+ this.updateParams_();
147
+ Blockly.Procedures.mutateCallers(this);
148
+
149
+ // Show or hide the statement input.
150
+ this.setStatements_(xmlElement.getAttribute('statements') !== 'false');
151
+ },
152
+ /**
153
+ * Populate the mutator's dialog with this block's components.
154
+ * @param {!Blockly.Workspace} workspace Mutator's workspace.
155
+ * @return {!Blockly.Block} Root block in mutator.
156
+ * @this {Blockly.Block}
157
+ */
158
+ decompose: function(workspace) {
159
+ /*
160
+ * Creates the following XML:
161
+ * <block type="procedures_mutatorcontainer">
162
+ * <statement name="STACK">
163
+ * <block type="procedures_mutatorarg">
164
+ * <field name="NAME">arg1_name</field>
165
+ * <next>etc...</next>
166
+ * </block>
167
+ * </statement>
168
+ * </block>
169
+ */
170
+
171
+ var containerBlockNode = Blockly.utils.xml.createElement('block');
172
+ containerBlockNode.setAttribute('type', 'procedures_mutatorcontainer');
173
+ var statementNode = Blockly.utils.xml.createElement('statement');
174
+ statementNode.setAttribute('name', 'STACK');
175
+ containerBlockNode.appendChild(statementNode);
176
+
177
+ var node = statementNode;
178
+ for (var i = 0; i < this.arguments_.length; i++) {
179
+ var argBlockNode = Blockly.utils.xml.createElement('block');
180
+ argBlockNode.setAttribute('type', 'procedures_mutatorarg');
181
+ var fieldNode = Blockly.utils.xml.createElement('field');
182
+ fieldNode.setAttribute('name', 'NAME');
183
+ var argumentName = Blockly.utils.xml.createTextNode(this.arguments_[i]);
184
+ fieldNode.appendChild(argumentName);
185
+ argBlockNode.appendChild(fieldNode);
186
+ var nextNode = Blockly.utils.xml.createElement('next');
187
+ argBlockNode.appendChild(nextNode);
188
+
189
+ node.appendChild(argBlockNode);
190
+ node = nextNode;
191
+ }
192
+
193
+ var containerBlock = Blockly.Xml.domToBlock(containerBlockNode, workspace);
194
+
195
+ if (this.type == 'procedures_defreturn') {
196
+ containerBlock.setFieldValue(this.hasStatements_, 'STATEMENTS');
197
+ } else {
198
+ containerBlock.removeInput('STATEMENT_INPUT');
199
+ }
200
+
201
+ // Initialize procedure's callers with blank IDs.
202
+ Blockly.Procedures.mutateCallers(this);
203
+ return containerBlock;
204
+ },
205
+ /**
206
+ * Reconfigure this block based on the mutator dialog's components.
207
+ * @param {!Blockly.Block} containerBlock Root block in mutator.
208
+ * @this {Blockly.Block}
209
+ */
210
+ compose: function(containerBlock) {
211
+ // Parameter list.
212
+ this.arguments_ = [];
213
+ this.paramIds_ = [];
214
+ this.argumentVarModels_ = [];
215
+ var paramBlock = containerBlock.getInputTargetBlock('STACK');
216
+ while (paramBlock) {
217
+ var varName = paramBlock.getFieldValue('NAME');
218
+ this.arguments_.push(varName);
219
+ var variable = this.workspace.getVariable(varName, '');
220
+ this.argumentVarModels_.push(variable);
221
+
222
+ this.paramIds_.push(paramBlock.id);
223
+ paramBlock = paramBlock.nextConnection &&
224
+ paramBlock.nextConnection.targetBlock();
225
+ }
226
+ this.updateParams_();
227
+ Blockly.Procedures.mutateCallers(this);
228
+
229
+ // Show/hide the statement input.
230
+ var hasStatements = containerBlock.getFieldValue('STATEMENTS');
231
+ if (hasStatements !== null) {
232
+ hasStatements = hasStatements == 'TRUE';
233
+ if (this.hasStatements_ != hasStatements) {
234
+ if (hasStatements) {
235
+ this.setStatements_(true);
236
+ // Restore the stack, if one was saved.
237
+ Blockly.Mutator.reconnect(this.statementConnection_, this, 'STACK');
238
+ this.statementConnection_ = null;
239
+ } else {
240
+ // Save the stack, then disconnect it.
241
+ var stackConnection = this.getInput('STACK').connection;
242
+ this.statementConnection_ = stackConnection.targetConnection;
243
+ if (this.statementConnection_) {
244
+ var stackBlock = stackConnection.targetBlock();
245
+ stackBlock.unplug();
246
+ stackBlock.bumpNeighbours();
247
+ }
248
+ this.setStatements_(false);
249
+ }
250
+ }
251
+ }
252
+ },
253
+ /**
254
+ * Return the signature of this procedure definition.
255
+ * @return {!Array} Tuple containing three elements:
256
+ * - the name of the defined procedure,
257
+ * - a list of all its arguments,
258
+ * - that it DOES NOT have a return value.
259
+ * @this {Blockly.Block}
260
+ */
261
+ getProcedureDef: function() {
262
+ return [this.getFieldValue('NAME'), this.arguments_, false];
263
+ },
264
+ /**
265
+ * Return all variables referenced by this block.
266
+ * @return {!Array.<string>} List of variable names.
267
+ * @this {Blockly.Block}
268
+ */
269
+ getVars: function() {
270
+ return this.arguments_;
271
+ },
272
+ /**
273
+ * Return all variables referenced by this block.
274
+ * @return {!Array.<!Blockly.VariableModel>} List of variable models.
275
+ * @this {Blockly.Block}
276
+ */
277
+ getVarModels: function() {
278
+ return this.argumentVarModels_;
279
+ },
280
+ /**
281
+ * Notification that a variable is renaming.
282
+ * If the ID matches one of this block's variables, rename it.
283
+ * @param {string} oldId ID of variable to rename.
284
+ * @param {string} newId ID of new variable. May be the same as oldId, but
285
+ * with an updated name. Guaranteed to be the same type as the old
286
+ * variable.
287
+ * @override
288
+ * @this {Blockly.Block}
289
+ */
290
+ renameVarById: function(oldId, newId) {
291
+ var oldVariable = this.workspace.getVariableById(oldId);
292
+ if (oldVariable.type != '') {
293
+ // Procedure arguments always have the empty type.
294
+ return;
295
+ }
296
+ var oldName = oldVariable.name;
297
+ var newVar = this.workspace.getVariableById(newId);
298
+
299
+ var change = false;
300
+ for (var i = 0; i < this.argumentVarModels_.length; i++) {
301
+ if (this.argumentVarModels_[i].getId() == oldId) {
302
+ this.arguments_[i] = newVar.name;
303
+ this.argumentVarModels_[i] = newVar;
304
+ change = true;
305
+ }
306
+ }
307
+ if (change) {
308
+ this.displayRenamedVar_(oldName, newVar.name);
309
+ Blockly.Procedures.mutateCallers(this);
310
+ }
311
+ },
312
+ /**
313
+ * Notification that a variable is renaming but keeping the same ID. If the
314
+ * variable is in use on this block, rerender to show the new name.
315
+ * @param {!Blockly.VariableModel} variable The variable being renamed.
316
+ * @package
317
+ * @override
318
+ * @this {Blockly.Block}
319
+ */
320
+ updateVarName: function(variable) {
321
+ var newName = variable.name;
322
+ var change = false;
323
+ for (var i = 0; i < this.argumentVarModels_.length; i++) {
324
+ if (this.argumentVarModels_[i].getId() == variable.getId()) {
325
+ var oldName = this.arguments_[i];
326
+ this.arguments_[i] = newName;
327
+ change = true;
328
+ }
329
+ }
330
+ if (change) {
331
+ this.displayRenamedVar_(oldName, newName);
332
+ Blockly.Procedures.mutateCallers(this);
333
+ }
334
+ },
335
+ /**
336
+ * Update the display to reflect a newly renamed argument.
337
+ * @param {string} oldName The old display name of the argument.
338
+ * @param {string} newName The new display name of the argument.
339
+ * @private
340
+ * @this {Blockly.Block}
341
+ */
342
+ displayRenamedVar_: function(oldName, newName) {
343
+ this.updateParams_();
344
+ // Update the mutator's variables if the mutator is open.
345
+ if (this.mutator && this.mutator.isVisible()) {
346
+ var blocks = this.mutator.workspace_.getAllBlocks(false);
347
+ for (var i = 0, block; (block = blocks[i]); i++) {
348
+ if (block.type == 'procedures_mutatorarg' &&
349
+ Blockly.Names.equals(oldName, block.getFieldValue('NAME'))) {
350
+ block.setFieldValue(newName, 'NAME');
351
+ }
352
+ }
353
+ }
354
+ },
355
+ /**
356
+ * Add custom menu options to this block's context menu.
357
+ * @param {!Array} options List of menu options to add to.
358
+ * @this {Blockly.Block}
359
+ */
360
+ customContextMenu: function(options) {
361
+ if (this.isInFlyout) {
362
+ return;
363
+ }
364
+ // Add option to create caller.
365
+ var option = {enabled: true};
366
+ var name = this.getFieldValue('NAME');
367
+ option.text = Blockly.Msg['PROCEDURES_CREATE_DO'].replace('%1', name);
368
+ var xmlMutation = Blockly.utils.xml.createElement('mutation');
369
+ xmlMutation.setAttribute('name', name);
370
+ for (var i = 0; i < this.arguments_.length; i++) {
371
+ var xmlArg = Blockly.utils.xml.createElement('arg');
372
+ xmlArg.setAttribute('name', this.arguments_[i]);
373
+ xmlMutation.appendChild(xmlArg);
374
+ }
375
+ var xmlBlock = Blockly.utils.xml.createElement('block');
376
+ xmlBlock.setAttribute('type', this.callType_);
377
+ xmlBlock.appendChild(xmlMutation);
378
+ option.callback = Blockly.ContextMenu.callbackFactory(this, xmlBlock);
379
+ options.push(option);
380
+
381
+ // Add options to create getters for each parameter.
382
+ if (!this.isCollapsed()) {
383
+ for (var i = 0; i < this.argumentVarModels_.length; i++) {
384
+ var argOption = {enabled: true};
385
+ var argVar = this.argumentVarModels_[i];
386
+ argOption.text = Blockly.Msg['VARIABLES_SET_CREATE_GET']
387
+ .replace('%1', argVar.name);
388
+
389
+ var argXmlField = Blockly.Variables.generateVariableFieldDom(argVar);
390
+ var argXmlBlock = Blockly.utils.xml.createElement('block');
391
+ argXmlBlock.setAttribute('type', 'variables_get');
392
+ argXmlBlock.appendChild(argXmlField);
393
+ argOption.callback =
394
+ Blockly.ContextMenu.callbackFactory(this, argXmlBlock);
395
+ options.push(argOption);
396
+ }
397
+ }
398
+ },
399
+ callType_: 'procedures_callnoreturn'
400
+ };
401
+
402
+ Blockly.Blocks['procedures_defreturn'] = {
403
+ /**
404
+ * Block for defining a procedure with a return value.
405
+ * @this {Blockly.Block}
406
+ */
407
+ init: function() {
408
+ var nameField = new Blockly.FieldTextInput('',
409
+ Blockly.Procedures.rename);
410
+ nameField.setSpellcheck(false);
411
+ this.appendDummyInput()
412
+ .appendField(Blockly.Msg['PROCEDURES_DEFRETURN_TITLE'])
413
+ .appendField(nameField, 'NAME')
414
+ .appendField('', 'PARAMS');
415
+ this.appendValueInput('RETURN')
416
+ .setAlign(Blockly.ALIGN_RIGHT)
417
+ .appendField(Blockly.Msg['PROCEDURES_DEFRETURN_RETURN']);
418
+ this.setMutator(new Blockly.Mutator(['procedures_mutatorarg']));
419
+ if ((this.workspace.options.comments ||
420
+ (this.workspace.options.parentWorkspace &&
421
+ this.workspace.options.parentWorkspace.options.comments)) &&
422
+ Blockly.Msg['PROCEDURES_DEFRETURN_COMMENT']) {
423
+ this.setCommentText(Blockly.Msg['PROCEDURES_DEFRETURN_COMMENT']);
424
+ }
425
+ this.setStyle('procedure_blocks');
426
+ this.setTooltip(Blockly.Msg['PROCEDURES_DEFRETURN_TOOLTIP']);
427
+ this.setHelpUrl(Blockly.Msg['PROCEDURES_DEFRETURN_HELPURL']);
428
+ this.arguments_ = [];
429
+ this.argumentVarModels_ = [];
430
+ this.setStatements_(true);
431
+ this.statementConnection_ = null;
432
+ },
433
+ setStatements_: Blockly.Blocks['procedures_defnoreturn'].setStatements_,
434
+ updateParams_: Blockly.Blocks['procedures_defnoreturn'].updateParams_,
435
+ mutationToDom: Blockly.Blocks['procedures_defnoreturn'].mutationToDom,
436
+ domToMutation: Blockly.Blocks['procedures_defnoreturn'].domToMutation,
437
+ decompose: Blockly.Blocks['procedures_defnoreturn'].decompose,
438
+ compose: Blockly.Blocks['procedures_defnoreturn'].compose,
439
+ /**
440
+ * Return the signature of this procedure definition.
441
+ * @return {!Array} Tuple containing three elements:
442
+ * - the name of the defined procedure,
443
+ * - a list of all its arguments,
444
+ * - that it DOES have a return value.
445
+ * @this {Blockly.Block}
446
+ */
447
+ getProcedureDef: function() {
448
+ return [this.getFieldValue('NAME'), this.arguments_, true];
449
+ },
450
+ getVars: Blockly.Blocks['procedures_defnoreturn'].getVars,
451
+ getVarModels: Blockly.Blocks['procedures_defnoreturn'].getVarModels,
452
+ renameVarById: Blockly.Blocks['procedures_defnoreturn'].renameVarById,
453
+ updateVarName: Blockly.Blocks['procedures_defnoreturn'].updateVarName,
454
+ displayRenamedVar_: Blockly.Blocks['procedures_defnoreturn'].displayRenamedVar_,
455
+ customContextMenu: Blockly.Blocks['procedures_defnoreturn'].customContextMenu,
456
+ callType_: 'procedures_callreturn'
457
+ };
458
+
459
+ Blockly.Blocks['procedures_mutatorcontainer'] = {
460
+ /**
461
+ * Mutator block for procedure container.
462
+ * @this {Blockly.Block}
463
+ */
464
+ init: function() {
465
+ this.appendDummyInput()
466
+ .appendField(Blockly.Msg['PROCEDURES_MUTATORCONTAINER_TITLE']);
467
+ this.appendStatementInput('STACK');
468
+ this.appendDummyInput('STATEMENT_INPUT')
469
+ .appendField(Blockly.Msg['PROCEDURES_ALLOW_STATEMENTS'])
470
+ .appendField(new Blockly.FieldCheckbox('TRUE'), 'STATEMENTS');
471
+ this.setStyle('procedure_blocks');
472
+ this.setTooltip(Blockly.Msg['PROCEDURES_MUTATORCONTAINER_TOOLTIP']);
473
+ this.contextMenu = false;
474
+ },
475
+ };
476
+
477
+ Blockly.Blocks['procedures_mutatorarg'] = {
478
+ /**
479
+ * Mutator block for procedure argument.
480
+ * @this {Blockly.Block}
481
+ */
482
+ init: function() {
483
+ var field = new Blockly.FieldTextInput(
484
+ Blockly.Procedures.DEFAULT_ARG, this.validator_);
485
+ // Hack: override showEditor to do just a little bit more work.
486
+ // We don't have a good place to hook into the start of a text edit.
487
+ field.oldShowEditorFn_ = field.showEditor_;
488
+ var newShowEditorFn = function() {
489
+ this.createdVariables_ = [];
490
+ this.oldShowEditorFn_();
491
+ };
492
+ field.showEditor_ = newShowEditorFn;
493
+
494
+ this.appendDummyInput()
495
+ .appendField(Blockly.Msg['PROCEDURES_MUTATORARG_TITLE'])
496
+ .appendField(field, 'NAME');
497
+ this.setPreviousStatement(true);
498
+ this.setNextStatement(true);
499
+ this.setStyle('procedure_blocks');
500
+ this.setTooltip(Blockly.Msg['PROCEDURES_MUTATORARG_TOOLTIP']);
501
+ this.contextMenu = false;
502
+
503
+ // Create the default variable when we drag the block in from the flyout.
504
+ // Have to do this after installing the field on the block.
505
+ field.onFinishEditing_ = this.deleteIntermediateVars_;
506
+ // Create an empty list so onFinishEditing_ has something to look at, even
507
+ // though the editor was never opened.
508
+ field.createdVariables_ = [];
509
+ field.onFinishEditing_('x');
510
+ },
511
+
512
+ /**
513
+ * Obtain a valid name for the procedure argument. Create a variable if
514
+ * necessary.
515
+ * Merge runs of whitespace. Strip leading and trailing whitespace.
516
+ * Beyond this, all names are legal.
517
+ * @param {string} varName User-supplied name.
518
+ * @return {?string} Valid name, or null if a name was not specified.
519
+ * @private
520
+ * @this Blockly.FieldTextInput
521
+ */
522
+ validator_: function(varName) {
523
+ var sourceBlock = this.getSourceBlock();
524
+ var outerWs = Blockly.Mutator.findParentWs(sourceBlock.workspace);
525
+ varName = varName.replace(/[\s\xa0]+/g, ' ').replace(/^ | $/g, '');
526
+ if (!varName) {
527
+ return null;
528
+ }
529
+
530
+ // Prevents duplicate parameter names in functions
531
+ var workspace = sourceBlock.workspace.targetWorkspace ||
532
+ sourceBlock.workspace;
533
+ var blocks = workspace.getAllBlocks(false);
534
+ var caselessName = varName.toLowerCase();
535
+ for (var i = 0; i < blocks.length; i++) {
536
+ if (blocks[i].id == this.getSourceBlock().id) {
537
+ continue;
538
+ }
539
+ // Other blocks values may not be set yet when this is loaded.
540
+ var otherVar = blocks[i].getFieldValue('NAME');
541
+ if (otherVar && otherVar.toLowerCase() == caselessName) {
542
+ return null;
543
+ }
544
+ }
545
+
546
+ // Don't create variables for arg blocks that
547
+ // only exist in the mutator's flyout.
548
+ if (sourceBlock.isInFlyout) {
549
+ return varName;
550
+ }
551
+
552
+ var model = outerWs.getVariable(varName, '');
553
+ if (model && model.name != varName) {
554
+ // Rename the variable (case change)
555
+ outerWs.renameVariableById(model.getId(), varName);
556
+ }
557
+ if (!model) {
558
+ model = outerWs.createVariable(varName, '');
559
+ if (model && this.createdVariables_) {
560
+ this.createdVariables_.push(model);
561
+ }
562
+ }
563
+ return varName;
564
+ },
565
+
566
+ /**
567
+ * Called when focusing away from the text field.
568
+ * Deletes all variables that were created as the user typed their intended
569
+ * variable name.
570
+ * @param {string} newText The new variable name.
571
+ * @private
572
+ * @this Blockly.FieldTextInput
573
+ */
574
+ deleteIntermediateVars_: function(newText) {
575
+ var outerWs = Blockly.Mutator.findParentWs(this.getSourceBlock().workspace);
576
+ if (!outerWs) {
577
+ return;
578
+ }
579
+ for (var i = 0; i < this.createdVariables_.length; i++) {
580
+ var model = this.createdVariables_[i];
581
+ if (model.name != newText) {
582
+ outerWs.deleteVariableById(model.getId());
583
+ }
584
+ }
585
+ }
586
+ };
587
+
588
+ Blockly.Blocks['procedures_callnoreturn'] = {
589
+ /**
590
+ * Block for calling a procedure with no return value.
591
+ * @this {Blockly.Block}
592
+ */
593
+ init: function() {
594
+ this.appendDummyInput('TOPROW')
595
+ .appendField(this.id, 'NAME');
596
+ this.setPreviousStatement(true);
597
+ this.setNextStatement(true);
598
+ this.setStyle('procedure_blocks');
599
+ // Tooltip is set in renameProcedure.
600
+ this.setHelpUrl(Blockly.Msg['PROCEDURES_CALLNORETURN_HELPURL']);
601
+ this.arguments_ = [];
602
+ this.argumentVarModels_ = [];
603
+ this.quarkConnections_ = {};
604
+ this.quarkIds_ = null;
605
+ this.previousEnabledState_ = true;
606
+ },
607
+
608
+ /**
609
+ * Returns the name of the procedure this block calls.
610
+ * @return {string} Procedure name.
611
+ * @this {Blockly.Block}
612
+ */
613
+ getProcedureCall: function() {
614
+ // The NAME field is guaranteed to exist, null will never be returned.
615
+ return /** @type {string} */ (this.getFieldValue('NAME'));
616
+ },
617
+ /**
618
+ * Notification that a procedure is renaming.
619
+ * If the name matches this block's procedure, rename it.
620
+ * @param {string} oldName Previous name of procedure.
621
+ * @param {string} newName Renamed procedure.
622
+ * @this {Blockly.Block}
623
+ */
624
+ renameProcedure: function(oldName, newName) {
625
+ if (Blockly.Names.equals(oldName, this.getProcedureCall())) {
626
+ this.setFieldValue(newName, 'NAME');
627
+ var baseMsg = this.outputConnection ?
628
+ Blockly.Msg['PROCEDURES_CALLRETURN_TOOLTIP'] :
629
+ Blockly.Msg['PROCEDURES_CALLNORETURN_TOOLTIP'];
630
+ this.setTooltip(baseMsg.replace('%1', newName));
631
+ }
632
+ },
633
+ /**
634
+ * Notification that the procedure's parameters have changed.
635
+ * @param {!Array.<string>} paramNames New param names, e.g. ['x', 'y', 'z'].
636
+ * @param {!Array.<string>} paramIds IDs of params (consistent for each
637
+ * parameter through the life of a mutator, regardless of param renaming),
638
+ * e.g. ['piua', 'f8b_', 'oi.o'].
639
+ * @private
640
+ * @this {Blockly.Block}
641
+ */
642
+ setProcedureParameters_: function(paramNames, paramIds) {
643
+ // Data structures:
644
+ // this.arguments = ['x', 'y']
645
+ // Existing param names.
646
+ // this.quarkConnections_ {piua: null, f8b_: Blockly.Connection}
647
+ // Look-up of paramIds to connections plugged into the call block.
648
+ // this.quarkIds_ = ['piua', 'f8b_']
649
+ // Existing param IDs.
650
+ // Note that quarkConnections_ may include IDs that no longer exist, but
651
+ // which might reappear if a param is reattached in the mutator.
652
+ var defBlock = Blockly.Procedures.getDefinition(this.getProcedureCall(),
653
+ this.workspace);
654
+ var mutatorOpen = defBlock && defBlock.mutator &&
655
+ defBlock.mutator.isVisible();
656
+ if (!mutatorOpen) {
657
+ this.quarkConnections_ = {};
658
+ this.quarkIds_ = null;
659
+ }
660
+ if (!paramIds) {
661
+ // Reset the quarks (a mutator is about to open).
662
+ return;
663
+ }
664
+ // Test arguments (arrays of strings) for changes. '\n' is not a valid
665
+ // argument name character, so it is a valid delimiter here.
666
+ if (paramNames.join('\n') == this.arguments_.join('\n')) {
667
+ // No change.
668
+ this.quarkIds_ = paramIds;
669
+ return;
670
+ }
671
+ if (paramIds.length != paramNames.length) {
672
+ throw RangeError('paramNames and paramIds must be the same length.');
673
+ }
674
+ this.setCollapsed(false);
675
+ if (!this.quarkIds_) {
676
+ // Initialize tracking for this block.
677
+ this.quarkConnections_ = {};
678
+ this.quarkIds_ = [];
679
+ }
680
+ // Switch off rendering while the block is rebuilt.
681
+ var savedRendered = this.rendered;
682
+ this.rendered = false;
683
+ // Update the quarkConnections_ with existing connections.
684
+ for (var i = 0; i < this.arguments_.length; i++) {
685
+ var input = this.getInput('ARG' + i);
686
+ if (input) {
687
+ var connection = input.connection.targetConnection;
688
+ this.quarkConnections_[this.quarkIds_[i]] = connection;
689
+ if (mutatorOpen && connection &&
690
+ paramIds.indexOf(this.quarkIds_[i]) == -1) {
691
+ // This connection should no longer be attached to this block.
692
+ connection.disconnect();
693
+ connection.getSourceBlock().bumpNeighbours();
694
+ }
695
+ }
696
+ }
697
+ // Rebuild the block's arguments.
698
+ this.arguments_ = [].concat(paramNames);
699
+ // And rebuild the argument model list.
700
+ this.argumentVarModels_ = [];
701
+ for (var i = 0; i < this.arguments_.length; i++) {
702
+ var variable = Blockly.Variables.getOrCreateVariablePackage(
703
+ this.workspace, null, this.arguments_[i], '');
704
+ this.argumentVarModels_.push(variable);
705
+ }
706
+
707
+ this.updateShape_();
708
+ this.quarkIds_ = paramIds;
709
+ // Reconnect any child blocks.
710
+ if (this.quarkIds_) {
711
+ for (var i = 0; i < this.arguments_.length; i++) {
712
+ var quarkId = this.quarkIds_[i];
713
+ if (quarkId in this.quarkConnections_) {
714
+ var connection = this.quarkConnections_[quarkId];
715
+ if (!Blockly.Mutator.reconnect(connection, this, 'ARG' + i)) {
716
+ // Block no longer exists or has been attached elsewhere.
717
+ delete this.quarkConnections_[quarkId];
718
+ }
719
+ }
720
+ }
721
+ }
722
+ // Restore rendering and show the changes.
723
+ this.rendered = savedRendered;
724
+ if (this.rendered) {
725
+ this.render();
726
+ }
727
+ },
728
+ /**
729
+ * Modify this block to have the correct number of arguments.
730
+ * @private
731
+ * @this {Blockly.Block}
732
+ */
733
+ updateShape_: function() {
734
+ for (var i = 0; i < this.arguments_.length; i++) {
735
+ var field = this.getField('ARGNAME' + i);
736
+ if (field) {
737
+ // Ensure argument name is up to date.
738
+ // The argument name field is deterministic based on the mutation,
739
+ // no need to fire a change event.
740
+ Blockly.Events.disable();
741
+ try {
742
+ field.setValue(this.arguments_[i]);
743
+ } finally {
744
+ Blockly.Events.enable();
745
+ }
746
+ } else {
747
+ // Add new input.
748
+ field = new Blockly.FieldLabel(this.arguments_[i]);
749
+ var input = this.appendValueInput('ARG' + i)
750
+ .setAlign(Blockly.ALIGN_RIGHT)
751
+ .appendField(field, 'ARGNAME' + i);
752
+ input.init();
753
+ }
754
+ }
755
+ // Remove deleted inputs.
756
+ while (this.getInput('ARG' + i)) {
757
+ this.removeInput('ARG' + i);
758
+ i++;
759
+ }
760
+ // Add 'with:' if there are parameters, remove otherwise.
761
+ var topRow = this.getInput('TOPROW');
762
+ if (topRow) {
763
+ if (this.arguments_.length) {
764
+ if (!this.getField('WITH')) {
765
+ topRow.appendField(Blockly.Msg['PROCEDURES_CALL_BEFORE_PARAMS'], 'WITH');
766
+ topRow.init();
767
+ }
768
+ } else {
769
+ if (this.getField('WITH')) {
770
+ topRow.removeField('WITH');
771
+ }
772
+ }
773
+ }
774
+ },
775
+ /**
776
+ * Create XML to represent the (non-editable) name and arguments.
777
+ * @return {!Element} XML storage element.
778
+ * @this {Blockly.Block}
779
+ */
780
+ mutationToDom: function() {
781
+ var container = Blockly.utils.xml.createElement('mutation');
782
+ container.setAttribute('name', this.getProcedureCall());
783
+ for (var i = 0; i < this.arguments_.length; i++) {
784
+ var parameter = Blockly.utils.xml.createElement('arg');
785
+ parameter.setAttribute('name', this.arguments_[i]);
786
+ container.appendChild(parameter);
787
+ }
788
+ return container;
789
+ },
790
+ /**
791
+ * Parse XML to restore the (non-editable) name and parameters.
792
+ * @param {!Element} xmlElement XML storage element.
793
+ * @this {Blockly.Block}
794
+ */
795
+ domToMutation: function(xmlElement) {
796
+ var name = xmlElement.getAttribute('name');
797
+ this.renameProcedure(this.getProcedureCall(), name);
798
+ var args = [];
799
+ var paramIds = [];
800
+ for (var i = 0, childNode; (childNode = xmlElement.childNodes[i]); i++) {
801
+ if (childNode.nodeName.toLowerCase() == 'arg') {
802
+ args.push(childNode.getAttribute('name'));
803
+ paramIds.push(childNode.getAttribute('paramId'));
804
+ }
805
+ }
806
+ this.setProcedureParameters_(args, paramIds);
807
+ },
808
+ /**
809
+ * Return all variables referenced by this block.
810
+ * @return {!Array.<string>} List of variable names.
811
+ * @this {Blockly.Block}
812
+ */
813
+ getVars: function() {
814
+ return this.arguments_;
815
+ },
816
+ /**
817
+ * Return all variables referenced by this block.
818
+ * @return {!Array.<!Blockly.VariableModel>} List of variable models.
819
+ * @this {Blockly.Block}
820
+ */
821
+ getVarModels: function() {
822
+ return this.argumentVarModels_;
823
+ },
824
+ /**
825
+ * Procedure calls cannot exist without the corresponding procedure
826
+ * definition. Enforce this link whenever an event is fired.
827
+ * @param {!Blockly.Events.Abstract} event Change event.
828
+ * @this {Blockly.Block}
829
+ */
830
+ onchange: function(event) {
831
+ if (!this.workspace || this.workspace.isFlyout) {
832
+ // Block is deleted or is in a flyout.
833
+ return;
834
+ }
835
+ if (!event.recordUndo) {
836
+ // Events not generated by user. Skip handling.
837
+ return;
838
+ }
839
+ if (event.type == Blockly.Events.BLOCK_CREATE &&
840
+ event.ids.indexOf(this.id) != -1) {
841
+ // Look for the case where a procedure call was created (usually through
842
+ // paste) and there is no matching definition. In this case, create
843
+ // an empty definition block with the correct signature.
844
+ var name = this.getProcedureCall();
845
+ var def = Blockly.Procedures.getDefinition(name, this.workspace);
846
+ if (def && (def.type != this.defType_ ||
847
+ JSON.stringify(def.getVars()) != JSON.stringify(this.arguments_))) {
848
+ // The signatures don't match.
849
+ def = null;
850
+ }
851
+ if (!def) {
852
+ Blockly.Events.setGroup(event.group);
853
+ /**
854
+ * Create matching definition block.
855
+ * <xml xmlns="https://developers.google.com/blockly/xml">
856
+ * <block type="procedures_defreturn" x="10" y="20">
857
+ * <mutation name="test">
858
+ * <arg name="x"></arg>
859
+ * </mutation>
860
+ * <field name="NAME">test</field>
861
+ * </block>
862
+ * </xml>
863
+ */
864
+ var xml = Blockly.utils.xml.createElement('xml');
865
+ var block = Blockly.utils.xml.createElement('block');
866
+ block.setAttribute('type', this.defType_);
867
+ var xy = this.getRelativeToSurfaceXY();
868
+ var x = xy.x + Blockly.SNAP_RADIUS * (this.RTL ? -1 : 1);
869
+ var y = xy.y + Blockly.SNAP_RADIUS * 2;
870
+ block.setAttribute('x', x);
871
+ block.setAttribute('y', y);
872
+ var mutation = this.mutationToDom();
873
+ block.appendChild(mutation);
874
+ var field = Blockly.utils.xml.createElement('field');
875
+ field.setAttribute('name', 'NAME');
876
+ field.appendChild(Blockly.utils.xml.createTextNode(
877
+ this.getProcedureCall()));
878
+ block.appendChild(field);
879
+ xml.appendChild(block);
880
+ Blockly.Xml.domToWorkspace(xml, this.workspace);
881
+ Blockly.Events.setGroup(false);
882
+ }
883
+ } else if (event.type == Blockly.Events.BLOCK_DELETE) {
884
+ // Look for the case where a procedure definition has been deleted,
885
+ // leaving this block (a procedure call) orphaned. In this case, delete
886
+ // the orphan.
887
+ var name = this.getProcedureCall();
888
+ var def = Blockly.Procedures.getDefinition(name, this.workspace);
889
+ if (!def) {
890
+ Blockly.Events.setGroup(event.group);
891
+ this.dispose(true);
892
+ Blockly.Events.setGroup(false);
893
+ }
894
+ } else if (event.type == Blockly.Events.CHANGE && event.element == 'disabled') {
895
+ var name = this.getProcedureCall();
896
+ var def = Blockly.Procedures.getDefinition(name, this.workspace);
897
+ if (def && def.id == event.blockId) {
898
+ // in most cases the old group should be ''
899
+ var oldGroup = Blockly.Events.getGroup();
900
+ if (oldGroup) {
901
+ // This should only be possible programmatically and may indicate a problem
902
+ // with event grouping. If you see this message please investigate. If the
903
+ // use ends up being valid we may need to reorder events in the undo stack.
904
+ console.log('Saw an existing group while responding to a definition change');
905
+ }
906
+ Blockly.Events.setGroup(event.group);
907
+ if (event.newValue) {
908
+ this.previousEnabledState_ = this.isEnabled();
909
+ this.setEnabled(false);
910
+ } else {
911
+ this.setEnabled(this.previousEnabledState_);
912
+ }
913
+ Blockly.Events.setGroup(oldGroup);
914
+ }
915
+ }
916
+ },
917
+ /**
918
+ * Add menu option to find the definition block for this call.
919
+ * @param {!Array} options List of menu options to add to.
920
+ * @this {Blockly.Block}
921
+ */
922
+ customContextMenu: function(options) {
923
+ if (!this.workspace.isMovable()) {
924
+ // If we center on the block and the workspace isn't movable we could
925
+ // loose blocks at the edges of the workspace.
926
+ return;
927
+ }
928
+
929
+ var option = {enabled: true};
930
+ option.text = Blockly.Msg['PROCEDURES_HIGHLIGHT_DEF'];
931
+ var name = this.getProcedureCall();
932
+ var workspace = this.workspace;
933
+ option.callback = function() {
934
+ var def = Blockly.Procedures.getDefinition(name, workspace);
935
+ if (def) {
936
+ workspace.centerOnBlock(def.id);
937
+ def.select();
938
+ }
939
+ };
940
+ options.push(option);
941
+ },
942
+ defType_: 'procedures_defnoreturn'
943
+ };
944
+
945
+ Blockly.Blocks['procedures_callreturn'] = {
946
+ /**
947
+ * Block for calling a procedure with a return value.
948
+ * @this {Blockly.Block}
949
+ */
950
+ init: function() {
951
+ this.appendDummyInput('TOPROW')
952
+ .appendField('', 'NAME');
953
+ this.setOutput(true);
954
+ this.setStyle('procedure_blocks');
955
+ // Tooltip is set in domToMutation.
956
+ this.setHelpUrl(Blockly.Msg['PROCEDURES_CALLRETURN_HELPURL']);
957
+ this.arguments_ = [];
958
+ this.quarkConnections_ = {};
959
+ this.quarkIds_ = null;
960
+ this.previousEnabledState_ = true;
961
+ },
962
+
963
+ getProcedureCall: Blockly.Blocks['procedures_callnoreturn'].getProcedureCall,
964
+ renameProcedure: Blockly.Blocks['procedures_callnoreturn'].renameProcedure,
965
+ setProcedureParameters_:
966
+ Blockly.Blocks['procedures_callnoreturn'].setProcedureParameters_,
967
+ updateShape_: Blockly.Blocks['procedures_callnoreturn'].updateShape_,
968
+ mutationToDom: Blockly.Blocks['procedures_callnoreturn'].mutationToDom,
969
+ domToMutation: Blockly.Blocks['procedures_callnoreturn'].domToMutation,
970
+ getVars: Blockly.Blocks['procedures_callnoreturn'].getVars,
971
+ getVarModels: Blockly.Blocks['procedures_callnoreturn'].getVarModels,
972
+ onchange: Blockly.Blocks['procedures_callnoreturn'].onchange,
973
+ customContextMenu:
974
+ Blockly.Blocks['procedures_callnoreturn'].customContextMenu,
975
+ defType_: 'procedures_defreturn'
976
+ };
977
+
978
+ Blockly.Blocks['procedures_ifreturn'] = {
979
+ /**
980
+ * Block for conditionally returning a value from a procedure.
981
+ * @this {Blockly.Block}
982
+ */
983
+ init: function() {
984
+ this.appendValueInput('CONDITION')
985
+ .setCheck('Boolean')
986
+ .appendField(Blockly.Msg['CONTROLS_IF_MSG_IF']);
987
+ this.appendValueInput('VALUE')
988
+ .appendField(Blockly.Msg['PROCEDURES_DEFRETURN_RETURN']);
989
+ this.setInputsInline(true);
990
+ this.setPreviousStatement(true);
991
+ this.setNextStatement(true);
992
+ this.setStyle('procedure_blocks');
993
+ this.setTooltip(Blockly.Msg['PROCEDURES_IFRETURN_TOOLTIP']);
994
+ this.setHelpUrl(Blockly.Msg['PROCEDURES_IFRETURN_HELPURL']);
995
+ this.hasReturnValue_ = true;
996
+ },
997
+ /**
998
+ * Create XML to represent whether this block has a return value.
999
+ * @return {!Element} XML storage element.
1000
+ * @this {Blockly.Block}
1001
+ */
1002
+ mutationToDom: function() {
1003
+ var container = Blockly.utils.xml.createElement('mutation');
1004
+ container.setAttribute('value', Number(this.hasReturnValue_));
1005
+ return container;
1006
+ },
1007
+ /**
1008
+ * Parse XML to restore whether this block has a return value.
1009
+ * @param {!Element} xmlElement XML storage element.
1010
+ * @this {Blockly.Block}
1011
+ */
1012
+ domToMutation: function(xmlElement) {
1013
+ var value = xmlElement.getAttribute('value');
1014
+ this.hasReturnValue_ = (value == 1);
1015
+ if (!this.hasReturnValue_) {
1016
+ this.removeInput('VALUE');
1017
+ this.appendDummyInput('VALUE')
1018
+ .appendField(Blockly.Msg['PROCEDURES_DEFRETURN_RETURN']);
1019
+ }
1020
+ },
1021
+ /**
1022
+ * Called whenever anything on the workspace changes.
1023
+ * Add warning if this flow block is not nested inside a loop.
1024
+ * @param {!Blockly.Events.Abstract} _e Change event.
1025
+ * @this {Blockly.Block}
1026
+ */
1027
+ onchange: function(_e) {
1028
+ if (!this.workspace.isDragging || this.workspace.isDragging()) {
1029
+ return; // Don't change state at the start of a drag.
1030
+ }
1031
+ var legal = false;
1032
+ // Is the block nested in a procedure?
1033
+ var block = this;
1034
+ do {
1035
+ if (this.FUNCTION_TYPES.indexOf(block.type) != -1) {
1036
+ legal = true;
1037
+ break;
1038
+ }
1039
+ block = block.getSurroundParent();
1040
+ } while (block);
1041
+ if (legal) {
1042
+ // If needed, toggle whether this block has a return value.
1043
+ if (block.type == 'procedures_defnoreturn' && this.hasReturnValue_) {
1044
+ this.removeInput('VALUE');
1045
+ this.appendDummyInput('VALUE')
1046
+ .appendField(Blockly.Msg['PROCEDURES_DEFRETURN_RETURN']);
1047
+ this.hasReturnValue_ = false;
1048
+ } else if (block.type == 'procedures_defreturn' &&
1049
+ !this.hasReturnValue_) {
1050
+ this.removeInput('VALUE');
1051
+ this.appendValueInput('VALUE')
1052
+ .appendField(Blockly.Msg['PROCEDURES_DEFRETURN_RETURN']);
1053
+ this.hasReturnValue_ = true;
1054
+ }
1055
+ this.setWarningText(null);
1056
+ if (!this.isInFlyout) {
1057
+ this.setEnabled(true);
1058
+ }
1059
+ } else {
1060
+ this.setWarningText(Blockly.Msg['PROCEDURES_IFRETURN_WARNING']);
1061
+ if (!this.isInFlyout && !this.getInheritedDisabled()) {
1062
+ this.setEnabled(false);
1063
+ }
1064
+ }
1065
+ },
1066
+ /**
1067
+ * List of block types that are functions and thus do not need warnings.
1068
+ * To add a new function type add this to your code:
1069
+ * Blockly.Blocks['procedures_ifreturn'].FUNCTION_TYPES.push('custom_func');
1070
+ */
1071
+ FUNCTION_TYPES: ['procedures_defnoreturn', 'procedures_defreturn']
1072
+ };