blockly 12.3.1 → 12.4.0

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