scratch-blocks 1.1.206 → 2.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1295) hide show
  1. package/.husky/commit-msg +0 -3
  2. package/CHANGELOG.md +111 -833
  3. package/TODO.md +16 -0
  4. package/blockly-rc/.eslintignore +28 -0
  5. package/blockly-rc/.eslintrc.js +187 -0
  6. package/blockly-rc/.gitattributes +1 -0
  7. package/blockly-rc/.github/CODEOWNERS +1 -0
  8. package/blockly-rc/.github/CONTRIBUTING.md +46 -0
  9. package/blockly-rc/.github/ISSUE_TEMPLATE/bug_report.yaml +58 -0
  10. package/blockly-rc/.github/ISSUE_TEMPLATE/config.yml +7 -0
  11. package/blockly-rc/.github/ISSUE_TEMPLATE/documentation.yaml +38 -0
  12. package/blockly-rc/.github/ISSUE_TEMPLATE/feature_request.yaml +39 -0
  13. package/blockly-rc/.github/PULL_REQUEST_TEMPLATE.md +42 -0
  14. package/blockly-rc/.github/dependabot.yml +27 -0
  15. package/blockly-rc/.github/release.yml +32 -0
  16. package/blockly-rc/.github/workflows/appengine_deploy.yml +54 -0
  17. package/blockly-rc/.github/workflows/assign_reviewers.yml +41 -0
  18. package/blockly-rc/.github/workflows/browser_test.yml +55 -0
  19. package/blockly-rc/.github/workflows/build.yml +86 -0
  20. package/blockly-rc/.github/workflows/conventional-label.yml +17 -0
  21. package/blockly-rc/.github/workflows/develop_freeze.yml +26 -0
  22. package/blockly-rc/.github/workflows/tag_module_cleanup.yml +37 -0
  23. package/blockly-rc/.github/workflows/welcome_new_contributors.yml +36 -0
  24. package/blockly-rc/.prettierignore +30 -0
  25. package/blockly-rc/.prettierrc.js +13 -0
  26. package/blockly-rc/CHANGELOG.md +77 -0
  27. package/blockly-rc/LICENSE +202 -0
  28. package/blockly-rc/README.md +80 -0
  29. package/blockly-rc/_config.yml +1 -0
  30. package/blockly-rc/api-extractor.json +385 -0
  31. package/blockly-rc/appengine/.gcloudignore +20 -0
  32. package/blockly-rc/appengine/README.txt +42 -0
  33. package/blockly-rc/appengine/add_timestamps.py +69 -0
  34. package/blockly-rc/appengine/app.yaml +104 -0
  35. package/blockly-rc/appengine/apple-touch-icon.png +0 -0
  36. package/blockly-rc/appengine/blockly_compressed.js +11 -0
  37. package/blockly-rc/appengine/expiration.py +52 -0
  38. package/blockly-rc/appengine/favicon.ico +0 -0
  39. package/blockly-rc/appengine/index.yaml +11 -0
  40. package/blockly-rc/appengine/main.py +39 -0
  41. package/blockly-rc/appengine/redirect.html +107 -0
  42. package/blockly-rc/appengine/requirements.txt +1 -0
  43. package/blockly-rc/appengine/robots.txt +2 -0
  44. package/blockly-rc/appengine/storage.js +190 -0
  45. package/blockly-rc/appengine/storage.py +125 -0
  46. package/blockly-rc/blocks/blocks.ts +44 -0
  47. package/blockly-rc/blocks/lists.ts +1085 -0
  48. package/blockly-rc/blocks/logic.ts +712 -0
  49. package/blockly-rc/blocks/loops.ts +408 -0
  50. package/blockly-rc/blocks/math.ts +591 -0
  51. package/blockly-rc/blocks/procedures.ts +1364 -0
  52. package/blockly-rc/blocks/text.ts +1007 -0
  53. package/blockly-rc/blocks/variables.ts +183 -0
  54. package/blockly-rc/blocks/variables_dynamic.ts +194 -0
  55. package/blockly-rc/core/any_aliases.ts +8 -0
  56. package/blockly-rc/core/block.ts +2523 -0
  57. package/blockly-rc/core/block_animations.ts +225 -0
  58. package/blockly-rc/core/block_flyout_inflater.ts +262 -0
  59. package/blockly-rc/core/block_svg.ts +1768 -0
  60. package/blockly-rc/core/blockly.ts +605 -0
  61. package/blockly-rc/core/blockly_options.ts +71 -0
  62. package/blockly-rc/core/blocks.ts +18 -0
  63. package/blockly-rc/core/browser_events.ts +244 -0
  64. package/blockly-rc/core/bubbles/bubble.ts +658 -0
  65. package/blockly-rc/core/bubbles/mini_workspace_bubble.ts +280 -0
  66. package/blockly-rc/core/bubbles/text_bubble.ts +103 -0
  67. package/blockly-rc/core/bubbles/textinput_bubble.ts +344 -0
  68. package/blockly-rc/core/bubbles.ts +12 -0
  69. package/blockly-rc/core/bump_objects.ts +192 -0
  70. package/blockly-rc/core/button_flyout_inflater.ts +63 -0
  71. package/blockly-rc/core/clipboard/block_paster.ts +142 -0
  72. package/blockly-rc/core/clipboard/registry.ts +31 -0
  73. package/blockly-rc/core/clipboard/workspace_comment_paster.ts +94 -0
  74. package/blockly-rc/core/clipboard.ts +113 -0
  75. package/blockly-rc/core/comments/comment_view.ts +899 -0
  76. package/blockly-rc/core/comments/rendered_workspace_comment.ts +297 -0
  77. package/blockly-rc/core/comments/workspace_comment.ts +237 -0
  78. package/blockly-rc/core/comments.ts +9 -0
  79. package/blockly-rc/core/common.ts +305 -0
  80. package/blockly-rc/core/component_manager.ts +235 -0
  81. package/blockly-rc/core/config.ts +65 -0
  82. package/blockly-rc/core/connection.ts +793 -0
  83. package/blockly-rc/core/connection_checker.ts +348 -0
  84. package/blockly-rc/core/connection_db.ts +297 -0
  85. package/blockly-rc/core/connection_type.ts +21 -0
  86. package/blockly-rc/core/constants.ts +23 -0
  87. package/blockly-rc/core/contextmenu.ts +268 -0
  88. package/blockly-rc/core/contextmenu_items.ts +700 -0
  89. package/blockly-rc/core/contextmenu_registry.ts +194 -0
  90. package/blockly-rc/core/css.ts +481 -0
  91. package/blockly-rc/core/delete_area.ts +77 -0
  92. package/blockly-rc/core/dialog.ts +121 -0
  93. package/blockly-rc/core/drag_target.ts +97 -0
  94. package/blockly-rc/core/dragging/block_drag_strategy.ts +454 -0
  95. package/blockly-rc/core/dragging/bubble_drag_strategy.ts +52 -0
  96. package/blockly-rc/core/dragging/comment_drag_strategy.ts +91 -0
  97. package/blockly-rc/core/dragging/dragger.ts +163 -0
  98. package/blockly-rc/core/dragging.ts +12 -0
  99. package/blockly-rc/core/dropdowndiv.ts +768 -0
  100. package/blockly-rc/core/events/events.ts +163 -0
  101. package/blockly-rc/core/events/events_abstract.ts +130 -0
  102. package/blockly-rc/core/events/events_block_base.ts +88 -0
  103. package/blockly-rc/core/events/events_block_change.ts +259 -0
  104. package/blockly-rc/core/events/events_block_create.ts +185 -0
  105. package/blockly-rc/core/events/events_block_delete.ts +182 -0
  106. package/blockly-rc/core/events/events_block_drag.ts +116 -0
  107. package/blockly-rc/core/events/events_block_field_intermediate_change.ts +167 -0
  108. package/blockly-rc/core/events/events_block_move.ts +307 -0
  109. package/blockly-rc/core/events/events_bubble_open.ts +120 -0
  110. package/blockly-rc/core/events/events_click.ts +110 -0
  111. package/blockly-rc/core/events/events_comment_base.ts +126 -0
  112. package/blockly-rc/core/events/events_comment_change.ts +161 -0
  113. package/blockly-rc/core/events/events_comment_collapse.ts +103 -0
  114. package/blockly-rc/core/events/events_comment_create.ts +118 -0
  115. package/blockly-rc/core/events/events_comment_delete.ts +117 -0
  116. package/blockly-rc/core/events/events_comment_drag.ts +99 -0
  117. package/blockly-rc/core/events/events_comment_move.ts +207 -0
  118. package/blockly-rc/core/events/events_comment_resize.ts +174 -0
  119. package/blockly-rc/core/events/events_marker_move.ts +134 -0
  120. package/blockly-rc/core/events/events_selected.ts +98 -0
  121. package/blockly-rc/core/events/events_theme_change.ts +84 -0
  122. package/blockly-rc/core/events/events_toolbox_item_select.ts +96 -0
  123. package/blockly-rc/core/events/events_trashcan_open.ts +88 -0
  124. package/blockly-rc/core/events/events_ui_base.ts +47 -0
  125. package/blockly-rc/core/events/events_var_base.ts +89 -0
  126. package/blockly-rc/core/events/events_var_create.ts +129 -0
  127. package/blockly-rc/core/events/events_var_delete.ts +124 -0
  128. package/blockly-rc/core/events/events_var_rename.ts +133 -0
  129. package/blockly-rc/core/events/events_var_type_change.ts +122 -0
  130. package/blockly-rc/core/events/events_viewport.ts +149 -0
  131. package/blockly-rc/core/events/utils.ts +595 -0
  132. package/blockly-rc/core/events/workspace_events.ts +46 -0
  133. package/blockly-rc/core/extensions.ts +491 -0
  134. package/blockly-rc/core/field.ts +1471 -0
  135. package/blockly-rc/core/field_checkbox.ts +271 -0
  136. package/blockly-rc/core/field_dropdown.ts +857 -0
  137. package/blockly-rc/core/field_image.ts +297 -0
  138. package/blockly-rc/core/field_input.ts +755 -0
  139. package/blockly-rc/core/field_label.ts +150 -0
  140. package/blockly-rc/core/field_label_serializable.ts +73 -0
  141. package/blockly-rc/core/field_number.ts +381 -0
  142. package/blockly-rc/core/field_registry.ts +115 -0
  143. package/blockly-rc/core/field_textinput.ts +117 -0
  144. package/blockly-rc/core/field_variable.ts +651 -0
  145. package/blockly-rc/core/flyout_base.ts +968 -0
  146. package/blockly-rc/core/flyout_button.ts +416 -0
  147. package/blockly-rc/core/flyout_horizontal.ts +374 -0
  148. package/blockly-rc/core/flyout_metrics_manager.ts +90 -0
  149. package/blockly-rc/core/flyout_separator.ts +61 -0
  150. package/blockly-rc/core/flyout_vertical.ts +353 -0
  151. package/blockly-rc/core/generator.ts +611 -0
  152. package/blockly-rc/core/gesture.ts +1191 -0
  153. package/blockly-rc/core/grid.ts +252 -0
  154. package/blockly-rc/core/icons/comment_icon.ts +435 -0
  155. package/blockly-rc/core/icons/exceptions.ts +23 -0
  156. package/blockly-rc/core/icons/icon.ts +147 -0
  157. package/blockly-rc/core/icons/icon_types.ts +32 -0
  158. package/blockly-rc/core/icons/mutator_icon.ts +354 -0
  159. package/blockly-rc/core/icons/registry.ts +33 -0
  160. package/blockly-rc/core/icons/warning_icon.ts +219 -0
  161. package/blockly-rc/core/icons.ts +24 -0
  162. package/blockly-rc/core/inject.ts +428 -0
  163. package/blockly-rc/core/inputs/align.ts +14 -0
  164. package/blockly-rc/core/inputs/dummy_input.ts +26 -0
  165. package/blockly-rc/core/inputs/end_row_input.ts +31 -0
  166. package/blockly-rc/core/inputs/input.ts +318 -0
  167. package/blockly-rc/core/inputs/input_types.ts +27 -0
  168. package/blockly-rc/core/inputs/statement_input.ts +34 -0
  169. package/blockly-rc/core/inputs/value_input.ts +30 -0
  170. package/blockly-rc/core/inputs.ts +23 -0
  171. package/blockly-rc/core/insertion_marker_manager.ts +742 -0
  172. package/blockly-rc/core/insertion_marker_previewer.ts +254 -0
  173. package/blockly-rc/core/interfaces/i_ast_node_location.ts +12 -0
  174. package/blockly-rc/core/interfaces/i_ast_node_location_svg.ts +28 -0
  175. package/blockly-rc/core/interfaces/i_ast_node_location_with_block.ts +22 -0
  176. package/blockly-rc/core/interfaces/i_autohideable.ts +22 -0
  177. package/blockly-rc/core/interfaces/i_bounded_element.ts +30 -0
  178. package/blockly-rc/core/interfaces/i_bubble.ts +63 -0
  179. package/blockly-rc/core/interfaces/i_collapsible_toolbox_item.ts +33 -0
  180. package/blockly-rc/core/interfaces/i_comment_icon.ts +47 -0
  181. package/blockly-rc/core/interfaces/i_component.ts +19 -0
  182. package/blockly-rc/core/interfaces/i_connection_checker.ts +100 -0
  183. package/blockly-rc/core/interfaces/i_connection_previewer.ts +50 -0
  184. package/blockly-rc/core/interfaces/i_contextmenu.ts +16 -0
  185. package/blockly-rc/core/interfaces/i_copyable.ts +31 -0
  186. package/blockly-rc/core/interfaces/i_deletable.ts +34 -0
  187. package/blockly-rc/core/interfaces/i_delete_area.ts +28 -0
  188. package/blockly-rc/core/interfaces/i_drag_target.ts +69 -0
  189. package/blockly-rc/core/interfaces/i_draggable.ts +72 -0
  190. package/blockly-rc/core/interfaces/i_dragger.ts +35 -0
  191. package/blockly-rc/core/interfaces/i_flyout.ts +189 -0
  192. package/blockly-rc/core/interfaces/i_flyout_inflater.ts +41 -0
  193. package/blockly-rc/core/interfaces/i_has_bubble.ts +20 -0
  194. package/blockly-rc/core/interfaces/i_icon.ts +114 -0
  195. package/blockly-rc/core/interfaces/i_keyboard_accessible.ts +21 -0
  196. package/blockly-rc/core/interfaces/i_legacy_procedure_blocks.ts +50 -0
  197. package/blockly-rc/core/interfaces/i_metrics_manager.ts +149 -0
  198. package/blockly-rc/core/interfaces/i_movable.ts +19 -0
  199. package/blockly-rc/core/interfaces/i_observable.ts +24 -0
  200. package/blockly-rc/core/interfaces/i_parameter_model.ts +51 -0
  201. package/blockly-rc/core/interfaces/i_paster.ts +25 -0
  202. package/blockly-rc/core/interfaces/i_positionable.ts +33 -0
  203. package/blockly-rc/core/interfaces/i_procedure_block.ts +27 -0
  204. package/blockly-rc/core/interfaces/i_procedure_map.ts +18 -0
  205. package/blockly-rc/core/interfaces/i_procedure_model.ts +71 -0
  206. package/blockly-rc/core/interfaces/i_registrable.ts +12 -0
  207. package/blockly-rc/core/interfaces/i_rendered_element.ts +22 -0
  208. package/blockly-rc/core/interfaces/i_selectable.ts +34 -0
  209. package/blockly-rc/core/interfaces/i_selectable_toolbox_item.ts +63 -0
  210. package/blockly-rc/core/interfaces/i_serializable.ts +28 -0
  211. package/blockly-rc/core/interfaces/i_serializer.ts +55 -0
  212. package/blockly-rc/core/interfaces/i_styleable.ts +26 -0
  213. package/blockly-rc/core/interfaces/i_toolbox.ts +112 -0
  214. package/blockly-rc/core/interfaces/i_toolbox_item.ts +81 -0
  215. package/blockly-rc/core/interfaces/i_variable_backed_parameter_model.ts +23 -0
  216. package/blockly-rc/core/interfaces/i_variable_map.ts +65 -0
  217. package/blockly-rc/core/interfaces/i_variable_model.ts +57 -0
  218. package/blockly-rc/core/internal_constants.ts +47 -0
  219. package/blockly-rc/core/keyboard_nav/ast_node.ts +884 -0
  220. package/blockly-rc/core/keyboard_nav/basic_cursor.ts +223 -0
  221. package/blockly-rc/core/keyboard_nav/cursor.ts +138 -0
  222. package/blockly-rc/core/keyboard_nav/marker.ts +113 -0
  223. package/blockly-rc/core/keyboard_nav/tab_navigate_cursor.ts +46 -0
  224. package/blockly-rc/core/label_flyout_inflater.ts +59 -0
  225. package/blockly-rc/core/layer_manager.ts +186 -0
  226. package/blockly-rc/core/layers.ts +17 -0
  227. package/blockly-rc/core/main.ts +31 -0
  228. package/blockly-rc/core/marker_manager.ts +189 -0
  229. package/blockly-rc/core/menu.ts +463 -0
  230. package/blockly-rc/core/menuitem.ts +221 -0
  231. package/blockly-rc/core/metrics_manager.ts +486 -0
  232. package/blockly-rc/core/msg.ts +27 -0
  233. package/blockly-rc/core/names.ts +275 -0
  234. package/blockly-rc/core/observable_procedure_map.ts +66 -0
  235. package/blockly-rc/core/options.ts +377 -0
  236. package/blockly-rc/core/positionable_helpers.ts +186 -0
  237. package/blockly-rc/core/procedures.ts +510 -0
  238. package/blockly-rc/core/registry.ts +400 -0
  239. package/blockly-rc/core/render_management.ts +193 -0
  240. package/blockly-rc/core/rendered_connection.ts +571 -0
  241. package/blockly-rc/core/renderers/common/block_rendering.ts +120 -0
  242. package/blockly-rc/core/renderers/common/constants.ts +1198 -0
  243. package/blockly-rc/core/renderers/common/drawer.ts +518 -0
  244. package/blockly-rc/core/renderers/common/i_path_object.ts +137 -0
  245. package/blockly-rc/core/renderers/common/info.ts +767 -0
  246. package/blockly-rc/core/renderers/common/marker_svg.ts +765 -0
  247. package/blockly-rc/core/renderers/common/path_object.ts +324 -0
  248. package/blockly-rc/core/renderers/common/renderer.ts +281 -0
  249. package/blockly-rc/core/renderers/geras/constants.ts +46 -0
  250. package/blockly-rc/core/renderers/geras/drawer.ts +167 -0
  251. package/blockly-rc/core/renderers/geras/geras.ts +31 -0
  252. package/blockly-rc/core/renderers/geras/highlight_constants.ts +342 -0
  253. package/blockly-rc/core/renderers/geras/highlighter.ts +313 -0
  254. package/blockly-rc/core/renderers/geras/info.ts +478 -0
  255. package/blockly-rc/core/renderers/geras/measurables/inline_input.ts +37 -0
  256. package/blockly-rc/core/renderers/geras/measurables/statement_input.ts +36 -0
  257. package/blockly-rc/core/renderers/geras/path_object.ts +135 -0
  258. package/blockly-rc/core/renderers/geras/renderer.ts +124 -0
  259. package/blockly-rc/core/renderers/measurables/base.ts +41 -0
  260. package/blockly-rc/core/renderers/measurables/bottom_row.ts +104 -0
  261. package/blockly-rc/core/renderers/measurables/connection.ts +43 -0
  262. package/blockly-rc/core/renderers/measurables/external_value_input.ts +53 -0
  263. package/blockly-rc/core/renderers/measurables/field.ts +50 -0
  264. package/blockly-rc/core/renderers/measurables/hat.ts +33 -0
  265. package/blockly-rc/core/renderers/measurables/icon.ts +42 -0
  266. package/blockly-rc/core/renderers/measurables/in_row_spacer.ts +29 -0
  267. package/blockly-rc/core/renderers/measurables/inline_input.ts +63 -0
  268. package/blockly-rc/core/renderers/measurables/input_connection.ts +57 -0
  269. package/blockly-rc/core/renderers/measurables/input_row.ts +67 -0
  270. package/blockly-rc/core/renderers/measurables/jagged_edge.ts +28 -0
  271. package/blockly-rc/core/renderers/measurables/next_connection.ts +34 -0
  272. package/blockly-rc/core/renderers/measurables/output_connection.ts +43 -0
  273. package/blockly-rc/core/renderers/measurables/previous_connection.ts +34 -0
  274. package/blockly-rc/core/renderers/measurables/round_corner.ts +34 -0
  275. package/blockly-rc/core/renderers/measurables/row.ts +191 -0
  276. package/blockly-rc/core/renderers/measurables/spacer_row.ts +44 -0
  277. package/blockly-rc/core/renderers/measurables/square_corner.ts +32 -0
  278. package/blockly-rc/core/renderers/measurables/statement_input.ts +41 -0
  279. package/blockly-rc/core/renderers/measurables/top_row.ts +110 -0
  280. package/blockly-rc/core/renderers/measurables/types.ts +319 -0
  281. package/blockly-rc/core/renderers/thrasos/info.ts +328 -0
  282. package/blockly-rc/core/renderers/thrasos/renderer.ts +40 -0
  283. package/blockly-rc/core/renderers/thrasos/thrasos.ts +14 -0
  284. package/blockly-rc/core/renderers/zelos/constants.ts +877 -0
  285. package/blockly-rc/core/renderers/zelos/drawer.ts +274 -0
  286. package/blockly-rc/core/renderers/zelos/info.ts +652 -0
  287. package/blockly-rc/core/renderers/zelos/marker_svg.ts +145 -0
  288. package/blockly-rc/core/renderers/zelos/measurables/bottom_row.ts +44 -0
  289. package/blockly-rc/core/renderers/zelos/measurables/inputs.ts +41 -0
  290. package/blockly-rc/core/renderers/zelos/measurables/row_elements.ts +29 -0
  291. package/blockly-rc/core/renderers/zelos/measurables/top_row.ts +50 -0
  292. package/blockly-rc/core/renderers/zelos/path_object.ts +209 -0
  293. package/blockly-rc/core/renderers/zelos/renderer.ts +143 -0
  294. package/blockly-rc/core/renderers/zelos/zelos.ts +33 -0
  295. package/blockly-rc/core/scrollbar.ts +898 -0
  296. package/blockly-rc/core/scrollbar_pair.ts +349 -0
  297. package/blockly-rc/core/separator_flyout_inflater.ts +69 -0
  298. package/blockly-rc/core/serialization/blocks.ts +868 -0
  299. package/blockly-rc/core/serialization/exceptions.ts +112 -0
  300. package/blockly-rc/core/serialization/priorities.ts +25 -0
  301. package/blockly-rc/core/serialization/procedures.ts +158 -0
  302. package/blockly-rc/core/serialization/registry.ts +30 -0
  303. package/blockly-rc/core/serialization/variables.ts +68 -0
  304. package/blockly-rc/core/serialization/workspace_comments.ts +143 -0
  305. package/blockly-rc/core/serialization/workspaces.ts +94 -0
  306. package/blockly-rc/core/serialization.ts +32 -0
  307. package/blockly-rc/core/shortcut_items.ts +338 -0
  308. package/blockly-rc/core/shortcut_registry.ts +368 -0
  309. package/blockly-rc/core/sprites.ts +15 -0
  310. package/blockly-rc/core/theme/classic.ts +40 -0
  311. package/blockly-rc/core/theme/themes.ts +12 -0
  312. package/blockly-rc/core/theme/zelos.ts +80 -0
  313. package/blockly-rc/core/theme.ts +232 -0
  314. package/blockly-rc/core/theme_manager.ts +192 -0
  315. package/blockly-rc/core/toolbox/category.ts +739 -0
  316. package/blockly-rc/core/toolbox/collapsible_category.ts +288 -0
  317. package/blockly-rc/core/toolbox/separator.ts +105 -0
  318. package/blockly-rc/core/toolbox/toolbox.ts +1134 -0
  319. package/blockly-rc/core/toolbox/toolbox_item.ts +152 -0
  320. package/blockly-rc/core/tooltip.ts +466 -0
  321. package/blockly-rc/core/touch.ts +155 -0
  322. package/blockly-rc/core/trashcan.ts +748 -0
  323. package/blockly-rc/core/utils/aria.ts +144 -0
  324. package/blockly-rc/core/utils/array.ts +24 -0
  325. package/blockly-rc/core/utils/colour.ts +265 -0
  326. package/blockly-rc/core/utils/coordinate.ts +129 -0
  327. package/blockly-rc/core/utils/deprecation.ts +47 -0
  328. package/blockly-rc/core/utils/dom.ts +356 -0
  329. package/blockly-rc/core/utils/idgenerator.ts +70 -0
  330. package/blockly-rc/core/utils/keycodes.ts +154 -0
  331. package/blockly-rc/core/utils/math.ts +50 -0
  332. package/blockly-rc/core/utils/metrics.ts +86 -0
  333. package/blockly-rc/core/utils/object.ts +28 -0
  334. package/blockly-rc/core/utils/parsing.ts +287 -0
  335. package/blockly-rc/core/utils/rect.ts +69 -0
  336. package/blockly-rc/core/utils/size.ts +62 -0
  337. package/blockly-rc/core/utils/string.ts +289 -0
  338. package/blockly-rc/core/utils/style.ts +219 -0
  339. package/blockly-rc/core/utils/svg.ts +84 -0
  340. package/blockly-rc/core/utils/svg_math.ts +208 -0
  341. package/blockly-rc/core/utils/svg_paths.ts +133 -0
  342. package/blockly-rc/core/utils/toolbox.ts +419 -0
  343. package/blockly-rc/core/utils/useragent.ts +86 -0
  344. package/blockly-rc/core/utils/xml.ts +165 -0
  345. package/blockly-rc/core/utils.ts +59 -0
  346. package/blockly-rc/core/variable_map.ts +437 -0
  347. package/blockly-rc/core/variable_model.ts +149 -0
  348. package/blockly-rc/core/variables.ts +773 -0
  349. package/blockly-rc/core/variables_dynamic.ts +142 -0
  350. package/blockly-rc/core/widgetdiv.ts +319 -0
  351. package/blockly-rc/core/workspace.ts +957 -0
  352. package/blockly-rc/core/workspace_audio.ts +171 -0
  353. package/blockly-rc/core/workspace_dragger.ts +97 -0
  354. package/blockly-rc/core/workspace_svg.ts +2519 -0
  355. package/blockly-rc/core/xml.ts +1133 -0
  356. package/blockly-rc/core/zoom_controls.ts +492 -0
  357. package/blockly-rc/demos/blockfactory/analytics.js +195 -0
  358. package/blockly-rc/demos/blockfactory/app_controller.js +726 -0
  359. package/blockly-rc/demos/blockfactory/block_definition_extractor.js +742 -0
  360. package/blockly-rc/demos/blockfactory/block_exporter_controller.js +311 -0
  361. package/blockly-rc/demos/blockfactory/block_exporter_tools.js +212 -0
  362. package/blockly-rc/demos/blockfactory/block_exporter_view.js +101 -0
  363. package/blockly-rc/demos/blockfactory/block_library_controller.js +325 -0
  364. package/blockly-rc/demos/blockfactory/block_library_storage.js +149 -0
  365. package/blockly-rc/demos/blockfactory/block_library_view.js +178 -0
  366. package/blockly-rc/demos/blockfactory/block_option.js +151 -0
  367. package/blockly-rc/demos/blockfactory/blocks.js +916 -0
  368. package/blockly-rc/demos/blockfactory/cp.css +46 -0
  369. package/blockly-rc/demos/blockfactory/cp.js +179 -0
  370. package/blockly-rc/demos/blockfactory/factory.css +586 -0
  371. package/blockly-rc/demos/blockfactory/factory.js +337 -0
  372. package/blockly-rc/demos/blockfactory/factory_utils.js +1036 -0
  373. package/blockly-rc/demos/blockfactory/icon.png +0 -0
  374. package/blockly-rc/demos/blockfactory/index.html +767 -0
  375. package/blockly-rc/demos/blockfactory/link.png +0 -0
  376. package/blockly-rc/demos/blockfactory/standard_categories.js +384 -0
  377. package/blockly-rc/demos/blockfactory/workspacefactory/wfactory_controller.js +1332 -0
  378. package/blockly-rc/demos/blockfactory/workspacefactory/wfactory_generator.js +224 -0
  379. package/blockly-rc/demos/blockfactory/workspacefactory/wfactory_init.js +541 -0
  380. package/blockly-rc/demos/blockfactory/workspacefactory/wfactory_model.js +548 -0
  381. package/blockly-rc/demos/blockfactory/workspacefactory/wfactory_view.js +424 -0
  382. package/blockly-rc/demos/code/code.js +626 -0
  383. package/blockly-rc/demos/code/icon.png +0 -0
  384. package/blockly-rc/demos/code/icons.png +0 -0
  385. package/blockly-rc/demos/code/index.html +359 -0
  386. package/blockly-rc/demos/code/msg/ar.js +24 -0
  387. package/blockly-rc/demos/code/msg/be-tarask.js +24 -0
  388. package/blockly-rc/demos/code/msg/br.js +24 -0
  389. package/blockly-rc/demos/code/msg/ca.js +24 -0
  390. package/blockly-rc/demos/code/msg/cs.js +24 -0
  391. package/blockly-rc/demos/code/msg/da.js +24 -0
  392. package/blockly-rc/demos/code/msg/de.js +24 -0
  393. package/blockly-rc/demos/code/msg/el.js +24 -0
  394. package/blockly-rc/demos/code/msg/en.js +24 -0
  395. package/blockly-rc/demos/code/msg/es.js +24 -0
  396. package/blockly-rc/demos/code/msg/et.js +24 -0
  397. package/blockly-rc/demos/code/msg/fa.js +24 -0
  398. package/blockly-rc/demos/code/msg/fr.js +24 -0
  399. package/blockly-rc/demos/code/msg/he.js +24 -0
  400. package/blockly-rc/demos/code/msg/hr.js +24 -0
  401. package/blockly-rc/demos/code/msg/hrx.js +24 -0
  402. package/blockly-rc/demos/code/msg/hu.js +24 -0
  403. package/blockly-rc/demos/code/msg/ia.js +24 -0
  404. package/blockly-rc/demos/code/msg/is.js +24 -0
  405. package/blockly-rc/demos/code/msg/it.js +24 -0
  406. package/blockly-rc/demos/code/msg/ja.js +24 -0
  407. package/blockly-rc/demos/code/msg/kab.js +24 -0
  408. package/blockly-rc/demos/code/msg/ko.js +24 -0
  409. package/blockly-rc/demos/code/msg/mk.js +24 -0
  410. package/blockly-rc/demos/code/msg/ms.js +24 -0
  411. package/blockly-rc/demos/code/msg/nb.js +24 -0
  412. package/blockly-rc/demos/code/msg/nl.js +24 -0
  413. package/blockly-rc/demos/code/msg/oc.js +24 -0
  414. package/blockly-rc/demos/code/msg/pl.js +24 -0
  415. package/blockly-rc/demos/code/msg/pms.js +24 -0
  416. package/blockly-rc/demos/code/msg/pt-br.js +24 -0
  417. package/blockly-rc/demos/code/msg/ro.js +24 -0
  418. package/blockly-rc/demos/code/msg/ru.js +24 -0
  419. package/blockly-rc/demos/code/msg/sc.js +24 -0
  420. package/blockly-rc/demos/code/msg/sk.js +24 -0
  421. package/blockly-rc/demos/code/msg/sr.js +24 -0
  422. package/blockly-rc/demos/code/msg/sv.js +24 -0
  423. package/blockly-rc/demos/code/msg/ta.js +24 -0
  424. package/blockly-rc/demos/code/msg/th.js +24 -0
  425. package/blockly-rc/demos/code/msg/tlh.js +24 -0
  426. package/blockly-rc/demos/code/msg/tr.js +24 -0
  427. package/blockly-rc/demos/code/msg/uk.js +24 -0
  428. package/blockly-rc/demos/code/msg/vi.js +24 -0
  429. package/blockly-rc/demos/code/msg/zh-hans.js +24 -0
  430. package/blockly-rc/demos/code/msg/zh-hant.js +24 -0
  431. package/blockly-rc/demos/code/style.css +184 -0
  432. package/blockly-rc/demos/index.html +68 -0
  433. package/blockly-rc/demos/minimap/icon.png +0 -0
  434. package/blockly-rc/demos/minimap/index.html +91 -0
  435. package/blockly-rc/demos/minimap/minimap.js +302 -0
  436. package/blockly-rc/demos/mobile/README.md +53 -0
  437. package/blockly-rc/demos/mobile/android/README.md +45 -0
  438. package/blockly-rc/demos/mobile/android/app/build.gradle +64 -0
  439. package/blockly-rc/demos/mobile/android/app/proguard-rules.pro +21 -0
  440. package/blockly-rc/demos/mobile/android/app/src/androidTest/java/com/example/blocklywebview/ExampleInstrumentedTest.java +26 -0
  441. package/blockly-rc/demos/mobile/android/app/src/main/AndroidManifest.xml +21 -0
  442. package/blockly-rc/demos/mobile/android/app/src/main/java/com/google/blockly/android/webview/BlocklyWebViewFragment.java +40 -0
  443. package/blockly-rc/demos/mobile/android/app/src/main/java/com/google/blockly/android/webview/JsDialogHelper.java +150 -0
  444. package/blockly-rc/demos/mobile/android/app/src/main/java/com/google/blockly/android/webview/WebChromeClient.java +32 -0
  445. package/blockly-rc/demos/mobile/android/app/src/main/java/com/google/blockly/android/webview/demo/MainActivity.java +18 -0
  446. package/blockly-rc/demos/mobile/android/app/src/main/res/drawable/ic_launcher_background.xml +74 -0
  447. package/blockly-rc/demos/mobile/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml +34 -0
  448. package/blockly-rc/demos/mobile/android/app/src/main/res/layout/activity_main.xml +17 -0
  449. package/blockly-rc/demos/mobile/android/app/src/main/res/layout/js_prompt.xml +37 -0
  450. package/blockly-rc/demos/mobile/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +5 -0
  451. package/blockly-rc/demos/mobile/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +5 -0
  452. package/blockly-rc/demos/mobile/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  453. package/blockly-rc/demos/mobile/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
  454. package/blockly-rc/demos/mobile/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  455. package/blockly-rc/demos/mobile/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
  456. package/blockly-rc/demos/mobile/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  457. package/blockly-rc/demos/mobile/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
  458. package/blockly-rc/demos/mobile/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  459. package/blockly-rc/demos/mobile/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  460. package/blockly-rc/demos/mobile/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  461. package/blockly-rc/demos/mobile/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
  462. package/blockly-rc/demos/mobile/android/app/src/main/res/values/colors.xml +6 -0
  463. package/blockly-rc/demos/mobile/android/app/src/main/res/values/js_dialog_helper.xml +7 -0
  464. package/blockly-rc/demos/mobile/android/app/src/main/res/values/strings.xml +3 -0
  465. package/blockly-rc/demos/mobile/android/app/src/main/res/values/styles.xml +11 -0
  466. package/blockly-rc/demos/mobile/android/app/src/test/java/com/example/blocklywebview/ExampleUnitTest.java +17 -0
  467. package/blockly-rc/demos/mobile/android/build.gradle +27 -0
  468. package/blockly-rc/demos/mobile/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  469. package/blockly-rc/demos/mobile/android/gradle/wrapper/gradle-wrapper.properties +6 -0
  470. package/blockly-rc/demos/mobile/android/gradle.properties +13 -0
  471. package/blockly-rc/demos/mobile/android/gradlew +172 -0
  472. package/blockly-rc/demos/mobile/android/gradlew.bat +84 -0
  473. package/blockly-rc/demos/mobile/android/settings.gradle +1 -0
  474. package/blockly-rc/demos/mobile/html/index.html +31 -0
  475. package/blockly-rc/demos/mobile/html/ln_resources.sh +22 -0
  476. package/blockly-rc/demos/mobile/html/toolbox_standard.js +333 -0
  477. package/blockly-rc/demos/mobile/ios/Blockly WebView/AppDelegate.swift +46 -0
  478. package/blockly-rc/demos/mobile/ios/Blockly WebView/Assets.xcassets/AppIcon.appiconset/Contents.json +98 -0
  479. package/blockly-rc/demos/mobile/ios/Blockly WebView/Assets.xcassets/Contents.json +6 -0
  480. package/blockly-rc/demos/mobile/ios/Blockly WebView/Base.lproj/LaunchScreen.storyboard +25 -0
  481. package/blockly-rc/demos/mobile/ios/Blockly WebView/Base.lproj/Main.storyboard +44 -0
  482. package/blockly-rc/demos/mobile/ios/Blockly WebView/Info.plist +45 -0
  483. package/blockly-rc/demos/mobile/ios/Blockly WebView/ViewController.swift +110 -0
  484. package/blockly-rc/demos/mobile/ios/Blockly WebView.xcodeproj/project.pbxproj +390 -0
  485. package/blockly-rc/demos/mobile/ios/Blockly WebView.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  486. package/blockly-rc/demos/mobile/ios/Blockly WebView.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  487. package/blockly-rc/demos/mobile/ios/cp_resources.sh +21 -0
  488. package/blockly-rc/demos/storage/icon.png +0 -0
  489. package/blockly-rc/demos/storage/index.html +104 -0
  490. package/blockly-rc/generators/dart/dart_generator.ts +321 -0
  491. package/blockly-rc/generators/dart/lists.ts +525 -0
  492. package/blockly-rc/generators/dart/logic.ts +155 -0
  493. package/blockly-rc/generators/dart/loops.ts +217 -0
  494. package/blockly-rc/generators/dart/math.ts +559 -0
  495. package/blockly-rc/generators/dart/procedures.ts +138 -0
  496. package/blockly-rc/generators/dart/text.ts +405 -0
  497. package/blockly-rc/generators/dart/variables.ts +32 -0
  498. package/blockly-rc/generators/dart/variables_dynamic.ts +17 -0
  499. package/blockly-rc/generators/dart.ts +50 -0
  500. package/blockly-rc/generators/javascript/javascript_generator.ts +346 -0
  501. package/blockly-rc/generators/javascript/lists.ts +465 -0
  502. package/blockly-rc/generators/javascript/logic.ts +153 -0
  503. package/blockly-rc/generators/javascript/loops.ts +245 -0
  504. package/blockly-rc/generators/javascript/math.ts +450 -0
  505. package/blockly-rc/generators/javascript/procedures.ts +142 -0
  506. package/blockly-rc/generators/javascript/text.ts +418 -0
  507. package/blockly-rc/generators/javascript/variables.ts +32 -0
  508. package/blockly-rc/generators/javascript/variables_dynamic.ts +17 -0
  509. package/blockly-rc/generators/javascript.ts +46 -0
  510. package/blockly-rc/generators/lua/lists.ts +445 -0
  511. package/blockly-rc/generators/lua/logic.ts +142 -0
  512. package/blockly-rc/generators/lua/loops.ts +192 -0
  513. package/blockly-rc/generators/lua/lua_generator.ts +225 -0
  514. package/blockly-rc/generators/lua/math.ts +473 -0
  515. package/blockly-rc/generators/lua/procedures.ts +144 -0
  516. package/blockly-rc/generators/lua/text.ts +380 -0
  517. package/blockly-rc/generators/lua/variables.ts +31 -0
  518. package/blockly-rc/generators/lua/variables_dynamic.ts +17 -0
  519. package/blockly-rc/generators/lua.ts +44 -0
  520. package/blockly-rc/generators/php/lists.ts +585 -0
  521. package/blockly-rc/generators/php/logic.ts +155 -0
  522. package/blockly-rc/generators/php/loops.ts +218 -0
  523. package/blockly-rc/generators/php/math.ts +408 -0
  524. package/blockly-rc/generators/php/php_generator.ts +320 -0
  525. package/blockly-rc/generators/php/procedures.ts +159 -0
  526. package/blockly-rc/generators/php/text.ts +315 -0
  527. package/blockly-rc/generators/php/variables.ts +32 -0
  528. package/blockly-rc/generators/php/variables_dynamic.ts +17 -0
  529. package/blockly-rc/generators/php.ts +46 -0
  530. package/blockly-rc/generators/python/lists.ts +398 -0
  531. package/blockly-rc/generators/python/logic.ts +148 -0
  532. package/blockly-rc/generators/python/loops.ts +251 -0
  533. package/blockly-rc/generators/python/math.ts +434 -0
  534. package/blockly-rc/generators/python/procedures.ts +159 -0
  535. package/blockly-rc/generators/python/python_generator.ts +355 -0
  536. package/blockly-rc/generators/python/text.ts +338 -0
  537. package/blockly-rc/generators/python/variables.ts +31 -0
  538. package/blockly-rc/generators/python/variables_dynamic.ts +17 -0
  539. package/blockly-rc/generators/python.ts +51 -0
  540. package/blockly-rc/gulpfile.js +54 -0
  541. package/blockly-rc/jsconfig.json +7 -0
  542. package/blockly-rc/media/1x1.gif +0 -0
  543. package/blockly-rc/media/click.mp3 +0 -0
  544. package/blockly-rc/media/click.ogg +0 -0
  545. package/blockly-rc/media/click.wav +0 -0
  546. package/blockly-rc/media/delete-icon.svg +1 -0
  547. package/blockly-rc/media/delete.mp3 +0 -0
  548. package/blockly-rc/media/delete.ogg +0 -0
  549. package/blockly-rc/media/delete.wav +0 -0
  550. package/blockly-rc/media/disconnect.mp3 +0 -0
  551. package/blockly-rc/media/disconnect.ogg +0 -0
  552. package/blockly-rc/media/disconnect.wav +0 -0
  553. package/blockly-rc/media/dropdown-arrow.svg +1 -0
  554. package/blockly-rc/media/foldout-icon.svg +1 -0
  555. package/blockly-rc/media/handclosed.cur +0 -0
  556. package/blockly-rc/media/handdelete.cur +0 -0
  557. package/blockly-rc/media/handopen.cur +0 -0
  558. package/blockly-rc/media/pilcrow.png +0 -0
  559. package/blockly-rc/media/quote0.png +0 -0
  560. package/blockly-rc/media/quote1.png +0 -0
  561. package/blockly-rc/media/resize-handle.svg +3 -0
  562. package/blockly-rc/media/sprites.png +0 -0
  563. package/blockly-rc/media/sprites.svg +74 -0
  564. package/blockly-rc/msg/json/README.md +33 -0
  565. package/blockly-rc/msg/json/ab.json +222 -0
  566. package/blockly-rc/msg/json/ace.json +7 -0
  567. package/blockly-rc/msg/json/af.json +34 -0
  568. package/blockly-rc/msg/json/am.json +30 -0
  569. package/blockly-rc/msg/json/ar.json +355 -0
  570. package/blockly-rc/msg/json/ast.json +10 -0
  571. package/blockly-rc/msg/json/az.json +332 -0
  572. package/blockly-rc/msg/json/ba.json +211 -0
  573. package/blockly-rc/msg/json/bcc.json +290 -0
  574. package/blockly-rc/msg/json/be-tarask.json +334 -0
  575. package/blockly-rc/msg/json/be.json +324 -0
  576. package/blockly-rc/msg/json/bg.json +345 -0
  577. package/blockly-rc/msg/json/bn.json +189 -0
  578. package/blockly-rc/msg/json/br.json +334 -0
  579. package/blockly-rc/msg/json/bs.json +166 -0
  580. package/blockly-rc/msg/json/ca.json +341 -0
  581. package/blockly-rc/msg/json/cdo.json +6 -0
  582. package/blockly-rc/msg/json/ce.json +326 -0
  583. package/blockly-rc/msg/json/constants.json +12 -0
  584. package/blockly-rc/msg/json/cs.json +343 -0
  585. package/blockly-rc/msg/json/da.json +346 -0
  586. package/blockly-rc/msg/json/de.json +369 -0
  587. package/blockly-rc/msg/json/diq.json +258 -0
  588. package/blockly-rc/msg/json/dtp.json +198 -0
  589. package/blockly-rc/msg/json/dty.json +97 -0
  590. package/blockly-rc/msg/json/ee.json +160 -0
  591. package/blockly-rc/msg/json/el.json +356 -0
  592. package/blockly-rc/msg/json/en-gb.json +199 -0
  593. package/blockly-rc/msg/json/en.json +400 -0
  594. package/blockly-rc/msg/json/eo.json +337 -0
  595. package/blockly-rc/msg/json/es.json +358 -0
  596. package/blockly-rc/msg/json/et.json +326 -0
  597. package/blockly-rc/msg/json/eu.json +219 -0
  598. package/blockly-rc/msg/json/fa.json +341 -0
  599. package/blockly-rc/msg/json/fi.json +350 -0
  600. package/blockly-rc/msg/json/fo.json +46 -0
  601. package/blockly-rc/msg/json/fr.json +373 -0
  602. package/blockly-rc/msg/json/frr.json +6 -0
  603. package/blockly-rc/msg/json/gl.json +338 -0
  604. package/blockly-rc/msg/json/gn.json +54 -0
  605. package/blockly-rc/msg/json/gor.json +87 -0
  606. package/blockly-rc/msg/json/ha.json +313 -0
  607. package/blockly-rc/msg/json/hak.json +17 -0
  608. package/blockly-rc/msg/json/he.json +354 -0
  609. package/blockly-rc/msg/json/hi.json +318 -0
  610. package/blockly-rc/msg/json/hr.json +327 -0
  611. package/blockly-rc/msg/json/hrx.json +287 -0
  612. package/blockly-rc/msg/json/hsb.json +128 -0
  613. package/blockly-rc/msg/json/hu.json +349 -0
  614. package/blockly-rc/msg/json/hy.json +337 -0
  615. package/blockly-rc/msg/json/ia.json +337 -0
  616. package/blockly-rc/msg/json/id.json +335 -0
  617. package/blockly-rc/msg/json/ig.json +323 -0
  618. package/blockly-rc/msg/json/inh.json +80 -0
  619. package/blockly-rc/msg/json/is.json +331 -0
  620. package/blockly-rc/msg/json/it.json +346 -0
  621. package/blockly-rc/msg/json/ja.json +361 -0
  622. package/blockly-rc/msg/json/ka.json +14 -0
  623. package/blockly-rc/msg/json/kab.json +323 -0
  624. package/blockly-rc/msg/json/kbd-cyrl.json +84 -0
  625. package/blockly-rc/msg/json/km.json +29 -0
  626. package/blockly-rc/msg/json/kn.json +332 -0
  627. package/blockly-rc/msg/json/ko.json +372 -0
  628. package/blockly-rc/msg/json/ksh.json +43 -0
  629. package/blockly-rc/msg/json/ku-latn.json +41 -0
  630. package/blockly-rc/msg/json/ky.json +71 -0
  631. package/blockly-rc/msg/json/la.json +6 -0
  632. package/blockly-rc/msg/json/lb.json +156 -0
  633. package/blockly-rc/msg/json/lki.json +282 -0
  634. package/blockly-rc/msg/json/lo.json +92 -0
  635. package/blockly-rc/msg/json/lrc.json +123 -0
  636. package/blockly-rc/msg/json/lt.json +321 -0
  637. package/blockly-rc/msg/json/lv.json +324 -0
  638. package/blockly-rc/msg/json/mg.json +58 -0
  639. package/blockly-rc/msg/json/mk.json +178 -0
  640. package/blockly-rc/msg/json/ml.json +35 -0
  641. package/blockly-rc/msg/json/mnw.json +90 -0
  642. package/blockly-rc/msg/json/ms.json +300 -0
  643. package/blockly-rc/msg/json/my.json +57 -0
  644. package/blockly-rc/msg/json/mzn.json +6 -0
  645. package/blockly-rc/msg/json/nb.json +330 -0
  646. package/blockly-rc/msg/json/ne.json +247 -0
  647. package/blockly-rc/msg/json/nl.json +357 -0
  648. package/blockly-rc/msg/json/oc.json +194 -0
  649. package/blockly-rc/msg/json/olo.json +37 -0
  650. package/blockly-rc/msg/json/pa.json +69 -0
  651. package/blockly-rc/msg/json/pl.json +357 -0
  652. package/blockly-rc/msg/json/pms.json +324 -0
  653. package/blockly-rc/msg/json/ps.json +50 -0
  654. package/blockly-rc/msg/json/pt-br.json +369 -0
  655. package/blockly-rc/msg/json/pt.json +358 -0
  656. package/blockly-rc/msg/json/qqq.json +406 -0
  657. package/blockly-rc/msg/json/ro.json +333 -0
  658. package/blockly-rc/msg/json/ru.json +363 -0
  659. package/blockly-rc/msg/json/sc.json +283 -0
  660. package/blockly-rc/msg/json/sco.json +11 -0
  661. package/blockly-rc/msg/json/sd.json +158 -0
  662. package/blockly-rc/msg/json/shn.json +109 -0
  663. package/blockly-rc/msg/json/si.json +16 -0
  664. package/blockly-rc/msg/json/sk.json +332 -0
  665. package/blockly-rc/msg/json/skr-arab.json +117 -0
  666. package/blockly-rc/msg/json/sl.json +355 -0
  667. package/blockly-rc/msg/json/smn.json +133 -0
  668. package/blockly-rc/msg/json/sq.json +343 -0
  669. package/blockly-rc/msg/json/sr-latn.json +324 -0
  670. package/blockly-rc/msg/json/sr.json +348 -0
  671. package/blockly-rc/msg/json/sv.json +347 -0
  672. package/blockly-rc/msg/json/sw.json +12 -0
  673. package/blockly-rc/msg/json/synonyms.json +22 -0
  674. package/blockly-rc/msg/json/ta.json +306 -0
  675. package/blockly-rc/msg/json/tcy.json +316 -0
  676. package/blockly-rc/msg/json/tdd.json +109 -0
  677. package/blockly-rc/msg/json/te.json +101 -0
  678. package/blockly-rc/msg/json/th.json +333 -0
  679. package/blockly-rc/msg/json/ti.json +50 -0
  680. package/blockly-rc/msg/json/tl.json +129 -0
  681. package/blockly-rc/msg/json/tlh.json +179 -0
  682. package/blockly-rc/msg/json/tr.json +369 -0
  683. package/blockly-rc/msg/json/ug-arab.json +132 -0
  684. package/blockly-rc/msg/json/uk.json +345 -0
  685. package/blockly-rc/msg/json/ur.json +117 -0
  686. package/blockly-rc/msg/json/uz.json +36 -0
  687. package/blockly-rc/msg/json/vi.json +345 -0
  688. package/blockly-rc/msg/json/xmf.json +96 -0
  689. package/blockly-rc/msg/json/yo.json +316 -0
  690. package/blockly-rc/msg/json/zgh.json +83 -0
  691. package/blockly-rc/msg/json/zh-hans.json +372 -0
  692. package/blockly-rc/msg/json/zh-hant.json +362 -0
  693. package/blockly-rc/msg/messages.js +1616 -0
  694. package/blockly-rc/package-lock.json +12324 -0
  695. package/blockly-rc/package.json +149 -0
  696. package/blockly-rc/patches/@microsoft+api-documenter+7.22.4.patch +81 -0
  697. package/blockly-rc/scripts/goog_module/convert-file.sh +406 -0
  698. package/blockly-rc/scripts/gulpfiles/appengine_tasks.js +195 -0
  699. package/blockly-rc/scripts/gulpfiles/build_tasks.js +752 -0
  700. package/blockly-rc/scripts/gulpfiles/config.js +41 -0
  701. package/blockly-rc/scripts/gulpfiles/docs_tasks.js +147 -0
  702. package/blockly-rc/scripts/gulpfiles/git_tasks.js +181 -0
  703. package/blockly-rc/scripts/gulpfiles/helper_tasks.js +19 -0
  704. package/blockly-rc/scripts/gulpfiles/package_tasks.js +262 -0
  705. package/blockly-rc/scripts/gulpfiles/release_tasks.js +183 -0
  706. package/blockly-rc/scripts/gulpfiles/test_tasks.js +405 -0
  707. package/blockly-rc/scripts/helpers.js +74 -0
  708. package/blockly-rc/scripts/i18n/common.py +233 -0
  709. package/blockly-rc/scripts/i18n/create_messages.py +167 -0
  710. package/blockly-rc/scripts/i18n/dedup_json.py +72 -0
  711. package/blockly-rc/scripts/i18n/js_to_json.py +135 -0
  712. package/blockly-rc/scripts/i18n/tests.py +46 -0
  713. package/blockly-rc/scripts/migration/cjs2esm +162 -0
  714. package/blockly-rc/scripts/migration/js2ts +168 -0
  715. package/blockly-rc/scripts/migration/renamings.json5 +1599 -0
  716. package/blockly-rc/scripts/package/README.md +93 -0
  717. package/blockly-rc/scripts/package/core-node.js +31 -0
  718. package/blockly-rc/scripts/package/index.js +23 -0
  719. package/blockly-rc/scripts/package/templates/umd-msg.template +16 -0
  720. package/blockly-rc/scripts/package/templates/umd.template +13 -0
  721. package/blockly-rc/scripts/themes/blockStyles_example.json +11 -0
  722. package/blockly-rc/scripts/themes/create_blockStyles.py +181 -0
  723. package/blockly-rc/scripts/tsick.js +86 -0
  724. package/blockly-rc/tests/.eslintrc.json +10 -0
  725. package/blockly-rc/tests/browser/.eslintrc.json +29 -0
  726. package/blockly-rc/tests/browser/.mocharc.js +6 -0
  727. package/blockly-rc/tests/browser/test/basic_block_factory_test.mjs +44 -0
  728. package/blockly-rc/tests/browser/test/basic_block_test.mjs +39 -0
  729. package/blockly-rc/tests/browser/test/basic_playground_test.mjs +198 -0
  730. package/blockly-rc/tests/browser/test/block_undo_test.mjs +50 -0
  731. package/blockly-rc/tests/browser/test/delete_blocks_test.mjs +211 -0
  732. package/blockly-rc/tests/browser/test/extensive_test.mjs +195 -0
  733. package/blockly-rc/tests/browser/test/field_edits_test.mjs +61 -0
  734. package/blockly-rc/tests/browser/test/hooks.mjs +23 -0
  735. package/blockly-rc/tests/browser/test/mutator_test.mjs +88 -0
  736. package/blockly-rc/tests/browser/test/procedure_test.mjs +109 -0
  737. package/blockly-rc/tests/browser/test/test_setup.mjs +589 -0
  738. package/blockly-rc/tests/browser/test/toolbox_drag_test.mjs +207 -0
  739. package/blockly-rc/tests/browser/test/workspace_comment_test.mjs +224 -0
  740. package/blockly-rc/tests/compile/index.html +43 -0
  741. package/blockly-rc/tests/compile/main.js +53 -0
  742. package/blockly-rc/tests/compile/test_blocks.js +47 -0
  743. package/blockly-rc/tests/compile/webdriver.js +81 -0
  744. package/blockly-rc/tests/generators/functions.xml +561 -0
  745. package/blockly-rc/tests/generators/golden/generated.dart +1604 -0
  746. package/blockly-rc/tests/generators/golden/generated.js +1552 -0
  747. package/blockly-rc/tests/generators/golden/generated.lua +1828 -0
  748. package/blockly-rc/tests/generators/golden/generated.php +1611 -0
  749. package/blockly-rc/tests/generators/golden/generated.py +1407 -0
  750. package/blockly-rc/tests/generators/index.html +405 -0
  751. package/blockly-rc/tests/generators/lists.xml +8675 -0
  752. package/blockly-rc/tests/generators/logic.xml +1019 -0
  753. package/blockly-rc/tests/generators/loops1.xml +345 -0
  754. package/blockly-rc/tests/generators/loops2.xml +891 -0
  755. package/blockly-rc/tests/generators/loops3.xml +735 -0
  756. package/blockly-rc/tests/generators/math.xml +2077 -0
  757. package/blockly-rc/tests/generators/text.xml +4651 -0
  758. package/blockly-rc/tests/generators/unittest.js +103 -0
  759. package/blockly-rc/tests/generators/unittest_dart.js +163 -0
  760. package/blockly-rc/tests/generators/unittest_javascript.js +167 -0
  761. package/blockly-rc/tests/generators/unittest_lua.js +165 -0
  762. package/blockly-rc/tests/generators/unittest_php.js +154 -0
  763. package/blockly-rc/tests/generators/unittest_python.js +138 -0
  764. package/blockly-rc/tests/generators/variables.xml +68 -0
  765. package/blockly-rc/tests/generators/webdriver.js +123 -0
  766. package/blockly-rc/tests/media/200px.png +0 -0
  767. package/blockly-rc/tests/media/30px.png +0 -0
  768. package/blockly-rc/tests/media/50px.png +0 -0
  769. package/blockly-rc/tests/media/a.png +0 -0
  770. package/blockly-rc/tests/media/arrow.png +0 -0
  771. package/blockly-rc/tests/media/b.png +0 -0
  772. package/blockly-rc/tests/media/c.png +0 -0
  773. package/blockly-rc/tests/media/d.png +0 -0
  774. package/blockly-rc/tests/media/e.png +0 -0
  775. package/blockly-rc/tests/media/f.png +0 -0
  776. package/blockly-rc/tests/media/g.png +0 -0
  777. package/blockly-rc/tests/media/h.png +0 -0
  778. package/blockly-rc/tests/media/i.png +0 -0
  779. package/blockly-rc/tests/media/j.png +0 -0
  780. package/blockly-rc/tests/media/k.png +0 -0
  781. package/blockly-rc/tests/media/l.png +0 -0
  782. package/blockly-rc/tests/media/m.png +0 -0
  783. package/blockly-rc/tests/migration/renamings.schema.json +59 -0
  784. package/blockly-rc/tests/migration/validate-renamings.mjs +60 -0
  785. package/blockly-rc/tests/mocha/.eslintrc.json +21 -0
  786. package/blockly-rc/tests/mocha/.mocharc.js +6 -0
  787. package/blockly-rc/tests/mocha/astnode_test.js +850 -0
  788. package/blockly-rc/tests/mocha/block_json_test.js +777 -0
  789. package/blockly-rc/tests/mocha/block_test.js +2743 -0
  790. package/blockly-rc/tests/mocha/blocks/lists_test.js +196 -0
  791. package/blockly-rc/tests/mocha/blocks/logic_ternary_test.js +320 -0
  792. package/blockly-rc/tests/mocha/blocks/loops_test.js +56 -0
  793. package/blockly-rc/tests/mocha/blocks/procedures_test.js +2495 -0
  794. package/blockly-rc/tests/mocha/blocks/variables_test.js +311 -0
  795. package/blockly-rc/tests/mocha/clipboard_test.js +136 -0
  796. package/blockly-rc/tests/mocha/comment_deserialization_test.js +122 -0
  797. package/blockly-rc/tests/mocha/comment_test.js +170 -0
  798. package/blockly-rc/tests/mocha/comment_view_test.js +188 -0
  799. package/blockly-rc/tests/mocha/connection_checker_test.js +666 -0
  800. package/blockly-rc/tests/mocha/connection_db_test.js +362 -0
  801. package/blockly-rc/tests/mocha/connection_test.js +3738 -0
  802. package/blockly-rc/tests/mocha/contextmenu_items_test.js +488 -0
  803. package/blockly-rc/tests/mocha/contextmenu_test.js +71 -0
  804. package/blockly-rc/tests/mocha/cursor_test.js +134 -0
  805. package/blockly-rc/tests/mocha/dropdowndiv_test.js +116 -0
  806. package/blockly-rc/tests/mocha/event_block_change_test.js +126 -0
  807. package/blockly-rc/tests/mocha/event_block_create_test.js +109 -0
  808. package/blockly-rc/tests/mocha/event_block_delete_test.js +55 -0
  809. package/blockly-rc/tests/mocha/event_block_drag_test.js +36 -0
  810. package/blockly-rc/tests/mocha/event_block_field_intermediate_change_test.js +67 -0
  811. package/blockly-rc/tests/mocha/event_block_move_test.js +39 -0
  812. package/blockly-rc/tests/mocha/event_bubble_open_test.js +42 -0
  813. package/blockly-rc/tests/mocha/event_click_test.js +40 -0
  814. package/blockly-rc/tests/mocha/event_comment_change_test.js +39 -0
  815. package/blockly-rc/tests/mocha/event_comment_collapse_test.js +34 -0
  816. package/blockly-rc/tests/mocha/event_comment_create_test.js +38 -0
  817. package/blockly-rc/tests/mocha/event_comment_delete_test.js +38 -0
  818. package/blockly-rc/tests/mocha/event_comment_drag_test.js +35 -0
  819. package/blockly-rc/tests/mocha/event_comment_move_test.js +40 -0
  820. package/blockly-rc/tests/mocha/event_comment_resize_test.js +38 -0
  821. package/blockly-rc/tests/mocha/event_marker_move_test.js +44 -0
  822. package/blockly-rc/tests/mocha/event_selected_test.js +41 -0
  823. package/blockly-rc/tests/mocha/event_test.js +1578 -0
  824. package/blockly-rc/tests/mocha/event_theme_change_test.js +36 -0
  825. package/blockly-rc/tests/mocha/event_toolbox_item_select_test.js +64 -0
  826. package/blockly-rc/tests/mocha/event_trashcan_open_test.js +36 -0
  827. package/blockly-rc/tests/mocha/event_var_create_test.js +54 -0
  828. package/blockly-rc/tests/mocha/event_var_delete_test.js +54 -0
  829. package/blockly-rc/tests/mocha/event_var_rename_test.js +39 -0
  830. package/blockly-rc/tests/mocha/event_var_type_change_test.js +43 -0
  831. package/blockly-rc/tests/mocha/event_viewport_test.js +39 -0
  832. package/blockly-rc/tests/mocha/extensions_test.js +613 -0
  833. package/blockly-rc/tests/mocha/field_checkbox_test.js +299 -0
  834. package/blockly-rc/tests/mocha/field_colour_test.js +395 -0
  835. package/blockly-rc/tests/mocha/field_dropdown_test.js +282 -0
  836. package/blockly-rc/tests/mocha/field_image_test.js +241 -0
  837. package/blockly-rc/tests/mocha/field_label_serializable_test.js +252 -0
  838. package/blockly-rc/tests/mocha/field_label_test.js +226 -0
  839. package/blockly-rc/tests/mocha/field_number_test.js +505 -0
  840. package/blockly-rc/tests/mocha/field_registry_test.js +116 -0
  841. package/blockly-rc/tests/mocha/field_test.js +822 -0
  842. package/blockly-rc/tests/mocha/field_textinput_test.js +297 -0
  843. package/blockly-rc/tests/mocha/field_variable_test.js +611 -0
  844. package/blockly-rc/tests/mocha/flyout_test.js +638 -0
  845. package/blockly-rc/tests/mocha/generator_test.js +233 -0
  846. package/blockly-rc/tests/mocha/gesture_test.js +97 -0
  847. package/blockly-rc/tests/mocha/icon_test.js +369 -0
  848. package/blockly-rc/tests/mocha/index.html +229 -0
  849. package/blockly-rc/tests/mocha/input_test.js +296 -0
  850. package/blockly-rc/tests/mocha/insertion_marker_manager_test.js +443 -0
  851. package/blockly-rc/tests/mocha/insertion_marker_test.js +432 -0
  852. package/blockly-rc/tests/mocha/jso_deserialization_test.js +849 -0
  853. package/blockly-rc/tests/mocha/jso_serialization_test.js +1067 -0
  854. package/blockly-rc/tests/mocha/json_test.js +315 -0
  855. package/blockly-rc/tests/mocha/keydown_test.js +364 -0
  856. package/blockly-rc/tests/mocha/layering_test.js +95 -0
  857. package/blockly-rc/tests/mocha/metrics_test.js +671 -0
  858. package/blockly-rc/tests/mocha/mutator_test.js +87 -0
  859. package/blockly-rc/tests/mocha/names_test.js +97 -0
  860. package/blockly-rc/tests/mocha/old_workspace_comment_test.js +256 -0
  861. package/blockly-rc/tests/mocha/procedure_map_test.js +57 -0
  862. package/blockly-rc/tests/mocha/registry_test.js +281 -0
  863. package/blockly-rc/tests/mocha/render_management_test.js +127 -0
  864. package/blockly-rc/tests/mocha/serializer_test.js +2104 -0
  865. package/blockly-rc/tests/mocha/shortcut_registry_test.js +450 -0
  866. package/blockly-rc/tests/mocha/test_helpers/block_definitions.js +204 -0
  867. package/blockly-rc/tests/mocha/test_helpers/code_generation.js +115 -0
  868. package/blockly-rc/tests/mocha/test_helpers/common.js +106 -0
  869. package/blockly-rc/tests/mocha/test_helpers/events.js +290 -0
  870. package/blockly-rc/tests/mocha/test_helpers/fields.js +310 -0
  871. package/blockly-rc/tests/mocha/test_helpers/icon_mocks.js +81 -0
  872. package/blockly-rc/tests/mocha/test_helpers/procedures.js +302 -0
  873. package/blockly-rc/tests/mocha/test_helpers/serialization.js +124 -0
  874. package/blockly-rc/tests/mocha/test_helpers/setup_teardown.js +209 -0
  875. package/blockly-rc/tests/mocha/test_helpers/toolbox_definitions.js +271 -0
  876. package/blockly-rc/tests/mocha/test_helpers/user_input.js +62 -0
  877. package/blockly-rc/tests/mocha/test_helpers/variables.js +23 -0
  878. package/blockly-rc/tests/mocha/test_helpers/warnings.js +83 -0
  879. package/blockly-rc/tests/mocha/test_helpers/workspace.js +1691 -0
  880. package/blockly-rc/tests/mocha/theme_test.js +307 -0
  881. package/blockly-rc/tests/mocha/toolbox_test.js +761 -0
  882. package/blockly-rc/tests/mocha/tooltip_test.js +276 -0
  883. package/blockly-rc/tests/mocha/touch_test.js +109 -0
  884. package/blockly-rc/tests/mocha/trashcan_test.js +375 -0
  885. package/blockly-rc/tests/mocha/utils_test.js +536 -0
  886. package/blockly-rc/tests/mocha/variable_map_test.js +509 -0
  887. package/blockly-rc/tests/mocha/variable_model_test.js +85 -0
  888. package/blockly-rc/tests/mocha/webdriver.js +96 -0
  889. package/blockly-rc/tests/mocha/widget_div_test.js +272 -0
  890. package/blockly-rc/tests/mocha/workspace_comment_test.js +171 -0
  891. package/blockly-rc/tests/mocha/workspace_svg_test.js +414 -0
  892. package/blockly-rc/tests/mocha/workspace_test.js +27 -0
  893. package/blockly-rc/tests/mocha/xml_test.js +951 -0
  894. package/blockly-rc/tests/mocha/zoom_controls_test.js +81 -0
  895. package/blockly-rc/tests/multi_playground.html +482 -0
  896. package/blockly-rc/tests/node/.eslintrc.json +12 -0
  897. package/blockly-rc/tests/node/.mocharc.js +6 -0
  898. package/blockly-rc/tests/node/run_node_test.mjs +72 -0
  899. package/blockly-rc/tests/playground.html +1280 -0
  900. package/blockly-rc/tests/playgrounds/advanced_playground.html +158 -0
  901. package/blockly-rc/tests/playgrounds/iframe.html +40 -0
  902. package/blockly-rc/tests/playgrounds/screenshot.js +123 -0
  903. package/blockly-rc/tests/scripts/check_metadata.sh +166 -0
  904. package/blockly-rc/tests/scripts/compile_typings.sh +32 -0
  905. package/blockly-rc/tests/scripts/load.mjs +140 -0
  906. package/blockly-rc/tests/scripts/setup_linux_env.sh +7 -0
  907. package/blockly-rc/tests/scripts/update_metadata.sh +46 -0
  908. package/blockly-rc/tests/themes/test_themes.js +62 -0
  909. package/blockly-rc/tests/typescript/README.md +4 -0
  910. package/blockly-rc/tests/typescript/src/field/different_user_input.ts +81 -0
  911. package/blockly-rc/tests/typescript/src/generators/dart.ts +24 -0
  912. package/blockly-rc/tests/typescript/src/generators/javascript.ts +28 -0
  913. package/blockly-rc/tests/typescript/src/generators/lua.ts +24 -0
  914. package/blockly-rc/tests/typescript/src/generators/php.ts +24 -0
  915. package/blockly-rc/tests/typescript/src/generators/python.ts +24 -0
  916. package/blockly-rc/tests/typescript/src/generators.ts +31 -0
  917. package/blockly-rc/tests/typescript/src/msg.ts +20 -0
  918. package/blockly-rc/tests/typescript/tsconfig.json +20 -0
  919. package/blockly-rc/tests/xml/README.txt +11 -0
  920. package/blockly-rc/tests/xml/blockly.xsd +178 -0
  921. package/blockly-rc/tests/xml/invalid.xml +6 -0
  922. package/blockly-rc/tests/xml/toolbox.xml +311 -0
  923. package/blockly-rc/tests/xml/workspace.xml +114 -0
  924. package/blockly-rc/tsconfig.json +37 -0
  925. package/blockly-rc/tsdoc.json +35 -0
  926. package/blockly-rc/typings/README.md +5 -0
  927. package/blockly-rc/typings/blocks.d.ts +17 -0
  928. package/blockly-rc/typings/core.d.ts +7 -0
  929. package/blockly-rc/typings/dart.d.ts +7 -0
  930. package/blockly-rc/typings/index.d.ts +10 -0
  931. package/blockly-rc/typings/javascript.d.ts +7 -0
  932. package/blockly-rc/typings/lua.d.ts +7 -0
  933. package/blockly-rc/typings/msg/ab.d.ts +8 -0
  934. package/blockly-rc/typings/msg/ace.d.ts +8 -0
  935. package/blockly-rc/typings/msg/af.d.ts +8 -0
  936. package/blockly-rc/typings/msg/am.d.ts +8 -0
  937. package/blockly-rc/typings/msg/ar.d.ts +8 -0
  938. package/blockly-rc/typings/msg/ast.d.ts +8 -0
  939. package/blockly-rc/typings/msg/az.d.ts +8 -0
  940. package/blockly-rc/typings/msg/ba.d.ts +8 -0
  941. package/blockly-rc/typings/msg/bcc.d.ts +8 -0
  942. package/blockly-rc/typings/msg/be-tarask.d.ts +8 -0
  943. package/blockly-rc/typings/msg/be.d.ts +8 -0
  944. package/blockly-rc/typings/msg/bg.d.ts +8 -0
  945. package/blockly-rc/typings/msg/bn.d.ts +8 -0
  946. package/blockly-rc/typings/msg/br.d.ts +8 -0
  947. package/blockly-rc/typings/msg/bs.d.ts +8 -0
  948. package/blockly-rc/typings/msg/ca.d.ts +8 -0
  949. package/blockly-rc/typings/msg/cdo.d.ts +8 -0
  950. package/blockly-rc/typings/msg/ce.d.ts +8 -0
  951. package/blockly-rc/typings/msg/cs.d.ts +8 -0
  952. package/blockly-rc/typings/msg/da.d.ts +8 -0
  953. package/blockly-rc/typings/msg/de.d.ts +8 -0
  954. package/blockly-rc/typings/msg/diq.d.ts +8 -0
  955. package/blockly-rc/typings/msg/dtp.d.ts +8 -0
  956. package/blockly-rc/typings/msg/dty.d.ts +8 -0
  957. package/blockly-rc/typings/msg/ee.d.ts +8 -0
  958. package/blockly-rc/typings/msg/el.d.ts +8 -0
  959. package/blockly-rc/typings/msg/en-gb.d.ts +8 -0
  960. package/blockly-rc/typings/msg/en.d.ts +8 -0
  961. package/blockly-rc/typings/msg/eo.d.ts +8 -0
  962. package/blockly-rc/typings/msg/es.d.ts +8 -0
  963. package/blockly-rc/typings/msg/et.d.ts +8 -0
  964. package/blockly-rc/typings/msg/eu.d.ts +8 -0
  965. package/blockly-rc/typings/msg/fa.d.ts +8 -0
  966. package/blockly-rc/typings/msg/fi.d.ts +8 -0
  967. package/blockly-rc/typings/msg/fo.d.ts +8 -0
  968. package/blockly-rc/typings/msg/fr.d.ts +8 -0
  969. package/blockly-rc/typings/msg/frr.d.ts +8 -0
  970. package/blockly-rc/typings/msg/gl.d.ts +8 -0
  971. package/blockly-rc/typings/msg/gn.d.ts +8 -0
  972. package/blockly-rc/typings/msg/gor.d.ts +8 -0
  973. package/blockly-rc/typings/msg/ha.d.ts +8 -0
  974. package/blockly-rc/typings/msg/hak.d.ts +8 -0
  975. package/blockly-rc/typings/msg/he.d.ts +8 -0
  976. package/blockly-rc/typings/msg/hi.d.ts +8 -0
  977. package/blockly-rc/typings/msg/hr.d.ts +8 -0
  978. package/blockly-rc/typings/msg/hrx.d.ts +8 -0
  979. package/blockly-rc/typings/msg/hsb.d.ts +8 -0
  980. package/blockly-rc/typings/msg/hu.d.ts +8 -0
  981. package/blockly-rc/typings/msg/hy.d.ts +8 -0
  982. package/blockly-rc/typings/msg/ia.d.ts +8 -0
  983. package/blockly-rc/typings/msg/id.d.ts +8 -0
  984. package/blockly-rc/typings/msg/ig.d.ts +8 -0
  985. package/blockly-rc/typings/msg/inh.d.ts +8 -0
  986. package/blockly-rc/typings/msg/is.d.ts +8 -0
  987. package/blockly-rc/typings/msg/it.d.ts +8 -0
  988. package/blockly-rc/typings/msg/ja.d.ts +8 -0
  989. package/blockly-rc/typings/msg/ka.d.ts +8 -0
  990. package/blockly-rc/typings/msg/kab.d.ts +8 -0
  991. package/blockly-rc/typings/msg/kbd-cyrl.d.ts +8 -0
  992. package/blockly-rc/typings/msg/km.d.ts +8 -0
  993. package/blockly-rc/typings/msg/kn.d.ts +8 -0
  994. package/blockly-rc/typings/msg/ko.d.ts +8 -0
  995. package/blockly-rc/typings/msg/ksh.d.ts +8 -0
  996. package/blockly-rc/typings/msg/ku-latn.d.ts +8 -0
  997. package/blockly-rc/typings/msg/ky.d.ts +8 -0
  998. package/blockly-rc/typings/msg/la.d.ts +8 -0
  999. package/blockly-rc/typings/msg/lb.d.ts +8 -0
  1000. package/blockly-rc/typings/msg/lki.d.ts +8 -0
  1001. package/blockly-rc/typings/msg/lo.d.ts +8 -0
  1002. package/blockly-rc/typings/msg/lrc.d.ts +8 -0
  1003. package/blockly-rc/typings/msg/lt.d.ts +8 -0
  1004. package/blockly-rc/typings/msg/lv.d.ts +8 -0
  1005. package/blockly-rc/typings/msg/mg.d.ts +8 -0
  1006. package/blockly-rc/typings/msg/mk.d.ts +8 -0
  1007. package/blockly-rc/typings/msg/ml.d.ts +8 -0
  1008. package/blockly-rc/typings/msg/mnw.d.ts +8 -0
  1009. package/blockly-rc/typings/msg/ms.d.ts +8 -0
  1010. package/blockly-rc/typings/msg/msg.d.ts +440 -0
  1011. package/blockly-rc/typings/msg/my.d.ts +8 -0
  1012. package/blockly-rc/typings/msg/mzn.d.ts +8 -0
  1013. package/blockly-rc/typings/msg/nb.d.ts +8 -0
  1014. package/blockly-rc/typings/msg/ne.d.ts +8 -0
  1015. package/blockly-rc/typings/msg/nl.d.ts +8 -0
  1016. package/blockly-rc/typings/msg/oc.d.ts +8 -0
  1017. package/blockly-rc/typings/msg/olo.d.ts +8 -0
  1018. package/blockly-rc/typings/msg/pa.d.ts +8 -0
  1019. package/blockly-rc/typings/msg/pl.d.ts +8 -0
  1020. package/blockly-rc/typings/msg/pms.d.ts +8 -0
  1021. package/blockly-rc/typings/msg/ps.d.ts +8 -0
  1022. package/blockly-rc/typings/msg/pt-br.d.ts +8 -0
  1023. package/blockly-rc/typings/msg/pt.d.ts +8 -0
  1024. package/blockly-rc/typings/msg/ro.d.ts +8 -0
  1025. package/blockly-rc/typings/msg/ru.d.ts +8 -0
  1026. package/blockly-rc/typings/msg/sc.d.ts +8 -0
  1027. package/blockly-rc/typings/msg/sco.d.ts +8 -0
  1028. package/blockly-rc/typings/msg/sd.d.ts +8 -0
  1029. package/blockly-rc/typings/msg/shn.d.ts +8 -0
  1030. package/blockly-rc/typings/msg/si.d.ts +8 -0
  1031. package/blockly-rc/typings/msg/sk.d.ts +8 -0
  1032. package/blockly-rc/typings/msg/skr-arab.d.ts +8 -0
  1033. package/blockly-rc/typings/msg/sl.d.ts +8 -0
  1034. package/blockly-rc/typings/msg/smn.d.ts +8 -0
  1035. package/blockly-rc/typings/msg/sq.d.ts +8 -0
  1036. package/blockly-rc/typings/msg/sr-latn.d.ts +8 -0
  1037. package/blockly-rc/typings/msg/sr.d.ts +8 -0
  1038. package/blockly-rc/typings/msg/sv.d.ts +8 -0
  1039. package/blockly-rc/typings/msg/sw.d.ts +8 -0
  1040. package/blockly-rc/typings/msg/ta.d.ts +8 -0
  1041. package/blockly-rc/typings/msg/tcy.d.ts +8 -0
  1042. package/blockly-rc/typings/msg/tdd.d.ts +8 -0
  1043. package/blockly-rc/typings/msg/te.d.ts +8 -0
  1044. package/blockly-rc/typings/msg/th.d.ts +8 -0
  1045. package/blockly-rc/typings/msg/ti.d.ts +8 -0
  1046. package/blockly-rc/typings/msg/tl.d.ts +8 -0
  1047. package/blockly-rc/typings/msg/tlh.d.ts +8 -0
  1048. package/blockly-rc/typings/msg/tr.d.ts +8 -0
  1049. package/blockly-rc/typings/msg/ug-arab.d.ts +8 -0
  1050. package/blockly-rc/typings/msg/uk.d.ts +8 -0
  1051. package/blockly-rc/typings/msg/ur.d.ts +8 -0
  1052. package/blockly-rc/typings/msg/uz.d.ts +8 -0
  1053. package/blockly-rc/typings/msg/vi.d.ts +8 -0
  1054. package/blockly-rc/typings/msg/xmf.d.ts +8 -0
  1055. package/blockly-rc/typings/msg/yo.d.ts +8 -0
  1056. package/blockly-rc/typings/msg/zgh.d.ts +8 -0
  1057. package/blockly-rc/typings/msg/zh-hans.d.ts +8 -0
  1058. package/blockly-rc/typings/msg/zh-hant.d.ts +8 -0
  1059. package/blockly-rc/typings/php.d.ts +7 -0
  1060. package/blockly-rc/typings/python.d.ts +7 -0
  1061. package/blockly-rc/typings/templates/blockly-header.template +11 -0
  1062. package/blockly-rc/typings/templates/blockly-interfaces.template +83 -0
  1063. package/blockly-rc/typings/templates/msg.template +15 -0
  1064. package/blockly-rc/typings/tsconfig.json +23 -0
  1065. package/continuous-toolbox.d.ts +1 -0
  1066. package/dist/main.js +2 -0
  1067. package/dist/main.js.LICENSE.txt +163 -0
  1068. package/media/delete-icon.svg +10 -0
  1069. package/media/resize-handle.svg +3 -0
  1070. package/msg/scratch_msgs.js +184 -164
  1071. package/package.json +25 -40
  1072. package/release.config.js +8 -0
  1073. package/src/block_reporting.js +31 -0
  1074. package/src/blocks/colour.js +56 -0
  1075. package/src/blocks/control.js +492 -0
  1076. package/src/blocks/data.js +690 -0
  1077. package/src/blocks/event.js +305 -0
  1078. package/src/blocks/looks.js +537 -0
  1079. package/src/blocks/math.js +137 -0
  1080. package/src/blocks/matrix.js +47 -0
  1081. package/src/blocks/motion.js +513 -0
  1082. package/src/blocks/note.js +48 -0
  1083. package/src/blocks/operators.js +463 -0
  1084. package/src/blocks/procedures.js +1009 -0
  1085. package/src/blocks/sensing.js +441 -0
  1086. package/src/blocks/sound.js +205 -0
  1087. package/src/blocks/text.js +45 -0
  1088. package/src/blocks/vertical_extensions.js +309 -0
  1089. package/src/categories.js +15 -0
  1090. package/src/checkable_continuous_flyout.js +138 -0
  1091. package/src/checkbox_bubble.js +282 -0
  1092. package/src/colours.js +77 -0
  1093. package/src/constants.js +63 -0
  1094. package/src/context_menu_items.js +150 -0
  1095. package/src/css.js +1197 -0
  1096. package/src/data_category.js +556 -0
  1097. package/src/events/events_block_comment_base.js +35 -0
  1098. package/src/events/events_block_comment_change.js +43 -0
  1099. package/src/events/events_block_comment_collapse.js +43 -0
  1100. package/src/events/events_block_comment_create.js +52 -0
  1101. package/src/events/events_block_comment_delete.js +27 -0
  1102. package/src/events/events_block_comment_move.js +54 -0
  1103. package/src/events/events_block_comment_resize.js +52 -0
  1104. package/src/events/events_block_drag_end.js +33 -0
  1105. package/src/events/events_block_drag_outside.js +30 -0
  1106. package/src/events/events_scratch_variable_create.js +67 -0
  1107. package/src/fields/field_angle.js +433 -0
  1108. package/src/fields/field_colour_slider.js +388 -0
  1109. package/src/fields/field_dropdown.js +42 -0
  1110. package/src/fields/field_matrix.js +634 -0
  1111. package/src/fields/field_note.js +937 -0
  1112. package/src/fields/field_number.js +380 -0
  1113. package/src/fields/field_textinput_removable.js +107 -0
  1114. package/src/fields/field_variable.js +171 -0
  1115. package/src/fields/field_variable_getter.js +109 -0
  1116. package/src/fields/field_vertical_separator.js +139 -0
  1117. package/src/flyout_checkbox_icon.js +88 -0
  1118. package/src/glows.js +98 -0
  1119. package/src/index.ts +137 -0
  1120. package/src/procedures.js +425 -0
  1121. package/src/recyclable_block_flyout_inflater.js +194 -0
  1122. package/src/renderer/bowler_hat.js +17 -0
  1123. package/src/renderer/constants.js +45 -0
  1124. package/src/renderer/drawer.js +51 -0
  1125. package/src/renderer/path_object.js +35 -0
  1126. package/src/renderer/render_info.js +98 -0
  1127. package/src/renderer/renderer.js +74 -0
  1128. package/src/scratch_block_paster.js +46 -0
  1129. package/src/scratch_blocks_utils.js +148 -0
  1130. package/src/scratch_comment_bubble.js +169 -0
  1131. package/src/scratch_comment_icon.js +195 -0
  1132. package/src/scratch_connection_checker.js +29 -0
  1133. package/src/scratch_continuous_category.js +80 -0
  1134. package/src/scratch_continuous_toolbox.js +78 -0
  1135. package/src/scratch_dragger.js +142 -0
  1136. package/src/scratch_variable_map.js +25 -0
  1137. package/src/scratch_variable_model.js +24 -0
  1138. package/src/shadows.js +61 -0
  1139. package/src/status_indicator_label.js +186 -0
  1140. package/src/status_indicator_label_flyout_inflater.js +42 -0
  1141. package/src/variables.js +355 -0
  1142. package/temp-use-blockly-v12-rc.sh +26 -0
  1143. package/tsconfig.json +13 -0
  1144. package/blockly_compressed_horizontal.js +0 -2255
  1145. package/blockly_compressed_vertical.js +0 -2283
  1146. package/blockly_uncompressed_horizontal.js +0 -1210
  1147. package/blockly_uncompressed_vertical.js +0 -1210
  1148. package/blocks_common/colour.js +0 -61
  1149. package/blocks_common/math.js +0 -159
  1150. package/blocks_common/matrix.js +0 -54
  1151. package/blocks_common/note.js +0 -58
  1152. package/blocks_common/text.js +0 -57
  1153. package/blocks_compressed.js +0 -36
  1154. package/blocks_compressed_horizontal.js +0 -67
  1155. package/blocks_compressed_vertical.js +0 -208
  1156. package/blocks_horizontal/control.js +0 -212
  1157. package/blocks_horizontal/default_toolbox.js +0 -139
  1158. package/blocks_horizontal/event.js +0 -190
  1159. package/blocks_horizontal/wedo.js +0 -325
  1160. package/blocks_vertical/control.js +0 -532
  1161. package/blocks_vertical/data.js +0 -666
  1162. package/blocks_vertical/default_toolbox.js +0 -564
  1163. package/blocks_vertical/event.js +0 -329
  1164. package/blocks_vertical/extensions.js +0 -294
  1165. package/blocks_vertical/looks.js +0 -591
  1166. package/blocks_vertical/motion.js +0 -587
  1167. package/blocks_vertical/operators.js +0 -470
  1168. package/blocks_vertical/procedures.js +0 -973
  1169. package/blocks_vertical/sensing.js +0 -539
  1170. package/blocks_vertical/sound.js +0 -246
  1171. package/blocks_vertical/vertical_extensions.js +0 -266
  1172. package/build/gen_blocks.js +0 -1
  1173. package/build/test_expect.js +0 -1
  1174. package/build/test_input.js +0 -1
  1175. package/build.py +0 -636
  1176. package/cleanup.sh +0 -101
  1177. package/core/block.js +0 -1837
  1178. package/core/block_animations.js +0 -107
  1179. package/core/block_drag_surface.js +0 -299
  1180. package/core/block_dragger.js +0 -421
  1181. package/core/block_events.js +0 -531
  1182. package/core/block_render_svg_horizontal.js +0 -890
  1183. package/core/block_render_svg_vertical.js +0 -1732
  1184. package/core/block_svg.js +0 -1316
  1185. package/core/blockly.js +0 -622
  1186. package/core/blocks.js +0 -37
  1187. package/core/bubble.js +0 -664
  1188. package/core/bubble_dragger.js +0 -285
  1189. package/core/colours.js +0 -160
  1190. package/core/comment.js +0 -293
  1191. package/core/comment_events.js +0 -539
  1192. package/core/connection.js +0 -766
  1193. package/core/connection_db.js +0 -300
  1194. package/core/constants.js +0 -387
  1195. package/core/contextmenu.js +0 -519
  1196. package/core/css.js +0 -1351
  1197. package/core/data_category.js +0 -490
  1198. package/core/dragged_connection_manager.js +0 -260
  1199. package/core/dropdowndiv.js +0 -408
  1200. package/core/events.js +0 -429
  1201. package/core/events_abstract.js +0 -113
  1202. package/core/extensions.js +0 -450
  1203. package/core/field.js +0 -807
  1204. package/core/field_angle.js +0 -398
  1205. package/core/field_checkbox.js +0 -133
  1206. package/core/field_colour.js +0 -253
  1207. package/core/field_colour_slider.js +0 -387
  1208. package/core/field_date.js +0 -353
  1209. package/core/field_dropdown.js +0 -483
  1210. package/core/field_iconmenu.js +0 -309
  1211. package/core/field_image.js +0 -193
  1212. package/core/field_label.js +0 -136
  1213. package/core/field_label_serializable.js +0 -125
  1214. package/core/field_matrix.js +0 -566
  1215. package/core/field_note.js +0 -850
  1216. package/core/field_number.js +0 -366
  1217. package/core/field_numberdropdown.js +0 -77
  1218. package/core/field_textdropdown.js +0 -164
  1219. package/core/field_textinput.js +0 -675
  1220. package/core/field_textinput_removable.js +0 -105
  1221. package/core/field_variable.js +0 -385
  1222. package/core/field_variable_getter.js +0 -185
  1223. package/core/field_vertical_separator.js +0 -161
  1224. package/core/flyout_base.js +0 -923
  1225. package/core/flyout_button.js +0 -322
  1226. package/core/flyout_dragger.js +0 -83
  1227. package/core/flyout_extension_category_header.js +0 -159
  1228. package/core/flyout_horizontal.js +0 -475
  1229. package/core/flyout_vertical.js +0 -770
  1230. package/core/generator.js +0 -426
  1231. package/core/gesture.js +0 -1011
  1232. package/core/grid.js +0 -227
  1233. package/core/icon.js +0 -205
  1234. package/core/inject.js +0 -491
  1235. package/core/input.js +0 -285
  1236. package/core/insertion_marker_manager.js +0 -678
  1237. package/core/msg.js +0 -62
  1238. package/core/mutator.js +0 -426
  1239. package/core/names.js +0 -198
  1240. package/core/options.js +0 -244
  1241. package/core/procedures.js +0 -577
  1242. package/core/rendered_connection.js +0 -417
  1243. package/core/scratch_block_comment.js +0 -653
  1244. package/core/scratch_blocks_utils.js +0 -244
  1245. package/core/scratch_bubble.js +0 -696
  1246. package/core/scratch_events.js +0 -131
  1247. package/core/scratch_msgs.js +0 -85
  1248. package/core/scrollbar.js +0 -875
  1249. package/core/toolbox.js +0 -801
  1250. package/core/tooltip.js +0 -337
  1251. package/core/touch.js +0 -226
  1252. package/core/trashcan.js +0 -343
  1253. package/core/ui_events.js +0 -91
  1254. package/core/ui_menu_utils.js +0 -68
  1255. package/core/utils.js +0 -948
  1256. package/core/variable_events.js +0 -259
  1257. package/core/variable_map.js +0 -415
  1258. package/core/variable_model.js +0 -116
  1259. package/core/variables.js +0 -674
  1260. package/core/warning.js +0 -199
  1261. package/core/widgetdiv.js +0 -344
  1262. package/core/workspace.js +0 -673
  1263. package/core/workspace_audio.js +0 -170
  1264. package/core/workspace_comment.js +0 -432
  1265. package/core/workspace_comment_render_svg.js +0 -723
  1266. package/core/workspace_comment_svg.js +0 -611
  1267. package/core/workspace_drag_surface_svg.js +0 -195
  1268. package/core/workspace_dragger.js +0 -132
  1269. package/core/workspace_svg.js +0 -2267
  1270. package/core/xml.js +0 -919
  1271. package/core/zoom_controls.js +0 -301
  1272. package/dist/horizontal.js +0 -222
  1273. package/dist/vertical.js +0 -222
  1274. package/dist/web/horizontal.js +0 -232
  1275. package/dist/web/vertical.js +0 -232
  1276. package/local_build.sh +0 -70
  1277. package/pack/scratch-blocks-1.1.206.tgz +0 -0
  1278. package/pull_from_blockly.sh +0 -151
  1279. package/shim/blockly_compressed_horizontal-blocks_compressed.js +0 -1
  1280. package/shim/blockly_compressed_horizontal.Blockly.js +0 -1
  1281. package/shim/blockly_compressed_horizontal.goog.js +0 -1
  1282. package/shim/blockly_compressed_horizontal.js +0 -1
  1283. package/shim/blockly_compressed_vertical-blocks_compressed.js +0 -1
  1284. package/shim/blockly_compressed_vertical.Blockly.js +0 -1
  1285. package/shim/blockly_compressed_vertical.goog.js +0 -1
  1286. package/shim/blockly_compressed_vertical.js +0 -1
  1287. package/shim/blocks_compressed_horizontal-blockly_compressed_horizontal-messages.js +0 -1
  1288. package/shim/blocks_compressed_horizontal.js +0 -1
  1289. package/shim/blocks_compressed_vertical-blockly_compressed_vertical-messages.js +0 -1
  1290. package/shim/blocks_compressed_vertical.js +0 -1
  1291. package/shim/gh-pages.js +0 -1
  1292. package/shim/horizontal.js +0 -1
  1293. package/shim/index.js +0 -17
  1294. package/shim/vertical.js +0 -1
  1295. /package/media/{comment-arrow-down.svg → foldout-icon.svg} +0 -0
package/core/block.js DELETED
@@ -1,1837 +0,0 @@
1
- /**
2
- * @license
3
- * Visual Blocks Editor
4
- *
5
- * Copyright 2011 Google Inc.
6
- * https://developers.google.com/blockly/
7
- *
8
- * Licensed under the Apache License, Version 2.0 (the "License");
9
- * you may not use this file except in compliance with the License.
10
- * You may obtain a copy of the License at
11
- *
12
- * http://www.apache.org/licenses/LICENSE-2.0
13
- *
14
- * Unless required by applicable law or agreed to in writing, software
15
- * distributed under the License is distributed on an "AS IS" BASIS,
16
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
- * See the License for the specific language governing permissions and
18
- * limitations under the License.
19
- */
20
-
21
- /**
22
- * @fileoverview The class representing one block.
23
- * @author fraser@google.com (Neil Fraser)
24
- */
25
- 'use strict';
26
-
27
- goog.provide('Blockly.Block');
28
-
29
- goog.require('Blockly.Blocks');
30
- goog.require('Blockly.Colours');
31
- goog.require('Blockly.Comment');
32
- goog.require('Blockly.ScratchBlockComment');
33
- goog.require('Blockly.Connection');
34
- goog.require('Blockly.Events.BlockChange');
35
- goog.require('Blockly.Events.BlockCreate');
36
- goog.require('Blockly.Events.BlockDelete');
37
- goog.require('Blockly.Events.BlockMove');
38
- goog.require('Blockly.Extensions');
39
- goog.require('Blockly.FieldLabelSerializable');
40
- goog.require('Blockly.FieldVariableGetter');
41
- goog.require('Blockly.Input');
42
- goog.require('Blockly.Mutator');
43
- goog.require('Blockly.Warning');
44
- goog.require('Blockly.Workspace');
45
- goog.require('Blockly.Xml');
46
- goog.require('goog.array');
47
- goog.require('goog.asserts');
48
- goog.require('goog.math.Coordinate');
49
- goog.require('goog.string');
50
-
51
-
52
- /**
53
- * Class for one block.
54
- * Not normally called directly, workspace.newBlock() is preferred.
55
- * @param {!Blockly.Workspace} workspace The block's workspace.
56
- * @param {?string} prototypeName Name of the language object containing
57
- * type-specific functions for this block.
58
- * @param {string=} opt_id Optional ID. Use this ID if provided, otherwise
59
- * create a new ID. If the ID conflicts with an in-use ID, a new one will
60
- * be generated.
61
- * @constructor
62
- */
63
- Blockly.Block = function(workspace, prototypeName, opt_id) {
64
- var flyoutWorkspace = workspace && workspace.getFlyout && workspace.getFlyout() ?
65
- workspace.getFlyout().getWorkspace() : null;
66
- /** @type {string} */
67
- this.id = (opt_id && !workspace.getBlockById(opt_id) &&
68
- (!flyoutWorkspace || !flyoutWorkspace.getBlockById(opt_id))) ?
69
- opt_id : Blockly.utils.genUid();
70
- workspace.blockDB_[this.id] = this;
71
- /** @type {Blockly.Connection} */
72
- this.outputConnection = null;
73
- /** @type {Blockly.Connection} */
74
- this.nextConnection = null;
75
- /** @type {Blockly.Connection} */
76
- this.previousConnection = null;
77
- /** @type {!Array.<!Blockly.Input>} */
78
- this.inputList = [];
79
- /** @type {boolean|undefined} */
80
- this.inputsInline = true;
81
- /** @type {boolean} */
82
- this.disabled = false;
83
- /** @type {string|!Function} */
84
- this.tooltip = '';
85
- /** @type {boolean} */
86
- this.contextMenu = true;
87
-
88
- /**
89
- * @type {Blockly.Block}
90
- * @protected
91
- */
92
- this.parentBlock_ = null;
93
-
94
- /**
95
- * @type {!Array.<!Blockly.Block>}
96
- * @protected
97
- */
98
- this.childBlocks_ = [];
99
-
100
- /**
101
- * @type {boolean}
102
- * @private
103
- */
104
- this.deletable_ = true;
105
-
106
- /**
107
- * @type {boolean}
108
- * @private
109
- */
110
- this.movable_ = true;
111
-
112
- /**
113
- * @type {boolean}
114
- * @private
115
- */
116
- this.editable_ = true;
117
-
118
- /**
119
- * @type {boolean}
120
- * @private
121
- */
122
- this.isShadow_ = false;
123
-
124
- /**
125
- * @type {boolean}
126
- * @protected
127
- */
128
- this.collapsed_ = false;
129
-
130
- /**
131
- * @type {boolean}
132
- * @private
133
- */
134
- this.checkboxInFlyout_ = false;
135
-
136
- /** @type {string|Blockly.Comment} */
137
- this.comment = null;
138
-
139
- /**
140
- * @type {?number}
141
- * @private
142
- */
143
- this.outputShape_ = null;
144
-
145
- /**
146
- * @type {?string}
147
- * @private
148
- */
149
- this.category_ = null;
150
-
151
- /**
152
- * The block's position in workspace units. (0, 0) is at the workspace's
153
- * origin; scale does not change this value.
154
- * @type {!goog.math.Coordinate}
155
- * @private
156
- */
157
- this.xy_ = new goog.math.Coordinate(0, 0);
158
-
159
- /** @type {!Blockly.Workspace} */
160
- this.workspace = workspace;
161
- /** @type {boolean} */
162
- this.isInFlyout = workspace.isFlyout;
163
- /** @type {boolean} */
164
- this.isInMutator = workspace.isMutator;
165
-
166
- /** @type {boolean} */
167
- this.RTL = workspace.RTL;
168
-
169
- /** @type {boolean} */
170
- this.isInsertionMarker_ = false;
171
-
172
- // Copy the type-specific functions and data from the prototype.
173
- if (prototypeName) {
174
- /** @type {string} */
175
- this.type = prototypeName;
176
- var prototype = Blockly.Blocks[prototypeName];
177
- goog.asserts.assertObject(prototype,
178
- 'Error: Unknown block type "%s".', prototypeName);
179
- goog.mixin(this, prototype);
180
- }
181
-
182
- workspace.addTopBlock(this);
183
-
184
- // Call an initialization function, if it exists.
185
- if (goog.isFunction(this.init)) {
186
- this.init();
187
- }
188
- // Record initial inline state.
189
- /** @type {boolean|undefined} */
190
- this.inputsInlineDefault = this.inputsInline;
191
-
192
- // Fire a create event.
193
- if (Blockly.Events.isEnabled()) {
194
- var existingGroup = Blockly.Events.getGroup();
195
- if (!existingGroup) {
196
- Blockly.Events.setGroup(true);
197
- }
198
- try {
199
- Blockly.Events.fire(new Blockly.Events.BlockCreate(this));
200
- } finally {
201
- if (!existingGroup) {
202
- Blockly.Events.setGroup(false);
203
- }
204
- }
205
-
206
- }
207
- // Bind an onchange function, if it exists.
208
- if (goog.isFunction(this.onchange)) {
209
- this.setOnChange(this.onchange);
210
- }
211
- };
212
-
213
- /**
214
- * Optional text data that round-trips beween blocks and XML.
215
- * Has no effect. May be used by 3rd parties for meta information.
216
- * @type {?string}
217
- */
218
- Blockly.Block.prototype.data = null;
219
-
220
- /**
221
- * Colour of the block in '#RRGGBB' format.
222
- * @type {string}
223
- * @private
224
- */
225
- Blockly.Block.prototype.colour_ = '#FF0000';
226
-
227
- /**
228
- * Secondary colour of the block in '#RRGGBB' format.
229
- * @type {string}
230
- * @private
231
- */
232
- Blockly.Block.prototype.colourSecondary_ = '#FF0000';
233
-
234
- /**
235
- * Tertiary colour of the block in '#RRGGBB' format.
236
- * @type {string}
237
- * @private
238
- */
239
- Blockly.Block.prototype.colourTertiary_ = '#FF0000';
240
-
241
- /**
242
- * Quaternary colour of the block in '#RRGGBB' format.
243
- * @type {string}
244
- * @private
245
- */
246
- Blockly.Block.prototype.colourQuaternary = '#FF0000';
247
-
248
- /**
249
- * Fill colour used to override default shadow colour behaviour.
250
- * @type {string}
251
- * @private
252
- */
253
- Blockly.Block.prototype.shadowColour_ = null;
254
-
255
- /**
256
- * Dispose of this block.
257
- * @param {boolean} healStack If true, then try to heal any gap by connecting
258
- * the next statement with the previous statement. Otherwise, dispose of
259
- * all children of this block.
260
- */
261
- Blockly.Block.prototype.dispose = function(healStack) {
262
- if (!this.workspace) {
263
- // Already deleted.
264
- return;
265
- }
266
- // Terminate onchange event calls.
267
- if (this.onchangeWrapper_) {
268
- this.workspace.removeChangeListener(this.onchangeWrapper_);
269
- }
270
- this.unplug(healStack);
271
- if (Blockly.Events.isEnabled()) {
272
- Blockly.Events.fire(new Blockly.Events.BlockDelete(this));
273
- }
274
- Blockly.Events.disable();
275
-
276
- try {
277
- // This block is now at the top of the workspace.
278
- // Remove this block from the workspace's list of top-most blocks.
279
- if (this.workspace) {
280
- this.workspace.removeTopBlock(this);
281
- // Remove from block database.
282
- delete this.workspace.blockDB_[this.id];
283
- this.workspace = null;
284
- }
285
-
286
- // Just deleting this block from the DOM would result in a memory leak as
287
- // well as corruption of the connection database. Therefore we must
288
- // methodically step through the blocks and carefully disassemble them.
289
-
290
- if (Blockly.selected == this) {
291
- Blockly.selected = null;
292
- }
293
-
294
- // First, dispose of all my children.
295
- for (var i = this.childBlocks_.length - 1; i >= 0; i--) {
296
- this.childBlocks_[i].dispose(false);
297
- }
298
- // Then dispose of myself.
299
- // Dispose of all inputs and their fields.
300
- for (var i = 0, input; input = this.inputList[i]; i++) {
301
- input.dispose();
302
- }
303
- this.inputList.length = 0;
304
- // Dispose of any remaining connections (next/previous/output).
305
- var connections = this.getConnections_(true);
306
- for (var i = 0; i < connections.length; i++) {
307
- var connection = connections[i];
308
- if (connection.isConnected()) {
309
- connection.disconnect();
310
- }
311
- connections[i].dispose();
312
- }
313
- } finally {
314
- Blockly.Events.enable();
315
- }
316
- };
317
-
318
- /**
319
- * Call initModel on all fields on the block.
320
- * May be called more than once.
321
- * Either initModel or initSvg must be called after creating a block and before
322
- * the first interaction with it. Interactions include UI actions
323
- * (e.g. clicking and dragging) and firing events (e.g. create, delete, and
324
- * change).
325
- * @public
326
- */
327
- Blockly.Block.prototype.initModel = function() {
328
- for (var i = 0, input; input = this.inputList[i]; i++) {
329
- for (var j = 0, field; field = input.fieldRow[j]; j++) {
330
- if (field.initModel) {
331
- field.initModel();
332
- }
333
- }
334
- }
335
- };
336
-
337
- /**
338
- * Unplug this block from its superior block. If this block is a statement,
339
- * optionally reconnect the block underneath with the block on top.
340
- * @param {boolean=} opt_healStack Disconnect child statement and reconnect
341
- * stack. Defaults to false.
342
- */
343
- Blockly.Block.prototype.unplug = function(opt_healStack) {
344
- if (this.outputConnection) {
345
- if (this.outputConnection.isConnected()) {
346
- // Disconnect from any superior block.
347
- this.outputConnection.disconnect();
348
- }
349
- } else {
350
- if (this.previousConnection) {
351
- var previousTarget = null;
352
- if (this.previousConnection.isConnected()) {
353
- // Remember the connection that any next statements need to connect to.
354
- previousTarget = this.previousConnection.targetConnection;
355
- // Detach this block from the parent's tree.
356
- this.previousConnection.disconnect();
357
- }
358
- }
359
- var nextBlock = this.getNextBlock();
360
- if (opt_healStack && nextBlock) {
361
- // Disconnect the next statement.
362
- var nextTarget = this.nextConnection.targetConnection;
363
- nextTarget.disconnect();
364
- if (previousTarget && previousTarget.checkType_(nextTarget)) {
365
- // Attach the next statement to the previous statement.
366
- previousTarget.connect(nextTarget);
367
- }
368
- }
369
- }
370
- };
371
-
372
- /**
373
- * Returns all connections originating from this block.
374
- * @return {!Array.<!Blockly.Connection>} Array of connections.
375
- * @private
376
- */
377
- Blockly.Block.prototype.getConnections_ = function() {
378
- var myConnections = [];
379
- if (this.outputConnection) {
380
- myConnections.push(this.outputConnection);
381
- }
382
- if (this.previousConnection) {
383
- myConnections.push(this.previousConnection);
384
- }
385
- if (this.nextConnection) {
386
- myConnections.push(this.nextConnection);
387
- }
388
- for (var i = 0, input; input = this.inputList[i]; i++) {
389
- if (input.connection) {
390
- myConnections.push(input.connection);
391
- }
392
- }
393
- return myConnections;
394
- };
395
-
396
- /**
397
- * Walks down a stack of blocks and finds the last next connection on the stack.
398
- * @return {Blockly.Connection} The last next connection on the stack, or null.
399
- * @package
400
- */
401
- Blockly.Block.prototype.lastConnectionInStack = function() {
402
- var nextConnection = this.nextConnection;
403
- while (nextConnection) {
404
- var nextBlock = nextConnection.targetBlock();
405
- if (!nextBlock) {
406
- // Found a next connection with nothing on the other side.
407
- return nextConnection;
408
- }
409
- nextConnection = nextBlock.nextConnection;
410
- }
411
- // Ran out of next connections.
412
- return null;
413
- };
414
-
415
- /**
416
- * Bump unconnected blocks out of alignment. Two blocks which aren't actually
417
- * connected should not coincidentally line up on screen.
418
- * @protected
419
- */
420
- Blockly.Block.prototype.bumpNeighbours_ = function() {
421
- console.warn('Not expected to reach this bumpNeighbours_ function. The ' +
422
- 'BlockSvg function for bumpNeighbours_ was expected to be called instead.');
423
- };
424
-
425
- /**
426
- * Return the parent block or null if this block is at the top level.
427
- * @return {Blockly.Block} The block that holds the current block.
428
- */
429
- Blockly.Block.prototype.getParent = function() {
430
- // Look at the DOM to see if we are nested in another block.
431
- return this.parentBlock_;
432
- };
433
-
434
- /**
435
- * Return the input that connects to the specified block.
436
- * @param {!Blockly.Block} block A block connected to an input on this block.
437
- * @return {Blockly.Input} The input that connects to the specified block.
438
- */
439
- Blockly.Block.prototype.getInputWithBlock = function(block) {
440
- for (var i = 0, input; input = this.inputList[i]; i++) {
441
- if (input.connection && input.connection.targetBlock() == block) {
442
- return input;
443
- }
444
- }
445
- return null;
446
- };
447
-
448
- /**
449
- * Return the input that contains the specified connection
450
- * @param {!Blockly.Connection} conn A connection on this block.
451
- * @return {Blockly.Input} The input that contains the specified connection.
452
- */
453
- Blockly.Block.prototype.getInputWithConnection = function(conn) {
454
- for (var i = 0, input; input = this.inputList[i]; i++) {
455
- if (input.connection == conn) {
456
- return input;
457
- }
458
- }
459
- return null;
460
- };
461
-
462
- /**
463
- * Return the parent block that surrounds the current block, or null if this
464
- * block has no surrounding block. A parent block might just be the previous
465
- * statement, whereas the surrounding block is an if statement, while loop, etc.
466
- * @return {Blockly.Block} The block that surrounds the current block.
467
- */
468
- Blockly.Block.prototype.getSurroundParent = function() {
469
- var block = this;
470
- do {
471
- var prevBlock = block;
472
- block = block.getParent();
473
- if (!block) {
474
- // Ran off the top.
475
- return null;
476
- }
477
- } while (block.getNextBlock() == prevBlock);
478
- // This block is an enclosing parent, not just a statement in a stack.
479
- return block;
480
- };
481
-
482
- /**
483
- * Return the next statement block directly connected to this block.
484
- * @return {Blockly.Block} The next statement block or null.
485
- */
486
- Blockly.Block.prototype.getNextBlock = function() {
487
- return this.nextConnection && this.nextConnection.targetBlock();
488
- };
489
-
490
- /**
491
- * Return the previous statement block directly connected to this block.
492
- * @return {Blockly.Block} The previous statement block or null.
493
- */
494
- Blockly.Block.prototype.getPreviousBlock = function() {
495
- return this.previousConnection && this.previousConnection.targetBlock();
496
- };
497
-
498
- /**
499
- * Return the connection on the first statement input on this block, or null if
500
- * there are none.
501
- * @return {Blockly.Connection} The first statement connection or null.
502
- */
503
- Blockly.Block.prototype.getFirstStatementConnection = function() {
504
- for (var i = 0, input; input = this.inputList[i]; i++) {
505
- if (input.connection && input.connection.type == Blockly.NEXT_STATEMENT) {
506
- return input.connection;
507
- }
508
- }
509
- return null;
510
- };
511
-
512
- /**
513
- * Return the top-most block in this block's tree.
514
- * This will return itself if this block is at the top level.
515
- * @return {!Blockly.Block} The root block.
516
- */
517
- Blockly.Block.prototype.getRootBlock = function() {
518
- var rootBlock;
519
- var block = this;
520
- do {
521
- rootBlock = block;
522
- block = rootBlock.parentBlock_;
523
- } while (block);
524
- return rootBlock;
525
- };
526
-
527
- /**
528
- * Find all the blocks that are directly nested inside this one.
529
- * Includes value and statement inputs, as well as any following statement.
530
- * Excludes any connection on an output tab or any preceding statement.
531
- * Blocks are optionally sorted by position; top to bottom.
532
- * @param {boolean} ordered Sort the list if true.
533
- * @return {!Array.<!Blockly.Block>} Array of blocks.
534
- */
535
- Blockly.Block.prototype.getChildren = function(ordered) {
536
- if (!ordered) {
537
- return this.childBlocks_;
538
- }
539
- var blocks = [];
540
- for (var i = 0, input; input = this.inputList[i]; i++) {
541
- if (input.connection) {
542
- var child = input.connection.targetBlock();
543
- if (child) {
544
- blocks.push(child);
545
- }
546
- }
547
- }
548
- var next = this.getNextBlock();
549
- if (next) {
550
- blocks.push(next);
551
- }
552
- return blocks;
553
- };
554
-
555
- /**
556
- * Set parent of this block to be a new block or null.
557
- * @param {Blockly.Block} newParent New parent block.
558
- */
559
- Blockly.Block.prototype.setParent = function(newParent) {
560
- if (newParent == this.parentBlock_) {
561
- return;
562
- }
563
- if (this.parentBlock_) {
564
- // Remove this block from the old parent's child list.
565
- goog.array.remove(this.parentBlock_.childBlocks_, this);
566
-
567
- // Disconnect from superior blocks.
568
- if (this.previousConnection && this.previousConnection.isConnected()) {
569
- throw 'Still connected to previous block.';
570
- }
571
- if (this.outputConnection && this.outputConnection.isConnected()) {
572
- throw 'Still connected to parent block.';
573
- }
574
- this.parentBlock_ = null;
575
- // This block hasn't actually moved on-screen, so there's no need to update
576
- // its connection locations.
577
- } else {
578
- // Remove this block from the workspace's list of top-most blocks.
579
- this.workspace.removeTopBlock(this);
580
- }
581
-
582
- this.parentBlock_ = newParent;
583
- if (newParent) {
584
- // Add this block to the new parent's child list.
585
- newParent.childBlocks_.push(this);
586
- } else {
587
- this.workspace.addTopBlock(this);
588
- }
589
- };
590
-
591
- /**
592
- * Find all the blocks that are directly or indirectly nested inside this one.
593
- * Includes this block in the list.
594
- * Includes value and statement inputs, as well as any following statements.
595
- * Excludes any connection on an output tab or any preceding statements.
596
- * Blocks are optionally sorted by position, top to bottom.
597
- * @param {boolean} ordered Sort the list if true.
598
- * @param {boolean=} opt_ignoreShadows If set, don't include shadow blocks.
599
- * @return {!Array.<!Blockly.Block>} Flattened array of blocks.
600
- */
601
- Blockly.Block.prototype.getDescendants = function(ordered, opt_ignoreShadows) {
602
- var blocks = [this];
603
- var childBlocks = this.getChildren(ordered);
604
- for (var child, i = 0; child = childBlocks[i]; i++) {
605
- if (!opt_ignoreShadows || !child.isShadow_) {
606
- blocks.push.apply(
607
- blocks, child.getDescendants(ordered, opt_ignoreShadows));
608
- }
609
- }
610
- return blocks;
611
- };
612
-
613
- /**
614
- * Get whether this block is deletable or not.
615
- * @return {boolean} True if deletable.
616
- */
617
- Blockly.Block.prototype.isDeletable = function() {
618
- return this.deletable_ && !this.isShadow_ &&
619
- !(this.workspace && this.workspace.options.readOnly);
620
- };
621
-
622
- /**
623
- * Set whether this block is deletable or not.
624
- * @param {boolean} deletable True if deletable.
625
- */
626
- Blockly.Block.prototype.setDeletable = function(deletable) {
627
- this.deletable_ = deletable;
628
- };
629
-
630
- /**
631
- * Get whether this block is movable or not.
632
- * @return {boolean} True if movable.
633
- */
634
- Blockly.Block.prototype.isMovable = function() {
635
- return this.movable_ && !this.isShadow_ &&
636
- !(this.workspace && this.workspace.options.readOnly);
637
- };
638
-
639
- /**
640
- * Set whether this block is movable or not.
641
- * @param {boolean} movable True if movable.
642
- */
643
- Blockly.Block.prototype.setMovable = function(movable) {
644
- this.movable_ = movable;
645
- };
646
-
647
- /**
648
- * Get whether this block is a shadow block or not.
649
- * @return {boolean} True if a shadow.
650
- */
651
- Blockly.Block.prototype.isShadow = function() {
652
- return this.isShadow_;
653
- };
654
-
655
- /**
656
- * Set whether this block is a shadow block or not.
657
- * @param {boolean} shadow True if a shadow.
658
- */
659
- Blockly.Block.prototype.setShadow = function(shadow) {
660
- this.isShadow_ = shadow;
661
- };
662
-
663
- /**
664
- * Get whether this block is an insertion marker block or not.
665
- * @return {boolean} True if an insertion marker.
666
- */
667
- Blockly.Block.prototype.isInsertionMarker = function() {
668
- return this.isInsertionMarker_;
669
- };
670
-
671
- /**
672
- * Set whether this block is an insertion marker block or not.
673
- * @param {boolean} insertionMarker True if an insertion marker.
674
- */
675
- Blockly.Block.prototype.setInsertionMarker = function(insertionMarker) {
676
- if (this.isInsertionMarker_ == insertionMarker) {
677
- return; // No change.
678
- }
679
- this.isInsertionMarker_ = insertionMarker;
680
- // TODO: handle removing insertion marker status.
681
- if (this.isInsertionMarker_) {
682
- this.setColour(Blockly.Colours.insertionMarker);
683
- this.setOpacity(Blockly.Colours.insertionMarkerOpacity);
684
- Blockly.utils.addClass(/** @type {!Element} */ (this.svgGroup_),
685
- 'blocklyInsertionMarker');
686
- }
687
- };
688
-
689
- /**
690
- * Get whether this block is editable or not.
691
- * @return {boolean} True if editable.
692
- */
693
- Blockly.Block.prototype.isEditable = function() {
694
- return this.editable_ && !(this.workspace && this.workspace.options.readOnly);
695
- };
696
-
697
- /**
698
- * Set whether this block is editable or not.
699
- * @param {boolean} editable True if editable.
700
- */
701
- Blockly.Block.prototype.setEditable = function(editable) {
702
- this.editable_ = editable;
703
- for (var i = 0, input; input = this.inputList[i]; i++) {
704
- for (var j = 0, field; field = input.fieldRow[j]; j++) {
705
- field.updateEditable();
706
- }
707
- }
708
- };
709
-
710
- /**
711
- * Set whether the connections are hidden (not tracked in a database) or not.
712
- * Recursively walk down all child blocks (except collapsed blocks).
713
- * @param {boolean} hidden True if connections are hidden.
714
- */
715
- Blockly.Block.prototype.setConnectionsHidden = function(hidden) {
716
- if (!hidden && this.isCollapsed()) {
717
- if (this.outputConnection) {
718
- this.outputConnection.setHidden(hidden);
719
- }
720
- if (this.previousConnection) {
721
- this.previousConnection.setHidden(hidden);
722
- }
723
- if (this.nextConnection) {
724
- this.nextConnection.setHidden(hidden);
725
- var child = this.nextConnection.targetBlock();
726
- if (child) {
727
- child.setConnectionsHidden(hidden);
728
- }
729
- }
730
- } else {
731
- var myConnections = this.getConnections_(true);
732
- for (var i = 0, connection; connection = myConnections[i]; i++) {
733
- connection.setHidden(hidden);
734
- if (connection.isSuperior()) {
735
- var child = connection.targetBlock();
736
- if (child) {
737
- child.setConnectionsHidden(hidden);
738
- }
739
- }
740
- }
741
- }
742
- };
743
-
744
- /**
745
- * Find the connection on this block that corresponds to the given connection
746
- * on the other block.
747
- * Used to match connections between a block and its insertion marker.
748
- * @param {!Blockly.Block} otherBlock The other block to match against.
749
- * @param {!Blockly.Connection} conn The other connection to match.
750
- * @return {Blockly.Connection} the matching connection on this block, or null.
751
- */
752
- Blockly.Block.prototype.getMatchingConnection = function(otherBlock, conn) {
753
- var connections = this.getConnections_(true);
754
- var otherConnections = otherBlock.getConnections_(true);
755
- if (connections.length != otherConnections.length) {
756
- throw "Connection lists did not match in length.";
757
- }
758
- for (var i = 0; i < otherConnections.length; i++) {
759
- if (otherConnections[i] == conn) {
760
- return connections[i];
761
- }
762
- }
763
- return null;
764
- };
765
-
766
- /**
767
- * Set the URL of this block's help page.
768
- * @param {string|Function} url URL string for block help, or function that
769
- * returns a URL. Null for no help.
770
- */
771
- Blockly.Block.prototype.setHelpUrl = function(url) {
772
- this.helpUrl = url;
773
- };
774
-
775
- /**
776
- * Change the tooltip text for a block.
777
- * @param {string|!Function} newTip Text for tooltip or a parent element to
778
- * link to for its tooltip. May be a function that returns a string.
779
- */
780
- Blockly.Block.prototype.setTooltip = function(newTip) {
781
- this.tooltip = newTip;
782
- };
783
-
784
- /**
785
- * Get the colour of a block.
786
- * @return {string} #RRGGBB string.
787
- */
788
- Blockly.Block.prototype.getColour = function() {
789
- return this.colour_;
790
- };
791
-
792
- /**
793
- * Get the secondary colour of a block.
794
- * @return {string} #RRGGBB string.
795
- */
796
- Blockly.Block.prototype.getColourSecondary = function() {
797
- return this.colourSecondary_;
798
- };
799
-
800
- /**
801
- * Get the tertiary colour of a block.
802
- * @return {string} #RRGGBB string.
803
- */
804
- Blockly.Block.prototype.getColourTertiary = function() {
805
- return this.colourTertiary_;
806
- };
807
-
808
- /**
809
- * Get the quaternary colour of a block.
810
- * @return {string} #RRGGBB string.
811
- */
812
- Blockly.Block.prototype.getColourQuaternary = function() {
813
- return this.colourQuaternary_;
814
- };
815
-
816
- /**
817
- * Get the shadow colour of a block.
818
- * @return {string} #RRGGBB string.
819
- */
820
- Blockly.Block.prototype.getShadowColour = function() {
821
- return this.shadowColour_;
822
- };
823
-
824
- /**
825
- * Set the shadow colour of a block.
826
- * @param {number|string} colour HSV hue value, or #RRGGBB string.
827
- */
828
- Blockly.Block.prototype.setShadowColour = function(colour) {
829
- this.shadowColour_ = this.makeColour_(colour);
830
- if (this.rendered) {
831
- this.updateColour();
832
- }
833
- };
834
-
835
- /**
836
- * Clear the shadow colour of a block.
837
- */
838
- Blockly.Block.prototype.clearShadowColour = function() {
839
- this.shadowColour_ = null;
840
- if (this.rendered) {
841
- this.updateColour();
842
- }
843
- };
844
-
845
- /**
846
- * Create an #RRGGBB string colour from a colour HSV hue value or #RRGGBB string.
847
- * @param {number|string} colour HSV hue value, or #RRGGBB string.
848
- * @return {string} #RRGGBB string.
849
- * @private
850
- */
851
- Blockly.Block.prototype.makeColour_ = function(colour) {
852
- var hue = Number(colour);
853
- if (!isNaN(hue)) {
854
- return Blockly.hueToRgb(hue);
855
- } else if (goog.isString(colour) && colour.match(/^#[0-9a-fA-F]{6}$/)) {
856
- return colour;
857
- } else {
858
- throw 'Invalid colour: ' + colour;
859
- }
860
- };
861
-
862
- /**
863
- * Change the colour of a block, and optional secondary/teriarty colours.
864
- * @param {number|string} colour HSV hue value, or #RRGGBB string.
865
- * @param {number|string} colourSecondary HSV hue value, or #RRGGBB string.
866
- * @param {number|string} colourTertiary HSV hue value, or #RRGGBB string.
867
- * @param {number|string} colourQuaternary HSV hue value, or #RRGGBB string.
868
- */
869
- Blockly.Block.prototype.setColour = function(colour, colourSecondary, colourTertiary,
870
- colourQuaternary) {
871
- this.colour_ = this.makeColour_(colour);
872
- if (colourSecondary !== undefined) {
873
- this.colourSecondary_ = this.makeColour_(colourSecondary);
874
- } else {
875
- this.colourSecondary_ = goog.color.rgbArrayToHex(
876
- goog.color.darken(goog.color.hexToRgb(this.colour_), 0.1));
877
- }
878
- if (colourTertiary !== undefined) {
879
- this.colourTertiary_ = this.makeColour_(colourTertiary);
880
- } else {
881
- this.colourTertiary_ = goog.color.rgbArrayToHex(
882
- goog.color.darken(goog.color.hexToRgb(this.colour_), 0.2));
883
- }
884
- if (colourQuaternary !== undefined) {
885
- this.colourQuaternary_ = this.makeColour_(colourQuaternary);
886
- } else {
887
- this.colourQuaternary_ = this.colourTertiary_;
888
- }
889
- if (this.rendered) {
890
- this.updateColour();
891
- }
892
- };
893
-
894
- /**
895
- * Sets a callback function to use whenever the block's parent workspace
896
- * changes, replacing any prior onchange handler. This is usually only called
897
- * from the constructor, the block type initializer function, or an extension
898
- * initializer function.
899
- * @param {function(Blockly.Events.Abstract)} onchangeFn The callback to call
900
- * when the block's workspace changes.
901
- * @throws {Error} if onchangeFn is not falsey or a function.
902
- */
903
- Blockly.Block.prototype.setOnChange = function(onchangeFn) {
904
- if (onchangeFn && !goog.isFunction(onchangeFn)) {
905
- throw new Error("onchange must be a function.");
906
- }
907
- if (this.onchangeWrapper_) {
908
- this.workspace.removeChangeListener(this.onchangeWrapper_);
909
- }
910
- this.onchange = onchangeFn;
911
- if (this.onchange) {
912
- this.onchangeWrapper_ = onchangeFn.bind(this);
913
- this.workspace.addChangeListener(this.onchangeWrapper_);
914
- }
915
- };
916
-
917
- /**
918
- * Returns the named field from a block.
919
- * @param {string} name The name of the field.
920
- * @return {Blockly.Field} Named field, or null if field does not exist.
921
- */
922
- Blockly.Block.prototype.getField = function(name) {
923
- for (var i = 0, input; input = this.inputList[i]; i++) {
924
- for (var j = 0, field; field = input.fieldRow[j]; j++) {
925
- if (field.name === name) {
926
- return field;
927
- }
928
- }
929
- }
930
- return null;
931
- };
932
-
933
- /**
934
- * Return all variables referenced by this block.
935
- * @return {!Array.<string>} List of variable names.
936
- * @package
937
- */
938
- Blockly.Block.prototype.getVars = function() {
939
- var vars = [];
940
- for (var i = 0, input; input = this.inputList[i]; i++) {
941
- for (var j = 0, field; field = input.fieldRow[j]; j++) {
942
- if (field.referencesVariables()) {
943
- vars.push(field.getValue());
944
- }
945
- }
946
- }
947
- return vars;
948
- };
949
-
950
- /**
951
- * Return all variables referenced by this block.
952
- * @return {!Array.<!Blockly.VariableModel>} List of variable models.
953
- * @package
954
- */
955
- Blockly.Block.prototype.getVarModels = function() {
956
- var vars = [];
957
- for (var i = 0, input; input = this.inputList[i]; i++) {
958
- for (var j = 0, field; field = input.fieldRow[j]; j++) {
959
- if (field.referencesVariables()) {
960
- var model = this.workspace.getVariableById(field.getValue());
961
- // Check if the variable actually exists (and isn't just a potential
962
- // variable).
963
- if (model) {
964
- vars.push(model);
965
- }
966
- }
967
- }
968
- }
969
- return vars;
970
- };
971
-
972
- /**
973
- * Notification that a variable is renaming but keeping the same ID. If the
974
- * variable is in use on this block, rerender to show the new name.
975
- * @param {!Blockly.VariableModel} variable The variable being renamed.
976
- * @package
977
- */
978
- Blockly.Block.prototype.updateVarName = function(variable) {
979
- for (var i = 0, input; input = this.inputList[i]; i++) {
980
- for (var j = 0, field; field = input.fieldRow[j]; j++) {
981
- if (field.referencesVariables() &&
982
- variable.getId() == field.getValue()) {
983
- field.setText(variable.name);
984
- }
985
- }
986
- }
987
- };
988
-
989
- /**
990
- * Notification that a variable is renaming.
991
- * If the ID matches one of this block's variables, rename it.
992
- * @param {string} oldId ID of variable to rename.
993
- * @param {string} newId ID of new variable. May be the same as oldId, but with
994
- * an updated name.
995
- */
996
- Blockly.Block.prototype.renameVarById = function(oldId, newId) {
997
- for (var i = 0, input; input = this.inputList[i]; i++) {
998
- for (var j = 0, field; field = input.fieldRow[j]; j++) {
999
- if (field.referencesVariables() &&
1000
- oldId == field.getValue()) {
1001
- field.setValue(newId);
1002
- }
1003
- }
1004
- }
1005
- };
1006
-
1007
- /**
1008
- * Returns the language-neutral value from the field of a block.
1009
- * @param {string} name The name of the field.
1010
- * @return {?string} Value from the field or null if field does not exist.
1011
- */
1012
- Blockly.Block.prototype.getFieldValue = function(name) {
1013
- var field = this.getField(name);
1014
- if (field) {
1015
- return field.getValue();
1016
- }
1017
- return null;
1018
- };
1019
-
1020
- /**
1021
- * Change the field value for a block (e.g. 'CHOOSE' or 'REMOVE').
1022
- * @param {string} newValue Value to be the new field.
1023
- * @param {string} name The name of the field.
1024
- */
1025
- Blockly.Block.prototype.setFieldValue = function(newValue, name) {
1026
- var field = this.getField(name);
1027
- goog.asserts.assertObject(field, 'Field "%s" not found.', name);
1028
- field.setValue(newValue);
1029
- };
1030
-
1031
- /**
1032
- * Set whether this block can chain onto the bottom of another block.
1033
- * @param {boolean} newBoolean True if there can be a previous statement.
1034
- * @param {(string|Array.<string>|null)=} opt_check Statement type or
1035
- * list of statement types. Null/undefined if any type could be connected.
1036
- */
1037
- Blockly.Block.prototype.setPreviousStatement = function(newBoolean, opt_check) {
1038
- if (newBoolean) {
1039
- if (opt_check === undefined) {
1040
- opt_check = null;
1041
- }
1042
- if (!this.previousConnection) {
1043
- goog.asserts.assert(!this.outputConnection,
1044
- 'Remove output connection prior to adding previous connection.');
1045
- this.previousConnection =
1046
- this.makeConnection_(Blockly.PREVIOUS_STATEMENT);
1047
- }
1048
- this.previousConnection.setCheck(opt_check);
1049
- } else {
1050
- if (this.previousConnection) {
1051
- goog.asserts.assert(!this.previousConnection.isConnected(),
1052
- 'Must disconnect previous statement before removing connection.');
1053
- this.previousConnection.dispose();
1054
- this.previousConnection = null;
1055
- }
1056
- }
1057
- };
1058
-
1059
- /**
1060
- * Set whether another block can chain onto the bottom of this block.
1061
- * @param {boolean} newBoolean True if there can be a next statement.
1062
- * @param {(string|Array.<string>|null)=} opt_check Statement type or
1063
- * list of statement types. Null/undefined if any type could be connected.
1064
- */
1065
- Blockly.Block.prototype.setNextStatement = function(newBoolean, opt_check) {
1066
- if (newBoolean) {
1067
- if (opt_check === undefined) {
1068
- opt_check = null;
1069
- }
1070
- if (!this.nextConnection) {
1071
- this.nextConnection = this.makeConnection_(Blockly.NEXT_STATEMENT);
1072
- }
1073
- this.nextConnection.setCheck(opt_check);
1074
- } else {
1075
- if (this.nextConnection) {
1076
- goog.asserts.assert(!this.nextConnection.isConnected(),
1077
- 'Must disconnect next statement before removing connection.');
1078
- this.nextConnection.dispose();
1079
- this.nextConnection = null;
1080
- }
1081
- }
1082
- };
1083
-
1084
- /**
1085
- * Set whether this block returns a value.
1086
- * @param {boolean} newBoolean True if there is an output.
1087
- * @param {(string|Array.<string>|null)=} opt_check Returned type or list
1088
- * of returned types. Null or undefined if any type could be returned
1089
- * (e.g. variable get).
1090
- */
1091
- Blockly.Block.prototype.setOutput = function(newBoolean, opt_check) {
1092
- if (newBoolean) {
1093
- if (opt_check === undefined) {
1094
- opt_check = null;
1095
- }
1096
- if (!this.outputConnection) {
1097
- goog.asserts.assert(!this.previousConnection,
1098
- 'Remove previous connection prior to adding output connection.');
1099
- this.outputConnection = this.makeConnection_(Blockly.OUTPUT_VALUE);
1100
- }
1101
- this.outputConnection.setCheck(opt_check);
1102
- } else {
1103
- if (this.outputConnection) {
1104
- goog.asserts.assert(!this.outputConnection.isConnected(),
1105
- 'Must disconnect output value before removing connection.');
1106
- this.outputConnection.dispose();
1107
- this.outputConnection = null;
1108
- }
1109
- }
1110
- };
1111
-
1112
- /**
1113
- * Set whether value inputs are arranged horizontally or vertically.
1114
- * @param {boolean} newBoolean True if inputs are horizontal.
1115
- */
1116
- Blockly.Block.prototype.setInputsInline = function(newBoolean) {
1117
- if (this.inputsInline != newBoolean) {
1118
- Blockly.Events.fire(new Blockly.Events.BlockChange(
1119
- this, 'inline', null, this.inputsInline, newBoolean));
1120
- this.inputsInline = newBoolean;
1121
- }
1122
- };
1123
-
1124
- /**
1125
- * Get whether value inputs are arranged horizontally or vertically.
1126
- * @return {boolean} True if inputs are horizontal.
1127
- */
1128
- Blockly.Block.prototype.getInputsInline = function() {
1129
- if (this.inputsInline != undefined) {
1130
- // Set explicitly.
1131
- return this.inputsInline;
1132
- }
1133
- // Not defined explicitly. Figure out what would look best.
1134
- for (var i = 1; i < this.inputList.length; i++) {
1135
- if (this.inputList[i - 1].type == Blockly.DUMMY_INPUT &&
1136
- this.inputList[i].type == Blockly.DUMMY_INPUT) {
1137
- // Two dummy inputs in a row. Don't inline them.
1138
- return false;
1139
- }
1140
- }
1141
- for (var i = 1; i < this.inputList.length; i++) {
1142
- if (this.inputList[i - 1].type == Blockly.INPUT_VALUE &&
1143
- this.inputList[i].type == Blockly.DUMMY_INPUT) {
1144
- // Dummy input after a value input. Inline them.
1145
- return true;
1146
- }
1147
- }
1148
- return false;
1149
- };
1150
-
1151
- /**
1152
- * Set whether the block is disabled or not.
1153
- * @param {boolean} disabled True if disabled.
1154
- */
1155
- Blockly.Block.prototype.setDisabled = function(disabled) {
1156
- if (this.disabled != disabled) {
1157
- Blockly.Events.fire(new Blockly.Events.BlockChange(
1158
- this, 'disabled', null, this.disabled, disabled));
1159
- this.disabled = disabled;
1160
- }
1161
- };
1162
-
1163
- /**
1164
- * Get whether the block is disabled or not due to parents.
1165
- * The block's own disabled property is not considered.
1166
- * @return {boolean} True if disabled.
1167
- */
1168
- Blockly.Block.prototype.getInheritedDisabled = function() {
1169
- var ancestor = this.getSurroundParent();
1170
- while (ancestor) {
1171
- if (ancestor.disabled) {
1172
- return true;
1173
- }
1174
- ancestor = ancestor.getSurroundParent();
1175
- }
1176
- // Ran off the top.
1177
- return false;
1178
- };
1179
-
1180
- /**
1181
- * Get whether the block is collapsed or not.
1182
- * @return {boolean} True if collapsed.
1183
- */
1184
- Blockly.Block.prototype.isCollapsed = function() {
1185
- return this.collapsed_;
1186
- };
1187
-
1188
- /**
1189
- * Set whether the block is collapsed or not.
1190
- * @param {boolean} collapsed True if collapsed.
1191
- */
1192
- Blockly.Block.prototype.setCollapsed = function(collapsed) {
1193
- if (this.collapsed_ != collapsed) {
1194
- Blockly.Events.fire(new Blockly.Events.BlockChange(
1195
- this, 'collapsed', null, this.collapsed_, collapsed));
1196
- this.collapsed_ = collapsed;
1197
- }
1198
- };
1199
-
1200
- /**
1201
- * Create a human-readable text representation of this block and any children.
1202
- * @param {number=} opt_maxLength Truncate the string to this length.
1203
- * @param {string=} opt_emptyToken The placeholder string used to denote an
1204
- * empty field. If not specified, '?' is used.
1205
- * @return {string} Text of block.
1206
- */
1207
- Blockly.Block.prototype.toString = function(opt_maxLength, opt_emptyToken) {
1208
- var text = [];
1209
- var emptyFieldPlaceholder = opt_emptyToken || '?';
1210
- if (this.collapsed_) {
1211
- text.push(this.getInput('_TEMP_COLLAPSED_INPUT').fieldRow[0].text_);
1212
- } else {
1213
- for (var i = 0, input; input = this.inputList[i]; i++) {
1214
- for (var j = 0, field; field = input.fieldRow[j]; j++) {
1215
- if (field instanceof Blockly.FieldDropdown && !field.getValue()) {
1216
- text.push(emptyFieldPlaceholder);
1217
- } else {
1218
- text.push(field.getText());
1219
- }
1220
- }
1221
- if (input.connection) {
1222
- var child = input.connection.targetBlock();
1223
- if (child) {
1224
- text.push(child.toString(undefined, opt_emptyToken));
1225
- } else {
1226
- text.push(emptyFieldPlaceholder);
1227
- }
1228
- }
1229
- }
1230
- }
1231
- text = goog.string.trim(text.join(' ')) || '???';
1232
- if (opt_maxLength) {
1233
- // TODO: Improve truncation so that text from this block is given priority.
1234
- // 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...".
1235
- // E.g. "1+2+3+4+5=6+7+8+9+0" should be "...4+5=6+7...".
1236
- text = goog.string.truncate(text, opt_maxLength);
1237
- }
1238
- return text;
1239
- };
1240
-
1241
- /**
1242
- * Shortcut for appending a value input row.
1243
- * @param {string} name Language-neutral identifier which may used to find this
1244
- * input again. Should be unique to this block.
1245
- * @return {!Blockly.Input} The input object created.
1246
- */
1247
- Blockly.Block.prototype.appendValueInput = function(name) {
1248
- return this.appendInput_(Blockly.INPUT_VALUE, name);
1249
- };
1250
-
1251
- /**
1252
- * Shortcut for appending a statement input row.
1253
- * @param {string} name Language-neutral identifier which may used to find this
1254
- * input again. Should be unique to this block.
1255
- * @return {!Blockly.Input} The input object created.
1256
- */
1257
- Blockly.Block.prototype.appendStatementInput = function(name) {
1258
- return this.appendInput_(Blockly.NEXT_STATEMENT, name);
1259
- };
1260
-
1261
- /**
1262
- * Shortcut for appending a dummy input row.
1263
- * @param {string=} opt_name Language-neutral identifier which may used to find
1264
- * this input again. Should be unique to this block.
1265
- * @return {!Blockly.Input} The input object created.
1266
- */
1267
- Blockly.Block.prototype.appendDummyInput = function(opt_name) {
1268
- return this.appendInput_(Blockly.DUMMY_INPUT, opt_name || '');
1269
- };
1270
-
1271
- /**
1272
- * Initialize this block using a cross-platform, internationalization-friendly
1273
- * JSON description.
1274
- * @param {!Object} json Structured data describing the block.
1275
- */
1276
- Blockly.Block.prototype.jsonInit = function(json) {
1277
- var warningPrefix = json['type'] ? 'Block "' + json['type'] + '": ' : '';
1278
-
1279
- // Validate inputs.
1280
- goog.asserts.assert(
1281
- json['output'] == undefined || json['previousStatement'] == undefined,
1282
- warningPrefix + 'Must not have both an output and a previousStatement.');
1283
-
1284
- // Set basic properties of block.
1285
- if (json['colour'] !== undefined) {
1286
- this.setColourFromJson_(json);
1287
- }
1288
-
1289
- // Interpolate the message blocks.
1290
- var i = 0;
1291
- while (json['message' + i] !== undefined) {
1292
- this.interpolate_(json['message' + i], json['args' + i] || [],
1293
- json['lastDummyAlign' + i]);
1294
- i++;
1295
- }
1296
-
1297
- if (json['inputsInline'] !== undefined) {
1298
- this.setInputsInline(json['inputsInline']);
1299
- }
1300
- // Set output and previous/next connections.
1301
- if (json['output'] !== undefined) {
1302
- this.setOutput(true, json['output']);
1303
- }
1304
- if (json['previousStatement'] !== undefined) {
1305
- this.setPreviousStatement(true, json['previousStatement']);
1306
- }
1307
- if (json['nextStatement'] !== undefined) {
1308
- this.setNextStatement(true, json['nextStatement']);
1309
- }
1310
- if (json['tooltip'] !== undefined) {
1311
- var rawValue = json['tooltip'];
1312
- var localizedText = Blockly.utils.replaceMessageReferences(rawValue);
1313
- this.setTooltip(localizedText);
1314
- }
1315
- if (json['enableContextMenu'] !== undefined) {
1316
- var rawValue = json['enableContextMenu'];
1317
- this.contextMenu = !!rawValue;
1318
- }
1319
- if (json['helpUrl'] !== undefined) {
1320
- var rawValue = json['helpUrl'];
1321
- var localizedValue = Blockly.utils.replaceMessageReferences(rawValue);
1322
- this.setHelpUrl(localizedValue);
1323
- }
1324
- if (goog.isString(json['extensions'])) {
1325
- console.warn('JSON attribute \'extensions\' should be an array of ' +
1326
- 'strings. Found raw string in JSON for \'' + json['type'] + '\' block.');
1327
- json['extensions'] = [json['extensions']]; // Correct and continue.
1328
- }
1329
-
1330
- // Add the mutator to the block
1331
- if (json['mutator'] !== undefined) {
1332
- Blockly.Extensions.apply(json['mutator'], this, true);
1333
- }
1334
-
1335
- if (Array.isArray(json['extensions'])) {
1336
- var extensionNames = json['extensions'];
1337
- for (var i = 0; i < extensionNames.length; ++i) {
1338
- var extensionName = extensionNames[i];
1339
- Blockly.Extensions.apply(extensionName, this, false);
1340
- }
1341
- }
1342
- if (json['outputShape'] !== undefined) {
1343
- this.setOutputShape(json['outputShape']);
1344
- }
1345
- if (json['checkboxInFlyout'] !== undefined) {
1346
- this.setCheckboxInFlyout(json['checkboxInFlyout']);
1347
- }
1348
- if (json['category'] !== undefined) {
1349
- this.setCategory(json['category']);
1350
- }
1351
- };
1352
-
1353
- /**
1354
- * Add key/values from mixinObj to this block object. By default, this method
1355
- * will check that the keys in mixinObj will not overwrite existing values in
1356
- * the block, including prototype values. This provides some insurance against
1357
- * mixin / extension incompatibilities with future block features. This check
1358
- * can be disabled by passing true as the second argument.
1359
- * @param {!Object} mixinObj The key/values pairs to add to this block object.
1360
- * @param {boolean=} opt_disableCheck Option flag to disable overwrite checks.
1361
- */
1362
- Blockly.Block.prototype.mixin = function(mixinObj, opt_disableCheck) {
1363
- if (goog.isDef(opt_disableCheck) && !goog.isBoolean(opt_disableCheck)) {
1364
- throw new Error("opt_disableCheck must be a boolean if provided");
1365
- }
1366
- if (!opt_disableCheck) {
1367
- var overwrites = [];
1368
- for (var key in mixinObj) {
1369
- if (this[key] !== undefined) {
1370
- overwrites.push(key);
1371
- }
1372
- }
1373
- if (overwrites.length) {
1374
- throw new Error('Mixin will overwrite block members: ' +
1375
- JSON.stringify(overwrites));
1376
- }
1377
- }
1378
- goog.mixin(this, mixinObj);
1379
- };
1380
-
1381
- /**
1382
- * Set the colour of the block from strings or string table references.
1383
- * @param {string|?} primary Primary colour, which may be a string that contains
1384
- * string table references.
1385
- * @param {string|?} secondary Secondary colour, which may be a string that
1386
- * contains string table references.
1387
- * @param {string|?} tertiary Tertiary colour, which may be a string that
1388
- * contains string table references.
1389
- * @param {string|?} quaternary Quaternary colour, which may be a string that
1390
- * contains string table references.
1391
- * @private
1392
- */
1393
- Blockly.Block.prototype.setColourFromRawValues_ = function(primary, secondary,
1394
- tertiary, quaternary) {
1395
- primary = goog.isString(primary) ?
1396
- Blockly.utils.replaceMessageReferences(primary) : primary;
1397
- secondary = goog.isString(secondary) ?
1398
- Blockly.utils.replaceMessageReferences(secondary) : secondary;
1399
- tertiary = goog.isString(tertiary) ?
1400
- Blockly.utils.replaceMessageReferences(tertiary) : tertiary;
1401
- quaternary = goog.isString(quaternary) ?
1402
- Blockly.utils.replaceMessageReferences(quaternary) : quaternary;
1403
-
1404
- this.setColour(primary, secondary, tertiary, quaternary);
1405
- };
1406
-
1407
- /**
1408
- * Set the colour of the block from JSON, replacing message references as
1409
- * needed.
1410
- * @param {!Object} json Structured data describing the block.
1411
- * @private
1412
- */
1413
- Blockly.Block.prototype.setColourFromJson_ = function(json) {
1414
- this.setColourFromRawValues_(json['colour'], json['colourSecondary'],
1415
- json['colourTertiary'], json['colourQuaternary']);
1416
- };
1417
-
1418
- /**
1419
- * Interpolate a message description onto the block.
1420
- * @param {string} message Text contains interpolation tokens (%1, %2, ...)
1421
- * that match with fields or inputs defined in the args array.
1422
- * @param {!Array} args Array of arguments to be interpolated.
1423
- * @param {string=} lastDummyAlign If a dummy input is added at the end,
1424
- * how should it be aligned?
1425
- * @private
1426
- */
1427
- Blockly.Block.prototype.interpolate_ = function(message, args, lastDummyAlign) {
1428
- var tokens = Blockly.utils.tokenizeInterpolation(message);
1429
- // Interpolate the arguments. Build a list of elements.
1430
- var indexDup = [];
1431
- var indexCount = 0;
1432
- var elements = [];
1433
- for (var i = 0; i < tokens.length; i++) {
1434
- var token = tokens[i];
1435
- if (typeof token == 'number') {
1436
- if (token <= 0 || token > args.length) {
1437
- throw new Error('Block "' + this.type + '": ' +
1438
- 'Message index %' + token + ' out of range.');
1439
- }
1440
- if (indexDup[token]) {
1441
- throw new Error('Block "' + this.type + '": ' +
1442
- 'Message index %' + token + ' duplicated.');
1443
- }
1444
- indexDup[token] = true;
1445
- indexCount++;
1446
- elements.push(args[token - 1]);
1447
- } else {
1448
- token = token.trim();
1449
- if (token) {
1450
- elements.push(token);
1451
- }
1452
- }
1453
- }
1454
- if (indexCount != args.length) {
1455
- throw new Error('Block "' + this.type + '": ' +
1456
- 'Message does not reference all ' + args.length + ' arg(s).');
1457
- }
1458
- // Add last dummy input if needed.
1459
- if (elements.length && (typeof elements[elements.length - 1] == 'string' ||
1460
- goog.string.startsWith(
1461
- elements[elements.length - 1]['type'], 'field_'))) {
1462
- var dummyInput = {type: 'input_dummy'};
1463
- if (lastDummyAlign) {
1464
- dummyInput['align'] = lastDummyAlign;
1465
- }
1466
- elements.push(dummyInput);
1467
- }
1468
- // Lookup of alignment constants.
1469
- var alignmentLookup = {
1470
- 'LEFT': Blockly.ALIGN_LEFT,
1471
- 'RIGHT': Blockly.ALIGN_RIGHT,
1472
- 'CENTRE': Blockly.ALIGN_CENTRE
1473
- };
1474
- // Populate block with inputs and fields.
1475
- var fieldStack = [];
1476
- for (var i = 0; i < elements.length; i++) {
1477
- var element = elements[i];
1478
- if (typeof element == 'string') {
1479
- fieldStack.push([element, undefined]);
1480
- } else {
1481
- var field = null;
1482
- var input = null;
1483
- do {
1484
- var altRepeat = false;
1485
- if (typeof element == 'string') {
1486
- field = new Blockly.FieldLabel(element);
1487
- } else {
1488
- switch (element['type']) {
1489
- case 'input_value':
1490
- input = this.appendValueInput(element['name']);
1491
- break;
1492
- case 'input_statement':
1493
- input = this.appendStatementInput(element['name']);
1494
- break;
1495
- case 'input_dummy':
1496
- input = this.appendDummyInput(element['name']);
1497
- break;
1498
- default:
1499
- field = Blockly.Field.fromJson(element);
1500
-
1501
- // Unknown field.
1502
- if (!field) {
1503
- if (element['alt']) {
1504
- element = element['alt'];
1505
- altRepeat = true;
1506
- } else {
1507
- console.warn('Blockly could not create a field of type ' +
1508
- element['type'] +
1509
- '. You may need to register your custom field. See ' +
1510
- 'github.com/google/blockly/issues/1584');
1511
- }
1512
- }
1513
- }
1514
- }
1515
- } while (altRepeat);
1516
- if (field) {
1517
- fieldStack.push([field, element['name']]);
1518
- } else if (input) {
1519
- if (element['check']) {
1520
- input.setCheck(element['check']);
1521
- }
1522
- if (element['align']) {
1523
- input.setAlign(alignmentLookup[element['align']]);
1524
- }
1525
- for (var j = 0; j < fieldStack.length; j++) {
1526
- input.appendField(fieldStack[j][0], fieldStack[j][1]);
1527
- }
1528
- fieldStack.length = 0;
1529
- }
1530
- }
1531
- }
1532
- };
1533
-
1534
- /**
1535
- * Add a value input, statement input or local variable to this block.
1536
- * @param {number} type Either Blockly.INPUT_VALUE or Blockly.NEXT_STATEMENT or
1537
- * Blockly.DUMMY_INPUT.
1538
- * @param {string} name Language-neutral identifier which may used to find this
1539
- * input again. Should be unique to this block.
1540
- * @return {!Blockly.Input} The input object created.
1541
- * @protected
1542
- */
1543
- Blockly.Block.prototype.appendInput_ = function(type, name) {
1544
- var connection = null;
1545
- if (type == Blockly.INPUT_VALUE || type == Blockly.NEXT_STATEMENT) {
1546
- connection = this.makeConnection_(type);
1547
- }
1548
- var input = new Blockly.Input(type, name, this, connection);
1549
- // Append input to list.
1550
- this.inputList.push(input);
1551
- return input;
1552
- };
1553
-
1554
- /**
1555
- * Move a named input to a different location on this block.
1556
- * @param {string} name The name of the input to move.
1557
- * @param {?string} refName Name of input that should be after the moved input,
1558
- * or null to be the input at the end.
1559
- */
1560
- Blockly.Block.prototype.moveInputBefore = function(name, refName) {
1561
- if (name == refName) {
1562
- return;
1563
- }
1564
- // Find both inputs.
1565
- var inputIndex = -1;
1566
- var refIndex = refName ? -1 : this.inputList.length;
1567
- for (var i = 0, input; input = this.inputList[i]; i++) {
1568
- if (input.name == name) {
1569
- inputIndex = i;
1570
- if (refIndex != -1) {
1571
- break;
1572
- }
1573
- } else if (refName && input.name == refName) {
1574
- refIndex = i;
1575
- if (inputIndex != -1) {
1576
- break;
1577
- }
1578
- }
1579
- }
1580
- goog.asserts.assert(inputIndex != -1, 'Named input "%s" not found.', name);
1581
- goog.asserts.assert(
1582
- refIndex != -1, 'Reference input "%s" not found.', refName);
1583
- this.moveNumberedInputBefore(inputIndex, refIndex);
1584
- };
1585
-
1586
- /**
1587
- * Move a numbered input to a different location on this block.
1588
- * @param {number} inputIndex Index of the input to move.
1589
- * @param {number} refIndex Index of input that should be after the moved input.
1590
- */
1591
- Blockly.Block.prototype.moveNumberedInputBefore = function(
1592
- inputIndex, refIndex) {
1593
- // Validate arguments.
1594
- goog.asserts.assert(inputIndex != refIndex, 'Can\'t move input to itself.');
1595
- goog.asserts.assert(inputIndex < this.inputList.length,
1596
- 'Input index ' + inputIndex + ' out of bounds.');
1597
- goog.asserts.assert(refIndex <= this.inputList.length,
1598
- 'Reference input ' + refIndex + ' out of bounds.');
1599
- // Remove input.
1600
- var input = this.inputList[inputIndex];
1601
- this.inputList.splice(inputIndex, 1);
1602
- if (inputIndex < refIndex) {
1603
- refIndex--;
1604
- }
1605
- // Reinsert input.
1606
- this.inputList.splice(refIndex, 0, input);
1607
- };
1608
-
1609
- /**
1610
- * Remove an input from this block.
1611
- * @param {string} name The name of the input.
1612
- * @param {boolean=} opt_quiet True to prevent error if input is not present.
1613
- * @throws {goog.asserts.AssertionError} if the input is not present and
1614
- * opt_quiet is not true.
1615
- */
1616
- Blockly.Block.prototype.removeInput = function(name, opt_quiet) {
1617
- for (var i = 0, input; input = this.inputList[i]; i++) {
1618
- if (input.name == name) {
1619
- if (input.connection && input.connection.isConnected()) {
1620
- input.connection.setShadowDom(null);
1621
- var block = input.connection.targetBlock();
1622
- if (block.isShadow()) {
1623
- // Destroy any attached shadow block.
1624
- block.dispose();
1625
- } else {
1626
- // Disconnect any attached normal block.
1627
- block.unplug();
1628
- }
1629
- }
1630
- input.dispose();
1631
- this.inputList.splice(i, 1);
1632
- return;
1633
- }
1634
- }
1635
- if (!opt_quiet) {
1636
- goog.asserts.fail('Input "%s" not found.', name);
1637
- }
1638
- };
1639
-
1640
- /**
1641
- * Fetches the named input object.
1642
- * @param {string} name The name of the input.
1643
- * @return {Blockly.Input} The input object, or null if input does not exist.
1644
- */
1645
- Blockly.Block.prototype.getInput = function(name) {
1646
- for (var i = 0, input; input = this.inputList[i]; i++) {
1647
- if (input.name == name) {
1648
- return input;
1649
- }
1650
- }
1651
- // This input does not exist.
1652
- return null;
1653
- };
1654
-
1655
- /**
1656
- * Fetches the block attached to the named input.
1657
- * @param {string} name The name of the input.
1658
- * @return {Blockly.Block} The attached value block, or null if the input is
1659
- * either disconnected or if the input does not exist.
1660
- */
1661
- Blockly.Block.prototype.getInputTargetBlock = function(name) {
1662
- var input = this.getInput(name);
1663
- return input && input.connection && input.connection.targetBlock();
1664
- };
1665
-
1666
- /**
1667
- * Returns the comment on this block (or '' if none).
1668
- * @return {string} Block's comment.
1669
- */
1670
- Blockly.Block.prototype.getCommentText = function() {
1671
- return this.comment || '';
1672
- };
1673
-
1674
- /**
1675
- * Set this block's comment text.
1676
- * @param {?string} text The text, or null to delete.
1677
- */
1678
- Blockly.Block.prototype.setCommentText = function(text) {
1679
- if (this.comment != text) {
1680
- Blockly.Events.fire(new Blockly.Events.BlockChange(
1681
- this, 'comment', null, this.comment, text || ''));
1682
- this.comment = text;
1683
- }
1684
- };
1685
-
1686
- /**
1687
- * Set this block's output shape.
1688
- * e.g., null, OUTPUT_SHAPE_HEXAGONAL, OUTPUT_SHAPE_ROUND, OUTPUT_SHAPE_SQUARE.
1689
- * @param {?number} outputShape Value representing output shape
1690
- * (see constants.js).
1691
- */
1692
- Blockly.Block.prototype.setOutputShape = function(outputShape) {
1693
- this.outputShape_ = outputShape;
1694
- };
1695
-
1696
- /**
1697
- * Get this block's output shape.
1698
- * @return {?number} Value representing output shape (see constants.js).
1699
- */
1700
- Blockly.Block.prototype.getOutputShape = function() {
1701
- return this.outputShape_;
1702
- };
1703
-
1704
- /**
1705
- * Set this block's category (for styling purposes)
1706
- * @param {?string} category The block's category (see constants.js).
1707
- */
1708
- Blockly.Block.prototype.setCategory = function(category) {
1709
- this.category_ = category;
1710
- };
1711
-
1712
- /**
1713
- * Get this block's category (for styling purposes)
1714
- * @return {?string} category The block's category (see constants.js).
1715
- */
1716
- Blockly.Block.prototype.getCategory = function() {
1717
- return this.category_;
1718
- };
1719
-
1720
- /**
1721
- * Set whether this block has a checkbox next to it in the flyout.
1722
- * @param {boolean} hasCheckbox True if this block should have a checkbox.
1723
- */
1724
- Blockly.Block.prototype.setCheckboxInFlyout = function(hasCheckbox) {
1725
- this.checkboxInFlyout_ = hasCheckbox;
1726
- };
1727
-
1728
- /**
1729
- * Get whether this block has a checkbox next to it in the flyout.
1730
- * @return {boolean} True if this block should have a checkbox.
1731
- */
1732
- Blockly.Block.prototype.hasCheckboxInFlyout = function() {
1733
- return this.checkboxInFlyout_;
1734
- };
1735
-
1736
- /**
1737
- * Set this block's warning text.
1738
- * @param {?string} text The text, or null to delete.
1739
- * @abstract
1740
- */
1741
- Blockly.Block.prototype.setWarningText = function(/* text */) {
1742
- // NOP.
1743
- };
1744
-
1745
- /**
1746
- * Give this block a mutator dialog.
1747
- * @param {Blockly.Mutator} mutator A mutator dialog instance or null to remove.
1748
- * @abstract
1749
- */
1750
- Blockly.Block.prototype.setMutator = function(/* mutator */) {
1751
- // NOP.
1752
- };
1753
-
1754
- /**
1755
- * Return the coordinates of the top-left corner of this block relative to the
1756
- * drawing surface's origin (0,0), in workspace units.
1757
- * @return {!goog.math.Coordinate} Object with .x and .y properties.
1758
- */
1759
- Blockly.Block.prototype.getRelativeToSurfaceXY = function() {
1760
- return this.xy_;
1761
- };
1762
-
1763
- /**
1764
- * Move a block by a relative offset.
1765
- * @param {number} dx Horizontal offset, in workspace units.
1766
- * @param {number} dy Vertical offset, in workspace units.
1767
- */
1768
- Blockly.Block.prototype.moveBy = function(dx, dy) {
1769
- goog.asserts.assert(!this.parentBlock_, 'Block has parent.');
1770
- var event = new Blockly.Events.BlockMove(this);
1771
- this.xy_.translate(dx, dy);
1772
- event.recordNew();
1773
- Blockly.Events.fire(event);
1774
- };
1775
-
1776
- /**
1777
- * Create a connection of the specified type.
1778
- * @param {number} type The type of the connection to create.
1779
- * @return {!Blockly.Connection} A new connection of the specified type.
1780
- * @private
1781
- */
1782
- Blockly.Block.prototype.makeConnection_ = function(type) {
1783
- return new Blockly.Connection(this, type);
1784
- };
1785
-
1786
- /**
1787
- * Recursively checks whether all statement and value inputs are filled with
1788
- * blocks. Also checks all following statement blocks in this stack.
1789
- * @param {boolean=} opt_shadowBlocksAreFilled An optional argument controlling
1790
- * whether shadow blocks are counted as filled. Defaults to true.
1791
- * @return {boolean} True if all inputs are filled, false otherwise.
1792
- */
1793
- Blockly.Block.prototype.allInputsFilled = function(opt_shadowBlocksAreFilled) {
1794
- // Account for the shadow block filledness toggle.
1795
- if (opt_shadowBlocksAreFilled === undefined) {
1796
- opt_shadowBlocksAreFilled = true;
1797
- }
1798
- if (!opt_shadowBlocksAreFilled && this.isShadow()) {
1799
- return false;
1800
- }
1801
-
1802
- // Recursively check each input block of the current block.
1803
- for (var i = 0, input; input = this.inputList[i]; i++) {
1804
- if (!input.connection) {
1805
- continue;
1806
- }
1807
- var target = input.connection.targetBlock();
1808
- if (!target || !target.allInputsFilled(opt_shadowBlocksAreFilled)) {
1809
- return false;
1810
- }
1811
- }
1812
-
1813
- // Recursively check the next block after the current block.
1814
- var next = this.getNextBlock();
1815
- if (next) {
1816
- return next.allInputsFilled(opt_shadowBlocksAreFilled);
1817
- }
1818
-
1819
- return true;
1820
- };
1821
-
1822
- /**
1823
- * This method returns a string describing this Block in developer terms (type
1824
- * name and ID; English only).
1825
- *
1826
- * Intended to on be used in console logs and errors. If you need a string that
1827
- * uses the user's native language (including block text, field values, and
1828
- * child blocks), use [toString()]{@link Blockly.Block#toString}.
1829
- * @return {string} The description.
1830
- */
1831
- Blockly.Block.prototype.toDevString = function() {
1832
- var msg = this.type ? '"' + this.type + '" block' : 'Block';
1833
- if (this.id) {
1834
- msg += ' (id="' + this.id + '")';
1835
- }
1836
- return msg;
1837
- };