scratch-blocks 1.2.0-beta.1 → 1.2.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 (1297) hide show
  1. package/.husky/commit-msg +3 -0
  2. package/blockly_compressed_horizontal.js +2255 -0
  3. package/blockly_compressed_vertical.js +2283 -0
  4. package/blockly_uncompressed_horizontal.js +1210 -0
  5. package/blockly_uncompressed_vertical.js +1210 -0
  6. package/blocks_common/colour.js +61 -0
  7. package/blocks_common/math.js +159 -0
  8. package/blocks_common/matrix.js +54 -0
  9. package/blocks_common/note.js +58 -0
  10. package/blocks_common/text.js +57 -0
  11. package/blocks_compressed.js +36 -0
  12. package/blocks_compressed_horizontal.js +67 -0
  13. package/blocks_compressed_vertical.js +208 -0
  14. package/blocks_horizontal/control.js +212 -0
  15. package/blocks_horizontal/default_toolbox.js +139 -0
  16. package/blocks_horizontal/event.js +190 -0
  17. package/blocks_horizontal/wedo.js +325 -0
  18. package/blocks_vertical/control.js +532 -0
  19. package/blocks_vertical/data.js +666 -0
  20. package/blocks_vertical/default_toolbox.js +564 -0
  21. package/blocks_vertical/event.js +329 -0
  22. package/blocks_vertical/extensions.js +294 -0
  23. package/blocks_vertical/looks.js +591 -0
  24. package/blocks_vertical/motion.js +587 -0
  25. package/blocks_vertical/operators.js +470 -0
  26. package/blocks_vertical/procedures.js +973 -0
  27. package/blocks_vertical/sensing.js +554 -0
  28. package/blocks_vertical/sound.js +246 -0
  29. package/blocks_vertical/vertical_extensions.js +266 -0
  30. package/build/gen_blocks.js +1 -0
  31. package/build/test_expect.js +1 -0
  32. package/build/test_input.js +1 -0
  33. package/build.py +636 -0
  34. package/cleanup.sh +101 -0
  35. package/core/block.js +1837 -0
  36. package/core/block_animations.js +107 -0
  37. package/core/block_drag_surface.js +299 -0
  38. package/core/block_dragger.js +421 -0
  39. package/core/block_events.js +531 -0
  40. package/core/block_render_svg_horizontal.js +890 -0
  41. package/core/block_render_svg_vertical.js +1732 -0
  42. package/core/block_svg.js +1316 -0
  43. package/core/blockly.js +622 -0
  44. package/core/blocks.js +37 -0
  45. package/core/bubble.js +664 -0
  46. package/core/bubble_dragger.js +285 -0
  47. package/core/colours.js +160 -0
  48. package/core/comment.js +293 -0
  49. package/core/comment_events.js +539 -0
  50. package/core/connection.js +766 -0
  51. package/core/connection_db.js +300 -0
  52. package/core/constants.js +387 -0
  53. package/core/contextmenu.js +519 -0
  54. package/core/css.js +1351 -0
  55. package/core/data_category.js +490 -0
  56. package/core/dragged_connection_manager.js +260 -0
  57. package/core/dropdowndiv.js +408 -0
  58. package/core/events.js +429 -0
  59. package/core/events_abstract.js +113 -0
  60. package/core/extensions.js +450 -0
  61. package/core/field.js +807 -0
  62. package/core/field_angle.js +398 -0
  63. package/core/field_checkbox.js +133 -0
  64. package/core/field_colour.js +253 -0
  65. package/core/field_colour_slider.js +387 -0
  66. package/core/field_date.js +353 -0
  67. package/core/field_dropdown.js +483 -0
  68. package/core/field_iconmenu.js +309 -0
  69. package/core/field_image.js +193 -0
  70. package/core/field_label.js +136 -0
  71. package/core/field_label_serializable.js +125 -0
  72. package/core/field_matrix.js +566 -0
  73. package/core/field_note.js +850 -0
  74. package/core/field_number.js +366 -0
  75. package/core/field_numberdropdown.js +77 -0
  76. package/core/field_textdropdown.js +164 -0
  77. package/core/field_textinput.js +675 -0
  78. package/core/field_textinput_removable.js +105 -0
  79. package/core/field_variable.js +385 -0
  80. package/core/field_variable_getter.js +185 -0
  81. package/core/field_vertical_separator.js +161 -0
  82. package/core/flyout_base.js +923 -0
  83. package/core/flyout_button.js +322 -0
  84. package/core/flyout_dragger.js +83 -0
  85. package/core/flyout_extension_category_header.js +159 -0
  86. package/core/flyout_horizontal.js +475 -0
  87. package/core/flyout_vertical.js +770 -0
  88. package/core/generator.js +426 -0
  89. package/core/gesture.js +1011 -0
  90. package/core/grid.js +227 -0
  91. package/core/icon.js +205 -0
  92. package/core/inject.js +491 -0
  93. package/core/input.js +285 -0
  94. package/core/insertion_marker_manager.js +678 -0
  95. package/core/msg.js +62 -0
  96. package/core/mutator.js +426 -0
  97. package/core/names.js +198 -0
  98. package/core/options.js +244 -0
  99. package/core/procedures.js +577 -0
  100. package/core/rendered_connection.js +417 -0
  101. package/core/scratch_block_comment.js +653 -0
  102. package/core/scratch_blocks_utils.js +244 -0
  103. package/core/scratch_bubble.js +696 -0
  104. package/core/scratch_events.js +131 -0
  105. package/core/scratch_msgs.js +85 -0
  106. package/core/scrollbar.js +875 -0
  107. package/core/toolbox.js +801 -0
  108. package/core/tooltip.js +337 -0
  109. package/core/touch.js +226 -0
  110. package/core/trashcan.js +343 -0
  111. package/core/ui_events.js +91 -0
  112. package/core/ui_menu_utils.js +68 -0
  113. package/core/utils.js +948 -0
  114. package/core/variable_events.js +259 -0
  115. package/core/variable_map.js +415 -0
  116. package/core/variable_model.js +116 -0
  117. package/core/variables.js +674 -0
  118. package/core/warning.js +199 -0
  119. package/core/widgetdiv.js +344 -0
  120. package/core/workspace.js +673 -0
  121. package/core/workspace_audio.js +170 -0
  122. package/core/workspace_comment.js +432 -0
  123. package/core/workspace_comment_render_svg.js +723 -0
  124. package/core/workspace_comment_svg.js +611 -0
  125. package/core/workspace_drag_surface_svg.js +195 -0
  126. package/core/workspace_dragger.js +132 -0
  127. package/core/workspace_svg.js +2267 -0
  128. package/core/xml.js +919 -0
  129. package/core/zoom_controls.js +301 -0
  130. package/dist/horizontal.js +222 -0
  131. package/dist/vertical.js +222 -0
  132. package/dist/web/horizontal.js +232 -0
  133. package/dist/web/vertical.js +232 -0
  134. package/local_build.sh +70 -0
  135. package/msg/js/en.js +1 -0
  136. package/msg/json/en.json +1 -0
  137. package/msg/messages.js +1 -0
  138. package/msg/scratch_msgs.js +281 -221
  139. package/package.json +40 -25
  140. package/pull_from_blockly.sh +151 -0
  141. package/release.config.js +0 -8
  142. package/shim/blockly_compressed_horizontal-blocks_compressed.js +1 -0
  143. package/shim/blockly_compressed_horizontal.Blockly.js +1 -0
  144. package/shim/blockly_compressed_horizontal.goog.js +1 -0
  145. package/shim/blockly_compressed_horizontal.js +1 -0
  146. package/shim/blockly_compressed_vertical-blocks_compressed.js +1 -0
  147. package/shim/blockly_compressed_vertical.Blockly.js +1 -0
  148. package/shim/blockly_compressed_vertical.goog.js +1 -0
  149. package/shim/blockly_compressed_vertical.js +1 -0
  150. package/shim/blocks_compressed_horizontal-blockly_compressed_horizontal-messages.js +1 -0
  151. package/shim/blocks_compressed_horizontal.js +1 -0
  152. package/shim/blocks_compressed_vertical-blockly_compressed_vertical-messages.js +1 -0
  153. package/shim/blocks_compressed_vertical.js +1 -0
  154. package/shim/gh-pages.js +1 -0
  155. package/shim/horizontal.js +1 -0
  156. package/shim/index.js +17 -0
  157. package/shim/vertical.js +1 -0
  158. package/CHANGELOG.md +0 -1104
  159. package/TODO.md +0 -16
  160. package/blockly-rc/.eslintignore +0 -28
  161. package/blockly-rc/.eslintrc.js +0 -187
  162. package/blockly-rc/.gitattributes +0 -1
  163. package/blockly-rc/.github/CODEOWNERS +0 -1
  164. package/blockly-rc/.github/CONTRIBUTING.md +0 -46
  165. package/blockly-rc/.github/ISSUE_TEMPLATE/bug_report.yaml +0 -58
  166. package/blockly-rc/.github/ISSUE_TEMPLATE/config.yml +0 -7
  167. package/blockly-rc/.github/ISSUE_TEMPLATE/documentation.yaml +0 -38
  168. package/blockly-rc/.github/ISSUE_TEMPLATE/feature_request.yaml +0 -39
  169. package/blockly-rc/.github/PULL_REQUEST_TEMPLATE.md +0 -42
  170. package/blockly-rc/.github/dependabot.yml +0 -27
  171. package/blockly-rc/.github/release.yml +0 -32
  172. package/blockly-rc/.github/workflows/appengine_deploy.yml +0 -54
  173. package/blockly-rc/.github/workflows/assign_reviewers.yml +0 -41
  174. package/blockly-rc/.github/workflows/browser_test.yml +0 -55
  175. package/blockly-rc/.github/workflows/build.yml +0 -86
  176. package/blockly-rc/.github/workflows/conventional-label.yml +0 -17
  177. package/blockly-rc/.github/workflows/develop_freeze.yml +0 -26
  178. package/blockly-rc/.github/workflows/tag_module_cleanup.yml +0 -37
  179. package/blockly-rc/.github/workflows/welcome_new_contributors.yml +0 -36
  180. package/blockly-rc/.prettierignore +0 -30
  181. package/blockly-rc/.prettierrc.js +0 -13
  182. package/blockly-rc/CHANGELOG.md +0 -77
  183. package/blockly-rc/LICENSE +0 -202
  184. package/blockly-rc/README.md +0 -80
  185. package/blockly-rc/_config.yml +0 -1
  186. package/blockly-rc/api-extractor.json +0 -385
  187. package/blockly-rc/appengine/.gcloudignore +0 -20
  188. package/blockly-rc/appengine/README.txt +0 -42
  189. package/blockly-rc/appengine/add_timestamps.py +0 -69
  190. package/blockly-rc/appengine/app.yaml +0 -104
  191. package/blockly-rc/appengine/apple-touch-icon.png +0 -0
  192. package/blockly-rc/appengine/blockly_compressed.js +0 -11
  193. package/blockly-rc/appengine/expiration.py +0 -52
  194. package/blockly-rc/appengine/favicon.ico +0 -0
  195. package/blockly-rc/appengine/index.yaml +0 -11
  196. package/blockly-rc/appengine/main.py +0 -39
  197. package/blockly-rc/appengine/redirect.html +0 -107
  198. package/blockly-rc/appengine/requirements.txt +0 -1
  199. package/blockly-rc/appengine/robots.txt +0 -2
  200. package/blockly-rc/appengine/storage.js +0 -190
  201. package/blockly-rc/appengine/storage.py +0 -125
  202. package/blockly-rc/blocks/blocks.ts +0 -44
  203. package/blockly-rc/blocks/lists.ts +0 -1085
  204. package/blockly-rc/blocks/logic.ts +0 -712
  205. package/blockly-rc/blocks/loops.ts +0 -408
  206. package/blockly-rc/blocks/math.ts +0 -591
  207. package/blockly-rc/blocks/procedures.ts +0 -1364
  208. package/blockly-rc/blocks/text.ts +0 -1007
  209. package/blockly-rc/blocks/variables.ts +0 -183
  210. package/blockly-rc/blocks/variables_dynamic.ts +0 -194
  211. package/blockly-rc/core/any_aliases.ts +0 -8
  212. package/blockly-rc/core/block.ts +0 -2523
  213. package/blockly-rc/core/block_animations.ts +0 -225
  214. package/blockly-rc/core/block_flyout_inflater.ts +0 -262
  215. package/blockly-rc/core/block_svg.ts +0 -1768
  216. package/blockly-rc/core/blockly.ts +0 -605
  217. package/blockly-rc/core/blockly_options.ts +0 -71
  218. package/blockly-rc/core/blocks.ts +0 -18
  219. package/blockly-rc/core/browser_events.ts +0 -244
  220. package/blockly-rc/core/bubbles/bubble.ts +0 -658
  221. package/blockly-rc/core/bubbles/mini_workspace_bubble.ts +0 -280
  222. package/blockly-rc/core/bubbles/text_bubble.ts +0 -103
  223. package/blockly-rc/core/bubbles/textinput_bubble.ts +0 -344
  224. package/blockly-rc/core/bubbles.ts +0 -12
  225. package/blockly-rc/core/bump_objects.ts +0 -192
  226. package/blockly-rc/core/button_flyout_inflater.ts +0 -63
  227. package/blockly-rc/core/clipboard/block_paster.ts +0 -142
  228. package/blockly-rc/core/clipboard/registry.ts +0 -31
  229. package/blockly-rc/core/clipboard/workspace_comment_paster.ts +0 -94
  230. package/blockly-rc/core/clipboard.ts +0 -113
  231. package/blockly-rc/core/comments/comment_view.ts +0 -899
  232. package/blockly-rc/core/comments/rendered_workspace_comment.ts +0 -297
  233. package/blockly-rc/core/comments/workspace_comment.ts +0 -237
  234. package/blockly-rc/core/comments.ts +0 -9
  235. package/blockly-rc/core/common.ts +0 -305
  236. package/blockly-rc/core/component_manager.ts +0 -235
  237. package/blockly-rc/core/config.ts +0 -65
  238. package/blockly-rc/core/connection.ts +0 -793
  239. package/blockly-rc/core/connection_checker.ts +0 -348
  240. package/blockly-rc/core/connection_db.ts +0 -297
  241. package/blockly-rc/core/connection_type.ts +0 -21
  242. package/blockly-rc/core/constants.ts +0 -23
  243. package/blockly-rc/core/contextmenu.ts +0 -268
  244. package/blockly-rc/core/contextmenu_items.ts +0 -700
  245. package/blockly-rc/core/contextmenu_registry.ts +0 -194
  246. package/blockly-rc/core/css.ts +0 -481
  247. package/blockly-rc/core/delete_area.ts +0 -77
  248. package/blockly-rc/core/dialog.ts +0 -121
  249. package/blockly-rc/core/drag_target.ts +0 -97
  250. package/blockly-rc/core/dragging/block_drag_strategy.ts +0 -454
  251. package/blockly-rc/core/dragging/bubble_drag_strategy.ts +0 -52
  252. package/blockly-rc/core/dragging/comment_drag_strategy.ts +0 -91
  253. package/blockly-rc/core/dragging/dragger.ts +0 -163
  254. package/blockly-rc/core/dragging.ts +0 -12
  255. package/blockly-rc/core/dropdowndiv.ts +0 -768
  256. package/blockly-rc/core/events/events.ts +0 -163
  257. package/blockly-rc/core/events/events_abstract.ts +0 -130
  258. package/blockly-rc/core/events/events_block_base.ts +0 -88
  259. package/blockly-rc/core/events/events_block_change.ts +0 -259
  260. package/blockly-rc/core/events/events_block_create.ts +0 -185
  261. package/blockly-rc/core/events/events_block_delete.ts +0 -182
  262. package/blockly-rc/core/events/events_block_drag.ts +0 -116
  263. package/blockly-rc/core/events/events_block_field_intermediate_change.ts +0 -167
  264. package/blockly-rc/core/events/events_block_move.ts +0 -307
  265. package/blockly-rc/core/events/events_bubble_open.ts +0 -120
  266. package/blockly-rc/core/events/events_click.ts +0 -110
  267. package/blockly-rc/core/events/events_comment_base.ts +0 -126
  268. package/blockly-rc/core/events/events_comment_change.ts +0 -161
  269. package/blockly-rc/core/events/events_comment_collapse.ts +0 -103
  270. package/blockly-rc/core/events/events_comment_create.ts +0 -118
  271. package/blockly-rc/core/events/events_comment_delete.ts +0 -117
  272. package/blockly-rc/core/events/events_comment_drag.ts +0 -99
  273. package/blockly-rc/core/events/events_comment_move.ts +0 -207
  274. package/blockly-rc/core/events/events_comment_resize.ts +0 -174
  275. package/blockly-rc/core/events/events_marker_move.ts +0 -134
  276. package/blockly-rc/core/events/events_selected.ts +0 -98
  277. package/blockly-rc/core/events/events_theme_change.ts +0 -84
  278. package/blockly-rc/core/events/events_toolbox_item_select.ts +0 -96
  279. package/blockly-rc/core/events/events_trashcan_open.ts +0 -88
  280. package/blockly-rc/core/events/events_ui_base.ts +0 -47
  281. package/blockly-rc/core/events/events_var_base.ts +0 -89
  282. package/blockly-rc/core/events/events_var_create.ts +0 -129
  283. package/blockly-rc/core/events/events_var_delete.ts +0 -124
  284. package/blockly-rc/core/events/events_var_rename.ts +0 -133
  285. package/blockly-rc/core/events/events_var_type_change.ts +0 -122
  286. package/blockly-rc/core/events/events_viewport.ts +0 -149
  287. package/blockly-rc/core/events/utils.ts +0 -595
  288. package/blockly-rc/core/events/workspace_events.ts +0 -46
  289. package/blockly-rc/core/extensions.ts +0 -491
  290. package/blockly-rc/core/field.ts +0 -1471
  291. package/blockly-rc/core/field_checkbox.ts +0 -271
  292. package/blockly-rc/core/field_dropdown.ts +0 -857
  293. package/blockly-rc/core/field_image.ts +0 -297
  294. package/blockly-rc/core/field_input.ts +0 -755
  295. package/blockly-rc/core/field_label.ts +0 -150
  296. package/blockly-rc/core/field_label_serializable.ts +0 -73
  297. package/blockly-rc/core/field_number.ts +0 -381
  298. package/blockly-rc/core/field_registry.ts +0 -115
  299. package/blockly-rc/core/field_textinput.ts +0 -117
  300. package/blockly-rc/core/field_variable.ts +0 -651
  301. package/blockly-rc/core/flyout_base.ts +0 -968
  302. package/blockly-rc/core/flyout_button.ts +0 -416
  303. package/blockly-rc/core/flyout_horizontal.ts +0 -374
  304. package/blockly-rc/core/flyout_metrics_manager.ts +0 -90
  305. package/blockly-rc/core/flyout_separator.ts +0 -61
  306. package/blockly-rc/core/flyout_vertical.ts +0 -353
  307. package/blockly-rc/core/generator.ts +0 -611
  308. package/blockly-rc/core/gesture.ts +0 -1191
  309. package/blockly-rc/core/grid.ts +0 -252
  310. package/blockly-rc/core/icons/comment_icon.ts +0 -435
  311. package/blockly-rc/core/icons/exceptions.ts +0 -23
  312. package/blockly-rc/core/icons/icon.ts +0 -147
  313. package/blockly-rc/core/icons/icon_types.ts +0 -32
  314. package/blockly-rc/core/icons/mutator_icon.ts +0 -354
  315. package/blockly-rc/core/icons/registry.ts +0 -33
  316. package/blockly-rc/core/icons/warning_icon.ts +0 -219
  317. package/blockly-rc/core/icons.ts +0 -24
  318. package/blockly-rc/core/inject.ts +0 -428
  319. package/blockly-rc/core/inputs/align.ts +0 -14
  320. package/blockly-rc/core/inputs/dummy_input.ts +0 -26
  321. package/blockly-rc/core/inputs/end_row_input.ts +0 -31
  322. package/blockly-rc/core/inputs/input.ts +0 -318
  323. package/blockly-rc/core/inputs/input_types.ts +0 -27
  324. package/blockly-rc/core/inputs/statement_input.ts +0 -34
  325. package/blockly-rc/core/inputs/value_input.ts +0 -30
  326. package/blockly-rc/core/inputs.ts +0 -23
  327. package/blockly-rc/core/insertion_marker_manager.ts +0 -742
  328. package/blockly-rc/core/insertion_marker_previewer.ts +0 -254
  329. package/blockly-rc/core/interfaces/i_ast_node_location.ts +0 -12
  330. package/blockly-rc/core/interfaces/i_ast_node_location_svg.ts +0 -28
  331. package/blockly-rc/core/interfaces/i_ast_node_location_with_block.ts +0 -22
  332. package/blockly-rc/core/interfaces/i_autohideable.ts +0 -22
  333. package/blockly-rc/core/interfaces/i_bounded_element.ts +0 -30
  334. package/blockly-rc/core/interfaces/i_bubble.ts +0 -63
  335. package/blockly-rc/core/interfaces/i_collapsible_toolbox_item.ts +0 -33
  336. package/blockly-rc/core/interfaces/i_comment_icon.ts +0 -47
  337. package/blockly-rc/core/interfaces/i_component.ts +0 -19
  338. package/blockly-rc/core/interfaces/i_connection_checker.ts +0 -100
  339. package/blockly-rc/core/interfaces/i_connection_previewer.ts +0 -50
  340. package/blockly-rc/core/interfaces/i_contextmenu.ts +0 -16
  341. package/blockly-rc/core/interfaces/i_copyable.ts +0 -31
  342. package/blockly-rc/core/interfaces/i_deletable.ts +0 -34
  343. package/blockly-rc/core/interfaces/i_delete_area.ts +0 -28
  344. package/blockly-rc/core/interfaces/i_drag_target.ts +0 -69
  345. package/blockly-rc/core/interfaces/i_draggable.ts +0 -72
  346. package/blockly-rc/core/interfaces/i_dragger.ts +0 -35
  347. package/blockly-rc/core/interfaces/i_flyout.ts +0 -189
  348. package/blockly-rc/core/interfaces/i_flyout_inflater.ts +0 -41
  349. package/blockly-rc/core/interfaces/i_has_bubble.ts +0 -20
  350. package/blockly-rc/core/interfaces/i_icon.ts +0 -114
  351. package/blockly-rc/core/interfaces/i_keyboard_accessible.ts +0 -21
  352. package/blockly-rc/core/interfaces/i_legacy_procedure_blocks.ts +0 -50
  353. package/blockly-rc/core/interfaces/i_metrics_manager.ts +0 -149
  354. package/blockly-rc/core/interfaces/i_movable.ts +0 -19
  355. package/blockly-rc/core/interfaces/i_observable.ts +0 -24
  356. package/blockly-rc/core/interfaces/i_parameter_model.ts +0 -51
  357. package/blockly-rc/core/interfaces/i_paster.ts +0 -25
  358. package/blockly-rc/core/interfaces/i_positionable.ts +0 -33
  359. package/blockly-rc/core/interfaces/i_procedure_block.ts +0 -27
  360. package/blockly-rc/core/interfaces/i_procedure_map.ts +0 -18
  361. package/blockly-rc/core/interfaces/i_procedure_model.ts +0 -71
  362. package/blockly-rc/core/interfaces/i_registrable.ts +0 -12
  363. package/blockly-rc/core/interfaces/i_rendered_element.ts +0 -22
  364. package/blockly-rc/core/interfaces/i_selectable.ts +0 -34
  365. package/blockly-rc/core/interfaces/i_selectable_toolbox_item.ts +0 -63
  366. package/blockly-rc/core/interfaces/i_serializable.ts +0 -28
  367. package/blockly-rc/core/interfaces/i_serializer.ts +0 -55
  368. package/blockly-rc/core/interfaces/i_styleable.ts +0 -26
  369. package/blockly-rc/core/interfaces/i_toolbox.ts +0 -112
  370. package/blockly-rc/core/interfaces/i_toolbox_item.ts +0 -81
  371. package/blockly-rc/core/interfaces/i_variable_backed_parameter_model.ts +0 -23
  372. package/blockly-rc/core/interfaces/i_variable_map.ts +0 -65
  373. package/blockly-rc/core/interfaces/i_variable_model.ts +0 -57
  374. package/blockly-rc/core/internal_constants.ts +0 -47
  375. package/blockly-rc/core/keyboard_nav/ast_node.ts +0 -884
  376. package/blockly-rc/core/keyboard_nav/basic_cursor.ts +0 -223
  377. package/blockly-rc/core/keyboard_nav/cursor.ts +0 -138
  378. package/blockly-rc/core/keyboard_nav/marker.ts +0 -113
  379. package/blockly-rc/core/keyboard_nav/tab_navigate_cursor.ts +0 -46
  380. package/blockly-rc/core/label_flyout_inflater.ts +0 -59
  381. package/blockly-rc/core/layer_manager.ts +0 -186
  382. package/blockly-rc/core/layers.ts +0 -17
  383. package/blockly-rc/core/main.ts +0 -31
  384. package/blockly-rc/core/marker_manager.ts +0 -189
  385. package/blockly-rc/core/menu.ts +0 -463
  386. package/blockly-rc/core/menuitem.ts +0 -221
  387. package/blockly-rc/core/metrics_manager.ts +0 -486
  388. package/blockly-rc/core/msg.ts +0 -27
  389. package/blockly-rc/core/names.ts +0 -275
  390. package/blockly-rc/core/observable_procedure_map.ts +0 -66
  391. package/blockly-rc/core/options.ts +0 -377
  392. package/blockly-rc/core/positionable_helpers.ts +0 -186
  393. package/blockly-rc/core/procedures.ts +0 -510
  394. package/blockly-rc/core/registry.ts +0 -400
  395. package/blockly-rc/core/render_management.ts +0 -193
  396. package/blockly-rc/core/rendered_connection.ts +0 -571
  397. package/blockly-rc/core/renderers/common/block_rendering.ts +0 -120
  398. package/blockly-rc/core/renderers/common/constants.ts +0 -1198
  399. package/blockly-rc/core/renderers/common/drawer.ts +0 -518
  400. package/blockly-rc/core/renderers/common/i_path_object.ts +0 -137
  401. package/blockly-rc/core/renderers/common/info.ts +0 -767
  402. package/blockly-rc/core/renderers/common/marker_svg.ts +0 -765
  403. package/blockly-rc/core/renderers/common/path_object.ts +0 -324
  404. package/blockly-rc/core/renderers/common/renderer.ts +0 -281
  405. package/blockly-rc/core/renderers/geras/constants.ts +0 -46
  406. package/blockly-rc/core/renderers/geras/drawer.ts +0 -167
  407. package/blockly-rc/core/renderers/geras/geras.ts +0 -31
  408. package/blockly-rc/core/renderers/geras/highlight_constants.ts +0 -342
  409. package/blockly-rc/core/renderers/geras/highlighter.ts +0 -313
  410. package/blockly-rc/core/renderers/geras/info.ts +0 -478
  411. package/blockly-rc/core/renderers/geras/measurables/inline_input.ts +0 -37
  412. package/blockly-rc/core/renderers/geras/measurables/statement_input.ts +0 -36
  413. package/blockly-rc/core/renderers/geras/path_object.ts +0 -135
  414. package/blockly-rc/core/renderers/geras/renderer.ts +0 -124
  415. package/blockly-rc/core/renderers/measurables/base.ts +0 -41
  416. package/blockly-rc/core/renderers/measurables/bottom_row.ts +0 -104
  417. package/blockly-rc/core/renderers/measurables/connection.ts +0 -43
  418. package/blockly-rc/core/renderers/measurables/external_value_input.ts +0 -53
  419. package/blockly-rc/core/renderers/measurables/field.ts +0 -50
  420. package/blockly-rc/core/renderers/measurables/hat.ts +0 -33
  421. package/blockly-rc/core/renderers/measurables/icon.ts +0 -42
  422. package/blockly-rc/core/renderers/measurables/in_row_spacer.ts +0 -29
  423. package/blockly-rc/core/renderers/measurables/inline_input.ts +0 -63
  424. package/blockly-rc/core/renderers/measurables/input_connection.ts +0 -57
  425. package/blockly-rc/core/renderers/measurables/input_row.ts +0 -67
  426. package/blockly-rc/core/renderers/measurables/jagged_edge.ts +0 -28
  427. package/blockly-rc/core/renderers/measurables/next_connection.ts +0 -34
  428. package/blockly-rc/core/renderers/measurables/output_connection.ts +0 -43
  429. package/blockly-rc/core/renderers/measurables/previous_connection.ts +0 -34
  430. package/blockly-rc/core/renderers/measurables/round_corner.ts +0 -34
  431. package/blockly-rc/core/renderers/measurables/row.ts +0 -191
  432. package/blockly-rc/core/renderers/measurables/spacer_row.ts +0 -44
  433. package/blockly-rc/core/renderers/measurables/square_corner.ts +0 -32
  434. package/blockly-rc/core/renderers/measurables/statement_input.ts +0 -41
  435. package/blockly-rc/core/renderers/measurables/top_row.ts +0 -110
  436. package/blockly-rc/core/renderers/measurables/types.ts +0 -319
  437. package/blockly-rc/core/renderers/thrasos/info.ts +0 -328
  438. package/blockly-rc/core/renderers/thrasos/renderer.ts +0 -40
  439. package/blockly-rc/core/renderers/thrasos/thrasos.ts +0 -14
  440. package/blockly-rc/core/renderers/zelos/constants.ts +0 -877
  441. package/blockly-rc/core/renderers/zelos/drawer.ts +0 -274
  442. package/blockly-rc/core/renderers/zelos/info.ts +0 -652
  443. package/blockly-rc/core/renderers/zelos/marker_svg.ts +0 -145
  444. package/blockly-rc/core/renderers/zelos/measurables/bottom_row.ts +0 -44
  445. package/blockly-rc/core/renderers/zelos/measurables/inputs.ts +0 -41
  446. package/blockly-rc/core/renderers/zelos/measurables/row_elements.ts +0 -29
  447. package/blockly-rc/core/renderers/zelos/measurables/top_row.ts +0 -50
  448. package/blockly-rc/core/renderers/zelos/path_object.ts +0 -209
  449. package/blockly-rc/core/renderers/zelos/renderer.ts +0 -143
  450. package/blockly-rc/core/renderers/zelos/zelos.ts +0 -33
  451. package/blockly-rc/core/scrollbar.ts +0 -898
  452. package/blockly-rc/core/scrollbar_pair.ts +0 -349
  453. package/blockly-rc/core/separator_flyout_inflater.ts +0 -69
  454. package/blockly-rc/core/serialization/blocks.ts +0 -868
  455. package/blockly-rc/core/serialization/exceptions.ts +0 -112
  456. package/blockly-rc/core/serialization/priorities.ts +0 -25
  457. package/blockly-rc/core/serialization/procedures.ts +0 -158
  458. package/blockly-rc/core/serialization/registry.ts +0 -30
  459. package/blockly-rc/core/serialization/variables.ts +0 -68
  460. package/blockly-rc/core/serialization/workspace_comments.ts +0 -143
  461. package/blockly-rc/core/serialization/workspaces.ts +0 -94
  462. package/blockly-rc/core/serialization.ts +0 -32
  463. package/blockly-rc/core/shortcut_items.ts +0 -338
  464. package/blockly-rc/core/shortcut_registry.ts +0 -368
  465. package/blockly-rc/core/sprites.ts +0 -15
  466. package/blockly-rc/core/theme/classic.ts +0 -40
  467. package/blockly-rc/core/theme/themes.ts +0 -12
  468. package/blockly-rc/core/theme/zelos.ts +0 -80
  469. package/blockly-rc/core/theme.ts +0 -232
  470. package/blockly-rc/core/theme_manager.ts +0 -192
  471. package/blockly-rc/core/toolbox/category.ts +0 -739
  472. package/blockly-rc/core/toolbox/collapsible_category.ts +0 -288
  473. package/blockly-rc/core/toolbox/separator.ts +0 -105
  474. package/blockly-rc/core/toolbox/toolbox.ts +0 -1134
  475. package/blockly-rc/core/toolbox/toolbox_item.ts +0 -152
  476. package/blockly-rc/core/tooltip.ts +0 -466
  477. package/blockly-rc/core/touch.ts +0 -155
  478. package/blockly-rc/core/trashcan.ts +0 -748
  479. package/blockly-rc/core/utils/aria.ts +0 -144
  480. package/blockly-rc/core/utils/array.ts +0 -24
  481. package/blockly-rc/core/utils/colour.ts +0 -265
  482. package/blockly-rc/core/utils/coordinate.ts +0 -129
  483. package/blockly-rc/core/utils/deprecation.ts +0 -47
  484. package/blockly-rc/core/utils/dom.ts +0 -356
  485. package/blockly-rc/core/utils/idgenerator.ts +0 -70
  486. package/blockly-rc/core/utils/keycodes.ts +0 -154
  487. package/blockly-rc/core/utils/math.ts +0 -50
  488. package/blockly-rc/core/utils/metrics.ts +0 -86
  489. package/blockly-rc/core/utils/object.ts +0 -28
  490. package/blockly-rc/core/utils/parsing.ts +0 -287
  491. package/blockly-rc/core/utils/rect.ts +0 -69
  492. package/blockly-rc/core/utils/size.ts +0 -62
  493. package/blockly-rc/core/utils/string.ts +0 -289
  494. package/blockly-rc/core/utils/style.ts +0 -219
  495. package/blockly-rc/core/utils/svg.ts +0 -84
  496. package/blockly-rc/core/utils/svg_math.ts +0 -208
  497. package/blockly-rc/core/utils/svg_paths.ts +0 -133
  498. package/blockly-rc/core/utils/toolbox.ts +0 -419
  499. package/blockly-rc/core/utils/useragent.ts +0 -86
  500. package/blockly-rc/core/utils/xml.ts +0 -165
  501. package/blockly-rc/core/utils.ts +0 -59
  502. package/blockly-rc/core/variable_map.ts +0 -437
  503. package/blockly-rc/core/variable_model.ts +0 -149
  504. package/blockly-rc/core/variables.ts +0 -773
  505. package/blockly-rc/core/variables_dynamic.ts +0 -142
  506. package/blockly-rc/core/widgetdiv.ts +0 -319
  507. package/blockly-rc/core/workspace.ts +0 -957
  508. package/blockly-rc/core/workspace_audio.ts +0 -171
  509. package/blockly-rc/core/workspace_dragger.ts +0 -97
  510. package/blockly-rc/core/workspace_svg.ts +0 -2519
  511. package/blockly-rc/core/xml.ts +0 -1133
  512. package/blockly-rc/core/zoom_controls.ts +0 -492
  513. package/blockly-rc/demos/blockfactory/analytics.js +0 -195
  514. package/blockly-rc/demos/blockfactory/app_controller.js +0 -726
  515. package/blockly-rc/demos/blockfactory/block_definition_extractor.js +0 -742
  516. package/blockly-rc/demos/blockfactory/block_exporter_controller.js +0 -311
  517. package/blockly-rc/demos/blockfactory/block_exporter_tools.js +0 -212
  518. package/blockly-rc/demos/blockfactory/block_exporter_view.js +0 -101
  519. package/blockly-rc/demos/blockfactory/block_library_controller.js +0 -325
  520. package/blockly-rc/demos/blockfactory/block_library_storage.js +0 -149
  521. package/blockly-rc/demos/blockfactory/block_library_view.js +0 -178
  522. package/blockly-rc/demos/blockfactory/block_option.js +0 -151
  523. package/blockly-rc/demos/blockfactory/blocks.js +0 -916
  524. package/blockly-rc/demos/blockfactory/cp.css +0 -46
  525. package/blockly-rc/demos/blockfactory/cp.js +0 -179
  526. package/blockly-rc/demos/blockfactory/factory.css +0 -586
  527. package/blockly-rc/demos/blockfactory/factory.js +0 -337
  528. package/blockly-rc/demos/blockfactory/factory_utils.js +0 -1036
  529. package/blockly-rc/demos/blockfactory/icon.png +0 -0
  530. package/blockly-rc/demos/blockfactory/index.html +0 -767
  531. package/blockly-rc/demos/blockfactory/link.png +0 -0
  532. package/blockly-rc/demos/blockfactory/standard_categories.js +0 -384
  533. package/blockly-rc/demos/blockfactory/workspacefactory/wfactory_controller.js +0 -1332
  534. package/blockly-rc/demos/blockfactory/workspacefactory/wfactory_generator.js +0 -224
  535. package/blockly-rc/demos/blockfactory/workspacefactory/wfactory_init.js +0 -541
  536. package/blockly-rc/demos/blockfactory/workspacefactory/wfactory_model.js +0 -548
  537. package/blockly-rc/demos/blockfactory/workspacefactory/wfactory_view.js +0 -424
  538. package/blockly-rc/demos/code/code.js +0 -626
  539. package/blockly-rc/demos/code/icon.png +0 -0
  540. package/blockly-rc/demos/code/icons.png +0 -0
  541. package/blockly-rc/demos/code/index.html +0 -359
  542. package/blockly-rc/demos/code/msg/ar.js +0 -24
  543. package/blockly-rc/demos/code/msg/be-tarask.js +0 -24
  544. package/blockly-rc/demos/code/msg/br.js +0 -24
  545. package/blockly-rc/demos/code/msg/ca.js +0 -24
  546. package/blockly-rc/demos/code/msg/cs.js +0 -24
  547. package/blockly-rc/demos/code/msg/da.js +0 -24
  548. package/blockly-rc/demos/code/msg/de.js +0 -24
  549. package/blockly-rc/demos/code/msg/el.js +0 -24
  550. package/blockly-rc/demos/code/msg/en.js +0 -24
  551. package/blockly-rc/demos/code/msg/es.js +0 -24
  552. package/blockly-rc/demos/code/msg/et.js +0 -24
  553. package/blockly-rc/demos/code/msg/fa.js +0 -24
  554. package/blockly-rc/demos/code/msg/fr.js +0 -24
  555. package/blockly-rc/demos/code/msg/he.js +0 -24
  556. package/blockly-rc/demos/code/msg/hr.js +0 -24
  557. package/blockly-rc/demos/code/msg/hrx.js +0 -24
  558. package/blockly-rc/demos/code/msg/hu.js +0 -24
  559. package/blockly-rc/demos/code/msg/ia.js +0 -24
  560. package/blockly-rc/demos/code/msg/is.js +0 -24
  561. package/blockly-rc/demos/code/msg/it.js +0 -24
  562. package/blockly-rc/demos/code/msg/ja.js +0 -24
  563. package/blockly-rc/demos/code/msg/kab.js +0 -24
  564. package/blockly-rc/demos/code/msg/ko.js +0 -24
  565. package/blockly-rc/demos/code/msg/mk.js +0 -24
  566. package/blockly-rc/demos/code/msg/ms.js +0 -24
  567. package/blockly-rc/demos/code/msg/nb.js +0 -24
  568. package/blockly-rc/demos/code/msg/nl.js +0 -24
  569. package/blockly-rc/demos/code/msg/oc.js +0 -24
  570. package/blockly-rc/demos/code/msg/pl.js +0 -24
  571. package/blockly-rc/demos/code/msg/pms.js +0 -24
  572. package/blockly-rc/demos/code/msg/pt-br.js +0 -24
  573. package/blockly-rc/demos/code/msg/ro.js +0 -24
  574. package/blockly-rc/demos/code/msg/ru.js +0 -24
  575. package/blockly-rc/demos/code/msg/sc.js +0 -24
  576. package/blockly-rc/demos/code/msg/sk.js +0 -24
  577. package/blockly-rc/demos/code/msg/sr.js +0 -24
  578. package/blockly-rc/demos/code/msg/sv.js +0 -24
  579. package/blockly-rc/demos/code/msg/ta.js +0 -24
  580. package/blockly-rc/demos/code/msg/th.js +0 -24
  581. package/blockly-rc/demos/code/msg/tlh.js +0 -24
  582. package/blockly-rc/demos/code/msg/tr.js +0 -24
  583. package/blockly-rc/demos/code/msg/uk.js +0 -24
  584. package/blockly-rc/demos/code/msg/vi.js +0 -24
  585. package/blockly-rc/demos/code/msg/zh-hans.js +0 -24
  586. package/blockly-rc/demos/code/msg/zh-hant.js +0 -24
  587. package/blockly-rc/demos/code/style.css +0 -184
  588. package/blockly-rc/demos/index.html +0 -68
  589. package/blockly-rc/demos/minimap/icon.png +0 -0
  590. package/blockly-rc/demos/minimap/index.html +0 -91
  591. package/blockly-rc/demos/minimap/minimap.js +0 -302
  592. package/blockly-rc/demos/mobile/README.md +0 -53
  593. package/blockly-rc/demos/mobile/android/README.md +0 -45
  594. package/blockly-rc/demos/mobile/android/app/build.gradle +0 -64
  595. package/blockly-rc/demos/mobile/android/app/proguard-rules.pro +0 -21
  596. package/blockly-rc/demos/mobile/android/app/src/androidTest/java/com/example/blocklywebview/ExampleInstrumentedTest.java +0 -26
  597. package/blockly-rc/demos/mobile/android/app/src/main/AndroidManifest.xml +0 -21
  598. package/blockly-rc/demos/mobile/android/app/src/main/java/com/google/blockly/android/webview/BlocklyWebViewFragment.java +0 -40
  599. package/blockly-rc/demos/mobile/android/app/src/main/java/com/google/blockly/android/webview/JsDialogHelper.java +0 -150
  600. package/blockly-rc/demos/mobile/android/app/src/main/java/com/google/blockly/android/webview/WebChromeClient.java +0 -32
  601. package/blockly-rc/demos/mobile/android/app/src/main/java/com/google/blockly/android/webview/demo/MainActivity.java +0 -18
  602. package/blockly-rc/demos/mobile/android/app/src/main/res/drawable/ic_launcher_background.xml +0 -74
  603. package/blockly-rc/demos/mobile/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml +0 -34
  604. package/blockly-rc/demos/mobile/android/app/src/main/res/layout/activity_main.xml +0 -17
  605. package/blockly-rc/demos/mobile/android/app/src/main/res/layout/js_prompt.xml +0 -37
  606. package/blockly-rc/demos/mobile/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +0 -5
  607. package/blockly-rc/demos/mobile/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +0 -5
  608. package/blockly-rc/demos/mobile/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  609. package/blockly-rc/demos/mobile/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
  610. package/blockly-rc/demos/mobile/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  611. package/blockly-rc/demos/mobile/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
  612. package/blockly-rc/demos/mobile/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  613. package/blockly-rc/demos/mobile/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
  614. package/blockly-rc/demos/mobile/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  615. package/blockly-rc/demos/mobile/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  616. package/blockly-rc/demos/mobile/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  617. package/blockly-rc/demos/mobile/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
  618. package/blockly-rc/demos/mobile/android/app/src/main/res/values/colors.xml +0 -6
  619. package/blockly-rc/demos/mobile/android/app/src/main/res/values/js_dialog_helper.xml +0 -7
  620. package/blockly-rc/demos/mobile/android/app/src/main/res/values/strings.xml +0 -3
  621. package/blockly-rc/demos/mobile/android/app/src/main/res/values/styles.xml +0 -11
  622. package/blockly-rc/demos/mobile/android/app/src/test/java/com/example/blocklywebview/ExampleUnitTest.java +0 -17
  623. package/blockly-rc/demos/mobile/android/build.gradle +0 -27
  624. package/blockly-rc/demos/mobile/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  625. package/blockly-rc/demos/mobile/android/gradle/wrapper/gradle-wrapper.properties +0 -6
  626. package/blockly-rc/demos/mobile/android/gradle.properties +0 -13
  627. package/blockly-rc/demos/mobile/android/gradlew +0 -172
  628. package/blockly-rc/demos/mobile/android/gradlew.bat +0 -84
  629. package/blockly-rc/demos/mobile/android/settings.gradle +0 -1
  630. package/blockly-rc/demos/mobile/html/index.html +0 -31
  631. package/blockly-rc/demos/mobile/html/ln_resources.sh +0 -22
  632. package/blockly-rc/demos/mobile/html/toolbox_standard.js +0 -333
  633. package/blockly-rc/demos/mobile/ios/Blockly WebView/AppDelegate.swift +0 -46
  634. package/blockly-rc/demos/mobile/ios/Blockly WebView/Assets.xcassets/AppIcon.appiconset/Contents.json +0 -98
  635. package/blockly-rc/demos/mobile/ios/Blockly WebView/Assets.xcassets/Contents.json +0 -6
  636. package/blockly-rc/demos/mobile/ios/Blockly WebView/Base.lproj/LaunchScreen.storyboard +0 -25
  637. package/blockly-rc/demos/mobile/ios/Blockly WebView/Base.lproj/Main.storyboard +0 -44
  638. package/blockly-rc/demos/mobile/ios/Blockly WebView/Info.plist +0 -45
  639. package/blockly-rc/demos/mobile/ios/Blockly WebView/ViewController.swift +0 -110
  640. package/blockly-rc/demos/mobile/ios/Blockly WebView.xcodeproj/project.pbxproj +0 -390
  641. package/blockly-rc/demos/mobile/ios/Blockly WebView.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  642. package/blockly-rc/demos/mobile/ios/Blockly WebView.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  643. package/blockly-rc/demos/mobile/ios/cp_resources.sh +0 -21
  644. package/blockly-rc/demos/storage/icon.png +0 -0
  645. package/blockly-rc/demos/storage/index.html +0 -104
  646. package/blockly-rc/generators/dart/dart_generator.ts +0 -321
  647. package/blockly-rc/generators/dart/lists.ts +0 -525
  648. package/blockly-rc/generators/dart/logic.ts +0 -155
  649. package/blockly-rc/generators/dart/loops.ts +0 -217
  650. package/blockly-rc/generators/dart/math.ts +0 -559
  651. package/blockly-rc/generators/dart/procedures.ts +0 -138
  652. package/blockly-rc/generators/dart/text.ts +0 -405
  653. package/blockly-rc/generators/dart/variables.ts +0 -32
  654. package/blockly-rc/generators/dart/variables_dynamic.ts +0 -17
  655. package/blockly-rc/generators/dart.ts +0 -50
  656. package/blockly-rc/generators/javascript/javascript_generator.ts +0 -346
  657. package/blockly-rc/generators/javascript/lists.ts +0 -465
  658. package/blockly-rc/generators/javascript/logic.ts +0 -153
  659. package/blockly-rc/generators/javascript/loops.ts +0 -245
  660. package/blockly-rc/generators/javascript/math.ts +0 -450
  661. package/blockly-rc/generators/javascript/procedures.ts +0 -142
  662. package/blockly-rc/generators/javascript/text.ts +0 -418
  663. package/blockly-rc/generators/javascript/variables.ts +0 -32
  664. package/blockly-rc/generators/javascript/variables_dynamic.ts +0 -17
  665. package/blockly-rc/generators/javascript.ts +0 -46
  666. package/blockly-rc/generators/lua/lists.ts +0 -445
  667. package/blockly-rc/generators/lua/logic.ts +0 -142
  668. package/blockly-rc/generators/lua/loops.ts +0 -192
  669. package/blockly-rc/generators/lua/lua_generator.ts +0 -225
  670. package/blockly-rc/generators/lua/math.ts +0 -473
  671. package/blockly-rc/generators/lua/procedures.ts +0 -144
  672. package/blockly-rc/generators/lua/text.ts +0 -380
  673. package/blockly-rc/generators/lua/variables.ts +0 -31
  674. package/blockly-rc/generators/lua/variables_dynamic.ts +0 -17
  675. package/blockly-rc/generators/lua.ts +0 -44
  676. package/blockly-rc/generators/php/lists.ts +0 -585
  677. package/blockly-rc/generators/php/logic.ts +0 -155
  678. package/blockly-rc/generators/php/loops.ts +0 -218
  679. package/blockly-rc/generators/php/math.ts +0 -408
  680. package/blockly-rc/generators/php/php_generator.ts +0 -320
  681. package/blockly-rc/generators/php/procedures.ts +0 -159
  682. package/blockly-rc/generators/php/text.ts +0 -315
  683. package/blockly-rc/generators/php/variables.ts +0 -32
  684. package/blockly-rc/generators/php/variables_dynamic.ts +0 -17
  685. package/blockly-rc/generators/php.ts +0 -46
  686. package/blockly-rc/generators/python/lists.ts +0 -398
  687. package/blockly-rc/generators/python/logic.ts +0 -148
  688. package/blockly-rc/generators/python/loops.ts +0 -251
  689. package/blockly-rc/generators/python/math.ts +0 -434
  690. package/blockly-rc/generators/python/procedures.ts +0 -159
  691. package/blockly-rc/generators/python/python_generator.ts +0 -355
  692. package/blockly-rc/generators/python/text.ts +0 -338
  693. package/blockly-rc/generators/python/variables.ts +0 -31
  694. package/blockly-rc/generators/python/variables_dynamic.ts +0 -17
  695. package/blockly-rc/generators/python.ts +0 -51
  696. package/blockly-rc/gulpfile.js +0 -54
  697. package/blockly-rc/jsconfig.json +0 -7
  698. package/blockly-rc/media/1x1.gif +0 -0
  699. package/blockly-rc/media/click.mp3 +0 -0
  700. package/blockly-rc/media/click.ogg +0 -0
  701. package/blockly-rc/media/click.wav +0 -0
  702. package/blockly-rc/media/delete-icon.svg +0 -1
  703. package/blockly-rc/media/delete.mp3 +0 -0
  704. package/blockly-rc/media/delete.ogg +0 -0
  705. package/blockly-rc/media/delete.wav +0 -0
  706. package/blockly-rc/media/disconnect.mp3 +0 -0
  707. package/blockly-rc/media/disconnect.ogg +0 -0
  708. package/blockly-rc/media/disconnect.wav +0 -0
  709. package/blockly-rc/media/dropdown-arrow.svg +0 -1
  710. package/blockly-rc/media/foldout-icon.svg +0 -1
  711. package/blockly-rc/media/handclosed.cur +0 -0
  712. package/blockly-rc/media/handdelete.cur +0 -0
  713. package/blockly-rc/media/handopen.cur +0 -0
  714. package/blockly-rc/media/pilcrow.png +0 -0
  715. package/blockly-rc/media/quote0.png +0 -0
  716. package/blockly-rc/media/quote1.png +0 -0
  717. package/blockly-rc/media/resize-handle.svg +0 -3
  718. package/blockly-rc/media/sprites.png +0 -0
  719. package/blockly-rc/media/sprites.svg +0 -74
  720. package/blockly-rc/msg/json/README.md +0 -33
  721. package/blockly-rc/msg/json/ab.json +0 -222
  722. package/blockly-rc/msg/json/ace.json +0 -7
  723. package/blockly-rc/msg/json/af.json +0 -34
  724. package/blockly-rc/msg/json/am.json +0 -30
  725. package/blockly-rc/msg/json/ar.json +0 -355
  726. package/blockly-rc/msg/json/ast.json +0 -10
  727. package/blockly-rc/msg/json/az.json +0 -332
  728. package/blockly-rc/msg/json/ba.json +0 -211
  729. package/blockly-rc/msg/json/bcc.json +0 -290
  730. package/blockly-rc/msg/json/be-tarask.json +0 -334
  731. package/blockly-rc/msg/json/be.json +0 -324
  732. package/blockly-rc/msg/json/bg.json +0 -345
  733. package/blockly-rc/msg/json/bn.json +0 -189
  734. package/blockly-rc/msg/json/br.json +0 -334
  735. package/blockly-rc/msg/json/bs.json +0 -166
  736. package/blockly-rc/msg/json/ca.json +0 -341
  737. package/blockly-rc/msg/json/cdo.json +0 -6
  738. package/blockly-rc/msg/json/ce.json +0 -326
  739. package/blockly-rc/msg/json/constants.json +0 -12
  740. package/blockly-rc/msg/json/cs.json +0 -343
  741. package/blockly-rc/msg/json/da.json +0 -346
  742. package/blockly-rc/msg/json/de.json +0 -369
  743. package/blockly-rc/msg/json/diq.json +0 -258
  744. package/blockly-rc/msg/json/dtp.json +0 -198
  745. package/blockly-rc/msg/json/dty.json +0 -97
  746. package/blockly-rc/msg/json/ee.json +0 -160
  747. package/blockly-rc/msg/json/el.json +0 -356
  748. package/blockly-rc/msg/json/en-gb.json +0 -199
  749. package/blockly-rc/msg/json/en.json +0 -400
  750. package/blockly-rc/msg/json/eo.json +0 -337
  751. package/blockly-rc/msg/json/es.json +0 -358
  752. package/blockly-rc/msg/json/et.json +0 -326
  753. package/blockly-rc/msg/json/eu.json +0 -219
  754. package/blockly-rc/msg/json/fa.json +0 -341
  755. package/blockly-rc/msg/json/fi.json +0 -350
  756. package/blockly-rc/msg/json/fo.json +0 -46
  757. package/blockly-rc/msg/json/fr.json +0 -373
  758. package/blockly-rc/msg/json/frr.json +0 -6
  759. package/blockly-rc/msg/json/gl.json +0 -338
  760. package/blockly-rc/msg/json/gn.json +0 -54
  761. package/blockly-rc/msg/json/gor.json +0 -87
  762. package/blockly-rc/msg/json/ha.json +0 -313
  763. package/blockly-rc/msg/json/hak.json +0 -17
  764. package/blockly-rc/msg/json/he.json +0 -354
  765. package/blockly-rc/msg/json/hi.json +0 -318
  766. package/blockly-rc/msg/json/hr.json +0 -327
  767. package/blockly-rc/msg/json/hrx.json +0 -287
  768. package/blockly-rc/msg/json/hsb.json +0 -128
  769. package/blockly-rc/msg/json/hu.json +0 -349
  770. package/blockly-rc/msg/json/hy.json +0 -337
  771. package/blockly-rc/msg/json/ia.json +0 -337
  772. package/blockly-rc/msg/json/id.json +0 -335
  773. package/blockly-rc/msg/json/ig.json +0 -323
  774. package/blockly-rc/msg/json/inh.json +0 -80
  775. package/blockly-rc/msg/json/is.json +0 -331
  776. package/blockly-rc/msg/json/it.json +0 -346
  777. package/blockly-rc/msg/json/ja.json +0 -361
  778. package/blockly-rc/msg/json/ka.json +0 -14
  779. package/blockly-rc/msg/json/kab.json +0 -323
  780. package/blockly-rc/msg/json/kbd-cyrl.json +0 -84
  781. package/blockly-rc/msg/json/km.json +0 -29
  782. package/blockly-rc/msg/json/kn.json +0 -332
  783. package/blockly-rc/msg/json/ko.json +0 -372
  784. package/blockly-rc/msg/json/ksh.json +0 -43
  785. package/blockly-rc/msg/json/ku-latn.json +0 -41
  786. package/blockly-rc/msg/json/ky.json +0 -71
  787. package/blockly-rc/msg/json/la.json +0 -6
  788. package/blockly-rc/msg/json/lb.json +0 -156
  789. package/blockly-rc/msg/json/lki.json +0 -282
  790. package/blockly-rc/msg/json/lo.json +0 -92
  791. package/blockly-rc/msg/json/lrc.json +0 -123
  792. package/blockly-rc/msg/json/lt.json +0 -321
  793. package/blockly-rc/msg/json/lv.json +0 -324
  794. package/blockly-rc/msg/json/mg.json +0 -58
  795. package/blockly-rc/msg/json/mk.json +0 -178
  796. package/blockly-rc/msg/json/ml.json +0 -35
  797. package/blockly-rc/msg/json/mnw.json +0 -90
  798. package/blockly-rc/msg/json/ms.json +0 -300
  799. package/blockly-rc/msg/json/my.json +0 -57
  800. package/blockly-rc/msg/json/mzn.json +0 -6
  801. package/blockly-rc/msg/json/nb.json +0 -330
  802. package/blockly-rc/msg/json/ne.json +0 -247
  803. package/blockly-rc/msg/json/nl.json +0 -357
  804. package/blockly-rc/msg/json/oc.json +0 -194
  805. package/blockly-rc/msg/json/olo.json +0 -37
  806. package/blockly-rc/msg/json/pa.json +0 -69
  807. package/blockly-rc/msg/json/pl.json +0 -357
  808. package/blockly-rc/msg/json/pms.json +0 -324
  809. package/blockly-rc/msg/json/ps.json +0 -50
  810. package/blockly-rc/msg/json/pt-br.json +0 -369
  811. package/blockly-rc/msg/json/pt.json +0 -358
  812. package/blockly-rc/msg/json/qqq.json +0 -406
  813. package/blockly-rc/msg/json/ro.json +0 -333
  814. package/blockly-rc/msg/json/ru.json +0 -363
  815. package/blockly-rc/msg/json/sc.json +0 -283
  816. package/blockly-rc/msg/json/sco.json +0 -11
  817. package/blockly-rc/msg/json/sd.json +0 -158
  818. package/blockly-rc/msg/json/shn.json +0 -109
  819. package/blockly-rc/msg/json/si.json +0 -16
  820. package/blockly-rc/msg/json/sk.json +0 -332
  821. package/blockly-rc/msg/json/skr-arab.json +0 -117
  822. package/blockly-rc/msg/json/sl.json +0 -355
  823. package/blockly-rc/msg/json/smn.json +0 -133
  824. package/blockly-rc/msg/json/sq.json +0 -343
  825. package/blockly-rc/msg/json/sr-latn.json +0 -324
  826. package/blockly-rc/msg/json/sr.json +0 -348
  827. package/blockly-rc/msg/json/sv.json +0 -347
  828. package/blockly-rc/msg/json/sw.json +0 -12
  829. package/blockly-rc/msg/json/synonyms.json +0 -22
  830. package/blockly-rc/msg/json/ta.json +0 -306
  831. package/blockly-rc/msg/json/tcy.json +0 -316
  832. package/blockly-rc/msg/json/tdd.json +0 -109
  833. package/blockly-rc/msg/json/te.json +0 -101
  834. package/blockly-rc/msg/json/th.json +0 -333
  835. package/blockly-rc/msg/json/ti.json +0 -50
  836. package/blockly-rc/msg/json/tl.json +0 -129
  837. package/blockly-rc/msg/json/tlh.json +0 -179
  838. package/blockly-rc/msg/json/tr.json +0 -369
  839. package/blockly-rc/msg/json/ug-arab.json +0 -132
  840. package/blockly-rc/msg/json/uk.json +0 -345
  841. package/blockly-rc/msg/json/ur.json +0 -117
  842. package/blockly-rc/msg/json/uz.json +0 -36
  843. package/blockly-rc/msg/json/vi.json +0 -345
  844. package/blockly-rc/msg/json/xmf.json +0 -96
  845. package/blockly-rc/msg/json/yo.json +0 -316
  846. package/blockly-rc/msg/json/zgh.json +0 -83
  847. package/blockly-rc/msg/json/zh-hans.json +0 -372
  848. package/blockly-rc/msg/json/zh-hant.json +0 -362
  849. package/blockly-rc/msg/messages.js +0 -1616
  850. package/blockly-rc/package-lock.json +0 -12324
  851. package/blockly-rc/package.json +0 -149
  852. package/blockly-rc/patches/@microsoft+api-documenter+7.22.4.patch +0 -81
  853. package/blockly-rc/scripts/goog_module/convert-file.sh +0 -406
  854. package/blockly-rc/scripts/gulpfiles/appengine_tasks.js +0 -195
  855. package/blockly-rc/scripts/gulpfiles/build_tasks.js +0 -752
  856. package/blockly-rc/scripts/gulpfiles/config.js +0 -41
  857. package/blockly-rc/scripts/gulpfiles/docs_tasks.js +0 -147
  858. package/blockly-rc/scripts/gulpfiles/git_tasks.js +0 -181
  859. package/blockly-rc/scripts/gulpfiles/helper_tasks.js +0 -19
  860. package/blockly-rc/scripts/gulpfiles/package_tasks.js +0 -262
  861. package/blockly-rc/scripts/gulpfiles/release_tasks.js +0 -183
  862. package/blockly-rc/scripts/gulpfiles/test_tasks.js +0 -405
  863. package/blockly-rc/scripts/helpers.js +0 -74
  864. package/blockly-rc/scripts/i18n/common.py +0 -233
  865. package/blockly-rc/scripts/i18n/create_messages.py +0 -167
  866. package/blockly-rc/scripts/i18n/dedup_json.py +0 -72
  867. package/blockly-rc/scripts/i18n/js_to_json.py +0 -135
  868. package/blockly-rc/scripts/i18n/tests.py +0 -46
  869. package/blockly-rc/scripts/migration/cjs2esm +0 -162
  870. package/blockly-rc/scripts/migration/js2ts +0 -168
  871. package/blockly-rc/scripts/migration/renamings.json5 +0 -1599
  872. package/blockly-rc/scripts/package/README.md +0 -93
  873. package/blockly-rc/scripts/package/core-node.js +0 -31
  874. package/blockly-rc/scripts/package/index.js +0 -23
  875. package/blockly-rc/scripts/package/templates/umd-msg.template +0 -16
  876. package/blockly-rc/scripts/package/templates/umd.template +0 -13
  877. package/blockly-rc/scripts/themes/blockStyles_example.json +0 -11
  878. package/blockly-rc/scripts/themes/create_blockStyles.py +0 -181
  879. package/blockly-rc/scripts/tsick.js +0 -86
  880. package/blockly-rc/tests/.eslintrc.json +0 -10
  881. package/blockly-rc/tests/browser/.eslintrc.json +0 -29
  882. package/blockly-rc/tests/browser/.mocharc.js +0 -6
  883. package/blockly-rc/tests/browser/test/basic_block_factory_test.mjs +0 -44
  884. package/blockly-rc/tests/browser/test/basic_block_test.mjs +0 -39
  885. package/blockly-rc/tests/browser/test/basic_playground_test.mjs +0 -198
  886. package/blockly-rc/tests/browser/test/block_undo_test.mjs +0 -50
  887. package/blockly-rc/tests/browser/test/delete_blocks_test.mjs +0 -211
  888. package/blockly-rc/tests/browser/test/extensive_test.mjs +0 -195
  889. package/blockly-rc/tests/browser/test/field_edits_test.mjs +0 -61
  890. package/blockly-rc/tests/browser/test/hooks.mjs +0 -23
  891. package/blockly-rc/tests/browser/test/mutator_test.mjs +0 -88
  892. package/blockly-rc/tests/browser/test/procedure_test.mjs +0 -109
  893. package/blockly-rc/tests/browser/test/test_setup.mjs +0 -589
  894. package/blockly-rc/tests/browser/test/toolbox_drag_test.mjs +0 -207
  895. package/blockly-rc/tests/browser/test/workspace_comment_test.mjs +0 -224
  896. package/blockly-rc/tests/compile/index.html +0 -43
  897. package/blockly-rc/tests/compile/main.js +0 -53
  898. package/blockly-rc/tests/compile/test_blocks.js +0 -47
  899. package/blockly-rc/tests/compile/webdriver.js +0 -81
  900. package/blockly-rc/tests/generators/functions.xml +0 -561
  901. package/blockly-rc/tests/generators/golden/generated.dart +0 -1604
  902. package/blockly-rc/tests/generators/golden/generated.js +0 -1552
  903. package/blockly-rc/tests/generators/golden/generated.lua +0 -1828
  904. package/blockly-rc/tests/generators/golden/generated.php +0 -1611
  905. package/blockly-rc/tests/generators/golden/generated.py +0 -1407
  906. package/blockly-rc/tests/generators/index.html +0 -405
  907. package/blockly-rc/tests/generators/lists.xml +0 -8675
  908. package/blockly-rc/tests/generators/logic.xml +0 -1019
  909. package/blockly-rc/tests/generators/loops1.xml +0 -345
  910. package/blockly-rc/tests/generators/loops2.xml +0 -891
  911. package/blockly-rc/tests/generators/loops3.xml +0 -735
  912. package/blockly-rc/tests/generators/math.xml +0 -2077
  913. package/blockly-rc/tests/generators/text.xml +0 -4651
  914. package/blockly-rc/tests/generators/unittest.js +0 -103
  915. package/blockly-rc/tests/generators/unittest_dart.js +0 -163
  916. package/blockly-rc/tests/generators/unittest_javascript.js +0 -167
  917. package/blockly-rc/tests/generators/unittest_lua.js +0 -165
  918. package/blockly-rc/tests/generators/unittest_php.js +0 -154
  919. package/blockly-rc/tests/generators/unittest_python.js +0 -138
  920. package/blockly-rc/tests/generators/variables.xml +0 -68
  921. package/blockly-rc/tests/generators/webdriver.js +0 -123
  922. package/blockly-rc/tests/media/200px.png +0 -0
  923. package/blockly-rc/tests/media/30px.png +0 -0
  924. package/blockly-rc/tests/media/50px.png +0 -0
  925. package/blockly-rc/tests/media/a.png +0 -0
  926. package/blockly-rc/tests/media/arrow.png +0 -0
  927. package/blockly-rc/tests/media/b.png +0 -0
  928. package/blockly-rc/tests/media/c.png +0 -0
  929. package/blockly-rc/tests/media/d.png +0 -0
  930. package/blockly-rc/tests/media/e.png +0 -0
  931. package/blockly-rc/tests/media/f.png +0 -0
  932. package/blockly-rc/tests/media/g.png +0 -0
  933. package/blockly-rc/tests/media/h.png +0 -0
  934. package/blockly-rc/tests/media/i.png +0 -0
  935. package/blockly-rc/tests/media/j.png +0 -0
  936. package/blockly-rc/tests/media/k.png +0 -0
  937. package/blockly-rc/tests/media/l.png +0 -0
  938. package/blockly-rc/tests/media/m.png +0 -0
  939. package/blockly-rc/tests/migration/renamings.schema.json +0 -59
  940. package/blockly-rc/tests/migration/validate-renamings.mjs +0 -60
  941. package/blockly-rc/tests/mocha/.eslintrc.json +0 -21
  942. package/blockly-rc/tests/mocha/.mocharc.js +0 -6
  943. package/blockly-rc/tests/mocha/astnode_test.js +0 -850
  944. package/blockly-rc/tests/mocha/block_json_test.js +0 -777
  945. package/blockly-rc/tests/mocha/block_test.js +0 -2743
  946. package/blockly-rc/tests/mocha/blocks/lists_test.js +0 -196
  947. package/blockly-rc/tests/mocha/blocks/logic_ternary_test.js +0 -320
  948. package/blockly-rc/tests/mocha/blocks/loops_test.js +0 -56
  949. package/blockly-rc/tests/mocha/blocks/procedures_test.js +0 -2495
  950. package/blockly-rc/tests/mocha/blocks/variables_test.js +0 -311
  951. package/blockly-rc/tests/mocha/clipboard_test.js +0 -136
  952. package/blockly-rc/tests/mocha/comment_deserialization_test.js +0 -122
  953. package/blockly-rc/tests/mocha/comment_test.js +0 -170
  954. package/blockly-rc/tests/mocha/comment_view_test.js +0 -188
  955. package/blockly-rc/tests/mocha/connection_checker_test.js +0 -666
  956. package/blockly-rc/tests/mocha/connection_db_test.js +0 -362
  957. package/blockly-rc/tests/mocha/connection_test.js +0 -3738
  958. package/blockly-rc/tests/mocha/contextmenu_items_test.js +0 -488
  959. package/blockly-rc/tests/mocha/contextmenu_test.js +0 -71
  960. package/blockly-rc/tests/mocha/cursor_test.js +0 -134
  961. package/blockly-rc/tests/mocha/dropdowndiv_test.js +0 -116
  962. package/blockly-rc/tests/mocha/event_block_change_test.js +0 -126
  963. package/blockly-rc/tests/mocha/event_block_create_test.js +0 -109
  964. package/blockly-rc/tests/mocha/event_block_delete_test.js +0 -55
  965. package/blockly-rc/tests/mocha/event_block_drag_test.js +0 -36
  966. package/blockly-rc/tests/mocha/event_block_field_intermediate_change_test.js +0 -67
  967. package/blockly-rc/tests/mocha/event_block_move_test.js +0 -39
  968. package/blockly-rc/tests/mocha/event_bubble_open_test.js +0 -42
  969. package/blockly-rc/tests/mocha/event_click_test.js +0 -40
  970. package/blockly-rc/tests/mocha/event_comment_change_test.js +0 -39
  971. package/blockly-rc/tests/mocha/event_comment_collapse_test.js +0 -34
  972. package/blockly-rc/tests/mocha/event_comment_create_test.js +0 -38
  973. package/blockly-rc/tests/mocha/event_comment_delete_test.js +0 -38
  974. package/blockly-rc/tests/mocha/event_comment_drag_test.js +0 -35
  975. package/blockly-rc/tests/mocha/event_comment_move_test.js +0 -40
  976. package/blockly-rc/tests/mocha/event_comment_resize_test.js +0 -38
  977. package/blockly-rc/tests/mocha/event_marker_move_test.js +0 -44
  978. package/blockly-rc/tests/mocha/event_selected_test.js +0 -41
  979. package/blockly-rc/tests/mocha/event_test.js +0 -1578
  980. package/blockly-rc/tests/mocha/event_theme_change_test.js +0 -36
  981. package/blockly-rc/tests/mocha/event_toolbox_item_select_test.js +0 -64
  982. package/blockly-rc/tests/mocha/event_trashcan_open_test.js +0 -36
  983. package/blockly-rc/tests/mocha/event_var_create_test.js +0 -54
  984. package/blockly-rc/tests/mocha/event_var_delete_test.js +0 -54
  985. package/blockly-rc/tests/mocha/event_var_rename_test.js +0 -39
  986. package/blockly-rc/tests/mocha/event_var_type_change_test.js +0 -43
  987. package/blockly-rc/tests/mocha/event_viewport_test.js +0 -39
  988. package/blockly-rc/tests/mocha/extensions_test.js +0 -613
  989. package/blockly-rc/tests/mocha/field_checkbox_test.js +0 -299
  990. package/blockly-rc/tests/mocha/field_colour_test.js +0 -395
  991. package/blockly-rc/tests/mocha/field_dropdown_test.js +0 -282
  992. package/blockly-rc/tests/mocha/field_image_test.js +0 -241
  993. package/blockly-rc/tests/mocha/field_label_serializable_test.js +0 -252
  994. package/blockly-rc/tests/mocha/field_label_test.js +0 -226
  995. package/blockly-rc/tests/mocha/field_number_test.js +0 -505
  996. package/blockly-rc/tests/mocha/field_registry_test.js +0 -116
  997. package/blockly-rc/tests/mocha/field_test.js +0 -822
  998. package/blockly-rc/tests/mocha/field_textinput_test.js +0 -297
  999. package/blockly-rc/tests/mocha/field_variable_test.js +0 -611
  1000. package/blockly-rc/tests/mocha/flyout_test.js +0 -638
  1001. package/blockly-rc/tests/mocha/generator_test.js +0 -233
  1002. package/blockly-rc/tests/mocha/gesture_test.js +0 -97
  1003. package/blockly-rc/tests/mocha/icon_test.js +0 -369
  1004. package/blockly-rc/tests/mocha/index.html +0 -229
  1005. package/blockly-rc/tests/mocha/input_test.js +0 -296
  1006. package/blockly-rc/tests/mocha/insertion_marker_manager_test.js +0 -443
  1007. package/blockly-rc/tests/mocha/insertion_marker_test.js +0 -432
  1008. package/blockly-rc/tests/mocha/jso_deserialization_test.js +0 -849
  1009. package/blockly-rc/tests/mocha/jso_serialization_test.js +0 -1067
  1010. package/blockly-rc/tests/mocha/json_test.js +0 -315
  1011. package/blockly-rc/tests/mocha/keydown_test.js +0 -364
  1012. package/blockly-rc/tests/mocha/layering_test.js +0 -95
  1013. package/blockly-rc/tests/mocha/metrics_test.js +0 -671
  1014. package/blockly-rc/tests/mocha/mutator_test.js +0 -87
  1015. package/blockly-rc/tests/mocha/names_test.js +0 -97
  1016. package/blockly-rc/tests/mocha/old_workspace_comment_test.js +0 -256
  1017. package/blockly-rc/tests/mocha/procedure_map_test.js +0 -57
  1018. package/blockly-rc/tests/mocha/registry_test.js +0 -281
  1019. package/blockly-rc/tests/mocha/render_management_test.js +0 -127
  1020. package/blockly-rc/tests/mocha/serializer_test.js +0 -2104
  1021. package/blockly-rc/tests/mocha/shortcut_registry_test.js +0 -450
  1022. package/blockly-rc/tests/mocha/test_helpers/block_definitions.js +0 -204
  1023. package/blockly-rc/tests/mocha/test_helpers/code_generation.js +0 -115
  1024. package/blockly-rc/tests/mocha/test_helpers/common.js +0 -106
  1025. package/blockly-rc/tests/mocha/test_helpers/events.js +0 -290
  1026. package/blockly-rc/tests/mocha/test_helpers/fields.js +0 -310
  1027. package/blockly-rc/tests/mocha/test_helpers/icon_mocks.js +0 -81
  1028. package/blockly-rc/tests/mocha/test_helpers/procedures.js +0 -302
  1029. package/blockly-rc/tests/mocha/test_helpers/serialization.js +0 -124
  1030. package/blockly-rc/tests/mocha/test_helpers/setup_teardown.js +0 -209
  1031. package/blockly-rc/tests/mocha/test_helpers/toolbox_definitions.js +0 -271
  1032. package/blockly-rc/tests/mocha/test_helpers/user_input.js +0 -62
  1033. package/blockly-rc/tests/mocha/test_helpers/variables.js +0 -23
  1034. package/blockly-rc/tests/mocha/test_helpers/warnings.js +0 -83
  1035. package/blockly-rc/tests/mocha/test_helpers/workspace.js +0 -1691
  1036. package/blockly-rc/tests/mocha/theme_test.js +0 -307
  1037. package/blockly-rc/tests/mocha/toolbox_test.js +0 -761
  1038. package/blockly-rc/tests/mocha/tooltip_test.js +0 -276
  1039. package/blockly-rc/tests/mocha/touch_test.js +0 -109
  1040. package/blockly-rc/tests/mocha/trashcan_test.js +0 -375
  1041. package/blockly-rc/tests/mocha/utils_test.js +0 -536
  1042. package/blockly-rc/tests/mocha/variable_map_test.js +0 -509
  1043. package/blockly-rc/tests/mocha/variable_model_test.js +0 -85
  1044. package/blockly-rc/tests/mocha/webdriver.js +0 -96
  1045. package/blockly-rc/tests/mocha/widget_div_test.js +0 -272
  1046. package/blockly-rc/tests/mocha/workspace_comment_test.js +0 -171
  1047. package/blockly-rc/tests/mocha/workspace_svg_test.js +0 -414
  1048. package/blockly-rc/tests/mocha/workspace_test.js +0 -27
  1049. package/blockly-rc/tests/mocha/xml_test.js +0 -951
  1050. package/blockly-rc/tests/mocha/zoom_controls_test.js +0 -81
  1051. package/blockly-rc/tests/multi_playground.html +0 -482
  1052. package/blockly-rc/tests/node/.eslintrc.json +0 -12
  1053. package/blockly-rc/tests/node/.mocharc.js +0 -6
  1054. package/blockly-rc/tests/node/run_node_test.mjs +0 -72
  1055. package/blockly-rc/tests/playground.html +0 -1280
  1056. package/blockly-rc/tests/playgrounds/advanced_playground.html +0 -158
  1057. package/blockly-rc/tests/playgrounds/iframe.html +0 -40
  1058. package/blockly-rc/tests/playgrounds/screenshot.js +0 -123
  1059. package/blockly-rc/tests/scripts/check_metadata.sh +0 -166
  1060. package/blockly-rc/tests/scripts/compile_typings.sh +0 -32
  1061. package/blockly-rc/tests/scripts/load.mjs +0 -140
  1062. package/blockly-rc/tests/scripts/setup_linux_env.sh +0 -7
  1063. package/blockly-rc/tests/scripts/update_metadata.sh +0 -46
  1064. package/blockly-rc/tests/themes/test_themes.js +0 -62
  1065. package/blockly-rc/tests/typescript/README.md +0 -4
  1066. package/blockly-rc/tests/typescript/src/field/different_user_input.ts +0 -81
  1067. package/blockly-rc/tests/typescript/src/generators/dart.ts +0 -24
  1068. package/blockly-rc/tests/typescript/src/generators/javascript.ts +0 -28
  1069. package/blockly-rc/tests/typescript/src/generators/lua.ts +0 -24
  1070. package/blockly-rc/tests/typescript/src/generators/php.ts +0 -24
  1071. package/blockly-rc/tests/typescript/src/generators/python.ts +0 -24
  1072. package/blockly-rc/tests/typescript/src/generators.ts +0 -31
  1073. package/blockly-rc/tests/typescript/src/msg.ts +0 -20
  1074. package/blockly-rc/tests/typescript/tsconfig.json +0 -20
  1075. package/blockly-rc/tests/xml/README.txt +0 -11
  1076. package/blockly-rc/tests/xml/blockly.xsd +0 -178
  1077. package/blockly-rc/tests/xml/invalid.xml +0 -6
  1078. package/blockly-rc/tests/xml/toolbox.xml +0 -311
  1079. package/blockly-rc/tests/xml/workspace.xml +0 -114
  1080. package/blockly-rc/tsconfig.json +0 -37
  1081. package/blockly-rc/tsdoc.json +0 -35
  1082. package/blockly-rc/typings/README.md +0 -5
  1083. package/blockly-rc/typings/blocks.d.ts +0 -17
  1084. package/blockly-rc/typings/core.d.ts +0 -7
  1085. package/blockly-rc/typings/dart.d.ts +0 -7
  1086. package/blockly-rc/typings/index.d.ts +0 -10
  1087. package/blockly-rc/typings/javascript.d.ts +0 -7
  1088. package/blockly-rc/typings/lua.d.ts +0 -7
  1089. package/blockly-rc/typings/msg/ab.d.ts +0 -8
  1090. package/blockly-rc/typings/msg/ace.d.ts +0 -8
  1091. package/blockly-rc/typings/msg/af.d.ts +0 -8
  1092. package/blockly-rc/typings/msg/am.d.ts +0 -8
  1093. package/blockly-rc/typings/msg/ar.d.ts +0 -8
  1094. package/blockly-rc/typings/msg/ast.d.ts +0 -8
  1095. package/blockly-rc/typings/msg/az.d.ts +0 -8
  1096. package/blockly-rc/typings/msg/ba.d.ts +0 -8
  1097. package/blockly-rc/typings/msg/bcc.d.ts +0 -8
  1098. package/blockly-rc/typings/msg/be-tarask.d.ts +0 -8
  1099. package/blockly-rc/typings/msg/be.d.ts +0 -8
  1100. package/blockly-rc/typings/msg/bg.d.ts +0 -8
  1101. package/blockly-rc/typings/msg/bn.d.ts +0 -8
  1102. package/blockly-rc/typings/msg/br.d.ts +0 -8
  1103. package/blockly-rc/typings/msg/bs.d.ts +0 -8
  1104. package/blockly-rc/typings/msg/ca.d.ts +0 -8
  1105. package/blockly-rc/typings/msg/cdo.d.ts +0 -8
  1106. package/blockly-rc/typings/msg/ce.d.ts +0 -8
  1107. package/blockly-rc/typings/msg/cs.d.ts +0 -8
  1108. package/blockly-rc/typings/msg/da.d.ts +0 -8
  1109. package/blockly-rc/typings/msg/de.d.ts +0 -8
  1110. package/blockly-rc/typings/msg/diq.d.ts +0 -8
  1111. package/blockly-rc/typings/msg/dtp.d.ts +0 -8
  1112. package/blockly-rc/typings/msg/dty.d.ts +0 -8
  1113. package/blockly-rc/typings/msg/ee.d.ts +0 -8
  1114. package/blockly-rc/typings/msg/el.d.ts +0 -8
  1115. package/blockly-rc/typings/msg/en-gb.d.ts +0 -8
  1116. package/blockly-rc/typings/msg/en.d.ts +0 -8
  1117. package/blockly-rc/typings/msg/eo.d.ts +0 -8
  1118. package/blockly-rc/typings/msg/es.d.ts +0 -8
  1119. package/blockly-rc/typings/msg/et.d.ts +0 -8
  1120. package/blockly-rc/typings/msg/eu.d.ts +0 -8
  1121. package/blockly-rc/typings/msg/fa.d.ts +0 -8
  1122. package/blockly-rc/typings/msg/fi.d.ts +0 -8
  1123. package/blockly-rc/typings/msg/fo.d.ts +0 -8
  1124. package/blockly-rc/typings/msg/fr.d.ts +0 -8
  1125. package/blockly-rc/typings/msg/frr.d.ts +0 -8
  1126. package/blockly-rc/typings/msg/gl.d.ts +0 -8
  1127. package/blockly-rc/typings/msg/gn.d.ts +0 -8
  1128. package/blockly-rc/typings/msg/gor.d.ts +0 -8
  1129. package/blockly-rc/typings/msg/ha.d.ts +0 -8
  1130. package/blockly-rc/typings/msg/hak.d.ts +0 -8
  1131. package/blockly-rc/typings/msg/he.d.ts +0 -8
  1132. package/blockly-rc/typings/msg/hi.d.ts +0 -8
  1133. package/blockly-rc/typings/msg/hr.d.ts +0 -8
  1134. package/blockly-rc/typings/msg/hrx.d.ts +0 -8
  1135. package/blockly-rc/typings/msg/hsb.d.ts +0 -8
  1136. package/blockly-rc/typings/msg/hu.d.ts +0 -8
  1137. package/blockly-rc/typings/msg/hy.d.ts +0 -8
  1138. package/blockly-rc/typings/msg/ia.d.ts +0 -8
  1139. package/blockly-rc/typings/msg/id.d.ts +0 -8
  1140. package/blockly-rc/typings/msg/ig.d.ts +0 -8
  1141. package/blockly-rc/typings/msg/inh.d.ts +0 -8
  1142. package/blockly-rc/typings/msg/is.d.ts +0 -8
  1143. package/blockly-rc/typings/msg/it.d.ts +0 -8
  1144. package/blockly-rc/typings/msg/ja.d.ts +0 -8
  1145. package/blockly-rc/typings/msg/ka.d.ts +0 -8
  1146. package/blockly-rc/typings/msg/kab.d.ts +0 -8
  1147. package/blockly-rc/typings/msg/kbd-cyrl.d.ts +0 -8
  1148. package/blockly-rc/typings/msg/km.d.ts +0 -8
  1149. package/blockly-rc/typings/msg/kn.d.ts +0 -8
  1150. package/blockly-rc/typings/msg/ko.d.ts +0 -8
  1151. package/blockly-rc/typings/msg/ksh.d.ts +0 -8
  1152. package/blockly-rc/typings/msg/ku-latn.d.ts +0 -8
  1153. package/blockly-rc/typings/msg/ky.d.ts +0 -8
  1154. package/blockly-rc/typings/msg/la.d.ts +0 -8
  1155. package/blockly-rc/typings/msg/lb.d.ts +0 -8
  1156. package/blockly-rc/typings/msg/lki.d.ts +0 -8
  1157. package/blockly-rc/typings/msg/lo.d.ts +0 -8
  1158. package/blockly-rc/typings/msg/lrc.d.ts +0 -8
  1159. package/blockly-rc/typings/msg/lt.d.ts +0 -8
  1160. package/blockly-rc/typings/msg/lv.d.ts +0 -8
  1161. package/blockly-rc/typings/msg/mg.d.ts +0 -8
  1162. package/blockly-rc/typings/msg/mk.d.ts +0 -8
  1163. package/blockly-rc/typings/msg/ml.d.ts +0 -8
  1164. package/blockly-rc/typings/msg/mnw.d.ts +0 -8
  1165. package/blockly-rc/typings/msg/ms.d.ts +0 -8
  1166. package/blockly-rc/typings/msg/msg.d.ts +0 -440
  1167. package/blockly-rc/typings/msg/my.d.ts +0 -8
  1168. package/blockly-rc/typings/msg/mzn.d.ts +0 -8
  1169. package/blockly-rc/typings/msg/nb.d.ts +0 -8
  1170. package/blockly-rc/typings/msg/ne.d.ts +0 -8
  1171. package/blockly-rc/typings/msg/nl.d.ts +0 -8
  1172. package/blockly-rc/typings/msg/oc.d.ts +0 -8
  1173. package/blockly-rc/typings/msg/olo.d.ts +0 -8
  1174. package/blockly-rc/typings/msg/pa.d.ts +0 -8
  1175. package/blockly-rc/typings/msg/pl.d.ts +0 -8
  1176. package/blockly-rc/typings/msg/pms.d.ts +0 -8
  1177. package/blockly-rc/typings/msg/ps.d.ts +0 -8
  1178. package/blockly-rc/typings/msg/pt-br.d.ts +0 -8
  1179. package/blockly-rc/typings/msg/pt.d.ts +0 -8
  1180. package/blockly-rc/typings/msg/ro.d.ts +0 -8
  1181. package/blockly-rc/typings/msg/ru.d.ts +0 -8
  1182. package/blockly-rc/typings/msg/sc.d.ts +0 -8
  1183. package/blockly-rc/typings/msg/sco.d.ts +0 -8
  1184. package/blockly-rc/typings/msg/sd.d.ts +0 -8
  1185. package/blockly-rc/typings/msg/shn.d.ts +0 -8
  1186. package/blockly-rc/typings/msg/si.d.ts +0 -8
  1187. package/blockly-rc/typings/msg/sk.d.ts +0 -8
  1188. package/blockly-rc/typings/msg/skr-arab.d.ts +0 -8
  1189. package/blockly-rc/typings/msg/sl.d.ts +0 -8
  1190. package/blockly-rc/typings/msg/smn.d.ts +0 -8
  1191. package/blockly-rc/typings/msg/sq.d.ts +0 -8
  1192. package/blockly-rc/typings/msg/sr-latn.d.ts +0 -8
  1193. package/blockly-rc/typings/msg/sr.d.ts +0 -8
  1194. package/blockly-rc/typings/msg/sv.d.ts +0 -8
  1195. package/blockly-rc/typings/msg/sw.d.ts +0 -8
  1196. package/blockly-rc/typings/msg/ta.d.ts +0 -8
  1197. package/blockly-rc/typings/msg/tcy.d.ts +0 -8
  1198. package/blockly-rc/typings/msg/tdd.d.ts +0 -8
  1199. package/blockly-rc/typings/msg/te.d.ts +0 -8
  1200. package/blockly-rc/typings/msg/th.d.ts +0 -8
  1201. package/blockly-rc/typings/msg/ti.d.ts +0 -8
  1202. package/blockly-rc/typings/msg/tl.d.ts +0 -8
  1203. package/blockly-rc/typings/msg/tlh.d.ts +0 -8
  1204. package/blockly-rc/typings/msg/tr.d.ts +0 -8
  1205. package/blockly-rc/typings/msg/ug-arab.d.ts +0 -8
  1206. package/blockly-rc/typings/msg/uk.d.ts +0 -8
  1207. package/blockly-rc/typings/msg/ur.d.ts +0 -8
  1208. package/blockly-rc/typings/msg/uz.d.ts +0 -8
  1209. package/blockly-rc/typings/msg/vi.d.ts +0 -8
  1210. package/blockly-rc/typings/msg/xmf.d.ts +0 -8
  1211. package/blockly-rc/typings/msg/yo.d.ts +0 -8
  1212. package/blockly-rc/typings/msg/zgh.d.ts +0 -8
  1213. package/blockly-rc/typings/msg/zh-hans.d.ts +0 -8
  1214. package/blockly-rc/typings/msg/zh-hant.d.ts +0 -8
  1215. package/blockly-rc/typings/php.d.ts +0 -7
  1216. package/blockly-rc/typings/python.d.ts +0 -7
  1217. package/blockly-rc/typings/templates/blockly-header.template +0 -11
  1218. package/blockly-rc/typings/templates/blockly-interfaces.template +0 -83
  1219. package/blockly-rc/typings/templates/msg.template +0 -15
  1220. package/blockly-rc/typings/tsconfig.json +0 -23
  1221. package/continuous-toolbox.d.ts +0 -1
  1222. package/dist/main.js +0 -2
  1223. package/dist/main.js.LICENSE.txt +0 -163
  1224. package/media/delete-icon.svg +0 -10
  1225. package/media/resize-handle.svg +0 -3
  1226. package/src/block_reporting.js +0 -31
  1227. package/src/blocks/colour.js +0 -56
  1228. package/src/blocks/control.js +0 -492
  1229. package/src/blocks/data.js +0 -690
  1230. package/src/blocks/event.js +0 -305
  1231. package/src/blocks/looks.js +0 -537
  1232. package/src/blocks/math.js +0 -137
  1233. package/src/blocks/matrix.js +0 -47
  1234. package/src/blocks/motion.js +0 -513
  1235. package/src/blocks/note.js +0 -48
  1236. package/src/blocks/operators.js +0 -463
  1237. package/src/blocks/procedures.js +0 -1009
  1238. package/src/blocks/sensing.js +0 -441
  1239. package/src/blocks/sound.js +0 -205
  1240. package/src/blocks/text.js +0 -45
  1241. package/src/blocks/vertical_extensions.js +0 -309
  1242. package/src/categories.js +0 -15
  1243. package/src/checkable_continuous_flyout.js +0 -138
  1244. package/src/checkbox_bubble.js +0 -282
  1245. package/src/colours.js +0 -77
  1246. package/src/constants.js +0 -63
  1247. package/src/context_menu_items.js +0 -150
  1248. package/src/css.js +0 -1197
  1249. package/src/data_category.js +0 -556
  1250. package/src/events/events_block_comment_base.js +0 -35
  1251. package/src/events/events_block_comment_change.js +0 -43
  1252. package/src/events/events_block_comment_collapse.js +0 -43
  1253. package/src/events/events_block_comment_create.js +0 -52
  1254. package/src/events/events_block_comment_delete.js +0 -27
  1255. package/src/events/events_block_comment_move.js +0 -54
  1256. package/src/events/events_block_comment_resize.js +0 -52
  1257. package/src/events/events_block_drag_end.js +0 -33
  1258. package/src/events/events_block_drag_outside.js +0 -30
  1259. package/src/events/events_scratch_variable_create.js +0 -67
  1260. package/src/fields/field_angle.js +0 -433
  1261. package/src/fields/field_colour_slider.js +0 -388
  1262. package/src/fields/field_dropdown.js +0 -42
  1263. package/src/fields/field_matrix.js +0 -634
  1264. package/src/fields/field_note.js +0 -937
  1265. package/src/fields/field_number.js +0 -380
  1266. package/src/fields/field_textinput_removable.js +0 -107
  1267. package/src/fields/field_variable.js +0 -171
  1268. package/src/fields/field_variable_getter.js +0 -109
  1269. package/src/fields/field_vertical_separator.js +0 -139
  1270. package/src/flyout_checkbox_icon.js +0 -88
  1271. package/src/glows.js +0 -98
  1272. package/src/index.ts +0 -137
  1273. package/src/procedures.js +0 -425
  1274. package/src/recyclable_block_flyout_inflater.js +0 -194
  1275. package/src/renderer/bowler_hat.js +0 -17
  1276. package/src/renderer/constants.js +0 -45
  1277. package/src/renderer/drawer.js +0 -51
  1278. package/src/renderer/path_object.js +0 -35
  1279. package/src/renderer/render_info.js +0 -98
  1280. package/src/renderer/renderer.js +0 -74
  1281. package/src/scratch_block_paster.js +0 -46
  1282. package/src/scratch_blocks_utils.js +0 -148
  1283. package/src/scratch_comment_bubble.js +0 -169
  1284. package/src/scratch_comment_icon.js +0 -195
  1285. package/src/scratch_connection_checker.js +0 -29
  1286. package/src/scratch_continuous_category.js +0 -80
  1287. package/src/scratch_continuous_toolbox.js +0 -78
  1288. package/src/scratch_dragger.js +0 -142
  1289. package/src/scratch_variable_map.js +0 -25
  1290. package/src/scratch_variable_model.js +0 -24
  1291. package/src/shadows.js +0 -61
  1292. package/src/status_indicator_label.js +0 -186
  1293. package/src/status_indicator_label_flyout_inflater.js +0 -42
  1294. package/src/variables.js +0 -355
  1295. package/temp-use-blockly-v12-rc.sh +0 -26
  1296. package/tsconfig.json +0 -13
  1297. /package/media/{foldout-icon.svg → comment-arrow-down.svg} +0 -0
@@ -1,2523 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2011 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
-
7
- /**
8
- * The class representing one block.
9
- *
10
- * @class
11
- */
12
- // Former goog.module ID: Blockly.Block
13
-
14
- // Unused import preserved for side-effects. Remove if unneeded.
15
- import './events/events_block_change.js';
16
- // Unused import preserved for side-effects. Remove if unneeded.
17
- import './events/events_block_create.js';
18
- // Unused import preserved for side-effects. Remove if unneeded.
19
- import './events/events_block_delete.js';
20
-
21
- import {Blocks} from './blocks.js';
22
- import * as common from './common.js';
23
- import {Connection} from './connection.js';
24
- import {ConnectionType} from './connection_type.js';
25
- import * as constants from './constants.js';
26
- import {DuplicateIconType} from './icons/exceptions.js';
27
- import type {Abstract} from './events/events_abstract.js';
28
- import type {BlockChange} from './events/events_block_change.js';
29
- import type {BlockMove} from './events/events_block_move.js';
30
- import * as deprecation from './utils/deprecation.js';
31
- import * as eventUtils from './events/utils.js';
32
- import * as Extensions from './extensions.js';
33
- import type {Field} from './field.js';
34
- import * as fieldRegistry from './field_registry.js';
35
- import {Input} from './inputs/input.js';
36
- import {Align} from './inputs/align.js';
37
- import type {IASTNodeLocation} from './interfaces/i_ast_node_location.js';
38
- import {type IIcon} from './interfaces/i_icon.js';
39
- import {isCommentIcon} from './interfaces/i_comment_icon.js';
40
- import type {MutatorIcon} from './icons/mutator_icon.js';
41
- import * as Tooltip from './tooltip.js';
42
- import * as arrayUtils from './utils/array.js';
43
- import {Coordinate} from './utils/coordinate.js';
44
- import * as idGenerator from './utils/idgenerator.js';
45
- import * as parsing from './utils/parsing.js';
46
- import * as registry from './registry.js';
47
- import {Size} from './utils/size.js';
48
- import type {
49
- IVariableModel,
50
- IVariableState,
51
- } from './interfaces/i_variable_model.js';
52
- import type {Workspace} from './workspace.js';
53
- import {DummyInput} from './inputs/dummy_input.js';
54
- import {EndRowInput} from './inputs/end_row_input.js';
55
- import {ValueInput} from './inputs/value_input.js';
56
- import {StatementInput} from './inputs/statement_input.js';
57
- import {IconType} from './icons/icon_types.js';
58
-
59
- /**
60
- * Class for one block.
61
- * Not normally called directly, workspace.newBlock() is preferred.
62
- */
63
- export class Block implements IASTNodeLocation {
64
- /**
65
- * An optional callback method to use whenever the block's parent workspace
66
- * changes. This is usually only called from the constructor, the block type
67
- * initializer function, or an extension initializer function.
68
- */
69
- onchange?: ((p1: Abstract) => void) | null;
70
-
71
- /** The language-neutral ID given to the collapsed input. */
72
- static readonly COLLAPSED_INPUT_NAME: string = constants.COLLAPSED_INPUT_NAME;
73
-
74
- /** The language-neutral ID given to the collapsed field. */
75
- static readonly COLLAPSED_FIELD_NAME: string = constants.COLLAPSED_FIELD_NAME;
76
-
77
- /**
78
- * Optional text data that round-trips between blocks and XML.
79
- * Has no effect. May be used by 3rd parties for meta information.
80
- */
81
- data: string | null = null;
82
-
83
- /**
84
- * Has this block been disposed of?
85
- *
86
- * @internal
87
- */
88
- disposed = false;
89
-
90
- /**
91
- * Colour of the block as HSV hue value (0-360)
92
- * This may be null if the block colour was not set via a hue number.
93
- */
94
- private hue_: number | null = null;
95
-
96
- /** Colour of the block in '#RRGGBB' format. */
97
- protected colour_ = '#000000';
98
-
99
- /** Name of the block style. */
100
- protected styleName_ = '';
101
-
102
- /** An optional method called during initialization. */
103
- init?: () => void;
104
-
105
- /** An optional method called during disposal. */
106
- destroy?: () => void;
107
-
108
- /**
109
- * An optional serialization method for defining how to serialize the
110
- * mutation state to XML. This must be coupled with defining
111
- * `domToMutation`.
112
- */
113
- mutationToDom?: (...p1: AnyDuringMigration[]) => Element;
114
-
115
- /**
116
- * An optional deserialization method for defining how to deserialize the
117
- * mutation state from XML. This must be coupled with defining
118
- * `mutationToDom`.
119
- */
120
- domToMutation?: (p1: Element) => void;
121
-
122
- /**
123
- * An optional serialization method for defining how to serialize the
124
- * block's extra state (eg mutation state) to something JSON compatible.
125
- * This must be coupled with defining `loadExtraState`.
126
- *
127
- * @param doFullSerialization Whether or not to serialize the full state of
128
- * the extra state (rather than possibly saving a reference to some
129
- * state). This is used during copy-paste. See the
130
- * {@link https://developers.devsite.google.com/blockly/guides/create-custom-blocks/extensions#full_serialization_and_backing_data | block serialization docs}
131
- * for more information.
132
- */
133
- saveExtraState?: (doFullSerialization?: boolean) => AnyDuringMigration;
134
-
135
- /**
136
- * An optional serialization method for defining how to deserialize the
137
- * block's extra state (eg mutation state) from something JSON compatible.
138
- * This must be coupled with defining `saveExtraState`.
139
- */
140
- loadExtraState?: (p1: AnyDuringMigration) => void;
141
-
142
- /**
143
- * An optional property for suppressing adding STATEMENT_PREFIX and
144
- * STATEMENT_SUFFIX to generated code.
145
- */
146
- suppressPrefixSuffix: boolean | null = false;
147
-
148
- /**
149
- * An optional property for declaring developer variables. Return a list of
150
- * variable names for use by generators. Developer variables are never
151
- * shown to the user, but are declared as global variables in the generated
152
- * code.
153
- */
154
- getDeveloperVariables?: () => string[];
155
-
156
- /**
157
- * An optional function that reconfigures the block based on the contents of
158
- * the mutator dialog.
159
- */
160
- compose?: (p1: Block) => void;
161
-
162
- /**
163
- * An optional function that populates the mutator's dialog with
164
- * this block's components.
165
- */
166
- decompose?: (p1: Workspace) => Block;
167
- id: string;
168
- outputConnection: Connection | null = null;
169
- nextConnection: Connection | null = null;
170
- previousConnection: Connection | null = null;
171
- inputList: Input[] = [];
172
- inputsInline?: boolean;
173
- icons: IIcon[] = [];
174
- private disabledReasons = new Set<string>();
175
- tooltip: Tooltip.TipInfo = '';
176
- contextMenu = true;
177
-
178
- protected parentBlock_: this | null = null;
179
-
180
- protected childBlocks_: this[] = [];
181
-
182
- private deletable_ = true;
183
-
184
- private movable_ = true;
185
-
186
- private editable_ = true;
187
-
188
- private isShadow_ = false;
189
-
190
- protected collapsed_ = false;
191
- protected outputShape_: number | null = null;
192
-
193
- /**
194
- * Is the current block currently in the process of being disposed?
195
- */
196
- protected disposing = false;
197
-
198
- /**
199
- * Has this block been fully initialized? E.g. all fields initailized.
200
- *
201
- * @internal
202
- */
203
- initialized = false;
204
-
205
- private readonly xy_: Coordinate;
206
- isInFlyout: boolean;
207
- isInMutator: boolean;
208
- RTL: boolean;
209
-
210
- /** True if this block is an insertion marker. */
211
- protected isInsertionMarker_ = false;
212
-
213
- /** Name of the type of hat. */
214
- hat?: string;
215
-
216
- /** Is this block a BlockSVG? */
217
- readonly rendered: boolean = false;
218
-
219
- /**
220
- * String for block help, or function that returns a URL. Null for no help.
221
- */
222
- helpUrl: string | Function | null = null;
223
-
224
- /** A bound callback function to use when the parent workspace changes. */
225
- private onchangeWrapper_: ((p1: Abstract) => void) | null = null;
226
-
227
- /**
228
- * A count of statement inputs on the block.
229
- *
230
- * @internal
231
- */
232
- statementInputCount = 0;
233
- // TODO(b/109816955): remove '!', see go/strict-prop-init-fix.
234
- type!: string;
235
- // Record initial inline state.
236
- inputsInlineDefault?: boolean;
237
- workspace: Workspace;
238
-
239
- /**
240
- * @param workspace The block's workspace.
241
- * @param prototypeName Name of the language object containing type-specific
242
- * functions for this block.
243
- * @param opt_id Optional ID. Use this ID if provided, otherwise create a new
244
- * ID.
245
- * @throws When the prototypeName is not valid or not allowed.
246
- */
247
- constructor(workspace: Workspace, prototypeName: string, opt_id?: string) {
248
- this.workspace = workspace;
249
-
250
- this.id =
251
- opt_id && !workspace.getBlockById(opt_id) ? opt_id : idGenerator.genUid();
252
- workspace.setBlockById(this.id, this);
253
-
254
- /**
255
- * The block's position in workspace units. (0, 0) is at the workspace's
256
- * origin; scale does not change this value.
257
- */
258
- this.xy_ = new Coordinate(0, 0);
259
- this.isInFlyout = workspace.isFlyout;
260
- this.isInMutator = workspace.isMutator;
261
-
262
- this.RTL = workspace.RTL;
263
-
264
- // Copy the type-specific functions and data from the prototype.
265
- if (prototypeName) {
266
- this.type = prototypeName;
267
- const prototype = Blocks[prototypeName];
268
- if (!prototype || typeof prototype !== 'object') {
269
- throw TypeError('Invalid block definition for type: ' + prototypeName);
270
- }
271
- Object.assign(this, prototype);
272
- }
273
-
274
- workspace.addTopBlock(this);
275
- workspace.addTypedBlock(this);
276
-
277
- if (new.target === Block) {
278
- this.doInit_();
279
- }
280
- }
281
-
282
- /** Calls the init() function and handles associated event firing, etc. */
283
- protected doInit_() {
284
- // All events fired should be part of the same group.
285
- // Any events fired during init should not be undoable,
286
- // so that block creation is atomic.
287
- const existingGroup = eventUtils.getGroup();
288
- if (!existingGroup) {
289
- eventUtils.setGroup(true);
290
- }
291
- const initialUndoFlag = eventUtils.getRecordUndo();
292
-
293
- try {
294
- // Call an initialization function, if it exists.
295
- if (typeof this.init === 'function') {
296
- eventUtils.setRecordUndo(false);
297
- this.init();
298
- eventUtils.setRecordUndo(initialUndoFlag);
299
- }
300
-
301
- // Fire a create event.
302
- if (eventUtils.isEnabled()) {
303
- eventUtils.fire(new (eventUtils.get(eventUtils.BLOCK_CREATE))(this));
304
- }
305
- } finally {
306
- eventUtils.setGroup(existingGroup);
307
- // In case init threw, recordUndo flag should still be reset.
308
- eventUtils.setRecordUndo(initialUndoFlag);
309
- }
310
- this.inputsInlineDefault = this.inputsInline;
311
-
312
- // Bind an onchange function, if it exists.
313
- if (typeof this.onchange === 'function') {
314
- this.setOnChange(this.onchange);
315
- }
316
- }
317
-
318
- /**
319
- * Dispose of this block.
320
- *
321
- * @param healStack If true, then try to heal any gap by connecting the next
322
- * statement with the previous statement. Otherwise, dispose of all
323
- * children of this block.
324
- */
325
- dispose(healStack = false) {
326
- this.disposing = true;
327
-
328
- // Dispose of this change listener before unplugging.
329
- // Technically not necessary due to the event firing delay.
330
- // But future-proofing.
331
- if (this.onchangeWrapper_) {
332
- this.workspace.removeChangeListener(this.onchangeWrapper_);
333
- }
334
-
335
- this.unplug(healStack);
336
- if (eventUtils.isEnabled()) {
337
- // Constructing the delete event is costly. Only perform if necessary.
338
- eventUtils.fire(new (eventUtils.get(eventUtils.BLOCK_DELETE))(this));
339
- }
340
- this.workspace.removeTopBlock(this);
341
- this.disposeInternal();
342
- }
343
-
344
- /**
345
- * Disposes of this block without doing things required by the top block.
346
- * E.g. does not fire events, unplug the block, etc.
347
- */
348
- protected disposeInternal() {
349
- this.disposing = true;
350
- if (this.onchangeWrapper_) {
351
- this.workspace.removeChangeListener(this.onchangeWrapper_);
352
- }
353
-
354
- this.workspace.removeTypedBlock(this);
355
- this.workspace.removeBlockById(this.id);
356
-
357
- if (typeof this.destroy === 'function') this.destroy();
358
-
359
- this.childBlocks_.forEach((c) => c.disposeInternal());
360
- this.inputList.forEach((i) => i.dispose());
361
- this.inputList.length = 0;
362
- this.getConnections_(true).forEach((c) => c.dispose());
363
- this.disposed = true;
364
- }
365
-
366
- /**
367
- * Returns true if the block is either in the process of being disposed, or
368
- * is disposed.
369
- *
370
- * @internal
371
- */
372
- isDeadOrDying(): boolean {
373
- return this.disposing || this.disposed;
374
- }
375
-
376
- /**
377
- * Call initModel on all fields on the block.
378
- * May be called more than once.
379
- * Either initModel or initSvg must be called after creating a block and
380
- * before the first interaction with it. Interactions include UI actions
381
- * (e.g. clicking and dragging) and firing events (e.g. create, delete, and
382
- * change).
383
- */
384
- initModel() {
385
- if (this.initialized) return;
386
- for (const input of this.inputList) {
387
- input.initModel();
388
- }
389
- this.initialized = true;
390
- }
391
-
392
- /**
393
- * Unplug this block from its superior block. If this block is a statement,
394
- * optionally reconnect the block underneath with the block on top.
395
- *
396
- * @param opt_healStack Disconnect child statement and reconnect stack.
397
- * Defaults to false.
398
- */
399
- unplug(opt_healStack?: boolean) {
400
- if (this.outputConnection) {
401
- this.unplugFromRow_(opt_healStack);
402
- }
403
- if (this.previousConnection) {
404
- this.unplugFromStack_(opt_healStack);
405
- }
406
- }
407
-
408
- /**
409
- * Unplug this block's output from an input on another block. Optionally
410
- * reconnect the block's parent to the only child block, if possible.
411
- *
412
- * @param opt_healStack Disconnect right-side block and connect to left-side
413
- * block. Defaults to false.
414
- */
415
- private unplugFromRow_(opt_healStack?: boolean) {
416
- let parentConnection = null;
417
- if (this.outputConnection?.isConnected()) {
418
- parentConnection = this.outputConnection.targetConnection;
419
- // Disconnect from any superior block.
420
- this.outputConnection.disconnect();
421
- }
422
-
423
- // Return early in obvious cases.
424
- if (!parentConnection || !opt_healStack) {
425
- return;
426
- }
427
-
428
- const thisConnection = this.getOnlyValueConnection_();
429
- if (
430
- !thisConnection ||
431
- !thisConnection.isConnected() ||
432
- thisConnection.targetBlock()!.isShadow()
433
- ) {
434
- // Too many or too few possible connections on this block, or there's
435
- // nothing on the other side of this connection.
436
- return;
437
- }
438
-
439
- const childConnection = thisConnection.targetConnection;
440
- // Disconnect the child block.
441
- childConnection?.disconnect();
442
- // Connect child to the parent if possible, otherwise bump away.
443
- if (
444
- this.workspace.connectionChecker.canConnect(
445
- childConnection,
446
- parentConnection,
447
- false,
448
- )
449
- ) {
450
- parentConnection.connect(childConnection!);
451
- } else {
452
- childConnection?.onFailedConnect(parentConnection);
453
- }
454
- }
455
-
456
- /**
457
- * Returns the connection on the value input that is connected to another
458
- * block. When an insertion marker is connected to a connection with a block
459
- * already attached, the connected block is attached to the insertion marker.
460
- * Since only one block can be displaced and attached to the insertion marker
461
- * this should only ever return one connection.
462
- *
463
- * @returns The connection on the value input, or null.
464
- */
465
- private getOnlyValueConnection_(): Connection | null {
466
- let connection = null;
467
- for (let i = 0; i < this.inputList.length; i++) {
468
- const thisConnection = this.inputList[i].connection;
469
- if (
470
- thisConnection &&
471
- thisConnection.type === ConnectionType.INPUT_VALUE &&
472
- thisConnection.targetConnection
473
- ) {
474
- if (connection) {
475
- return null; // More than one value input found.
476
- }
477
- connection = thisConnection;
478
- }
479
- }
480
- return connection;
481
- }
482
-
483
- /**
484
- * Unplug this statement block from its superior block. Optionally reconnect
485
- * the block underneath with the block on top.
486
- *
487
- * @param opt_healStack Disconnect child statement and reconnect stack.
488
- * Defaults to false.
489
- */
490
- private unplugFromStack_(opt_healStack?: boolean) {
491
- let previousTarget = null;
492
- if (this.previousConnection?.isConnected()) {
493
- // Remember the connection that any next statements need to connect to.
494
- previousTarget = this.previousConnection.targetConnection;
495
- // Detach this block from the parent's tree.
496
- this.previousConnection.disconnect();
497
- }
498
- const nextBlock = this.getNextBlock();
499
- if (opt_healStack && nextBlock && !nextBlock.isShadow()) {
500
- // Disconnect the next statement.
501
- const nextTarget = this.nextConnection?.targetConnection ?? null;
502
- nextTarget?.disconnect();
503
- if (
504
- previousTarget &&
505
- this.workspace.connectionChecker.canConnect(
506
- previousTarget,
507
- nextTarget,
508
- false,
509
- )
510
- ) {
511
- // Attach the next statement to the previous statement.
512
- previousTarget.connect(nextTarget!);
513
- }
514
- }
515
- }
516
-
517
- /**
518
- * Returns all connections originating from this block.
519
- *
520
- * @param _all If true, return all connections even hidden ones.
521
- * @returns Array of connections.
522
- * @internal
523
- */
524
- getConnections_(_all: boolean): Connection[] {
525
- const myConnections = [];
526
- if (this.outputConnection) {
527
- myConnections.push(this.outputConnection);
528
- }
529
- if (this.previousConnection) {
530
- myConnections.push(this.previousConnection);
531
- }
532
- if (this.nextConnection) {
533
- myConnections.push(this.nextConnection);
534
- }
535
- for (let i = 0, input; (input = this.inputList[i]); i++) {
536
- if (input.connection) {
537
- myConnections.push(input.connection);
538
- }
539
- }
540
- return myConnections;
541
- }
542
-
543
- /**
544
- * Walks down a stack of blocks and finds the last next connection on the
545
- * stack.
546
- *
547
- * @param ignoreShadows If true,the last connection on a non-shadow block will
548
- * be returned. If false, this will follow shadows to find the last
549
- * connection.
550
- * @returns The last next connection on the stack, or null.
551
- * @internal
552
- */
553
- lastConnectionInStack(ignoreShadows: boolean): Connection | null {
554
- let nextConnection = this.nextConnection;
555
- while (nextConnection) {
556
- const nextBlock = nextConnection.targetBlock();
557
- if (!nextBlock || (ignoreShadows && nextBlock.isShadow())) {
558
- return nextConnection;
559
- }
560
- nextConnection = nextBlock.nextConnection;
561
- }
562
- return null;
563
- }
564
-
565
- /**
566
- * Bump unconnected blocks out of alignment. Two blocks which aren't actually
567
- * connected should not coincidentally line up on screen.
568
- */
569
- bumpNeighbours() {}
570
-
571
- /**
572
- * Return the parent block or null if this block is at the top level. The
573
- * parent block is either the block connected to the previous connection (for
574
- * a statement block) or the block connected to the output connection (for a
575
- * value block).
576
- *
577
- * @returns The block (if any) that holds the current block.
578
- */
579
- getParent(): this | null {
580
- return this.parentBlock_;
581
- }
582
-
583
- /**
584
- * Return the input that connects to the specified block.
585
- *
586
- * @param block A block connected to an input on this block.
587
- * @returns The input (if any) that connects to the specified block.
588
- */
589
- getInputWithBlock(block: Block): Input | null {
590
- for (let i = 0, input; (input = this.inputList[i]); i++) {
591
- if (input.connection && input.connection.targetBlock() === block) {
592
- return input;
593
- }
594
- }
595
- return null;
596
- }
597
-
598
- /**
599
- * Return the parent block that surrounds the current block, or null if this
600
- * block has no surrounding block. A parent block might just be the previous
601
- * statement, whereas the surrounding block is an if statement, while loop,
602
- * etc.
603
- *
604
- * @returns The block (if any) that surrounds the current block.
605
- */
606
- getSurroundParent(): this | null {
607
- /* eslint-disable-next-line @typescript-eslint/no-this-alias */
608
- let block: this | null = this;
609
- let prevBlock;
610
- do {
611
- prevBlock = block;
612
- block = block.getParent();
613
- if (!block) {
614
- // Ran off the top.
615
- return null;
616
- }
617
- } while (block.getNextBlock() === prevBlock);
618
- // This block is an enclosing parent, not just a statement in a stack.
619
- return block;
620
- }
621
-
622
- /**
623
- * Return the next statement block directly connected to this block.
624
- *
625
- * @returns The next statement block or null.
626
- */
627
- getNextBlock(): Block | null {
628
- return this.nextConnection && this.nextConnection.targetBlock();
629
- }
630
-
631
- /**
632
- * Returns the block connected to the previous connection.
633
- *
634
- * @returns The previous statement block or null.
635
- */
636
- getPreviousBlock(): Block | null {
637
- return this.previousConnection && this.previousConnection.targetBlock();
638
- }
639
-
640
- /**
641
- * Return the top-most block in this block's tree.
642
- * This will return itself if this block is at the top level.
643
- *
644
- * @returns The root block.
645
- */
646
- getRootBlock(): this {
647
- let rootBlock: this;
648
- /* eslint-disable-next-line @typescript-eslint/no-this-alias */
649
- let block: this | null = this;
650
- do {
651
- rootBlock = block;
652
- block = rootBlock.parentBlock_;
653
- } while (block);
654
- return rootBlock;
655
- }
656
-
657
- /**
658
- * Walk up from the given block up through the stack of blocks to find
659
- * the top block of the sub stack. If we are nested in a statement input only
660
- * find the top-most nested block. Do not go all the way to the root block.
661
- *
662
- * @returns The top block in a stack.
663
- * @internal
664
- */
665
- getTopStackBlock(): this {
666
- /* eslint-disable-next-line @typescript-eslint/no-this-alias */
667
- let block = this;
668
- let previous;
669
- do {
670
- previous = block.getPreviousBlock();
671
- // AnyDuringMigration because: Type 'Block' is not assignable to type
672
- // 'this'.
673
- } while (
674
- previous &&
675
- previous.getNextBlock() === block &&
676
- (block = previous as AnyDuringMigration)
677
- );
678
- return block;
679
- }
680
-
681
- /**
682
- * Find all the blocks that are directly nested inside this one.
683
- * Includes value and statement inputs, as well as any following statement.
684
- * Excludes any connection on an output tab or any preceding statement.
685
- * Blocks are optionally sorted by position; top to bottom.
686
- *
687
- * @param ordered Sort the list if true.
688
- * @returns Array of blocks.
689
- */
690
- getChildren(ordered: boolean): Block[] {
691
- if (!ordered) {
692
- return this.childBlocks_;
693
- }
694
- const blocks = [];
695
- for (let i = 0, input; (input = this.inputList[i]); i++) {
696
- if (input.connection) {
697
- const child = input.connection.targetBlock();
698
- if (child) {
699
- blocks.push(child);
700
- }
701
- }
702
- }
703
- const next = this.getNextBlock();
704
- if (next) {
705
- blocks.push(next);
706
- }
707
- return blocks;
708
- }
709
-
710
- /**
711
- * Set parent of this block to be a new block or null.
712
- *
713
- * @param newParent New parent block.
714
- * @internal
715
- */
716
- setParent(newParent: this | null) {
717
- if (newParent === this.parentBlock_) {
718
- return;
719
- }
720
-
721
- // Check that block is connected to new parent if new parent is not null and
722
- // that block is not connected to superior one if new parent is null.
723
- const targetBlock =
724
- (this.previousConnection && this.previousConnection.targetBlock()) ||
725
- (this.outputConnection && this.outputConnection.targetBlock());
726
- const isConnected = !!targetBlock;
727
-
728
- if (isConnected && newParent && targetBlock !== newParent) {
729
- throw Error('Block connected to superior one that is not new parent.');
730
- } else if (!isConnected && newParent) {
731
- throw Error('Block not connected to new parent.');
732
- } else if (isConnected && !newParent) {
733
- throw Error(
734
- 'Cannot set parent to null while block is still connected to' +
735
- ' superior block.',
736
- );
737
- }
738
-
739
- // This block hasn't actually moved on-screen, so there's no need to
740
- // update
741
- // its connection locations.
742
- if (this.parentBlock_) {
743
- // Remove this block from the old parent's child list.
744
- arrayUtils.removeElem(this.parentBlock_.childBlocks_, this);
745
- } else {
746
- // New parent must be non-null so remove this block from the workspace's
747
- // list of top-most blocks.
748
- this.workspace.removeTopBlock(this);
749
- }
750
-
751
- this.parentBlock_ = newParent;
752
- if (newParent) {
753
- // Add this block to the new parent's child list.
754
- newParent.childBlocks_.push(this);
755
- } else {
756
- this.workspace.addTopBlock(this);
757
- }
758
- }
759
-
760
- /**
761
- * Find all the blocks that are directly or indirectly nested inside this one.
762
- * Includes this block in the list.
763
- * Includes value and statement inputs, as well as any following statements.
764
- * Excludes any connection on an output tab or any preceding statements.
765
- * Blocks are optionally sorted by position; top to bottom.
766
- *
767
- * @param ordered Sort the list if true.
768
- * @returns Flattened array of blocks.
769
- */
770
- getDescendants(ordered: boolean): this[] {
771
- const blocks = [this];
772
- const childBlocks = this.getChildren(ordered);
773
- for (let child, i = 0; (child = childBlocks[i]); i++) {
774
- // AnyDuringMigration because: Argument of type 'Block[]' is not
775
- // assignable to parameter of type 'this[]'.
776
- blocks.push(...(child.getDescendants(ordered) as AnyDuringMigration));
777
- }
778
- return blocks;
779
- }
780
-
781
- /**
782
- * Get whether this block is deletable or not.
783
- *
784
- * @returns True if deletable.
785
- */
786
- isDeletable(): boolean {
787
- return (
788
- this.deletable_ &&
789
- !this.isShadow_ &&
790
- !this.isDeadOrDying() &&
791
- !this.workspace.options.readOnly
792
- );
793
- }
794
-
795
- /**
796
- * Return whether this block's own deletable property is true or false.
797
- *
798
- * @returns True if the block's deletable property is true, false otherwise.
799
- */
800
- isOwnDeletable(): boolean {
801
- return this.deletable_;
802
- }
803
-
804
- /**
805
- * Set whether this block is deletable or not.
806
- *
807
- * @param deletable True if deletable.
808
- */
809
- setDeletable(deletable: boolean) {
810
- this.deletable_ = deletable;
811
- }
812
-
813
- /**
814
- * Get whether this block is movable or not.
815
- *
816
- * @returns True if movable.
817
- * @internal
818
- */
819
- isMovable(): boolean {
820
- return (
821
- this.movable_ &&
822
- !this.isShadow_ &&
823
- !this.isDeadOrDying() &&
824
- !this.workspace.options.readOnly
825
- );
826
- }
827
-
828
- /**
829
- * Return whether this block's own movable property is true or false.
830
- *
831
- * @returns True if the block's movable property is true, false otherwise.
832
- * @internal
833
- */
834
- isOwnMovable(): boolean {
835
- return this.movable_;
836
- }
837
-
838
- /**
839
- * Set whether this block is movable or not.
840
- *
841
- * @param movable True if movable.
842
- */
843
- setMovable(movable: boolean) {
844
- this.movable_ = movable;
845
- }
846
-
847
- /**
848
- * Get whether is block is duplicatable or not. If duplicating this block and
849
- * descendants will put this block over the workspace's capacity this block is
850
- * not duplicatable. If duplicating this block and descendants will put any
851
- * type over their maxInstances this block is not duplicatable.
852
- *
853
- * @returns True if duplicatable.
854
- */
855
- isDuplicatable(): boolean {
856
- if (!this.workspace.hasBlockLimits()) {
857
- return true;
858
- }
859
- return this.workspace.isCapacityAvailable(
860
- common.getBlockTypeCounts(this, true),
861
- );
862
- }
863
-
864
- /**
865
- * Get whether this block is a shadow block or not.
866
- *
867
- * @returns True if a shadow.
868
- */
869
- isShadow(): boolean {
870
- return this.isShadow_;
871
- }
872
-
873
- /**
874
- * Set whether this block is a shadow block or not.
875
- * This method is internal and should not be called by users of Blockly. To
876
- * create shadow blocks programmatically call connection.setShadowState
877
- *
878
- * @param shadow True if a shadow.
879
- * @internal
880
- */
881
- setShadow(shadow: boolean) {
882
- this.isShadow_ = shadow;
883
- }
884
-
885
- /**
886
- * Get whether this block is an insertion marker block or not.
887
- *
888
- * @returns True if an insertion marker.
889
- */
890
- isInsertionMarker(): boolean {
891
- return this.isInsertionMarker_;
892
- }
893
-
894
- /**
895
- * Set whether this block is an insertion marker block or not.
896
- * Once set this cannot be unset.
897
- *
898
- * @param insertionMarker True if an insertion marker.
899
- * @internal
900
- */
901
- setInsertionMarker(insertionMarker: boolean) {
902
- this.isInsertionMarker_ = insertionMarker;
903
- }
904
-
905
- /**
906
- * Get whether this block is editable or not.
907
- *
908
- * @returns True if editable.
909
- * @internal
910
- */
911
- isEditable(): boolean {
912
- return (
913
- this.editable_ &&
914
- !this.isDeadOrDying() &&
915
- !this.workspace.options.readOnly
916
- );
917
- }
918
-
919
- /**
920
- * Return whether this block's own editable property is true or false.
921
- *
922
- * @returns True if the block's editable property is true, false otherwise.
923
- */
924
- isOwnEditable(): boolean {
925
- return this.editable_;
926
- }
927
-
928
- /**
929
- * Set whether this block is editable or not.
930
- *
931
- * @param editable True if editable.
932
- */
933
- setEditable(editable: boolean) {
934
- this.editable_ = editable;
935
- for (let i = 0, input; (input = this.inputList[i]); i++) {
936
- for (let j = 0, field; (field = input.fieldRow[j]); j++) {
937
- field.updateEditable();
938
- }
939
- }
940
- }
941
-
942
- /**
943
- * Returns if this block has been disposed of / deleted.
944
- *
945
- * @returns True if this block has been disposed of / deleted.
946
- */
947
- isDisposed(): boolean {
948
- return this.disposed;
949
- }
950
-
951
- /**
952
- * @returns True if this block is a value block with a single editable field.
953
- * @internal
954
- */
955
- isSimpleReporter(): boolean {
956
- if (!this.outputConnection) return false;
957
-
958
- for (const input of this.inputList) {
959
- if (input.connection || input.fieldRow.length > 1) return false;
960
- }
961
- return true;
962
- }
963
-
964
- /**
965
- * Find the connection on this block that corresponds to the given connection
966
- * on the other block.
967
- * Used to match connections between a block and its insertion marker.
968
- *
969
- * @param otherBlock The other block to match against.
970
- * @param conn The other connection to match.
971
- * @returns The matching connection on this block, or null.
972
- * @internal
973
- */
974
- getMatchingConnection(
975
- otherBlock: Block,
976
- conn: Connection,
977
- ): Connection | null {
978
- const connections = this.getConnections_(true);
979
- const otherConnections = otherBlock.getConnections_(true);
980
- if (connections.length !== otherConnections.length) {
981
- throw Error('Connection lists did not match in length.');
982
- }
983
- for (let i = 0; i < otherConnections.length; i++) {
984
- if (otherConnections[i] === conn) {
985
- return connections[i];
986
- }
987
- }
988
- return null;
989
- }
990
-
991
- /**
992
- * Set the URL of this block's help page.
993
- *
994
- * @param url URL string for block help, or function that returns a URL. Null
995
- * for no help.
996
- */
997
- setHelpUrl(url: string | Function) {
998
- this.helpUrl = url;
999
- }
1000
-
1001
- /**
1002
- * Sets the tooltip for this block.
1003
- *
1004
- * @param newTip The text for the tooltip, a function that returns the text
1005
- * for the tooltip, or a parent object whose tooltip will be used. To not
1006
- * display a tooltip pass the empty string.
1007
- */
1008
- setTooltip(newTip: Tooltip.TipInfo) {
1009
- this.tooltip = newTip;
1010
- }
1011
-
1012
- /**
1013
- * Returns the tooltip text for this block.
1014
- *
1015
- * @returns The tooltip text for this block.
1016
- */
1017
- getTooltip(): string {
1018
- return Tooltip.getTooltipOfObject(this);
1019
- }
1020
-
1021
- /**
1022
- * Get the colour of a block.
1023
- *
1024
- * @returns #RRGGBB string.
1025
- */
1026
- getColour(): string {
1027
- return this.colour_;
1028
- }
1029
-
1030
- /**
1031
- * Get the name of the block style.
1032
- *
1033
- * @returns Name of the block style.
1034
- */
1035
- getStyleName(): string {
1036
- return this.styleName_;
1037
- }
1038
-
1039
- /**
1040
- * Get the HSV hue value of a block. Null if hue not set.
1041
- *
1042
- * @returns Hue value (0-360).
1043
- */
1044
- getHue(): number | null {
1045
- return this.hue_;
1046
- }
1047
-
1048
- /**
1049
- * Change the colour of a block.
1050
- *
1051
- * @param colour HSV hue value (0 to 360), #RRGGBB string, or a message
1052
- * reference string pointing to one of those two values.
1053
- */
1054
- setColour(colour: number | string) {
1055
- const parsed = parsing.parseBlockColour(colour);
1056
- this.hue_ = parsed.hue;
1057
- this.colour_ = parsed.hex;
1058
- }
1059
-
1060
- /**
1061
- * Set the style and colour values of a block.
1062
- *
1063
- * @param blockStyleName Name of the block style.
1064
- */
1065
- setStyle(blockStyleName: string) {
1066
- this.styleName_ = blockStyleName;
1067
- }
1068
-
1069
- /**
1070
- * Sets a callback function to use whenever the block's parent workspace
1071
- * changes, replacing any prior onchange handler. This is usually only called
1072
- * from the constructor, the block type initializer function, or an extension
1073
- * initializer function.
1074
- *
1075
- * @param onchangeFn The callback to call when the block's workspace changes.
1076
- * @throws {Error} if onchangeFn is not falsey and not a function.
1077
- */
1078
- setOnChange(onchangeFn: (p1: Abstract) => void) {
1079
- if (onchangeFn && typeof onchangeFn !== 'function') {
1080
- throw Error('onchange must be a function.');
1081
- }
1082
- if (this.onchangeWrapper_) {
1083
- this.workspace.removeChangeListener(this.onchangeWrapper_);
1084
- }
1085
- this.onchange = onchangeFn;
1086
- this.onchangeWrapper_ = onchangeFn.bind(this);
1087
- this.workspace.addChangeListener(this.onchangeWrapper_);
1088
- }
1089
-
1090
- /**
1091
- * Returns the named field from a block.
1092
- *
1093
- * @param name The name of the field.
1094
- * @returns Named field, or null if field does not exist.
1095
- */
1096
- getField(name: string): Field | null {
1097
- if (typeof name !== 'string') {
1098
- throw TypeError(
1099
- 'Block.prototype.getField expects a string ' +
1100
- 'with the field name but received ' +
1101
- (name === undefined ? 'nothing' : name + ' of type ' + typeof name) +
1102
- ' instead',
1103
- );
1104
- }
1105
- for (let i = 0, input; (input = this.inputList[i]); i++) {
1106
- for (let j = 0, field; (field = input.fieldRow[j]); j++) {
1107
- if (field.name === name) {
1108
- return field;
1109
- }
1110
- }
1111
- }
1112
- return null;
1113
- }
1114
-
1115
- /**
1116
- * Return all variables referenced by this block.
1117
- *
1118
- * @returns List of variable ids.
1119
- */
1120
- getVars(): string[] {
1121
- const vars: string[] = [];
1122
- for (let i = 0, input; (input = this.inputList[i]); i++) {
1123
- for (let j = 0, field; (field = input.fieldRow[j]); j++) {
1124
- if (field.referencesVariables()) {
1125
- // NOTE: This only applies to `FieldVariable`, a `Field<string>`
1126
- vars.push(field.getValue() as string);
1127
- }
1128
- }
1129
- }
1130
- return vars;
1131
- }
1132
-
1133
- /**
1134
- * Return all variables referenced by this block.
1135
- *
1136
- * @returns List of variable models.
1137
- * @internal
1138
- */
1139
- getVarModels(): IVariableModel<IVariableState>[] {
1140
- const vars = [];
1141
- for (let i = 0, input; (input = this.inputList[i]); i++) {
1142
- for (let j = 0, field; (field = input.fieldRow[j]); j++) {
1143
- if (field.referencesVariables()) {
1144
- const model = this.workspace.getVariableById(
1145
- field.getValue() as string,
1146
- );
1147
- // Check if the variable actually exists (and isn't just a potential
1148
- // variable).
1149
- if (model) {
1150
- vars.push(model);
1151
- }
1152
- }
1153
- }
1154
- }
1155
- return vars;
1156
- }
1157
-
1158
- /**
1159
- * Notification that a variable is renaming but keeping the same ID. If the
1160
- * variable is in use on this block, rerender to show the new name.
1161
- *
1162
- * @param variable The variable being renamed.
1163
- * @internal
1164
- */
1165
- updateVarName(variable: IVariableModel<IVariableState>) {
1166
- for (let i = 0, input; (input = this.inputList[i]); i++) {
1167
- for (let j = 0, field; (field = input.fieldRow[j]); j++) {
1168
- if (
1169
- field.referencesVariables() &&
1170
- variable.getId() === field.getValue()
1171
- ) {
1172
- field.refreshVariableName();
1173
- }
1174
- }
1175
- }
1176
- }
1177
-
1178
- /**
1179
- * Notification that a variable is renaming.
1180
- * If the ID matches one of this block's variables, rename it.
1181
- *
1182
- * @param oldId ID of variable to rename.
1183
- * @param newId ID of new variable. May be the same as oldId, but with an
1184
- * updated name.
1185
- */
1186
- renameVarById(oldId: string, newId: string) {
1187
- for (let i = 0, input; (input = this.inputList[i]); i++) {
1188
- for (let j = 0, field; (field = input.fieldRow[j]); j++) {
1189
- if (field.referencesVariables() && oldId === field.getValue()) {
1190
- field.setValue(newId);
1191
- }
1192
- }
1193
- }
1194
- }
1195
-
1196
- /**
1197
- * Returns the language-neutral value of the given field.
1198
- *
1199
- * @param name The name of the field.
1200
- * @returns Value of the field or null if field does not exist.
1201
- */
1202
- getFieldValue(name: string): AnyDuringMigration {
1203
- const field = this.getField(name);
1204
- if (field) {
1205
- return field.getValue();
1206
- }
1207
- return null;
1208
- }
1209
-
1210
- /**
1211
- * Sets the value of the given field for this block.
1212
- *
1213
- * @param newValue The value to set.
1214
- * @param name The name of the field to set the value of.
1215
- */
1216
- setFieldValue(newValue: AnyDuringMigration, name: string) {
1217
- const field = this.getField(name);
1218
- if (!field) {
1219
- throw Error('Field "' + name + '" not found.');
1220
- }
1221
- field.setValue(newValue);
1222
- }
1223
-
1224
- /**
1225
- * Set whether this block can chain onto the bottom of another block.
1226
- *
1227
- * @param newBoolean True if there can be a previous statement.
1228
- * @param opt_check Statement type or list of statement types. Null/undefined
1229
- * if any type could be connected.
1230
- */
1231
- setPreviousStatement(
1232
- newBoolean: boolean,
1233
- opt_check?: string | string[] | null,
1234
- ) {
1235
- if (newBoolean) {
1236
- if (opt_check === undefined) {
1237
- opt_check = null;
1238
- }
1239
- if (!this.previousConnection) {
1240
- this.previousConnection = this.makeConnection_(
1241
- ConnectionType.PREVIOUS_STATEMENT,
1242
- );
1243
- }
1244
- this.previousConnection.setCheck(opt_check);
1245
- } else {
1246
- if (this.previousConnection) {
1247
- if (this.previousConnection.isConnected()) {
1248
- throw Error(
1249
- 'Must disconnect previous statement before removing ' +
1250
- 'connection.',
1251
- );
1252
- }
1253
- this.previousConnection.dispose();
1254
- this.previousConnection = null;
1255
- }
1256
- }
1257
- }
1258
-
1259
- /**
1260
- * Set whether another block can chain onto the bottom of this block.
1261
- *
1262
- * @param newBoolean True if there can be a next statement.
1263
- * @param opt_check Statement type or list of statement types. Null/undefined
1264
- * if any type could be connected.
1265
- */
1266
- setNextStatement(newBoolean: boolean, opt_check?: string | string[] | null) {
1267
- if (newBoolean) {
1268
- if (opt_check === undefined) {
1269
- opt_check = null;
1270
- }
1271
- if (!this.nextConnection) {
1272
- this.nextConnection = this.makeConnection_(
1273
- ConnectionType.NEXT_STATEMENT,
1274
- );
1275
- }
1276
- this.nextConnection.setCheck(opt_check);
1277
- } else {
1278
- if (this.nextConnection) {
1279
- if (this.nextConnection.isConnected()) {
1280
- throw Error(
1281
- 'Must disconnect next statement before removing ' + 'connection.',
1282
- );
1283
- }
1284
- this.nextConnection.dispose();
1285
- this.nextConnection = null;
1286
- }
1287
- }
1288
- }
1289
-
1290
- /**
1291
- * Set whether this block returns a value.
1292
- *
1293
- * @param newBoolean True if there is an output.
1294
- * @param opt_check Returned type or list of returned types. Null or
1295
- * undefined if any type could be returned (e.g. variable get).
1296
- */
1297
- setOutput(newBoolean: boolean, opt_check?: string | string[] | null) {
1298
- if (newBoolean) {
1299
- if (opt_check === undefined) {
1300
- opt_check = null;
1301
- }
1302
- if (!this.outputConnection) {
1303
- this.outputConnection = this.makeConnection_(
1304
- ConnectionType.OUTPUT_VALUE,
1305
- );
1306
- }
1307
- this.outputConnection.setCheck(opt_check);
1308
- } else {
1309
- if (this.outputConnection) {
1310
- if (this.outputConnection.isConnected()) {
1311
- throw Error(
1312
- 'Must disconnect output value before removing connection.',
1313
- );
1314
- }
1315
- this.outputConnection.dispose();
1316
- this.outputConnection = null;
1317
- }
1318
- }
1319
- }
1320
-
1321
- /**
1322
- * Set whether value inputs are arranged horizontally or vertically.
1323
- *
1324
- * @param newBoolean True if inputs are horizontal.
1325
- */
1326
- setInputsInline(newBoolean: boolean) {
1327
- if (this.inputsInline !== newBoolean) {
1328
- eventUtils.fire(
1329
- new (eventUtils.get(eventUtils.BLOCK_CHANGE))(
1330
- this,
1331
- 'inline',
1332
- null,
1333
- this.inputsInline,
1334
- newBoolean,
1335
- ),
1336
- );
1337
- this.inputsInline = newBoolean;
1338
- }
1339
- }
1340
-
1341
- /**
1342
- * Get whether value inputs are arranged horizontally or vertically.
1343
- *
1344
- * @returns True if inputs are horizontal.
1345
- */
1346
- getInputsInline(): boolean {
1347
- if (this.inputsInline !== undefined) {
1348
- // Set explicitly.
1349
- return this.inputsInline;
1350
- }
1351
- // Not defined explicitly. Figure out what would look best.
1352
- for (let i = 1; i < this.inputList.length; i++) {
1353
- if (
1354
- this.inputList[i - 1] instanceof DummyInput &&
1355
- this.inputList[i] instanceof DummyInput
1356
- ) {
1357
- // Two dummy inputs in a row. Don't inline them.
1358
- return false;
1359
- }
1360
- }
1361
- for (let i = 1; i < this.inputList.length; i++) {
1362
- if (
1363
- this.inputList[i - 1] instanceof ValueInput &&
1364
- this.inputList[i] instanceof DummyInput
1365
- ) {
1366
- // Dummy input after a value input. Inline them.
1367
- return true;
1368
- }
1369
- }
1370
- for (let i = 0; i < this.inputList.length; i++) {
1371
- if (this.inputList[i] instanceof EndRowInput) {
1372
- // A row-end input is present. Inline value inputs.
1373
- return true;
1374
- }
1375
- }
1376
- return false;
1377
- }
1378
-
1379
- /**
1380
- * Set the block's output shape.
1381
- *
1382
- * @param outputShape Value representing an output shape.
1383
- */
1384
- setOutputShape(outputShape: number | null) {
1385
- this.outputShape_ = outputShape;
1386
- }
1387
-
1388
- /**
1389
- * Get the block's output shape.
1390
- *
1391
- * @returns Value representing output shape if one exists.
1392
- */
1393
- getOutputShape(): number | null {
1394
- return this.outputShape_;
1395
- }
1396
-
1397
- /**
1398
- * Get whether this block is enabled or not. A block is considered enabled
1399
- * if there aren't any reasons why it would be disabled. A block may still
1400
- * be disabled for other reasons even if the user attempts to manually
1401
- * enable it, such as when the block is in an invalid location.
1402
- *
1403
- * @returns True if enabled.
1404
- */
1405
- isEnabled(): boolean {
1406
- return this.disabledReasons.size === 0;
1407
- }
1408
-
1409
- /** @deprecated v11 - Get whether the block is manually disabled. */
1410
- private get disabled(): boolean {
1411
- deprecation.warn(
1412
- 'disabled',
1413
- 'v11',
1414
- 'v12',
1415
- 'the isEnabled or hasDisabledReason methods of Block',
1416
- );
1417
- return this.hasDisabledReason(constants.MANUALLY_DISABLED);
1418
- }
1419
-
1420
- /** @deprecated v11 - Set whether the block is manually disabled. */
1421
- private set disabled(value: boolean) {
1422
- deprecation.warn(
1423
- 'disabled',
1424
- 'v11',
1425
- 'v12',
1426
- 'the setDisabledReason method of Block',
1427
- );
1428
- this.setDisabledReason(value, constants.MANUALLY_DISABLED);
1429
- }
1430
-
1431
- /**
1432
- * @deprecated v11 - Set whether the block is manually enabled or disabled.
1433
- * The user can toggle whether a block is disabled from a context menu
1434
- * option. A block may still be disabled for other reasons even if the user
1435
- * attempts to manually enable it, such as when the block is in an invalid
1436
- * location. This method is deprecated and setDisabledReason should be used
1437
- * instead.
1438
- *
1439
- * @param enabled True if enabled.
1440
- */
1441
- setEnabled(enabled: boolean) {
1442
- deprecation.warn(
1443
- 'setEnabled',
1444
- 'v11',
1445
- 'v12',
1446
- 'the setDisabledReason method of Block',
1447
- );
1448
- this.setDisabledReason(!enabled, constants.MANUALLY_DISABLED);
1449
- }
1450
-
1451
- /**
1452
- * Add or remove a reason why the block might be disabled. If a block has
1453
- * any reasons to be disabled, then the block itself will be considered
1454
- * disabled. A block could be disabled for multiple independent reasons
1455
- * simultaneously, such as when the user manually disables it, or the block
1456
- * is invalid.
1457
- *
1458
- * @param disabled If true, then the block should be considered disabled for
1459
- * at least the provided reason, otherwise the block is no longer disabled
1460
- * for that reason.
1461
- * @param reason A language-neutral identifier for a reason why the block
1462
- * could be disabled. Call this method again with the same identifier to
1463
- * update whether the block is currently disabled for this reason.
1464
- */
1465
- setDisabledReason(disabled: boolean, reason: string): void {
1466
- if (this.disabledReasons.has(reason) !== disabled) {
1467
- if (disabled) {
1468
- this.disabledReasons.add(reason);
1469
- } else {
1470
- this.disabledReasons.delete(reason);
1471
- }
1472
- const blockChangeEvent = new (eventUtils.get(eventUtils.BLOCK_CHANGE))(
1473
- this,
1474
- 'disabled',
1475
- /* name= */ null,
1476
- /* oldValue= */ !disabled,
1477
- /* newValue= */ disabled,
1478
- ) as BlockChange;
1479
- blockChangeEvent.setDisabledReason(reason);
1480
- eventUtils.fire(blockChangeEvent);
1481
- }
1482
- }
1483
-
1484
- /**
1485
- * Get whether the block is disabled or not due to parents.
1486
- * The block's own disabled property is not considered.
1487
- *
1488
- * @returns True if disabled.
1489
- */
1490
- getInheritedDisabled(): boolean {
1491
- let ancestor = this.getSurroundParent();
1492
- while (ancestor) {
1493
- if (!ancestor.isEnabled()) {
1494
- return true;
1495
- }
1496
- ancestor = ancestor.getSurroundParent();
1497
- }
1498
- // Ran off the top.
1499
- return false;
1500
- }
1501
-
1502
- /**
1503
- * Get whether the block is currently disabled for the provided reason.
1504
- *
1505
- * @param reason A language-neutral identifier for a reason why the block
1506
- * could be disabled.
1507
- * @returns Whether the block is disabled for the provided reason.
1508
- */
1509
- hasDisabledReason(reason: string): boolean {
1510
- return this.disabledReasons.has(reason);
1511
- }
1512
-
1513
- /**
1514
- * Get a set of reasons why the block is currently disabled, if any. If the
1515
- * block is enabled, this set will be empty.
1516
- *
1517
- * @returns The set of reasons why the block is disabled, if any.
1518
- */
1519
- getDisabledReasons(): ReadonlySet<string> {
1520
- return this.disabledReasons;
1521
- }
1522
-
1523
- /**
1524
- * Get whether the block is collapsed or not.
1525
- *
1526
- * @returns True if collapsed.
1527
- */
1528
- isCollapsed(): boolean {
1529
- return this.collapsed_;
1530
- }
1531
-
1532
- /**
1533
- * Set whether the block is collapsed or not.
1534
- *
1535
- * @param collapsed True if collapsed.
1536
- */
1537
- setCollapsed(collapsed: boolean) {
1538
- if (this.collapsed_ !== collapsed) {
1539
- eventUtils.fire(
1540
- new (eventUtils.get(eventUtils.BLOCK_CHANGE))(
1541
- this,
1542
- 'collapsed',
1543
- null,
1544
- this.collapsed_,
1545
- collapsed,
1546
- ),
1547
- );
1548
- this.collapsed_ = collapsed;
1549
- }
1550
- }
1551
-
1552
- /**
1553
- * Create a human-readable text representation of this block and any children.
1554
- *
1555
- * @param opt_maxLength Truncate the string to this length.
1556
- * @param opt_emptyToken The placeholder string used to denote an empty input.
1557
- * If not specified, '?' is used.
1558
- * @returns Text of block.
1559
- */
1560
- toString(opt_maxLength?: number, opt_emptyToken?: string): string {
1561
- const tokens = this.toTokens(opt_emptyToken);
1562
-
1563
- // Run through our tokens array and simplify expression to remove
1564
- // parentheses around single field blocks.
1565
- // E.g. ['repeat', '(', '10', ')', 'times', 'do', '?']
1566
- for (let i = 2; i < tokens.length; i++) {
1567
- if (tokens[i - 2] === '(' && tokens[i] === ')') {
1568
- tokens[i - 2] = tokens[i - 1];
1569
- tokens.splice(i - 1, 2);
1570
- }
1571
- }
1572
-
1573
- // Join the text array, removing the spaces around added parentheses.
1574
- let prev = '';
1575
- let text: string = tokens.reduce((acc, curr) => {
1576
- const val = acc + (prev === '(' || curr === ')' ? '' : ' ') + curr;
1577
- prev = curr[curr.length - 1];
1578
- return val;
1579
- }, '');
1580
-
1581
- text = text.trim() || '???';
1582
- if (opt_maxLength) {
1583
- // TODO: Improve truncation so that text from this block is given
1584
- // priority. E.g. "1+2+3+4+5+6+7+8+9=0" should be "...6+7+8+9=0", not
1585
- // "1+2+3+4+5...". E.g. "1+2+3+4+5=6+7+8+9+0" should be "...4+5=6+7...".
1586
- if (text.length > opt_maxLength) {
1587
- text = text.substring(0, opt_maxLength - 3) + '...';
1588
- }
1589
- }
1590
- return text;
1591
- }
1592
-
1593
- /**
1594
- * Converts this block into string tokens.
1595
- *
1596
- * @param emptyToken The token to use in place of an empty input.
1597
- * Defaults to '?'.
1598
- * @returns The array of string tokens representing this block.
1599
- */
1600
- private toTokens(emptyToken = '?'): string[] {
1601
- const tokens = [];
1602
- /**
1603
- * Whether or not to add parentheses around an input.
1604
- *
1605
- * @param connection The connection.
1606
- * @returns True if we should add parentheses around the input.
1607
- */
1608
- function shouldAddParentheses(connection: Connection): boolean {
1609
- let checks = connection.getCheck();
1610
- if (!checks && connection.targetConnection) {
1611
- checks = connection.targetConnection.getCheck();
1612
- }
1613
- return (
1614
- !!checks && (checks.includes('Boolean') || checks.includes('Number'))
1615
- );
1616
- }
1617
-
1618
- for (const input of this.inputList) {
1619
- if (input.name == constants.COLLAPSED_INPUT_NAME) {
1620
- continue;
1621
- }
1622
- for (const field of input.fieldRow) {
1623
- tokens.push(field.getText());
1624
- }
1625
- if (input.connection) {
1626
- const child = input.connection.targetBlock();
1627
- if (child) {
1628
- const shouldAddParens = shouldAddParentheses(input.connection);
1629
- if (shouldAddParens) tokens.push('(');
1630
- tokens.push(...child.toTokens(emptyToken));
1631
- if (shouldAddParens) tokens.push(')');
1632
- } else {
1633
- tokens.push(emptyToken);
1634
- }
1635
- }
1636
- }
1637
- return tokens;
1638
- }
1639
-
1640
- /**
1641
- * Appends a value input row.
1642
- *
1643
- * @param name Language-neutral identifier which may used to find this input
1644
- * again. Should be unique to this block.
1645
- * @returns The input object created.
1646
- */
1647
- appendValueInput(name: string): Input {
1648
- return this.appendInput(new ValueInput(name, this));
1649
- }
1650
-
1651
- /**
1652
- * Appends a statement input row.
1653
- *
1654
- * @param name Language-neutral identifier which may used to find this input
1655
- * again. Should be unique to this block.
1656
- * @returns The input object created.
1657
- */
1658
- appendStatementInput(name: string): Input {
1659
- this.statementInputCount++;
1660
- return this.appendInput(new StatementInput(name, this));
1661
- }
1662
-
1663
- /**
1664
- * Appends a dummy input row.
1665
- *
1666
- * @param name Optional language-neutral identifier which may used to find
1667
- * this input again. Should be unique to this block.
1668
- * @returns The input object created.
1669
- */
1670
- appendDummyInput(name = ''): Input {
1671
- return this.appendInput(new DummyInput(name, this));
1672
- }
1673
-
1674
- /**
1675
- * Appends an input that ends the row.
1676
- *
1677
- * @param name Optional language-neutral identifier which may used to find
1678
- * this input again. Should be unique to this block.
1679
- * @returns The input object created.
1680
- */
1681
- appendEndRowInput(name = ''): Input {
1682
- return this.appendInput(new EndRowInput(name, this));
1683
- }
1684
-
1685
- /**
1686
- * Appends the given input row.
1687
- *
1688
- * Allows for custom inputs to be appended to the block.
1689
- */
1690
- appendInput(input: Input): Input {
1691
- this.inputList.push(input);
1692
- return input;
1693
- }
1694
-
1695
- /**
1696
- * Appends an input with the given input type and name to the block after
1697
- * constructing it from the registry.
1698
- *
1699
- * @param type The name the input is registered under in the registry.
1700
- * @param name The name the input will have within the block.
1701
- * @returns The constucted input, or null if there was no constructor
1702
- * associated with the type.
1703
- */
1704
- private appendInputFromRegistry(type: string, name: string): Input | null {
1705
- const inputConstructor = registry.getClass(
1706
- registry.Type.INPUT,
1707
- type,
1708
- false,
1709
- );
1710
- if (!inputConstructor) return null;
1711
- return this.appendInput(new inputConstructor(name, this));
1712
- }
1713
-
1714
- /**
1715
- * Initialize this block using a cross-platform, internationalization-friendly
1716
- * JSON description.
1717
- *
1718
- * @param json Structured data describing the block.
1719
- */
1720
- jsonInit(json: AnyDuringMigration) {
1721
- const warningPrefix = json['type'] ? 'Block "' + json['type'] + '": ' : '';
1722
-
1723
- // Validate inputs.
1724
- if (json['output'] && json['previousStatement']) {
1725
- throw Error(
1726
- warningPrefix + 'Must not have both an output and a previousStatement.',
1727
- );
1728
- }
1729
-
1730
- // Validate that each arg has a corresponding message
1731
- let n = 0;
1732
- while (json['args' + n]) {
1733
- if (json['message' + n] === undefined) {
1734
- throw Error(
1735
- warningPrefix +
1736
- `args${n} must have a corresponding message (message${n}).`,
1737
- );
1738
- }
1739
- n++;
1740
- }
1741
-
1742
- // Set basic properties of block.
1743
- // Makes styles backward compatible with old way of defining hat style.
1744
- if (json['style'] && json['style'].hat) {
1745
- this.hat = json['style'].hat;
1746
- // Must set to null so it doesn't error when checking for style and
1747
- // colour.
1748
- json['style'] = null;
1749
- }
1750
-
1751
- if (json['style'] && json['colour']) {
1752
- throw Error(warningPrefix + 'Must not have both a colour and a style.');
1753
- } else if (json['style']) {
1754
- this.jsonInitStyle_(json, warningPrefix);
1755
- } else {
1756
- this.jsonInitColour_(json, warningPrefix);
1757
- }
1758
-
1759
- // Interpolate the message blocks.
1760
- let i = 0;
1761
- while (json['message' + i] !== undefined) {
1762
- this.interpolate_(
1763
- json['message' + i],
1764
- json['args' + i] || [],
1765
- // Backwards compatibility: lastDummyAlign aliases implicitAlign.
1766
- json['implicitAlign' + i] || json['lastDummyAlign' + i],
1767
- warningPrefix,
1768
- );
1769
- i++;
1770
- }
1771
-
1772
- if (json['inputsInline'] !== undefined) {
1773
- eventUtils.disable();
1774
- this.setInputsInline(json['inputsInline']);
1775
- eventUtils.enable();
1776
- }
1777
-
1778
- // Set output and previous/next connections.
1779
- if (json['output'] !== undefined) {
1780
- this.setOutput(true, json['output']);
1781
- }
1782
- if (json['outputShape'] !== undefined) {
1783
- this.setOutputShape(json['outputShape']);
1784
- }
1785
- if (json['previousStatement'] !== undefined) {
1786
- this.setPreviousStatement(true, json['previousStatement']);
1787
- }
1788
- if (json['nextStatement'] !== undefined) {
1789
- this.setNextStatement(true, json['nextStatement']);
1790
- }
1791
- if (json['tooltip'] !== undefined) {
1792
- const rawValue = json['tooltip'];
1793
- const localizedText = parsing.replaceMessageReferences(rawValue);
1794
- this.setTooltip(localizedText);
1795
- }
1796
- if (json['enableContextMenu'] !== undefined) {
1797
- this.contextMenu = !!json['enableContextMenu'];
1798
- }
1799
- if (json['suppressPrefixSuffix'] !== undefined) {
1800
- this.suppressPrefixSuffix = !!json['suppressPrefixSuffix'];
1801
- }
1802
- if (json['helpUrl'] !== undefined) {
1803
- const rawValue = json['helpUrl'];
1804
- const localizedValue = parsing.replaceMessageReferences(rawValue);
1805
- this.setHelpUrl(localizedValue);
1806
- }
1807
- if (typeof json['extensions'] === 'string') {
1808
- console.warn(
1809
- warningPrefix +
1810
- "JSON attribute 'extensions' should be an array of" +
1811
- " strings. Found raw string in JSON for '" +
1812
- json['type'] +
1813
- "' block.",
1814
- );
1815
- json['extensions'] = [json['extensions']]; // Correct and continue.
1816
- }
1817
-
1818
- // Add the mutator to the block.
1819
- if (json['mutator'] !== undefined) {
1820
- Extensions.apply(json['mutator'], this, true);
1821
- }
1822
-
1823
- const extensionNames = json['extensions'];
1824
- if (Array.isArray(extensionNames)) {
1825
- for (let j = 0; j < extensionNames.length; j++) {
1826
- Extensions.apply(extensionNames[j], this, false);
1827
- }
1828
- }
1829
- }
1830
-
1831
- /**
1832
- * Initialize the colour of this block from the JSON description.
1833
- *
1834
- * @param json Structured data describing the block.
1835
- * @param warningPrefix Warning prefix string identifying block.
1836
- */
1837
- private jsonInitColour_(json: AnyDuringMigration, warningPrefix: string) {
1838
- if ('colour' in json) {
1839
- if (json['colour'] === undefined) {
1840
- console.warn(warningPrefix + 'Undefined colour value.');
1841
- } else {
1842
- const rawValue = json['colour'];
1843
- try {
1844
- this.setColour(rawValue);
1845
- } catch (e) {
1846
- console.warn(warningPrefix + 'Illegal colour value: ', rawValue);
1847
- }
1848
- }
1849
- }
1850
- }
1851
-
1852
- /**
1853
- * Initialize the style of this block from the JSON description.
1854
- *
1855
- * @param json Structured data describing the block.
1856
- * @param warningPrefix Warning prefix string identifying block.
1857
- */
1858
- private jsonInitStyle_(json: AnyDuringMigration, warningPrefix: string) {
1859
- const blockStyleName = json['style'];
1860
- try {
1861
- this.setStyle(blockStyleName);
1862
- } catch (styleError) {
1863
- console.warn(warningPrefix + 'Style does not exist: ', blockStyleName);
1864
- }
1865
- }
1866
-
1867
- /**
1868
- * Add key/values from mixinObj to this block object. By default, this method
1869
- * will check that the keys in mixinObj will not overwrite existing values in
1870
- * the block, including prototype values. This provides some insurance against
1871
- * mixin / extension incompatibilities with future block features. This check
1872
- * can be disabled by passing true as the second argument.
1873
- *
1874
- * @param mixinObj The key/values pairs to add to this block object.
1875
- * @param opt_disableCheck Option flag to disable overwrite checks.
1876
- */
1877
- mixin(mixinObj: AnyDuringMigration, opt_disableCheck?: boolean) {
1878
- if (
1879
- opt_disableCheck !== undefined &&
1880
- typeof opt_disableCheck !== 'boolean'
1881
- ) {
1882
- throw Error('opt_disableCheck must be a boolean if provided');
1883
- }
1884
- if (!opt_disableCheck) {
1885
- const overwrites = [];
1886
- for (const key in mixinObj) {
1887
- if ((this as AnyDuringMigration)[key] !== undefined) {
1888
- overwrites.push(key);
1889
- }
1890
- }
1891
- if (overwrites.length) {
1892
- throw Error(
1893
- 'Mixin will overwrite block members: ' + JSON.stringify(overwrites),
1894
- );
1895
- }
1896
- }
1897
- Object.assign(this, mixinObj);
1898
- }
1899
-
1900
- /**
1901
- * Interpolate a message description onto the block.
1902
- *
1903
- * @param message Text contains interpolation tokens (%1, %2, ...) that match
1904
- * with fields or inputs defined in the args array.
1905
- * @param args Array of arguments to be interpolated.
1906
- * @param implicitAlign If an implicit input is added at the end or in place
1907
- * of newline tokens, how should it be aligned?
1908
- * @param warningPrefix Warning prefix string identifying block.
1909
- */
1910
- private interpolate_(
1911
- message: string,
1912
- args: AnyDuringMigration[],
1913
- implicitAlign: string | undefined,
1914
- warningPrefix: string,
1915
- ) {
1916
- const tokens = parsing.tokenizeInterpolation(message);
1917
- this.validateTokens_(tokens, args.length);
1918
- const elements = this.interpolateArguments_(tokens, args, implicitAlign);
1919
-
1920
- // An array of [field, fieldName] tuples.
1921
- const fieldStack = [];
1922
- for (let i = 0, element; (element = elements[i]); i++) {
1923
- if (this.isInputKeyword_(element['type'])) {
1924
- const input = this.inputFromJson_(element, warningPrefix);
1925
- // Should never be null, but just in case.
1926
- if (input) {
1927
- for (let j = 0, tuple; (tuple = fieldStack[j]); j++) {
1928
- input.appendField(tuple[0], tuple[1]);
1929
- }
1930
- fieldStack.length = 0;
1931
- }
1932
- } else {
1933
- // All other types, including ones starting with 'input_' get routed
1934
- // here.
1935
- const field = this.fieldFromJson_(element);
1936
- if (field) {
1937
- fieldStack.push([field, element['name']]);
1938
- }
1939
- }
1940
- }
1941
- }
1942
-
1943
- /**
1944
- * Validates that the tokens are within the correct bounds, with no
1945
- * duplicates, and that all of the arguments are referred to. Throws errors if
1946
- * any of these things are not true.
1947
- *
1948
- * @param tokens An array of tokens to validate
1949
- * @param argsCount The number of args that need to be referred to.
1950
- */
1951
- private validateTokens_(tokens: Array<string | number>, argsCount: number) {
1952
- const visitedArgsHash = [];
1953
- let visitedArgsCount = 0;
1954
- for (let i = 0; i < tokens.length; i++) {
1955
- const token = tokens[i];
1956
- if (typeof token !== 'number') {
1957
- continue;
1958
- }
1959
- if (token < 1 || token > argsCount) {
1960
- throw Error(
1961
- 'Block "' +
1962
- this.type +
1963
- '": ' +
1964
- 'Message index %' +
1965
- token +
1966
- ' out of range.',
1967
- );
1968
- }
1969
- if (visitedArgsHash[token]) {
1970
- throw Error(
1971
- 'Block "' +
1972
- this.type +
1973
- '": ' +
1974
- 'Message index %' +
1975
- token +
1976
- ' duplicated.',
1977
- );
1978
- }
1979
- visitedArgsHash[token] = true;
1980
- visitedArgsCount++;
1981
- }
1982
- if (visitedArgsCount !== argsCount) {
1983
- throw Error(
1984
- 'Block "' +
1985
- this.type +
1986
- '": ' +
1987
- 'Message does not reference all ' +
1988
- argsCount +
1989
- ' arg(s).',
1990
- );
1991
- }
1992
- }
1993
-
1994
- /**
1995
- * Inserts args in place of numerical tokens. String args are converted to
1996
- * JSON that defines a label field. Newline characters are converted to
1997
- * end-row inputs, and if necessary an extra dummy input is added to the end
1998
- * of the elements.
1999
- *
2000
- * @param tokens The tokens to interpolate
2001
- * @param args The arguments to insert.
2002
- * @param implicitAlign The alignment to use for any implicitly added end-row
2003
- * or dummy inputs, if necessary.
2004
- * @returns The JSON definitions of field and inputs to add to the block.
2005
- */
2006
- private interpolateArguments_(
2007
- tokens: Array<string | number>,
2008
- args: Array<AnyDuringMigration | string>,
2009
- implicitAlign: string | undefined,
2010
- ): AnyDuringMigration[] {
2011
- const elements = [];
2012
- for (let i = 0; i < tokens.length; i++) {
2013
- let element = tokens[i];
2014
- if (typeof element === 'number') {
2015
- element = args[element - 1];
2016
- }
2017
- // Args can be strings, which is why this isn't elseif.
2018
- if (typeof element === 'string') {
2019
- if (element === '\n') {
2020
- // Convert newline tokens to end-row inputs.
2021
- const newlineInput = {'type': 'input_end_row'};
2022
- if (implicitAlign) {
2023
- (newlineInput as AnyDuringMigration)['align'] = implicitAlign;
2024
- }
2025
- element = newlineInput as AnyDuringMigration;
2026
- } else {
2027
- // AnyDuringMigration because: Type '{ text: string; type: string; }
2028
- // | null' is not assignable to type 'string | number'.
2029
- element = this.stringToFieldJson_(element) as AnyDuringMigration;
2030
- if (!element) {
2031
- continue;
2032
- }
2033
- }
2034
- }
2035
- elements.push(element);
2036
- }
2037
-
2038
- const length = elements.length;
2039
- if (
2040
- length &&
2041
- !this.isInputKeyword_(
2042
- (elements as AnyDuringMigration)[length - 1]['type'],
2043
- )
2044
- ) {
2045
- const dummyInput = {'type': 'input_dummy'};
2046
- if (implicitAlign) {
2047
- (dummyInput as AnyDuringMigration)['align'] = implicitAlign;
2048
- }
2049
- elements.push(dummyInput);
2050
- }
2051
-
2052
- return elements;
2053
- }
2054
-
2055
- /**
2056
- * Creates a field from the JSON definition of a field. If a field with the
2057
- * given type cannot be found, this attempts to create a different field using
2058
- * the 'alt' property of the JSON definition (if it exists).
2059
- *
2060
- * @param element The element to try to turn into a field.
2061
- * @returns The field defined by the JSON, or null if one couldn't be created.
2062
- */
2063
- private fieldFromJson_(element: {
2064
- alt?: string;
2065
- type: string;
2066
- text?: string;
2067
- }): Field | null {
2068
- const field = fieldRegistry.fromJson(element);
2069
- if (!field && element['alt']) {
2070
- if (typeof element['alt'] === 'string') {
2071
- const json = this.stringToFieldJson_(element['alt']);
2072
- return json ? this.fieldFromJson_(json) : null;
2073
- }
2074
- return this.fieldFromJson_(element['alt']);
2075
- }
2076
- return field;
2077
- }
2078
-
2079
- /**
2080
- * Creates an input from the JSON definition of an input. Sets the input's
2081
- * check and alignment if they are provided.
2082
- *
2083
- * @param element The JSON to turn into an input.
2084
- * @param warningPrefix The prefix to add to warnings to help the developer
2085
- * debug.
2086
- * @returns The input that has been created, or null if one could not be
2087
- * created for some reason (should never happen).
2088
- */
2089
- private inputFromJson_(
2090
- element: AnyDuringMigration,
2091
- warningPrefix: string,
2092
- ): Input | null {
2093
- const alignmentLookup = {
2094
- 'LEFT': Align.LEFT,
2095
- 'RIGHT': Align.RIGHT,
2096
- 'CENTRE': Align.CENTRE,
2097
- 'CENTER': Align.CENTRE,
2098
- };
2099
-
2100
- let input = null;
2101
- switch (element['type']) {
2102
- case 'input_value':
2103
- input = this.appendValueInput(element['name']);
2104
- break;
2105
- case 'input_statement':
2106
- input = this.appendStatementInput(element['name']);
2107
- break;
2108
- case 'input_dummy':
2109
- input = this.appendDummyInput(element['name']);
2110
- break;
2111
- case 'input_end_row':
2112
- input = this.appendEndRowInput(element['name']);
2113
- break;
2114
- default: {
2115
- input = this.appendInputFromRegistry(element['type'], element['name']);
2116
- break;
2117
- }
2118
- }
2119
- // Should never be hit because of interpolate_'s checks, but just in case.
2120
- if (!input) {
2121
- return null;
2122
- }
2123
-
2124
- if (element['check']) {
2125
- input.setCheck(element['check']);
2126
- }
2127
- if (element['align']) {
2128
- const alignment = (alignmentLookup as AnyDuringMigration)[
2129
- element['align'].toUpperCase()
2130
- ];
2131
- if (alignment === undefined) {
2132
- console.warn(warningPrefix + 'Illegal align value: ', element['align']);
2133
- } else {
2134
- input.setAlign(alignment);
2135
- }
2136
- }
2137
- return input;
2138
- }
2139
-
2140
- /**
2141
- * Returns true if the given string matches one of the input keywords.
2142
- *
2143
- * @param str The string to check.
2144
- * @returns True if the given string matches one of the input keywords, false
2145
- * otherwise.
2146
- */
2147
- private isInputKeyword_(str: string): boolean {
2148
- return (
2149
- str === 'input_value' ||
2150
- str === 'input_statement' ||
2151
- str === 'input_dummy' ||
2152
- str === 'input_end_row' ||
2153
- registry.hasItem(registry.Type.INPUT, str)
2154
- );
2155
- }
2156
-
2157
- /**
2158
- * Turns a string into the JSON definition of a label field. If the string
2159
- * becomes an empty string when trimmed, this returns null.
2160
- *
2161
- * @param str String to turn into the JSON definition of a label field.
2162
- * @returns The JSON definition or null.
2163
- */
2164
- private stringToFieldJson_(str: string): {text: string; type: string} | null {
2165
- str = str.trim();
2166
- if (str) {
2167
- return {
2168
- 'type': 'field_label',
2169
- 'text': str,
2170
- };
2171
- }
2172
- return null;
2173
- }
2174
-
2175
- /**
2176
- * Move a named input to a different location on this block.
2177
- *
2178
- * @param name The name of the input to move.
2179
- * @param refName Name of input that should be after the moved input, or null
2180
- * to be the input at the end.
2181
- */
2182
- moveInputBefore(name: string, refName: string | null) {
2183
- if (name === refName) {
2184
- return;
2185
- }
2186
- // Find both inputs.
2187
- let inputIndex = -1;
2188
- let refIndex = refName ? -1 : this.inputList.length;
2189
- for (let i = 0, input; (input = this.inputList[i]); i++) {
2190
- if (input.name === name) {
2191
- inputIndex = i;
2192
- if (refIndex !== -1) {
2193
- break;
2194
- }
2195
- } else if (refName && input.name === refName) {
2196
- refIndex = i;
2197
- if (inputIndex !== -1) {
2198
- break;
2199
- }
2200
- }
2201
- }
2202
- if (inputIndex === -1) {
2203
- throw Error('Named input "' + name + '" not found.');
2204
- }
2205
- if (refIndex === -1) {
2206
- throw Error('Reference input "' + refName + '" not found.');
2207
- }
2208
- this.moveNumberedInputBefore(inputIndex, refIndex);
2209
- }
2210
-
2211
- /**
2212
- * Move a numbered input to a different location on this block.
2213
- *
2214
- * @param inputIndex Index of the input to move.
2215
- * @param refIndex Index of input that should be after the moved input.
2216
- */
2217
- moveNumberedInputBefore(inputIndex: number, refIndex: number) {
2218
- // Validate arguments.
2219
- if (inputIndex === refIndex) {
2220
- throw Error("Can't move input to itself.");
2221
- }
2222
- if (inputIndex >= this.inputList.length) {
2223
- throw RangeError('Input index ' + inputIndex + ' out of bounds.');
2224
- }
2225
- if (refIndex > this.inputList.length) {
2226
- throw RangeError('Reference input ' + refIndex + ' out of bounds.');
2227
- }
2228
- // Remove input.
2229
- const input = this.inputList[inputIndex];
2230
- this.inputList.splice(inputIndex, 1);
2231
- if (inputIndex < refIndex) {
2232
- refIndex--;
2233
- }
2234
- // Reinsert input.
2235
- this.inputList.splice(refIndex, 0, input);
2236
- }
2237
-
2238
- /**
2239
- * Remove an input from this block.
2240
- *
2241
- * @param name The name of the input.
2242
- * @param opt_quiet True to prevent an error if input is not present.
2243
- * @returns True if operation succeeds, false if input is not present and
2244
- * opt_quiet is true.
2245
- * @throws {Error} if the input is not present and opt_quiet is not true.
2246
- */
2247
- removeInput(name: string, opt_quiet?: boolean): boolean {
2248
- for (let i = 0, input; (input = this.inputList[i]); i++) {
2249
- if (input.name === name) {
2250
- if (input instanceof StatementInput) this.statementInputCount--;
2251
- input.dispose();
2252
- this.inputList.splice(i, 1);
2253
- return true;
2254
- }
2255
- }
2256
- if (opt_quiet) {
2257
- return false;
2258
- }
2259
- throw Error('Input not found: ' + name);
2260
- }
2261
-
2262
- /**
2263
- * Fetches the named input object.
2264
- *
2265
- * @param name The name of the input.
2266
- * @returns The input object, or null if input does not exist.
2267
- */
2268
- getInput(name: string): Input | null {
2269
- for (let i = 0, input; (input = this.inputList[i]); i++) {
2270
- if (input.name === name) {
2271
- return input;
2272
- }
2273
- }
2274
- // This input does not exist.
2275
- return null;
2276
- }
2277
-
2278
- /**
2279
- * Fetches the block attached to the named input.
2280
- *
2281
- * @param name The name of the input.
2282
- * @returns The attached value block, or null if the input is either
2283
- * disconnected or if the input does not exist.
2284
- */
2285
- getInputTargetBlock(name: string): Block | null {
2286
- const input = this.getInput(name);
2287
- return input && input.connection && input.connection.targetBlock();
2288
- }
2289
-
2290
- /**
2291
- * Returns the comment on this block (or null if there is no comment).
2292
- *
2293
- * @returns Block's comment.
2294
- */
2295
- getCommentText(): string | null {
2296
- const comment = this.getIcon(IconType.COMMENT);
2297
- return comment?.getText() ?? null;
2298
- }
2299
-
2300
- /**
2301
- * Set this block's comment text.
2302
- *
2303
- * @param text The text, or null to delete.
2304
- */
2305
- setCommentText(text: string | null) {
2306
- const comment = this.getIcon(IconType.COMMENT);
2307
- const oldText = comment?.getText() ?? null;
2308
- if (oldText === text) return;
2309
- if (text !== null) {
2310
- let comment = this.getIcon(IconType.COMMENT);
2311
- if (!comment) {
2312
- const commentConstructor = registry.getClass(
2313
- registry.Type.ICON,
2314
- IconType.COMMENT.toString(),
2315
- false,
2316
- );
2317
- if (!commentConstructor) {
2318
- throw new Error(
2319
- 'No comment icon class is registered, so a comment cannot be set',
2320
- );
2321
- }
2322
- const icon = new commentConstructor(this);
2323
- if (!isCommentIcon(icon)) {
2324
- throw new Error(
2325
- 'The class registered as a comment icon does not conform to the ' +
2326
- 'ICommentIcon interface',
2327
- );
2328
- }
2329
- comment = this.addIcon(icon);
2330
- }
2331
- eventUtils.disable();
2332
- comment.setText(text);
2333
- eventUtils.enable();
2334
- } else {
2335
- this.removeIcon(IconType.COMMENT);
2336
- }
2337
-
2338
- eventUtils.fire(
2339
- new (eventUtils.get(eventUtils.BLOCK_CHANGE))(
2340
- this,
2341
- 'comment',
2342
- null,
2343
- oldText,
2344
- text,
2345
- ),
2346
- );
2347
- }
2348
-
2349
- /**
2350
- * Set this block's warning text.
2351
- *
2352
- * @param _text The text, or null to delete.
2353
- * @param _opt_id An optional ID for the warning text to be able to maintain
2354
- * multiple warnings.
2355
- */
2356
- setWarningText(_text: string | null, _opt_id?: string) {
2357
- // NOOP.
2358
- }
2359
-
2360
- /**
2361
- * Give this block a mutator dialog.
2362
- *
2363
- * @param _mutator A mutator dialog instance or null to remove.
2364
- */
2365
- setMutator(_mutator: MutatorIcon) {
2366
- // NOOP.
2367
- }
2368
-
2369
- /** Adds the given icon to the block. */
2370
- addIcon<T extends IIcon>(icon: T): T {
2371
- if (this.hasIcon(icon.getType())) throw new DuplicateIconType(icon);
2372
- this.icons.push(icon);
2373
- this.icons.sort((a, b) => a.getWeight() - b.getWeight());
2374
- return icon;
2375
- }
2376
-
2377
- /**
2378
- * Removes the icon whose getType matches the given type iconType from the
2379
- * block.
2380
- *
2381
- * @param type The type of the icon to remove from the block.
2382
- * @returns True if an icon with the given type was found, false otherwise.
2383
- */
2384
- removeIcon(type: IconType<IIcon>): boolean {
2385
- if (!this.hasIcon(type)) return false;
2386
- this.getIcon(type)?.dispose();
2387
- this.icons = this.icons.filter((icon) => !icon.getType().equals(type));
2388
- return true;
2389
- }
2390
-
2391
- /**
2392
- * @returns True if an icon with the given type exists on the block,
2393
- * false otherwise.
2394
- */
2395
- hasIcon(type: IconType<IIcon>): boolean {
2396
- return this.icons.some((icon) => icon.getType().equals(type));
2397
- }
2398
-
2399
- /**
2400
- * @param type The type of the icon to retrieve. Prefer passing an `IconType`
2401
- * for proper type checking when using typescript.
2402
- * @returns The icon with the given type if it exists on the block, undefined
2403
- * otherwise.
2404
- */
2405
- getIcon<T extends IIcon>(type: IconType<T> | string): T | undefined {
2406
- if (type instanceof IconType) {
2407
- return this.icons.find((icon) => icon.getType().equals(type)) as T;
2408
- } else {
2409
- return this.icons.find((icon) => icon.getType().toString() === type) as T;
2410
- }
2411
- }
2412
-
2413
- /** @returns An array of the icons attached to this block. */
2414
- getIcons(): IIcon[] {
2415
- return [...this.icons];
2416
- }
2417
-
2418
- /**
2419
- * Return the coordinates of the top-left corner of this block relative to the
2420
- * drawing surface's origin (0,0), in workspace units.
2421
- *
2422
- * @returns Object with .x and .y properties.
2423
- */
2424
- getRelativeToSurfaceXY(): Coordinate {
2425
- return this.xy_;
2426
- }
2427
-
2428
- /**
2429
- * Move a block by a relative offset.
2430
- *
2431
- * @param dx Horizontal offset, in workspace units.
2432
- * @param dy Vertical offset, in workspace units.
2433
- * @param reason Why is this move happening? 'drag', 'bump', 'snap', ...
2434
- */
2435
- moveBy(dx: number, dy: number, reason?: string[]) {
2436
- if (this.parentBlock_) {
2437
- throw Error('Block has parent');
2438
- }
2439
- const event = new (eventUtils.get(eventUtils.BLOCK_MOVE))(
2440
- this,
2441
- ) as BlockMove;
2442
- reason && event.setReason(reason);
2443
- this.xy_.translate(dx, dy);
2444
- event.recordNew();
2445
- eventUtils.fire(event);
2446
- }
2447
-
2448
- /**
2449
- * Create a connection of the specified type.
2450
- *
2451
- * @param type The type of the connection to create.
2452
- * @returns A new connection of the specified type.
2453
- * @internal
2454
- */
2455
- makeConnection_(type: ConnectionType): Connection {
2456
- return new Connection(this, type);
2457
- }
2458
-
2459
- /**
2460
- * Recursively checks whether all statement and value inputs are filled with
2461
- * blocks. Also checks all following statement blocks in this stack.
2462
- *
2463
- * @param opt_shadowBlocksAreFilled An optional argument controlling whether
2464
- * shadow blocks are counted as filled. Defaults to true.
2465
- * @returns True if all inputs are filled, false otherwise.
2466
- */
2467
- allInputsFilled(opt_shadowBlocksAreFilled?: boolean): boolean {
2468
- // Account for the shadow block filledness toggle.
2469
- if (opt_shadowBlocksAreFilled === undefined) {
2470
- opt_shadowBlocksAreFilled = true;
2471
- }
2472
- if (!opt_shadowBlocksAreFilled && this.isShadow()) {
2473
- return false;
2474
- }
2475
-
2476
- // Recursively check each input block of the current block.
2477
- for (let i = 0, input; (input = this.inputList[i]); i++) {
2478
- if (!input.connection) {
2479
- continue;
2480
- }
2481
- const target = input.connection.targetBlock();
2482
- if (!target || !target.allInputsFilled(opt_shadowBlocksAreFilled)) {
2483
- return false;
2484
- }
2485
- }
2486
-
2487
- // Recursively check the next block after the current block.
2488
- const next = this.getNextBlock();
2489
- if (next) {
2490
- return next.allInputsFilled(opt_shadowBlocksAreFilled);
2491
- }
2492
-
2493
- return true;
2494
- }
2495
-
2496
- /**
2497
- * This method returns a string describing this Block in developer terms (type
2498
- * name and ID; English only).
2499
- *
2500
- * Intended to on be used in console logs and errors. If you need a string
2501
- * that uses the user's native language (including block text, field values,
2502
- * and child blocks), use [toString()]{@link Block#toString}.
2503
- *
2504
- * @returns The description.
2505
- */
2506
- toDevString(): string {
2507
- let msg = this.type ? '"' + this.type + '" block' : 'Block';
2508
- if (this.id) {
2509
- msg += ' (id="' + this.id + '")';
2510
- }
2511
- return msg;
2512
- }
2513
- }
2514
-
2515
- export namespace Block {
2516
- export interface CommentModel {
2517
- text: string | null;
2518
- pinned: boolean;
2519
- size: Size;
2520
- }
2521
- }
2522
-
2523
- export type CommentModel = Block.CommentModel;