nodeskini 1.0.1 → 1.0.2

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 +3 -3
@@ -0,0 +1,2010 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2011 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ /**
8
+ * @fileoverview The class representing one block.
9
+ * @author fraser@google.com (Neil Fraser)
10
+ */
11
+ 'use strict';
12
+
13
+ goog.provide('Blockly.Block');
14
+
15
+ goog.require('Blockly.ASTNode');
16
+ goog.require('Blockly.Blocks');
17
+ goog.require('Blockly.Connection');
18
+ goog.require('Blockly.Events');
19
+ goog.require('Blockly.Events.BlockChange');
20
+ goog.require('Blockly.Events.BlockCreate');
21
+ goog.require('Blockly.Events.BlockDelete');
22
+ goog.require('Blockly.Events.BlockMove');
23
+ goog.require('Blockly.Extensions');
24
+ goog.require('Blockly.fieldRegistry');
25
+ goog.require('Blockly.Input');
26
+ goog.require('Blockly.navigation');
27
+ goog.require('Blockly.Tooltip');
28
+ goog.require('Blockly.utils');
29
+ goog.require('Blockly.utils.deprecation');
30
+ goog.require('Blockly.utils.Coordinate');
31
+ goog.require('Blockly.utils.object');
32
+ goog.require('Blockly.utils.string');
33
+ goog.require('Blockly.Workspace');
34
+
35
+ goog.requireType('Blockly.IASTNodeLocation');
36
+
37
+
38
+ /**
39
+ * Class for one block.
40
+ * Not normally called directly, workspace.newBlock() is preferred.
41
+ * @param {!Blockly.Workspace} workspace The block's workspace.
42
+ * @param {!string} prototypeName Name of the language object containing
43
+ * type-specific functions for this block.
44
+ * @param {string=} opt_id Optional ID. Use this ID if provided, otherwise
45
+ * create a new ID.
46
+ * @constructor
47
+ * @implements {Blockly.IASTNodeLocation}
48
+ * @throws When the prototypeName is not valid or not allowed.
49
+ */
50
+ Blockly.Block = function(workspace, prototypeName, opt_id) {
51
+ if (Blockly.Generator &&
52
+ typeof Blockly.Generator.prototype[prototypeName] != 'undefined') {
53
+ // Occluding Generator class members is not allowed.
54
+ throw Error('Block prototypeName "' + prototypeName +
55
+ '" conflicts with Blockly.Generator members.');
56
+ }
57
+
58
+ /** @type {string} */
59
+ this.id = (opt_id && !workspace.getBlockById(opt_id)) ?
60
+ opt_id : Blockly.utils.genUid();
61
+ workspace.setBlockById(this.id, this);
62
+ /** @type {Blockly.Connection} */
63
+ this.outputConnection = null;
64
+ /** @type {Blockly.Connection} */
65
+ this.nextConnection = null;
66
+ /** @type {Blockly.Connection} */
67
+ this.previousConnection = null;
68
+ /** @type {!Array.<!Blockly.Input>} */
69
+ this.inputList = [];
70
+ /** @type {boolean|undefined} */
71
+ this.inputsInline = undefined;
72
+ /**
73
+ * @type {boolean}
74
+ * @private
75
+ */
76
+ this.disabled = false;
77
+ /** @type {!Blockly.Tooltip.TipInfo} */
78
+ this.tooltip = '';
79
+ /** @type {boolean} */
80
+ this.contextMenu = true;
81
+
82
+ /**
83
+ * @type {Blockly.Block}
84
+ * @protected
85
+ */
86
+ this.parentBlock_ = null;
87
+
88
+ /**
89
+ * @type {!Array.<!Blockly.Block>}
90
+ * @protected
91
+ */
92
+ this.childBlocks_ = [];
93
+
94
+ /**
95
+ * @type {boolean}
96
+ * @private
97
+ */
98
+ this.deletable_ = true;
99
+
100
+ /**
101
+ * @type {boolean}
102
+ * @private
103
+ */
104
+ this.movable_ = true;
105
+
106
+ /**
107
+ * @type {boolean}
108
+ * @private
109
+ */
110
+ this.editable_ = true;
111
+
112
+ /**
113
+ * @type {boolean}
114
+ * @private
115
+ */
116
+ this.isShadow_ = false;
117
+
118
+ /**
119
+ * @type {boolean}
120
+ * @protected
121
+ */
122
+ this.collapsed_ = false;
123
+
124
+ /**
125
+ * @type {?number}
126
+ * @protected
127
+ */
128
+ this.outputShape_ = null;
129
+
130
+ /**
131
+ * A string representing the comment attached to this block.
132
+ * @type {string|Blockly.Comment}
133
+ * @deprecated August 2019. Use getCommentText instead.
134
+ */
135
+ this.comment = null;
136
+
137
+ /**
138
+ * A model of the comment attached to this block.
139
+ * @type {!Blockly.Block.CommentModel}
140
+ * @package
141
+ */
142
+ this.commentModel = {
143
+ text: null,
144
+ pinned: false,
145
+ size: new Blockly.utils.Size(160, 80)
146
+ };
147
+
148
+ /**
149
+ * The block's position in workspace units. (0, 0) is at the workspace's
150
+ * origin; scale does not change this value.
151
+ * @type {!Blockly.utils.Coordinate}
152
+ * @private
153
+ */
154
+ this.xy_ = new Blockly.utils.Coordinate(0, 0);
155
+
156
+ /** @type {!Blockly.Workspace} */
157
+ this.workspace = workspace;
158
+ /** @type {boolean} */
159
+ this.isInFlyout = workspace.isFlyout;
160
+ /** @type {boolean} */
161
+ this.isInMutator = workspace.isMutator;
162
+
163
+ /** @type {boolean} */
164
+ this.RTL = workspace.RTL;
165
+
166
+ /**
167
+ * True if this block is an insertion marker.
168
+ * @type {boolean}
169
+ * @protected
170
+ */
171
+ this.isInsertionMarker_ = false;
172
+
173
+ /**
174
+ * Name of the type of hat.
175
+ * @type {string|undefined}
176
+ */
177
+ this.hat = undefined;
178
+
179
+ /** @type {?boolean} */
180
+ this.rendered = null;
181
+
182
+ /**
183
+ * A count of statement inputs on the block.
184
+ * @type {number}
185
+ * @package
186
+ */
187
+ this.statementInputCount = 0;
188
+
189
+ // Copy the type-specific functions and data from the prototype.
190
+ if (prototypeName) {
191
+ /** @type {string} */
192
+ this.type = prototypeName;
193
+ var prototype = Blockly.Blocks[prototypeName];
194
+ if (!prototype || typeof prototype != 'object') {
195
+ throw TypeError('Unknown block type: ' + prototypeName);
196
+ }
197
+ Blockly.utils.object.mixin(this, prototype);
198
+ }
199
+
200
+ workspace.addTopBlock(this);
201
+ workspace.addTypedBlock(this);
202
+
203
+ // All events fired should be part of the same group.
204
+ // Any events fired during init should not be undoable,
205
+ // so that block creation is atomic.
206
+ var existingGroup = Blockly.Events.getGroup();
207
+ if (!existingGroup) {
208
+ Blockly.Events.setGroup(true);
209
+ }
210
+ var initialUndoFlag = Blockly.Events.recordUndo;
211
+
212
+ try {
213
+ // Call an initialization function, if it exists.
214
+ if (typeof this.init == 'function') {
215
+ Blockly.Events.recordUndo = false;
216
+ this.init();
217
+ Blockly.Events.recordUndo = initialUndoFlag;
218
+ }
219
+
220
+ // Fire a create event.
221
+ if (Blockly.Events.isEnabled()) {
222
+ Blockly.Events.fire(new Blockly.Events.BlockCreate(this));
223
+ }
224
+
225
+ } finally {
226
+ if (!existingGroup) {
227
+ Blockly.Events.setGroup(false);
228
+ }
229
+ // In case init threw, recordUndo flag should still be reset.
230
+ Blockly.Events.recordUndo = initialUndoFlag;
231
+ }
232
+
233
+ // Record initial inline state.
234
+ /** @type {boolean|undefined} */
235
+ this.inputsInlineDefault = this.inputsInline;
236
+
237
+ // Bind an onchange function, if it exists.
238
+ if (typeof this.onchange == 'function') {
239
+ this.setOnChange(this.onchange);
240
+ }
241
+ };
242
+
243
+ /**
244
+ * @typedef {{
245
+ * text:?string,
246
+ * pinned:boolean,
247
+ * size:Blockly.utils.Size
248
+ * }}
249
+ */
250
+ Blockly.Block.CommentModel;
251
+
252
+ /**
253
+ * The language-neutral id given to the collapsed input.
254
+ * @const {string}
255
+ */
256
+ Blockly.Block.COLLAPSED_INPUT_NAME = '_TEMP_COLLAPSED_INPUT';
257
+ /**
258
+ * The language-neutral id given to the collapsed field.
259
+ * @const {string}
260
+ */
261
+ Blockly.Block.COLLAPSED_FIELD_NAME = '_TEMP_COLLAPSED_FIELD';
262
+
263
+ /**
264
+ * Optional text data that round-trips between blocks and XML.
265
+ * Has no effect. May be used by 3rd parties for meta information.
266
+ * @type {?string}
267
+ */
268
+ Blockly.Block.prototype.data = null;
269
+
270
+ /**
271
+ * Has this block been disposed of?
272
+ * @type {boolean}
273
+ * @package
274
+ */
275
+ Blockly.Block.prototype.disposed = false;
276
+
277
+ /**
278
+ * Colour of the block as HSV hue value (0-360)
279
+ * This may be null if the block colour was not set via a hue number.
280
+ * @type {?number}
281
+ * @private
282
+ */
283
+ Blockly.Block.prototype.hue_ = null;
284
+
285
+ /**
286
+ * Colour of the block in '#RRGGBB' format.
287
+ * @type {string}
288
+ * @protected
289
+ */
290
+ Blockly.Block.prototype.colour_ = '#000000';
291
+
292
+ /**
293
+ * Name of the block style.
294
+ * @type {?string}
295
+ * @protected
296
+ */
297
+ Blockly.Block.prototype.styleName_ = null;
298
+
299
+ /**
300
+ * An optional method called during initialization.
301
+ * @type {?function()}
302
+ */
303
+ Blockly.Block.prototype.init;
304
+
305
+ /**
306
+ * An optional callback method to use whenever the block's parent workspace
307
+ * changes. This is usually only called from the constructor, the block type
308
+ * initializer function, or an extension initializer function.
309
+ * @type {?function(Blockly.Events.Abstract)}
310
+ */
311
+ Blockly.Block.prototype.onchange;
312
+
313
+ /**
314
+ * An optional serialization method for defining how to serialize the
315
+ * mutation state. This must be coupled with defining `domToMutation`.
316
+ * @type {?function(...):!Element}
317
+ */
318
+ Blockly.Block.prototype.mutationToDom;
319
+
320
+ /**
321
+ * An optional deserialization method for defining how to deserialize the
322
+ * mutation state. This must be coupled with defining `mutationToDom`.
323
+ * @type {?function(!Element)}
324
+ */
325
+ Blockly.Block.prototype.domToMutation;
326
+
327
+ /**
328
+ * An optional property for suppressing adding STATEMENT_PREFIX and
329
+ * STATEMENT_SUFFIX to generated code.
330
+ * @type {?boolean}
331
+ */
332
+ Blockly.Block.prototype.suppressPrefixSuffix;
333
+
334
+ /**
335
+ * An optional property for declaring developer variables. Return a list of
336
+ * variable names for use by generators. Developer variables are never shown to
337
+ * the user, but are declared as global variables in the generated code.
338
+ * @type {?function():!Array.<string>}
339
+ */
340
+ Blockly.Block.prototype.getDeveloperVariables;
341
+
342
+ /**
343
+ * Dispose of this block.
344
+ * @param {boolean} healStack If true, then try to heal any gap by connecting
345
+ * the next statement with the previous statement. Otherwise, dispose of
346
+ * all children of this block.
347
+ * @suppress {checkTypes}
348
+ */
349
+ Blockly.Block.prototype.dispose = function(healStack) {
350
+ if (!this.workspace) {
351
+ // Already deleted.
352
+ return;
353
+ }
354
+ // Terminate onchange event calls.
355
+ if (this.onchangeWrapper_) {
356
+ this.workspace.removeChangeListener(this.onchangeWrapper_);
357
+ }
358
+
359
+ this.unplug(healStack);
360
+ if (Blockly.Events.isEnabled()) {
361
+ Blockly.Events.fire(new Blockly.Events.BlockDelete(this));
362
+ }
363
+ Blockly.Events.disable();
364
+
365
+ try {
366
+ // This block is now at the top of the workspace.
367
+ // Remove this block from the workspace's list of top-most blocks.
368
+ if (this.workspace) {
369
+ this.workspace.removeTopBlock(this);
370
+ this.workspace.removeTypedBlock(this);
371
+ // Remove from block database.
372
+ this.workspace.removeBlockById(this.id);
373
+ this.workspace = null;
374
+ }
375
+
376
+ // Just deleting this block from the DOM would result in a memory leak as
377
+ // well as corruption of the connection database. Therefore we must
378
+ // methodically step through the blocks and carefully disassemble them.
379
+
380
+ if (Blockly.selected == this) {
381
+ Blockly.selected = null;
382
+ }
383
+
384
+ // First, dispose of all my children.
385
+ for (var i = this.childBlocks_.length - 1; i >= 0; i--) {
386
+ this.childBlocks_[i].dispose(false);
387
+ }
388
+ // Then dispose of myself.
389
+ // Dispose of all inputs and their fields.
390
+ for (var i = 0, input; (input = this.inputList[i]); i++) {
391
+ input.dispose();
392
+ }
393
+ this.inputList.length = 0;
394
+ // Dispose of any remaining connections (next/previous/output).
395
+ var connections = this.getConnections_(true);
396
+ for (var i = 0, connection; (connection = connections[i]); i++) {
397
+ connection.dispose();
398
+ }
399
+ } finally {
400
+ Blockly.Events.enable();
401
+ this.disposed = true;
402
+ }
403
+ };
404
+
405
+ /**
406
+ * Call initModel on all fields on the block.
407
+ * May be called more than once.
408
+ * Either initModel or initSvg must be called after creating a block and before
409
+ * the first interaction with it. Interactions include UI actions
410
+ * (e.g. clicking and dragging) and firing events (e.g. create, delete, and
411
+ * change).
412
+ * @public
413
+ */
414
+ Blockly.Block.prototype.initModel = function() {
415
+ for (var i = 0, input; (input = this.inputList[i]); i++) {
416
+ for (var j = 0, field; (field = input.fieldRow[j]); j++) {
417
+ if (field.initModel) {
418
+ field.initModel();
419
+ }
420
+ }
421
+ }
422
+ };
423
+
424
+ /**
425
+ * Unplug this block from its superior block. If this block is a statement,
426
+ * optionally reconnect the block underneath with the block on top.
427
+ * @param {boolean=} opt_healStack Disconnect child statement and reconnect
428
+ * stack. Defaults to false.
429
+ */
430
+ Blockly.Block.prototype.unplug = function(opt_healStack) {
431
+ if (this.outputConnection) {
432
+ this.unplugFromRow_(opt_healStack);
433
+ } else if (this.previousConnection) {
434
+ this.unplugFromStack_(opt_healStack);
435
+ }
436
+ };
437
+
438
+ /**
439
+ * Unplug this block's output from an input on another block. Optionally
440
+ * reconnect the block's parent to the only child block, if possible.
441
+ * @param {boolean=} opt_healStack Disconnect right-side block and connect to
442
+ * left-side block. Defaults to false.
443
+ * @private
444
+ */
445
+ Blockly.Block.prototype.unplugFromRow_ = function(opt_healStack) {
446
+ var parentConnection = null;
447
+ if (this.outputConnection.isConnected()) {
448
+ parentConnection = this.outputConnection.targetConnection;
449
+ // Disconnect from any superior block.
450
+ this.outputConnection.disconnect();
451
+ }
452
+
453
+ // Return early in obvious cases.
454
+ if (!parentConnection || !opt_healStack) {
455
+ return;
456
+ }
457
+
458
+ var thisConnection = this.getOnlyValueConnection_();
459
+ if (!thisConnection ||
460
+ !thisConnection.isConnected() ||
461
+ thisConnection.targetBlock().isShadow()) {
462
+ // Too many or too few possible connections on this block, or there's
463
+ // nothing on the other side of this connection.
464
+ return;
465
+ }
466
+
467
+ var childConnection = thisConnection.targetConnection;
468
+ // Disconnect the child block.
469
+ childConnection.disconnect();
470
+ // Connect child to the parent if possible, otherwise bump away.
471
+ if (this.workspace.connectionChecker.canConnect(
472
+ childConnection, parentConnection, false)) {
473
+ parentConnection.connect(childConnection);
474
+ } else {
475
+ childConnection.onFailedConnect(parentConnection);
476
+ }
477
+ };
478
+
479
+ /**
480
+ * Returns the connection on the value input that is connected to another block.
481
+ * When an insertion marker is connected to a connection with a block already
482
+ * attached, the connected block is attached to the insertion marker.
483
+ * Since only one block can be displaced and attached to the insertion marker
484
+ * this should only ever return one connection.
485
+ *
486
+ * @return {Blockly.Connection} The connection on the value input, or null.
487
+ * @private
488
+ */
489
+ Blockly.Block.prototype.getOnlyValueConnection_ = function() {
490
+ var connection = null;
491
+ for (var i = 0; i < this.inputList.length; i++) {
492
+ var thisConnection = this.inputList[i].connection;
493
+ if (thisConnection && thisConnection.type == Blockly.INPUT_VALUE &&
494
+ thisConnection.targetConnection) {
495
+ if (connection) {
496
+ return null; // More than one value input found.
497
+ }
498
+ connection = thisConnection;
499
+ }
500
+ }
501
+ return connection;
502
+ };
503
+
504
+ /**
505
+ * Unplug this statement block from its superior block. Optionally reconnect
506
+ * the block underneath with the block on top.
507
+ * @param {boolean=} opt_healStack Disconnect child statement and reconnect
508
+ * stack. Defaults to false.
509
+ * @private
510
+ */
511
+ Blockly.Block.prototype.unplugFromStack_ = function(opt_healStack) {
512
+ var previousTarget = null;
513
+ if (this.previousConnection.isConnected()) {
514
+ // Remember the connection that any next statements need to connect to.
515
+ previousTarget = this.previousConnection.targetConnection;
516
+ // Detach this block from the parent's tree.
517
+ this.previousConnection.disconnect();
518
+ }
519
+ var nextBlock = this.getNextBlock();
520
+ if (opt_healStack && nextBlock && !nextBlock.isShadow()) {
521
+ // Disconnect the next statement.
522
+ var nextTarget = this.nextConnection.targetConnection;
523
+ nextTarget.disconnect();
524
+ if (previousTarget &&
525
+ this.workspace.connectionChecker.canConnect(
526
+ previousTarget, nextTarget, false)) {
527
+ // Attach the next statement to the previous statement.
528
+ previousTarget.connect(nextTarget);
529
+ }
530
+ }
531
+ };
532
+
533
+ /**
534
+ * Returns all connections originating from this block.
535
+ * @param {boolean} _all If true, return all connections even hidden ones.
536
+ * @return {!Array.<!Blockly.Connection>} Array of connections.
537
+ * @package
538
+ */
539
+ Blockly.Block.prototype.getConnections_ = function(_all) {
540
+ var myConnections = [];
541
+ if (this.outputConnection) {
542
+ myConnections.push(this.outputConnection);
543
+ }
544
+ if (this.previousConnection) {
545
+ myConnections.push(this.previousConnection);
546
+ }
547
+ if (this.nextConnection) {
548
+ myConnections.push(this.nextConnection);
549
+ }
550
+ for (var i = 0, input; (input = this.inputList[i]); i++) {
551
+ if (input.connection) {
552
+ myConnections.push(input.connection);
553
+ }
554
+ }
555
+ return myConnections;
556
+ };
557
+
558
+ /**
559
+ * Walks down a stack of blocks and finds the last next connection on the stack.
560
+ * @return {Blockly.Connection} The last next connection on the stack, or null.
561
+ * @package
562
+ */
563
+ Blockly.Block.prototype.lastConnectionInStack = function() {
564
+ var nextConnection = this.nextConnection;
565
+ while (nextConnection) {
566
+ var nextBlock = nextConnection.targetBlock();
567
+ if (!nextBlock) {
568
+ // Found a next connection with nothing on the other side.
569
+ return nextConnection;
570
+ }
571
+ nextConnection = nextBlock.nextConnection;
572
+ }
573
+ // Ran out of next connections.
574
+ return null;
575
+ };
576
+
577
+ /**
578
+ * Bump unconnected blocks out of alignment. Two blocks which aren't actually
579
+ * connected should not coincidentally line up on screen.
580
+ */
581
+ Blockly.Block.prototype.bumpNeighbours = function() {
582
+ console.warn('Not expected to reach Block.bumpNeighbours function. ' +
583
+ 'BlockSvg.bumpNeighbours was expected to be called instead.');
584
+ };
585
+
586
+ /**
587
+ * Return the parent block or null if this block is at the top level. The parent
588
+ * block is either the block connected to the previous connection (for a statement
589
+ * block) or the block connected to the output connection (for a value block).
590
+ * @return {Blockly.Block} The block that holds the current block.
591
+ */
592
+ Blockly.Block.prototype.getParent = function() {
593
+ // Look at the DOM to see if we are nested in another block.
594
+ return this.parentBlock_;
595
+ };
596
+
597
+ /**
598
+ * Return the input that connects to the specified block.
599
+ * @param {!Blockly.Block} block A block connected to an input on this block.
600
+ * @return {Blockly.Input} The input that connects to the specified block.
601
+ */
602
+ Blockly.Block.prototype.getInputWithBlock = function(block) {
603
+ for (var i = 0, input; (input = this.inputList[i]); i++) {
604
+ if (input.connection && input.connection.targetBlock() == block) {
605
+ return input;
606
+ }
607
+ }
608
+ return null;
609
+ };
610
+
611
+ /**
612
+ * Return the parent block that surrounds the current block, or null if this
613
+ * block has no surrounding block. A parent block might just be the previous
614
+ * statement, whereas the surrounding block is an if statement, while loop, etc.
615
+ * @return {Blockly.Block} The block that surrounds the current block.
616
+ */
617
+ Blockly.Block.prototype.getSurroundParent = function() {
618
+ var block = this;
619
+ do {
620
+ var prevBlock = block;
621
+ block = block.getParent();
622
+ if (!block) {
623
+ // Ran off the top.
624
+ return null;
625
+ }
626
+ } while (block.getNextBlock() == prevBlock);
627
+ // This block is an enclosing parent, not just a statement in a stack.
628
+ return block;
629
+ };
630
+
631
+ /**
632
+ * Return the next statement block directly connected to this block.
633
+ * @return {Blockly.Block} The next statement block or null.
634
+ */
635
+ Blockly.Block.prototype.getNextBlock = function() {
636
+ return this.nextConnection && this.nextConnection.targetBlock();
637
+ };
638
+
639
+ /**
640
+ * Returns the block connected to the previous connection.
641
+ * @return {Blockly.Block} The previous statement block or null.
642
+ */
643
+ Blockly.Block.prototype.getPreviousBlock = function() {
644
+ return this.previousConnection && this.previousConnection.targetBlock();
645
+ };
646
+
647
+ /**
648
+ * Return the connection on the first statement input on this block, or null if
649
+ * there are none.
650
+ * @return {Blockly.Connection} The first statement connection or null.
651
+ * @package
652
+ */
653
+ Blockly.Block.prototype.getFirstStatementConnection = function() {
654
+ for (var i = 0, input; (input = this.inputList[i]); i++) {
655
+ if (input.connection && input.connection.type == Blockly.NEXT_STATEMENT) {
656
+ return input.connection;
657
+ }
658
+ }
659
+ return null;
660
+ };
661
+
662
+ /**
663
+ * Return the top-most block in this block's tree.
664
+ * This will return itself if this block is at the top level.
665
+ * @return {!Blockly.Block} The root block.
666
+ */
667
+ Blockly.Block.prototype.getRootBlock = function() {
668
+ var rootBlock;
669
+ var block = this;
670
+ do {
671
+ rootBlock = block;
672
+ block = rootBlock.parentBlock_;
673
+ } while (block);
674
+ return rootBlock;
675
+ };
676
+
677
+ /**
678
+ * Walk up from the given block up through the stack of blocks to find
679
+ * the top block of the sub stack. If we are nested in a statement input only
680
+ * find the top-most nested block. Do not go all the way to the root block.
681
+ * @return {!Blockly.Block} The top block in a stack.
682
+ * @package
683
+ */
684
+ Blockly.Block.prototype.getTopStackBlock = function() {
685
+ var block = this;
686
+ do {
687
+ var previous = block.getPreviousBlock();
688
+ } while (previous && previous.getNextBlock() == block && (block = previous));
689
+ return block;
690
+ };
691
+
692
+ /**
693
+ * Find all the blocks that are directly nested inside this one.
694
+ * Includes value and statement inputs, as well as any following statement.
695
+ * Excludes any connection on an output tab or any preceding statement.
696
+ * Blocks are optionally sorted by position; top to bottom.
697
+ * @param {boolean} ordered Sort the list if true.
698
+ * @return {!Array.<!Blockly.Block>} Array of blocks.
699
+ */
700
+ Blockly.Block.prototype.getChildren = function(ordered) {
701
+ if (!ordered) {
702
+ return this.childBlocks_;
703
+ }
704
+ var blocks = [];
705
+ for (var i = 0, input; (input = this.inputList[i]); i++) {
706
+ if (input.connection) {
707
+ var child = input.connection.targetBlock();
708
+ if (child) {
709
+ blocks.push(child);
710
+ }
711
+ }
712
+ }
713
+ var next = this.getNextBlock();
714
+ if (next) {
715
+ blocks.push(next);
716
+ }
717
+ return blocks;
718
+ };
719
+
720
+ /**
721
+ * Set parent of this block to be a new block or null.
722
+ * @param {Blockly.Block} newParent New parent block.
723
+ */
724
+ Blockly.Block.prototype.setParent = function(newParent) {
725
+ if (newParent == this.parentBlock_) {
726
+ return;
727
+ }
728
+ if (this.parentBlock_) {
729
+ // Remove this block from the old parent's child list.
730
+ Blockly.utils.arrayRemove(this.parentBlock_.childBlocks_, this);
731
+
732
+ // Disconnect from superior blocks.
733
+ if (this.previousConnection && this.previousConnection.isConnected()) {
734
+ throw Error('Still connected to previous block.');
735
+ }
736
+ if (this.outputConnection && this.outputConnection.isConnected()) {
737
+ throw Error('Still connected to parent block.');
738
+ }
739
+ this.parentBlock_ = null;
740
+ // This block hasn't actually moved on-screen, so there's no need to update
741
+ // its connection locations.
742
+ } else {
743
+ // Remove this block from the workspace's list of top-most blocks.
744
+ this.workspace.removeTopBlock(this);
745
+ }
746
+
747
+ this.parentBlock_ = newParent;
748
+ if (newParent) {
749
+ // Add this block to the new parent's child list.
750
+ newParent.childBlocks_.push(this);
751
+ } else {
752
+ this.workspace.addTopBlock(this);
753
+ }
754
+ };
755
+
756
+ /**
757
+ * Find all the blocks that are directly or indirectly nested inside this one.
758
+ * Includes this block in the list.
759
+ * Includes value and statement inputs, as well as any following statements.
760
+ * Excludes any connection on an output tab or any preceding statements.
761
+ * Blocks are optionally sorted by position; top to bottom.
762
+ * @param {boolean} ordered Sort the list if true.
763
+ * @return {!Array.<!Blockly.Block>} Flattened array of blocks.
764
+ */
765
+ Blockly.Block.prototype.getDescendants = function(ordered) {
766
+ var blocks = [this];
767
+ var childBlocks = this.getChildren(ordered);
768
+ for (var child, i = 0; (child = childBlocks[i]); i++) {
769
+ blocks.push.apply(blocks, child.getDescendants(ordered));
770
+ }
771
+ return blocks;
772
+ };
773
+
774
+ /**
775
+ * Get whether this block is deletable or not.
776
+ * @return {boolean} True if deletable.
777
+ */
778
+ Blockly.Block.prototype.isDeletable = function() {
779
+ return this.deletable_ && !this.isShadow_ &&
780
+ !(this.workspace && this.workspace.options.readOnly);
781
+ };
782
+
783
+ /**
784
+ * Set whether this block is deletable or not.
785
+ * @param {boolean} deletable True if deletable.
786
+ */
787
+ Blockly.Block.prototype.setDeletable = function(deletable) {
788
+ this.deletable_ = deletable;
789
+ };
790
+
791
+ /**
792
+ * Get whether this block is movable or not.
793
+ * @return {boolean} True if movable.
794
+ */
795
+ Blockly.Block.prototype.isMovable = function() {
796
+ return this.movable_ && !this.isShadow_ &&
797
+ !(this.workspace && this.workspace.options.readOnly);
798
+ };
799
+
800
+ /**
801
+ * Set whether this block is movable or not.
802
+ * @param {boolean} movable True if movable.
803
+ */
804
+ Blockly.Block.prototype.setMovable = function(movable) {
805
+ this.movable_ = movable;
806
+ };
807
+
808
+ /**
809
+ * Get whether is block is duplicatable or not. If duplicating this block and
810
+ * descendants will put this block over the workspace's capacity this block is
811
+ * not duplicatable. If duplicating this block and descendants will put any
812
+ * type over their maxInstances this block is not duplicatable.
813
+ * @return {boolean} True if duplicatable.
814
+ */
815
+ Blockly.Block.prototype.isDuplicatable = function() {
816
+ if (!this.workspace.hasBlockLimits()) {
817
+ return true;
818
+ }
819
+ return this.workspace.isCapacityAvailable(
820
+ Blockly.utils.getBlockTypeCounts(this, true));
821
+ };
822
+
823
+ /**
824
+ * Get whether this block is a shadow block or not.
825
+ * @return {boolean} True if a shadow.
826
+ */
827
+ Blockly.Block.prototype.isShadow = function() {
828
+ return this.isShadow_;
829
+ };
830
+
831
+ /**
832
+ * Set whether this block is a shadow block or not.
833
+ * @param {boolean} shadow True if a shadow.
834
+ */
835
+ Blockly.Block.prototype.setShadow = function(shadow) {
836
+ this.isShadow_ = shadow;
837
+ };
838
+
839
+ /**
840
+ * Get whether this block is an insertion marker block or not.
841
+ * @return {boolean} True if an insertion marker.
842
+ * @package
843
+ */
844
+ Blockly.Block.prototype.isInsertionMarker = function() {
845
+ return this.isInsertionMarker_;
846
+ };
847
+
848
+ /**
849
+ * Set whether this block is an insertion marker block or not.
850
+ * Once set this cannot be unset.
851
+ * @param {boolean} insertionMarker True if an insertion marker.
852
+ * @package
853
+ */
854
+ Blockly.Block.prototype.setInsertionMarker = function(insertionMarker) {
855
+ this.isInsertionMarker_ = insertionMarker;
856
+ };
857
+
858
+ /**
859
+ * Get whether this block is editable or not.
860
+ * @return {boolean} True if editable.
861
+ */
862
+ Blockly.Block.prototype.isEditable = function() {
863
+ return this.editable_ && !(this.workspace && this.workspace.options.readOnly);
864
+ };
865
+
866
+ /**
867
+ * Set whether this block is editable or not.
868
+ * @param {boolean} editable True if editable.
869
+ */
870
+ Blockly.Block.prototype.setEditable = function(editable) {
871
+ this.editable_ = editable;
872
+ for (var i = 0, input; (input = this.inputList[i]); i++) {
873
+ for (var j = 0, field; (field = input.fieldRow[j]); j++) {
874
+ field.updateEditable();
875
+ }
876
+ }
877
+ };
878
+
879
+ /**
880
+ * Returns if this block has been disposed of / deleted.
881
+ * @return {boolean} True if this block has been disposed of / deleted.
882
+ */
883
+ Blockly.Block.prototype.isDisposed = function() {
884
+ return this.disposed;
885
+ };
886
+
887
+ /**
888
+ * Find the connection on this block that corresponds to the given connection
889
+ * on the other block.
890
+ * Used to match connections between a block and its insertion marker.
891
+ * @param {!Blockly.Block} otherBlock The other block to match against.
892
+ * @param {!Blockly.Connection} conn The other connection to match.
893
+ * @return {Blockly.Connection} The matching connection on this block, or null.
894
+ * @package
895
+ */
896
+ Blockly.Block.prototype.getMatchingConnection = function(otherBlock, conn) {
897
+ var connections = this.getConnections_(true);
898
+ var otherConnections = otherBlock.getConnections_(true);
899
+ if (connections.length != otherConnections.length) {
900
+ throw Error("Connection lists did not match in length.");
901
+ }
902
+ for (var i = 0; i < otherConnections.length; i++) {
903
+ if (otherConnections[i] == conn) {
904
+ return connections[i];
905
+ }
906
+ }
907
+ return null;
908
+ };
909
+
910
+ /**
911
+ * Set the URL of this block's help page.
912
+ * @param {string|Function} url URL string for block help, or function that
913
+ * returns a URL. Null for no help.
914
+ */
915
+ Blockly.Block.prototype.setHelpUrl = function(url) {
916
+ this.helpUrl = url;
917
+ };
918
+
919
+ /**
920
+ * Sets the tooltip for this block.
921
+ * @param {!Blockly.Tooltip.TipInfo} newTip The text for the tooltip, a function
922
+ * that returns the text for the tooltip, or a parent object whose tooltip
923
+ * will be used. To not display a tooltip pass the empty string.
924
+ */
925
+ Blockly.Block.prototype.setTooltip = function(newTip) {
926
+ this.tooltip = newTip;
927
+ };
928
+
929
+ /**
930
+ * Returns the tooltip text for this block.
931
+ * @returns {!string} The tooltip text for this block.
932
+ */
933
+ Blockly.Block.prototype.getTooltip = function() {
934
+ return Blockly.Tooltip.getTooltipOfObject(this);
935
+ };
936
+
937
+ /**
938
+ * Get the colour of a block.
939
+ * @return {string} #RRGGBB string.
940
+ */
941
+ Blockly.Block.prototype.getColour = function() {
942
+ return this.colour_;
943
+ };
944
+
945
+ /**
946
+ * Get the name of the block style.
947
+ * @return {?string} Name of the block style.
948
+ */
949
+ Blockly.Block.prototype.getStyleName = function() {
950
+ return this.styleName_;
951
+ };
952
+
953
+ /**
954
+ * Get the HSV hue value of a block. Null if hue not set.
955
+ * @return {?number} Hue value (0-360).
956
+ */
957
+ Blockly.Block.prototype.getHue = function() {
958
+ return this.hue_;
959
+ };
960
+
961
+ /**
962
+ * Change the colour of a block.
963
+ * @param {number|string} colour HSV hue value (0 to 360), #RRGGBB string,
964
+ * or a message reference string pointing to one of those two values.
965
+ */
966
+ Blockly.Block.prototype.setColour = function(colour) {
967
+ var parsed = Blockly.utils.parseBlockColour(colour);
968
+ this.hue_ = parsed.hue;
969
+ this.colour_ = parsed.hex;
970
+ };
971
+
972
+ /**
973
+ * Set the style and colour values of a block.
974
+ * @param {string} blockStyleName Name of the block style
975
+ */
976
+ Blockly.Block.prototype.setStyle = function(blockStyleName) {
977
+ this.styleName_ = blockStyleName;
978
+ };
979
+
980
+ /**
981
+ * Sets a callback function to use whenever the block's parent workspace
982
+ * changes, replacing any prior onchange handler. This is usually only called
983
+ * from the constructor, the block type initializer function, or an extension
984
+ * initializer function.
985
+ * @param {function(Blockly.Events.Abstract)} onchangeFn The callback to call
986
+ * when the block's workspace changes.
987
+ * @throws {Error} if onchangeFn is not falsey and not a function.
988
+ */
989
+ Blockly.Block.prototype.setOnChange = function(onchangeFn) {
990
+ if (onchangeFn && typeof onchangeFn != 'function') {
991
+ throw Error('onchange must be a function.');
992
+ }
993
+ if (this.onchangeWrapper_) {
994
+ this.workspace.removeChangeListener(this.onchangeWrapper_);
995
+ }
996
+ this.onchange = onchangeFn;
997
+ if (this.onchange) {
998
+ this.onchangeWrapper_ = onchangeFn.bind(this);
999
+ this.workspace.addChangeListener(this.onchangeWrapper_);
1000
+ }
1001
+ };
1002
+
1003
+ /**
1004
+ * Returns the named field from a block.
1005
+ * @param {string} name The name of the field.
1006
+ * @return {Blockly.Field} Named field, or null if field does not exist.
1007
+ */
1008
+ Blockly.Block.prototype.getField = function(name) {
1009
+ for (var i = 0, input; (input = this.inputList[i]); i++) {
1010
+ for (var j = 0, field; (field = input.fieldRow[j]); j++) {
1011
+ if (field.name == name) {
1012
+ return field;
1013
+ }
1014
+ }
1015
+ }
1016
+ return null;
1017
+ };
1018
+
1019
+ /**
1020
+ * Return all variables referenced by this block.
1021
+ * @return {!Array.<string>} List of variable names.
1022
+ */
1023
+ Blockly.Block.prototype.getVars = function() {
1024
+ var vars = [];
1025
+ for (var i = 0, input; (input = this.inputList[i]); i++) {
1026
+ for (var j = 0, field; (field = input.fieldRow[j]); j++) {
1027
+ if (field.referencesVariables()) {
1028
+ vars.push(field.getValue());
1029
+ }
1030
+ }
1031
+ }
1032
+ return vars;
1033
+ };
1034
+
1035
+ /**
1036
+ * Return all variables referenced by this block.
1037
+ * @return {!Array.<!Blockly.VariableModel>} List of variable models.
1038
+ * @package
1039
+ */
1040
+ Blockly.Block.prototype.getVarModels = function() {
1041
+ var vars = [];
1042
+ for (var i = 0, input; (input = this.inputList[i]); i++) {
1043
+ for (var j = 0, field; (field = input.fieldRow[j]); j++) {
1044
+ if (field.referencesVariables()) {
1045
+ var model = this.workspace.getVariableById(
1046
+ /** @type {string} */ (field.getValue()));
1047
+ // Check if the variable actually exists (and isn't just a potential
1048
+ // variable).
1049
+ if (model) {
1050
+ vars.push(model);
1051
+ }
1052
+ }
1053
+ }
1054
+ }
1055
+ return vars;
1056
+ };
1057
+
1058
+ /**
1059
+ * Notification that a variable is renaming but keeping the same ID. If the
1060
+ * variable is in use on this block, rerender to show the new name.
1061
+ * @param {!Blockly.VariableModel} variable The variable being renamed.
1062
+ * @package
1063
+ */
1064
+ Blockly.Block.prototype.updateVarName = function(variable) {
1065
+ for (var i = 0, input; (input = this.inputList[i]); i++) {
1066
+ for (var j = 0, field; (field = input.fieldRow[j]); j++) {
1067
+ if (field.referencesVariables() &&
1068
+ variable.getId() == field.getValue()) {
1069
+ field.refreshVariableName();
1070
+ }
1071
+ }
1072
+ }
1073
+ };
1074
+
1075
+ /**
1076
+ * Notification that a variable is renaming.
1077
+ * If the ID matches one of this block's variables, rename it.
1078
+ * @param {string} oldId ID of variable to rename.
1079
+ * @param {string} newId ID of new variable. May be the same as oldId, but with
1080
+ * an updated name.
1081
+ */
1082
+ Blockly.Block.prototype.renameVarById = function(oldId, newId) {
1083
+ for (var i = 0, input; (input = this.inputList[i]); i++) {
1084
+ for (var j = 0, field; (field = input.fieldRow[j]); j++) {
1085
+ if (field.referencesVariables() &&
1086
+ oldId == field.getValue()) {
1087
+ field.setValue(newId);
1088
+ }
1089
+ }
1090
+ }
1091
+ };
1092
+
1093
+ /**
1094
+ * Returns the language-neutral value of the given field.
1095
+ * @param {string} name The name of the field.
1096
+ * @return {*} Value of the field or null if field does not exist.
1097
+ */
1098
+ Blockly.Block.prototype.getFieldValue = function(name) {
1099
+ var field = this.getField(name);
1100
+ if (field) {
1101
+ return field.getValue();
1102
+ }
1103
+ return null;
1104
+ };
1105
+
1106
+ /**
1107
+ * Sets the value of the given field for this block.
1108
+ * @param {*} newValue The value to set.
1109
+ * @param {!string} name The name of the field to set the value of.
1110
+ */
1111
+ Blockly.Block.prototype.setFieldValue = function(newValue, name) {
1112
+ var field = this.getField(name);
1113
+ if (!field) {
1114
+ throw Error('Field "' + name + '" not found.');
1115
+ }
1116
+ field.setValue(newValue);
1117
+ };
1118
+
1119
+ /**
1120
+ * Set whether this block can chain onto the bottom of another block.
1121
+ * @param {boolean} newBoolean True if there can be a previous statement.
1122
+ * @param {(string|Array.<string>|null)=} opt_check Statement type or
1123
+ * list of statement types. Null/undefined if any type could be connected.
1124
+ */
1125
+ Blockly.Block.prototype.setPreviousStatement = function(newBoolean, opt_check) {
1126
+ if (newBoolean) {
1127
+ if (opt_check === undefined) {
1128
+ opt_check = null;
1129
+ }
1130
+ if (!this.previousConnection) {
1131
+ if (this.outputConnection) {
1132
+ throw Error('Remove output connection prior to adding previous ' +
1133
+ 'connection.');
1134
+ }
1135
+ this.previousConnection =
1136
+ this.makeConnection_(Blockly.PREVIOUS_STATEMENT);
1137
+ }
1138
+ this.previousConnection.setCheck(opt_check);
1139
+ } else {
1140
+ if (this.previousConnection) {
1141
+ if (this.previousConnection.isConnected()) {
1142
+ throw Error('Must disconnect previous statement before removing ' +
1143
+ 'connection.');
1144
+ }
1145
+ this.previousConnection.dispose();
1146
+ this.previousConnection = null;
1147
+ }
1148
+ }
1149
+ };
1150
+
1151
+ /**
1152
+ * Set whether another block can chain onto the bottom of this block.
1153
+ * @param {boolean} newBoolean True if there can be a next statement.
1154
+ * @param {(string|Array.<string>|null)=} opt_check Statement type or
1155
+ * list of statement types. Null/undefined if any type could be connected.
1156
+ */
1157
+ Blockly.Block.prototype.setNextStatement = function(newBoolean, opt_check) {
1158
+ if (newBoolean) {
1159
+ if (opt_check === undefined) {
1160
+ opt_check = null;
1161
+ }
1162
+ if (!this.nextConnection) {
1163
+ this.nextConnection = this.makeConnection_(Blockly.NEXT_STATEMENT);
1164
+ }
1165
+ this.nextConnection.setCheck(opt_check);
1166
+ } else {
1167
+ if (this.nextConnection) {
1168
+ if (this.nextConnection.isConnected()) {
1169
+ throw Error('Must disconnect next statement before removing ' +
1170
+ 'connection.');
1171
+ }
1172
+ this.nextConnection.dispose();
1173
+ this.nextConnection = null;
1174
+ }
1175
+ }
1176
+ };
1177
+
1178
+ /**
1179
+ * Set whether this block returns a value.
1180
+ * @param {boolean} newBoolean True if there is an output.
1181
+ * @param {(string|Array.<string>|null)=} opt_check Returned type or list
1182
+ * of returned types. Null or undefined if any type could be returned
1183
+ * (e.g. variable get).
1184
+ */
1185
+ Blockly.Block.prototype.setOutput = function(newBoolean, opt_check) {
1186
+ if (newBoolean) {
1187
+ if (opt_check === undefined) {
1188
+ opt_check = null;
1189
+ }
1190
+ if (!this.outputConnection) {
1191
+ if (this.previousConnection) {
1192
+ throw Error('Remove previous connection prior to adding output ' +
1193
+ 'connection.');
1194
+ }
1195
+ this.outputConnection = this.makeConnection_(Blockly.OUTPUT_VALUE);
1196
+ }
1197
+ this.outputConnection.setCheck(opt_check);
1198
+ } else {
1199
+ if (this.outputConnection) {
1200
+ if (this.outputConnection.isConnected()) {
1201
+ throw Error('Must disconnect output value before removing connection.');
1202
+ }
1203
+ this.outputConnection.dispose();
1204
+ this.outputConnection = null;
1205
+ }
1206
+ }
1207
+ };
1208
+
1209
+ /**
1210
+ * Set whether value inputs are arranged horizontally or vertically.
1211
+ * @param {boolean} newBoolean True if inputs are horizontal.
1212
+ */
1213
+ Blockly.Block.prototype.setInputsInline = function(newBoolean) {
1214
+ if (this.inputsInline != newBoolean) {
1215
+ Blockly.Events.fire(new Blockly.Events.BlockChange(
1216
+ this, 'inline', null, this.inputsInline, newBoolean));
1217
+ this.inputsInline = newBoolean;
1218
+ }
1219
+ };
1220
+
1221
+ /**
1222
+ * Get whether value inputs are arranged horizontally or vertically.
1223
+ * @return {boolean} True if inputs are horizontal.
1224
+ */
1225
+ Blockly.Block.prototype.getInputsInline = function() {
1226
+ if (this.inputsInline != undefined) {
1227
+ // Set explicitly.
1228
+ return this.inputsInline;
1229
+ }
1230
+ // Not defined explicitly. Figure out what would look best.
1231
+ for (var i = 1; i < this.inputList.length; i++) {
1232
+ if (this.inputList[i - 1].type == Blockly.DUMMY_INPUT &&
1233
+ this.inputList[i].type == Blockly.DUMMY_INPUT) {
1234
+ // Two dummy inputs in a row. Don't inline them.
1235
+ return false;
1236
+ }
1237
+ }
1238
+ for (var i = 1; i < this.inputList.length; i++) {
1239
+ if (this.inputList[i - 1].type == Blockly.INPUT_VALUE &&
1240
+ this.inputList[i].type == Blockly.DUMMY_INPUT) {
1241
+ // Dummy input after a value input. Inline them.
1242
+ return true;
1243
+ }
1244
+ }
1245
+ return false;
1246
+ };
1247
+
1248
+ /**
1249
+ * Set the block's output shape.
1250
+ * @param {?number} outputShape Value representing an output shape.
1251
+ */
1252
+ Blockly.Block.prototype.setOutputShape = function(outputShape) {
1253
+ this.outputShape_ = outputShape;
1254
+ };
1255
+
1256
+ /**
1257
+ * Get the block's output shape.
1258
+ * @return {?number} Value representing output shape if one exists.
1259
+ */
1260
+ Blockly.Block.prototype.getOutputShape = function() {
1261
+ return this.outputShape_;
1262
+ };
1263
+
1264
+ /**
1265
+ * Set whether the block is disabled or not.
1266
+ * @param {boolean} disabled True if disabled.
1267
+ * @deprecated May 2019
1268
+ */
1269
+ Blockly.Block.prototype.setDisabled = function(disabled) {
1270
+ Blockly.utils.deprecation.warn(
1271
+ 'Block.prototype.setDisabled',
1272
+ 'May 2019',
1273
+ 'May 2020',
1274
+ 'Block.prototype.setEnabled');
1275
+ this.setEnabled(!disabled);
1276
+ };
1277
+
1278
+ /**
1279
+ * Get whether this block is enabled or not.
1280
+ * @return {boolean} True if enabled.
1281
+ */
1282
+ Blockly.Block.prototype.isEnabled = function() {
1283
+ return !this.disabled;
1284
+ };
1285
+
1286
+ /**
1287
+ * Set whether the block is enabled or not.
1288
+ * @param {boolean} enabled True if enabled.
1289
+ */
1290
+ Blockly.Block.prototype.setEnabled = function(enabled) {
1291
+ if (this.isEnabled() != enabled) {
1292
+ Blockly.Events.fire(new Blockly.Events.BlockChange(
1293
+ this, 'disabled', null, this.disabled, !enabled));
1294
+ this.disabled = !enabled;
1295
+ }
1296
+ };
1297
+
1298
+ /**
1299
+ * Get whether the block is disabled or not due to parents.
1300
+ * The block's own disabled property is not considered.
1301
+ * @return {boolean} True if disabled.
1302
+ */
1303
+ Blockly.Block.prototype.getInheritedDisabled = function() {
1304
+ var ancestor = this.getSurroundParent();
1305
+ while (ancestor) {
1306
+ if (ancestor.disabled) {
1307
+ return true;
1308
+ }
1309
+ ancestor = ancestor.getSurroundParent();
1310
+ }
1311
+ // Ran off the top.
1312
+ return false;
1313
+ };
1314
+
1315
+ /**
1316
+ * Get whether the block is collapsed or not.
1317
+ * @return {boolean} True if collapsed.
1318
+ */
1319
+ Blockly.Block.prototype.isCollapsed = function() {
1320
+ return this.collapsed_;
1321
+ };
1322
+
1323
+ /**
1324
+ * Set whether the block is collapsed or not.
1325
+ * @param {boolean} collapsed True if collapsed.
1326
+ */
1327
+ Blockly.Block.prototype.setCollapsed = function(collapsed) {
1328
+ if (this.collapsed_ != collapsed) {
1329
+ Blockly.Events.fire(new Blockly.Events.BlockChange(
1330
+ this, 'collapsed', null, this.collapsed_, collapsed));
1331
+ this.collapsed_ = collapsed;
1332
+ }
1333
+ };
1334
+
1335
+ /**
1336
+ * Create a human-readable text representation of this block and any children.
1337
+ * @param {number=} opt_maxLength Truncate the string to this length.
1338
+ * @param {string=} opt_emptyToken The placeholder string used to denote an
1339
+ * empty field. If not specified, '?' is used.
1340
+ * @return {string} Text of block.
1341
+ */
1342
+ Blockly.Block.prototype.toString = function(opt_maxLength, opt_emptyToken) {
1343
+ var text = [];
1344
+ var emptyFieldPlaceholder = opt_emptyToken || '?';
1345
+
1346
+ // Temporarily set flag to navigate to all fields.
1347
+ var prevNavigateFields = Blockly.ASTNode.NAVIGATE_ALL_FIELDS;
1348
+ Blockly.ASTNode.NAVIGATE_ALL_FIELDS = true;
1349
+
1350
+ var node = Blockly.ASTNode.createBlockNode(this);
1351
+ var rootNode = node;
1352
+
1353
+ /**
1354
+ * Whether or not to add parentheses around an input.
1355
+ * @param {!Blockly.Connection} connection The connection.
1356
+ * @return {boolean} True if we should add parentheses around the input.
1357
+ */
1358
+ function shouldAddParentheses(connection) {
1359
+ var checks = connection.getCheck();
1360
+ if (!checks && connection.targetConnection) {
1361
+ checks = connection.targetConnection.getCheck();
1362
+ }
1363
+ return !!checks && (checks.indexOf('Boolean') != -1 ||
1364
+ checks.indexOf('Number') != -1);
1365
+ }
1366
+
1367
+ /**
1368
+ * Check that we haven't circled back to the original root node.
1369
+ */
1370
+ function checkRoot() {
1371
+ if (node && node.getType() == rootNode.getType() &&
1372
+ node.getLocation() == rootNode.getLocation()) {
1373
+ node = null;
1374
+ }
1375
+ }
1376
+
1377
+ // Traverse the AST building up our text string.
1378
+ while (node) {
1379
+ switch (node.getType()) {
1380
+ case Blockly.ASTNode.types.INPUT:
1381
+ var connection = /** @type {!Blockly.Connection} */ (node.getLocation());
1382
+ if (!node.in()) {
1383
+ text.push(emptyFieldPlaceholder);
1384
+ } else if (shouldAddParentheses(connection)) {
1385
+ text.push('(');
1386
+ }
1387
+ break;
1388
+ case Blockly.ASTNode.types.FIELD:
1389
+ var field = /** @type {Blockly.Field} */ (node.getLocation());
1390
+ if (field.name != Blockly.Block.COLLAPSED_FIELD_NAME) {
1391
+ text.push(field.getText());
1392
+ }
1393
+ break;
1394
+ }
1395
+
1396
+ var current = node;
1397
+ node = current.in() || current.next();
1398
+ if (!node) {
1399
+ // Can't go in or next, keep going out until we can go next.
1400
+ node = current.out();
1401
+ checkRoot();
1402
+ while (node && !node.next()) {
1403
+ node = node.out();
1404
+ checkRoot();
1405
+ // If we hit an input on the way up, possibly close out parentheses.
1406
+ if (node && node.getType() == Blockly.ASTNode.types.INPUT &&
1407
+ shouldAddParentheses(
1408
+ /** @type {!Blockly.Connection} */ (node.getLocation()))) {
1409
+ text.push(')');
1410
+ }
1411
+ }
1412
+ if (node) {
1413
+ node = node.next();
1414
+ }
1415
+ }
1416
+ }
1417
+
1418
+ // Restore state of NAVIGATE_ALL_FIELDS.
1419
+ Blockly.ASTNode.NAVIGATE_ALL_FIELDS = prevNavigateFields;
1420
+
1421
+ // Run through our text array and simplify expression to remove parentheses
1422
+ // around single field blocks.
1423
+ for (var i = 2, l = text.length; i < l; i++) {
1424
+ if (text[i - 2] == '(' && text[i] == ')') {
1425
+ text[i - 2] = text[i - 1];
1426
+ text.splice(i - 1, 2);
1427
+ l -= 2;
1428
+ }
1429
+ }
1430
+
1431
+ // Join the text array, removing spaces around added paranthesis.
1432
+ text = text.join(' ').replace(/(\() | (\))/gmi, '$1$2').trim() || '???';
1433
+ if (opt_maxLength) {
1434
+ // TODO: Improve truncation so that text from this block is given priority.
1435
+ // E.g. "1+2+3+4+5+6+7+8+9=0" should be "...6+7+8+9=0", not "1+2+3+4+5...".
1436
+ // E.g. "1+2+3+4+5=6+7+8+9+0" should be "...4+5=6+7...".
1437
+ if (text.length > opt_maxLength) {
1438
+ text = text.substring(0, opt_maxLength - 3) + '...';
1439
+ }
1440
+ }
1441
+ return text;
1442
+ };
1443
+
1444
+ /**
1445
+ * Shortcut for appending a value input row.
1446
+ * @param {string} name Language-neutral identifier which may used to find this
1447
+ * input again. Should be unique to this block.
1448
+ * @return {!Blockly.Input} The input object created.
1449
+ */
1450
+ Blockly.Block.prototype.appendValueInput = function(name) {
1451
+ return this.appendInput_(Blockly.INPUT_VALUE, name);
1452
+ };
1453
+
1454
+ /**
1455
+ * Shortcut for appending a statement input row.
1456
+ * @param {string} name Language-neutral identifier which may used to find this
1457
+ * input again. Should be unique to this block.
1458
+ * @return {!Blockly.Input} The input object created.
1459
+ */
1460
+ Blockly.Block.prototype.appendStatementInput = function(name) {
1461
+ return this.appendInput_(Blockly.NEXT_STATEMENT, name);
1462
+ };
1463
+
1464
+ /**
1465
+ * Shortcut for appending a dummy input row.
1466
+ * @param {string=} opt_name Language-neutral identifier which may used to find
1467
+ * this input again. Should be unique to this block.
1468
+ * @return {!Blockly.Input} The input object created.
1469
+ */
1470
+ Blockly.Block.prototype.appendDummyInput = function(opt_name) {
1471
+ return this.appendInput_(Blockly.DUMMY_INPUT, opt_name || '');
1472
+ };
1473
+
1474
+ /**
1475
+ * Initialize this block using a cross-platform, internationalization-friendly
1476
+ * JSON description.
1477
+ * @param {!Object} json Structured data describing the block.
1478
+ */
1479
+ Blockly.Block.prototype.jsonInit = function(json) {
1480
+ var warningPrefix = json['type'] ? 'Block "' + json['type'] + '": ' : '';
1481
+
1482
+ // Validate inputs.
1483
+ if (json['output'] && json['previousStatement']) {
1484
+ throw Error(warningPrefix +
1485
+ 'Must not have both an output and a previousStatement.');
1486
+ }
1487
+
1488
+ // Set basic properties of block.
1489
+ // Makes styles backward compatible with old way of defining hat style.
1490
+ if (json['style'] && json['style'].hat) {
1491
+ this.hat = json['style'].hat;
1492
+ // Must set to null so it doesn't error when checking for style and colour.
1493
+ json['style'] = null;
1494
+ }
1495
+
1496
+ if (json['style'] && json['colour']) {
1497
+ throw Error(warningPrefix + 'Must not have both a colour and a style.');
1498
+ } else if (json['style']) {
1499
+ this.jsonInitStyle_(json, warningPrefix);
1500
+ } else {
1501
+ this.jsonInitColour_(json, warningPrefix);
1502
+ }
1503
+
1504
+ // Interpolate the message blocks.
1505
+ var i = 0;
1506
+ while (json['message' + i] !== undefined) {
1507
+ this.interpolate_(json['message' + i], json['args' + i] || [],
1508
+ json['lastDummyAlign' + i], warningPrefix);
1509
+ i++;
1510
+ }
1511
+
1512
+ if (json['inputsInline'] !== undefined) {
1513
+ this.setInputsInline(json['inputsInline']);
1514
+ }
1515
+ // Set output and previous/next connections.
1516
+ if (json['output'] !== undefined) {
1517
+ this.setOutput(true, json['output']);
1518
+ }
1519
+ if (json['outputShape'] !== undefined) {
1520
+ this.setOutputShape(json['outputShape']);
1521
+ }
1522
+ if (json['previousStatement'] !== undefined) {
1523
+ this.setPreviousStatement(true, json['previousStatement']);
1524
+ }
1525
+ if (json['nextStatement'] !== undefined) {
1526
+ this.setNextStatement(true, json['nextStatement']);
1527
+ }
1528
+ if (json['tooltip'] !== undefined) {
1529
+ var rawValue = json['tooltip'];
1530
+ var localizedText = Blockly.utils.replaceMessageReferences(rawValue);
1531
+ this.setTooltip(localizedText);
1532
+ }
1533
+ if (json['enableContextMenu'] !== undefined) {
1534
+ var rawValue = json['enableContextMenu'];
1535
+ this.contextMenu = !!rawValue;
1536
+ }
1537
+ if (json['helpUrl'] !== undefined) {
1538
+ var rawValue = json['helpUrl'];
1539
+ var localizedValue = Blockly.utils.replaceMessageReferences(rawValue);
1540
+ this.setHelpUrl(localizedValue);
1541
+ }
1542
+ if (typeof json['extensions'] == 'string') {
1543
+ console.warn(
1544
+ warningPrefix + 'JSON attribute \'extensions\' should be an array of' +
1545
+ ' strings. Found raw string in JSON for \'' + json['type'] +
1546
+ '\' block.');
1547
+ json['extensions'] = [json['extensions']]; // Correct and continue.
1548
+ }
1549
+
1550
+ // Add the mutator to the block
1551
+ if (json['mutator'] !== undefined) {
1552
+ Blockly.Extensions.apply(json['mutator'], this, true);
1553
+ }
1554
+
1555
+ if (Array.isArray(json['extensions'])) {
1556
+ var extensionNames = json['extensions'];
1557
+ for (var j = 0; j < extensionNames.length; ++j) {
1558
+ var extensionName = extensionNames[j];
1559
+ Blockly.Extensions.apply(extensionName, this, false);
1560
+ }
1561
+ }
1562
+ };
1563
+
1564
+ /**
1565
+ * Initialize the colour of this block from the JSON description.
1566
+ * @param {!Object} json Structured data describing the block.
1567
+ * @param {string} warningPrefix Warning prefix string identifying block.
1568
+ * @private
1569
+ */
1570
+ Blockly.Block.prototype.jsonInitColour_ = function(json, warningPrefix) {
1571
+ if ('colour' in json) {
1572
+ if (json['colour'] === undefined) {
1573
+ console.warn(warningPrefix + 'Undefined colour value.');
1574
+ } else {
1575
+ var rawValue = json['colour'];
1576
+ try {
1577
+ this.setColour(rawValue);
1578
+ } catch (e) {
1579
+ console.warn(warningPrefix + 'Illegal colour value: ', rawValue);
1580
+ }
1581
+ }
1582
+ }
1583
+ };
1584
+
1585
+ /**
1586
+ * Initialize the style of this block from the JSON description.
1587
+ * @param {!Object} json Structured data describing the block.
1588
+ * @param {string} warningPrefix Warning prefix string identifying block.
1589
+ * @private
1590
+ */
1591
+ Blockly.Block.prototype.jsonInitStyle_ = function(json, warningPrefix) {
1592
+ var blockStyleName = json['style'];
1593
+ try {
1594
+ this.setStyle(blockStyleName);
1595
+ } catch (styleError) {
1596
+ console.warn(warningPrefix + 'Style does not exist: ', blockStyleName);
1597
+ }
1598
+ };
1599
+
1600
+ /**
1601
+ * Add key/values from mixinObj to this block object. By default, this method
1602
+ * will check that the keys in mixinObj will not overwrite existing values in
1603
+ * the block, including prototype values. This provides some insurance against
1604
+ * mixin / extension incompatibilities with future block features. This check
1605
+ * can be disabled by passing true as the second argument.
1606
+ * @param {!Object} mixinObj The key/values pairs to add to this block object.
1607
+ * @param {boolean=} opt_disableCheck Option flag to disable overwrite checks.
1608
+ */
1609
+ Blockly.Block.prototype.mixin = function(mixinObj, opt_disableCheck) {
1610
+ if (opt_disableCheck !== undefined && typeof opt_disableCheck != 'boolean') {
1611
+ throw Error('opt_disableCheck must be a boolean if provided');
1612
+ }
1613
+ if (!opt_disableCheck) {
1614
+ var overwrites = [];
1615
+ for (var key in mixinObj) {
1616
+ if (this[key] !== undefined) {
1617
+ overwrites.push(key);
1618
+ }
1619
+ }
1620
+ if (overwrites.length) {
1621
+ throw Error('Mixin will overwrite block members: ' +
1622
+ JSON.stringify(overwrites));
1623
+ }
1624
+ }
1625
+ Blockly.utils.object.mixin(this, mixinObj);
1626
+ };
1627
+
1628
+ /**
1629
+ * Interpolate a message description onto the block.
1630
+ * @param {string} message Text contains interpolation tokens (%1, %2, ...)
1631
+ * that match with fields or inputs defined in the args array.
1632
+ * @param {!Array} args Array of arguments to be interpolated.
1633
+ * @param {string|undefined} lastDummyAlign If a dummy input is added at the
1634
+ * end, how should it be aligned?
1635
+ * @param {string} warningPrefix Warning prefix string identifying block.
1636
+ * @private
1637
+ */
1638
+ Blockly.Block.prototype.interpolate_ = function(message, args, lastDummyAlign,
1639
+ warningPrefix) {
1640
+ var tokens = Blockly.utils.tokenizeInterpolation(message);
1641
+ // Interpolate the arguments. Build a list of elements.
1642
+ var indexDup = [];
1643
+ var indexCount = 0;
1644
+ var elements = [];
1645
+ for (var i = 0; i < tokens.length; i++) {
1646
+ var token = tokens[i];
1647
+ if (typeof token == 'number') {
1648
+ if (token <= 0 || token > args.length) {
1649
+ throw Error('Block "' + this.type + '": ' +
1650
+ 'Message index %' + token + ' out of range.');
1651
+ }
1652
+ if (indexDup[token]) {
1653
+ throw Error('Block "' + this.type + '": ' +
1654
+ 'Message index %' + token + ' duplicated.');
1655
+ }
1656
+ indexDup[token] = true;
1657
+ indexCount++;
1658
+ elements.push(args[token - 1]);
1659
+ } else {
1660
+ token = token.trim();
1661
+ if (token) {
1662
+ elements.push(token);
1663
+ }
1664
+ }
1665
+ }
1666
+ if (indexCount != args.length) {
1667
+ throw Error('Block "' + this.type + '": ' +
1668
+ 'Message does not reference all ' + args.length + ' arg(s).');
1669
+ }
1670
+ // Add last dummy input if needed.
1671
+ if (elements.length && (typeof elements[elements.length - 1] == 'string' ||
1672
+ Blockly.utils.string.startsWith(
1673
+ elements[elements.length - 1]['type'], 'field_'))) {
1674
+ var dummyInput = {type: 'input_dummy'};
1675
+ if (lastDummyAlign) {
1676
+ dummyInput['align'] = lastDummyAlign;
1677
+ }
1678
+ elements.push(dummyInput);
1679
+ }
1680
+ // Lookup of alignment constants.
1681
+ var alignmentLookup = {
1682
+ 'LEFT': Blockly.ALIGN_LEFT,
1683
+ 'RIGHT': Blockly.ALIGN_RIGHT,
1684
+ 'CENTRE': Blockly.ALIGN_CENTRE,
1685
+ 'CENTER': Blockly.ALIGN_CENTRE
1686
+ };
1687
+ // Populate block with inputs and fields.
1688
+ var fieldStack = [];
1689
+ for (var i = 0; i < elements.length; i++) {
1690
+ var element = elements[i];
1691
+ if (typeof element == 'string') {
1692
+ fieldStack.push([element, undefined]);
1693
+ } else {
1694
+ var field = null;
1695
+ var input = null;
1696
+ do {
1697
+ var altRepeat = false;
1698
+ if (typeof element == 'string') {
1699
+ field = new Blockly.FieldLabel(element);
1700
+ } else {
1701
+ switch (element['type']) {
1702
+ case 'input_value':
1703
+ input = this.appendValueInput(element['name']);
1704
+ break;
1705
+ case 'input_statement':
1706
+ input = this.appendStatementInput(element['name']);
1707
+ break;
1708
+ case 'input_dummy':
1709
+ input = this.appendDummyInput(element['name']);
1710
+ break;
1711
+ default:
1712
+ // This should handle all field JSON parsing, including
1713
+ // options that can be applied to any field type.
1714
+ field = Blockly.fieldRegistry.fromJson(element);
1715
+
1716
+ // Unknown field.
1717
+ if (!field && element['alt']) {
1718
+ element = element['alt'];
1719
+ altRepeat = true;
1720
+ }
1721
+ }
1722
+ }
1723
+ } while (altRepeat);
1724
+ if (field) {
1725
+ fieldStack.push([field, element['name']]);
1726
+ } else if (input) {
1727
+ if (element['check']) {
1728
+ input.setCheck(element['check']);
1729
+ }
1730
+ if (element['align']) {
1731
+ var alignment = alignmentLookup[element['align'].toUpperCase()];
1732
+ if (alignment === undefined) {
1733
+ console.warn(warningPrefix + 'Illegal align value: ',
1734
+ element['align']);
1735
+ } else {
1736
+ input.setAlign(alignment);
1737
+ }
1738
+ }
1739
+ for (var j = 0; j < fieldStack.length; j++) {
1740
+ input.appendField(fieldStack[j][0], fieldStack[j][1]);
1741
+ }
1742
+ fieldStack.length = 0;
1743
+ }
1744
+ }
1745
+ }
1746
+ };
1747
+
1748
+ /**
1749
+ * Add a value input, statement input or local variable to this block.
1750
+ * @param {number} type Either Blockly.INPUT_VALUE or Blockly.NEXT_STATEMENT or
1751
+ * Blockly.DUMMY_INPUT.
1752
+ * @param {string} name Language-neutral identifier which may used to find this
1753
+ * input again. Should be unique to this block.
1754
+ * @return {!Blockly.Input} The input object created.
1755
+ * @protected
1756
+ */
1757
+ Blockly.Block.prototype.appendInput_ = function(type, name) {
1758
+ var connection = null;
1759
+ if (type == Blockly.INPUT_VALUE || type == Blockly.NEXT_STATEMENT) {
1760
+ connection = this.makeConnection_(type);
1761
+ }
1762
+ if (type == Blockly.NEXT_STATEMENT) {
1763
+ this.statementInputCount++;
1764
+ }
1765
+ var input = new Blockly.Input(type, name, this, connection);
1766
+ // Append input to list.
1767
+ this.inputList.push(input);
1768
+ return input;
1769
+ };
1770
+
1771
+ /**
1772
+ * Move a named input to a different location on this block.
1773
+ * @param {string} name The name of the input to move.
1774
+ * @param {?string} refName Name of input that should be after the moved input,
1775
+ * or null to be the input at the end.
1776
+ */
1777
+ Blockly.Block.prototype.moveInputBefore = function(name, refName) {
1778
+ if (name == refName) {
1779
+ return;
1780
+ }
1781
+ // Find both inputs.
1782
+ var inputIndex = -1;
1783
+ var refIndex = refName ? -1 : this.inputList.length;
1784
+ for (var i = 0, input; (input = this.inputList[i]); i++) {
1785
+ if (input.name == name) {
1786
+ inputIndex = i;
1787
+ if (refIndex != -1) {
1788
+ break;
1789
+ }
1790
+ } else if (refName && input.name == refName) {
1791
+ refIndex = i;
1792
+ if (inputIndex != -1) {
1793
+ break;
1794
+ }
1795
+ }
1796
+ }
1797
+ if (inputIndex == -1) {
1798
+ throw Error('Named input "' + name + '" not found.');
1799
+ }
1800
+ if (refIndex == -1) {
1801
+ throw Error('Reference input "' + refName + '" not found.');
1802
+ }
1803
+ this.moveNumberedInputBefore(inputIndex, refIndex);
1804
+ };
1805
+
1806
+ /**
1807
+ * Move a numbered input to a different location on this block.
1808
+ * @param {number} inputIndex Index of the input to move.
1809
+ * @param {number} refIndex Index of input that should be after the moved input.
1810
+ */
1811
+ Blockly.Block.prototype.moveNumberedInputBefore = function(
1812
+ inputIndex, refIndex) {
1813
+ // Validate arguments.
1814
+ if (inputIndex == refIndex) {
1815
+ throw Error('Can\'t move input to itself.');
1816
+ }
1817
+ if (inputIndex >= this.inputList.length) {
1818
+ throw RangeError('Input index ' + inputIndex + ' out of bounds.');
1819
+ }
1820
+ if (refIndex > this.inputList.length) {
1821
+ throw RangeError('Reference input ' + refIndex + ' out of bounds.');
1822
+ }
1823
+ // Remove input.
1824
+ var input = this.inputList[inputIndex];
1825
+ this.inputList.splice(inputIndex, 1);
1826
+ if (inputIndex < refIndex) {
1827
+ refIndex--;
1828
+ }
1829
+ // Reinsert input.
1830
+ this.inputList.splice(refIndex, 0, input);
1831
+ };
1832
+
1833
+ /**
1834
+ * Remove an input from this block.
1835
+ * @param {string} name The name of the input.
1836
+ * @param {boolean=} opt_quiet True to prevent an error if input is not present.
1837
+ * @return {boolean} True if operation succeeds, false if input is not present and opt_quiet is true
1838
+ * @throws {Error} if the input is not present and opt_quiet is not true.
1839
+ */
1840
+ Blockly.Block.prototype.removeInput = function(name, opt_quiet) {
1841
+ for (var i = 0, input; (input = this.inputList[i]); i++) {
1842
+ if (input.name == name) {
1843
+ if (input.type == Blockly.NEXT_STATEMENT) {
1844
+ this.statementInputCount--;
1845
+ }
1846
+ input.dispose();
1847
+ this.inputList.splice(i, 1);
1848
+ return true;
1849
+ }
1850
+ }
1851
+ if (opt_quiet) {
1852
+ return false;
1853
+ } else {
1854
+ throw Error('Input not found: ' + name);
1855
+ }
1856
+ };
1857
+
1858
+ /**
1859
+ * Fetches the named input object.
1860
+ * @param {string} name The name of the input.
1861
+ * @return {Blockly.Input} The input object, or null if input does not exist.
1862
+ */
1863
+ Blockly.Block.prototype.getInput = function(name) {
1864
+ for (var i = 0, input; (input = this.inputList[i]); i++) {
1865
+ if (input.name == name) {
1866
+ return input;
1867
+ }
1868
+ }
1869
+ // This input does not exist.
1870
+ return null;
1871
+ };
1872
+
1873
+ /**
1874
+ * Fetches the block attached to the named input.
1875
+ * @param {string} name The name of the input.
1876
+ * @return {Blockly.Block} The attached value block, or null if the input is
1877
+ * either disconnected or if the input does not exist.
1878
+ */
1879
+ Blockly.Block.prototype.getInputTargetBlock = function(name) {
1880
+ var input = this.getInput(name);
1881
+ return input && input.connection && input.connection.targetBlock();
1882
+ };
1883
+
1884
+ /**
1885
+ * Returns the comment on this block (or null if there is no comment).
1886
+ * @return {?string} Block's comment.
1887
+ */
1888
+ Blockly.Block.prototype.getCommentText = function() {
1889
+ return this.commentModel.text;
1890
+ };
1891
+
1892
+ /**
1893
+ * Set this block's comment text.
1894
+ * @param {?string} text The text, or null to delete.
1895
+ */
1896
+ Blockly.Block.prototype.setCommentText = function(text) {
1897
+ if (this.commentModel.text == text) {
1898
+ return;
1899
+ }
1900
+ Blockly.Events.fire(new Blockly.Events.BlockChange(
1901
+ this, 'comment', null, this.commentModel.text, text));
1902
+ this.commentModel.text = text;
1903
+ this.comment = text; // For backwards compatibility.
1904
+ };
1905
+
1906
+ /**
1907
+ * Set this block's warning text.
1908
+ * @param {?string} _text The text, or null to delete.
1909
+ * @param {string=} _opt_id An optional ID for the warning text to be able to
1910
+ * maintain multiple warnings.
1911
+ */
1912
+ Blockly.Block.prototype.setWarningText = function(_text, _opt_id) {
1913
+ // NOP.
1914
+ };
1915
+
1916
+ /**
1917
+ * Give this block a mutator dialog.
1918
+ * @param {Blockly.Mutator} _mutator A mutator dialog instance or null to
1919
+ * remove.
1920
+ */
1921
+ Blockly.Block.prototype.setMutator = function(_mutator) {
1922
+ // NOP.
1923
+ };
1924
+
1925
+ /**
1926
+ * Return the coordinates of the top-left corner of this block relative to the
1927
+ * drawing surface's origin (0,0), in workspace units.
1928
+ * @return {!Blockly.utils.Coordinate} Object with .x and .y properties.
1929
+ */
1930
+ Blockly.Block.prototype.getRelativeToSurfaceXY = function() {
1931
+ return this.xy_;
1932
+ };
1933
+
1934
+ /**
1935
+ * Move a block by a relative offset.
1936
+ * @param {number} dx Horizontal offset, in workspace units.
1937
+ * @param {number} dy Vertical offset, in workspace units.
1938
+ */
1939
+ Blockly.Block.prototype.moveBy = function(dx, dy) {
1940
+ if (this.parentBlock_) {
1941
+ throw Error('Block has parent.');
1942
+ }
1943
+ var event = new Blockly.Events.BlockMove(this);
1944
+ this.xy_.translate(dx, dy);
1945
+ event.recordNew();
1946
+ Blockly.Events.fire(event);
1947
+ };
1948
+
1949
+ /**
1950
+ * Create a connection of the specified type.
1951
+ * @param {number} type The type of the connection to create.
1952
+ * @return {!Blockly.Connection} A new connection of the specified type.
1953
+ * @protected
1954
+ */
1955
+ Blockly.Block.prototype.makeConnection_ = function(type) {
1956
+ return new Blockly.Connection(this, type);
1957
+ };
1958
+
1959
+ /**
1960
+ * Recursively checks whether all statement and value inputs are filled with
1961
+ * blocks. Also checks all following statement blocks in this stack.
1962
+ * @param {boolean=} opt_shadowBlocksAreFilled An optional argument controlling
1963
+ * whether shadow blocks are counted as filled. Defaults to true.
1964
+ * @return {boolean} True if all inputs are filled, false otherwise.
1965
+ */
1966
+ Blockly.Block.prototype.allInputsFilled = function(opt_shadowBlocksAreFilled) {
1967
+ // Account for the shadow block filledness toggle.
1968
+ if (opt_shadowBlocksAreFilled === undefined) {
1969
+ opt_shadowBlocksAreFilled = true;
1970
+ }
1971
+ if (!opt_shadowBlocksAreFilled && this.isShadow()) {
1972
+ return false;
1973
+ }
1974
+
1975
+ // Recursively check each input block of the current block.
1976
+ for (var i = 0, input; (input = this.inputList[i]); i++) {
1977
+ if (!input.connection) {
1978
+ continue;
1979
+ }
1980
+ var target = input.connection.targetBlock();
1981
+ if (!target || !target.allInputsFilled(opt_shadowBlocksAreFilled)) {
1982
+ return false;
1983
+ }
1984
+ }
1985
+
1986
+ // Recursively check the next block after the current block.
1987
+ var next = this.getNextBlock();
1988
+ if (next) {
1989
+ return next.allInputsFilled(opt_shadowBlocksAreFilled);
1990
+ }
1991
+
1992
+ return true;
1993
+ };
1994
+
1995
+ /**
1996
+ * This method returns a string describing this Block in developer terms (type
1997
+ * name and ID; English only).
1998
+ *
1999
+ * Intended to on be used in console logs and errors. If you need a string that
2000
+ * uses the user's native language (including block text, field values, and
2001
+ * child blocks), use [toString()]{@link Blockly.Block#toString}.
2002
+ * @return {string} The description.
2003
+ */
2004
+ Blockly.Block.prototype.toDevString = function() {
2005
+ var msg = this.type ? '"' + this.type + '" block' : 'Block';
2006
+ if (this.id) {
2007
+ msg += ' (id="' + this.id + '")';
2008
+ }
2009
+ return msg;
2010
+ };