scratch-blocks 1.1.206 → 2.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1295) hide show
  1. package/.husky/commit-msg +0 -3
  2. package/CHANGELOG.md +111 -833
  3. package/TODO.md +16 -0
  4. package/blockly-rc/.eslintignore +28 -0
  5. package/blockly-rc/.eslintrc.js +187 -0
  6. package/blockly-rc/.gitattributes +1 -0
  7. package/blockly-rc/.github/CODEOWNERS +1 -0
  8. package/blockly-rc/.github/CONTRIBUTING.md +46 -0
  9. package/blockly-rc/.github/ISSUE_TEMPLATE/bug_report.yaml +58 -0
  10. package/blockly-rc/.github/ISSUE_TEMPLATE/config.yml +7 -0
  11. package/blockly-rc/.github/ISSUE_TEMPLATE/documentation.yaml +38 -0
  12. package/blockly-rc/.github/ISSUE_TEMPLATE/feature_request.yaml +39 -0
  13. package/blockly-rc/.github/PULL_REQUEST_TEMPLATE.md +42 -0
  14. package/blockly-rc/.github/dependabot.yml +27 -0
  15. package/blockly-rc/.github/release.yml +32 -0
  16. package/blockly-rc/.github/workflows/appengine_deploy.yml +54 -0
  17. package/blockly-rc/.github/workflows/assign_reviewers.yml +41 -0
  18. package/blockly-rc/.github/workflows/browser_test.yml +55 -0
  19. package/blockly-rc/.github/workflows/build.yml +86 -0
  20. package/blockly-rc/.github/workflows/conventional-label.yml +17 -0
  21. package/blockly-rc/.github/workflows/develop_freeze.yml +26 -0
  22. package/blockly-rc/.github/workflows/tag_module_cleanup.yml +37 -0
  23. package/blockly-rc/.github/workflows/welcome_new_contributors.yml +36 -0
  24. package/blockly-rc/.prettierignore +30 -0
  25. package/blockly-rc/.prettierrc.js +13 -0
  26. package/blockly-rc/CHANGELOG.md +77 -0
  27. package/blockly-rc/LICENSE +202 -0
  28. package/blockly-rc/README.md +80 -0
  29. package/blockly-rc/_config.yml +1 -0
  30. package/blockly-rc/api-extractor.json +385 -0
  31. package/blockly-rc/appengine/.gcloudignore +20 -0
  32. package/blockly-rc/appengine/README.txt +42 -0
  33. package/blockly-rc/appengine/add_timestamps.py +69 -0
  34. package/blockly-rc/appengine/app.yaml +104 -0
  35. package/blockly-rc/appengine/apple-touch-icon.png +0 -0
  36. package/blockly-rc/appengine/blockly_compressed.js +11 -0
  37. package/blockly-rc/appengine/expiration.py +52 -0
  38. package/blockly-rc/appengine/favicon.ico +0 -0
  39. package/blockly-rc/appengine/index.yaml +11 -0
  40. package/blockly-rc/appengine/main.py +39 -0
  41. package/blockly-rc/appengine/redirect.html +107 -0
  42. package/blockly-rc/appengine/requirements.txt +1 -0
  43. package/blockly-rc/appengine/robots.txt +2 -0
  44. package/blockly-rc/appengine/storage.js +190 -0
  45. package/blockly-rc/appengine/storage.py +125 -0
  46. package/blockly-rc/blocks/blocks.ts +44 -0
  47. package/blockly-rc/blocks/lists.ts +1085 -0
  48. package/blockly-rc/blocks/logic.ts +712 -0
  49. package/blockly-rc/blocks/loops.ts +408 -0
  50. package/blockly-rc/blocks/math.ts +591 -0
  51. package/blockly-rc/blocks/procedures.ts +1364 -0
  52. package/blockly-rc/blocks/text.ts +1007 -0
  53. package/blockly-rc/blocks/variables.ts +183 -0
  54. package/blockly-rc/blocks/variables_dynamic.ts +194 -0
  55. package/blockly-rc/core/any_aliases.ts +8 -0
  56. package/blockly-rc/core/block.ts +2523 -0
  57. package/blockly-rc/core/block_animations.ts +225 -0
  58. package/blockly-rc/core/block_flyout_inflater.ts +262 -0
  59. package/blockly-rc/core/block_svg.ts +1768 -0
  60. package/blockly-rc/core/blockly.ts +605 -0
  61. package/blockly-rc/core/blockly_options.ts +71 -0
  62. package/blockly-rc/core/blocks.ts +18 -0
  63. package/blockly-rc/core/browser_events.ts +244 -0
  64. package/blockly-rc/core/bubbles/bubble.ts +658 -0
  65. package/blockly-rc/core/bubbles/mini_workspace_bubble.ts +280 -0
  66. package/blockly-rc/core/bubbles/text_bubble.ts +103 -0
  67. package/blockly-rc/core/bubbles/textinput_bubble.ts +344 -0
  68. package/blockly-rc/core/bubbles.ts +12 -0
  69. package/blockly-rc/core/bump_objects.ts +192 -0
  70. package/blockly-rc/core/button_flyout_inflater.ts +63 -0
  71. package/blockly-rc/core/clipboard/block_paster.ts +142 -0
  72. package/blockly-rc/core/clipboard/registry.ts +31 -0
  73. package/blockly-rc/core/clipboard/workspace_comment_paster.ts +94 -0
  74. package/blockly-rc/core/clipboard.ts +113 -0
  75. package/blockly-rc/core/comments/comment_view.ts +899 -0
  76. package/blockly-rc/core/comments/rendered_workspace_comment.ts +297 -0
  77. package/blockly-rc/core/comments/workspace_comment.ts +237 -0
  78. package/blockly-rc/core/comments.ts +9 -0
  79. package/blockly-rc/core/common.ts +305 -0
  80. package/blockly-rc/core/component_manager.ts +235 -0
  81. package/blockly-rc/core/config.ts +65 -0
  82. package/blockly-rc/core/connection.ts +793 -0
  83. package/blockly-rc/core/connection_checker.ts +348 -0
  84. package/blockly-rc/core/connection_db.ts +297 -0
  85. package/blockly-rc/core/connection_type.ts +21 -0
  86. package/blockly-rc/core/constants.ts +23 -0
  87. package/blockly-rc/core/contextmenu.ts +268 -0
  88. package/blockly-rc/core/contextmenu_items.ts +700 -0
  89. package/blockly-rc/core/contextmenu_registry.ts +194 -0
  90. package/blockly-rc/core/css.ts +481 -0
  91. package/blockly-rc/core/delete_area.ts +77 -0
  92. package/blockly-rc/core/dialog.ts +121 -0
  93. package/blockly-rc/core/drag_target.ts +97 -0
  94. package/blockly-rc/core/dragging/block_drag_strategy.ts +454 -0
  95. package/blockly-rc/core/dragging/bubble_drag_strategy.ts +52 -0
  96. package/blockly-rc/core/dragging/comment_drag_strategy.ts +91 -0
  97. package/blockly-rc/core/dragging/dragger.ts +163 -0
  98. package/blockly-rc/core/dragging.ts +12 -0
  99. package/blockly-rc/core/dropdowndiv.ts +768 -0
  100. package/blockly-rc/core/events/events.ts +163 -0
  101. package/blockly-rc/core/events/events_abstract.ts +130 -0
  102. package/blockly-rc/core/events/events_block_base.ts +88 -0
  103. package/blockly-rc/core/events/events_block_change.ts +259 -0
  104. package/blockly-rc/core/events/events_block_create.ts +185 -0
  105. package/blockly-rc/core/events/events_block_delete.ts +182 -0
  106. package/blockly-rc/core/events/events_block_drag.ts +116 -0
  107. package/blockly-rc/core/events/events_block_field_intermediate_change.ts +167 -0
  108. package/blockly-rc/core/events/events_block_move.ts +307 -0
  109. package/blockly-rc/core/events/events_bubble_open.ts +120 -0
  110. package/blockly-rc/core/events/events_click.ts +110 -0
  111. package/blockly-rc/core/events/events_comment_base.ts +126 -0
  112. package/blockly-rc/core/events/events_comment_change.ts +161 -0
  113. package/blockly-rc/core/events/events_comment_collapse.ts +103 -0
  114. package/blockly-rc/core/events/events_comment_create.ts +118 -0
  115. package/blockly-rc/core/events/events_comment_delete.ts +117 -0
  116. package/blockly-rc/core/events/events_comment_drag.ts +99 -0
  117. package/blockly-rc/core/events/events_comment_move.ts +207 -0
  118. package/blockly-rc/core/events/events_comment_resize.ts +174 -0
  119. package/blockly-rc/core/events/events_marker_move.ts +134 -0
  120. package/blockly-rc/core/events/events_selected.ts +98 -0
  121. package/blockly-rc/core/events/events_theme_change.ts +84 -0
  122. package/blockly-rc/core/events/events_toolbox_item_select.ts +96 -0
  123. package/blockly-rc/core/events/events_trashcan_open.ts +88 -0
  124. package/blockly-rc/core/events/events_ui_base.ts +47 -0
  125. package/blockly-rc/core/events/events_var_base.ts +89 -0
  126. package/blockly-rc/core/events/events_var_create.ts +129 -0
  127. package/blockly-rc/core/events/events_var_delete.ts +124 -0
  128. package/blockly-rc/core/events/events_var_rename.ts +133 -0
  129. package/blockly-rc/core/events/events_var_type_change.ts +122 -0
  130. package/blockly-rc/core/events/events_viewport.ts +149 -0
  131. package/blockly-rc/core/events/utils.ts +595 -0
  132. package/blockly-rc/core/events/workspace_events.ts +46 -0
  133. package/blockly-rc/core/extensions.ts +491 -0
  134. package/blockly-rc/core/field.ts +1471 -0
  135. package/blockly-rc/core/field_checkbox.ts +271 -0
  136. package/blockly-rc/core/field_dropdown.ts +857 -0
  137. package/blockly-rc/core/field_image.ts +297 -0
  138. package/blockly-rc/core/field_input.ts +755 -0
  139. package/blockly-rc/core/field_label.ts +150 -0
  140. package/blockly-rc/core/field_label_serializable.ts +73 -0
  141. package/blockly-rc/core/field_number.ts +381 -0
  142. package/blockly-rc/core/field_registry.ts +115 -0
  143. package/blockly-rc/core/field_textinput.ts +117 -0
  144. package/blockly-rc/core/field_variable.ts +651 -0
  145. package/blockly-rc/core/flyout_base.ts +968 -0
  146. package/blockly-rc/core/flyout_button.ts +416 -0
  147. package/blockly-rc/core/flyout_horizontal.ts +374 -0
  148. package/blockly-rc/core/flyout_metrics_manager.ts +90 -0
  149. package/blockly-rc/core/flyout_separator.ts +61 -0
  150. package/blockly-rc/core/flyout_vertical.ts +353 -0
  151. package/blockly-rc/core/generator.ts +611 -0
  152. package/blockly-rc/core/gesture.ts +1191 -0
  153. package/blockly-rc/core/grid.ts +252 -0
  154. package/blockly-rc/core/icons/comment_icon.ts +435 -0
  155. package/blockly-rc/core/icons/exceptions.ts +23 -0
  156. package/blockly-rc/core/icons/icon.ts +147 -0
  157. package/blockly-rc/core/icons/icon_types.ts +32 -0
  158. package/blockly-rc/core/icons/mutator_icon.ts +354 -0
  159. package/blockly-rc/core/icons/registry.ts +33 -0
  160. package/blockly-rc/core/icons/warning_icon.ts +219 -0
  161. package/blockly-rc/core/icons.ts +24 -0
  162. package/blockly-rc/core/inject.ts +428 -0
  163. package/blockly-rc/core/inputs/align.ts +14 -0
  164. package/blockly-rc/core/inputs/dummy_input.ts +26 -0
  165. package/blockly-rc/core/inputs/end_row_input.ts +31 -0
  166. package/blockly-rc/core/inputs/input.ts +318 -0
  167. package/blockly-rc/core/inputs/input_types.ts +27 -0
  168. package/blockly-rc/core/inputs/statement_input.ts +34 -0
  169. package/blockly-rc/core/inputs/value_input.ts +30 -0
  170. package/blockly-rc/core/inputs.ts +23 -0
  171. package/blockly-rc/core/insertion_marker_manager.ts +742 -0
  172. package/blockly-rc/core/insertion_marker_previewer.ts +254 -0
  173. package/blockly-rc/core/interfaces/i_ast_node_location.ts +12 -0
  174. package/blockly-rc/core/interfaces/i_ast_node_location_svg.ts +28 -0
  175. package/blockly-rc/core/interfaces/i_ast_node_location_with_block.ts +22 -0
  176. package/blockly-rc/core/interfaces/i_autohideable.ts +22 -0
  177. package/blockly-rc/core/interfaces/i_bounded_element.ts +30 -0
  178. package/blockly-rc/core/interfaces/i_bubble.ts +63 -0
  179. package/blockly-rc/core/interfaces/i_collapsible_toolbox_item.ts +33 -0
  180. package/blockly-rc/core/interfaces/i_comment_icon.ts +47 -0
  181. package/blockly-rc/core/interfaces/i_component.ts +19 -0
  182. package/blockly-rc/core/interfaces/i_connection_checker.ts +100 -0
  183. package/blockly-rc/core/interfaces/i_connection_previewer.ts +50 -0
  184. package/blockly-rc/core/interfaces/i_contextmenu.ts +16 -0
  185. package/blockly-rc/core/interfaces/i_copyable.ts +31 -0
  186. package/blockly-rc/core/interfaces/i_deletable.ts +34 -0
  187. package/blockly-rc/core/interfaces/i_delete_area.ts +28 -0
  188. package/blockly-rc/core/interfaces/i_drag_target.ts +69 -0
  189. package/blockly-rc/core/interfaces/i_draggable.ts +72 -0
  190. package/blockly-rc/core/interfaces/i_dragger.ts +35 -0
  191. package/blockly-rc/core/interfaces/i_flyout.ts +189 -0
  192. package/blockly-rc/core/interfaces/i_flyout_inflater.ts +41 -0
  193. package/blockly-rc/core/interfaces/i_has_bubble.ts +20 -0
  194. package/blockly-rc/core/interfaces/i_icon.ts +114 -0
  195. package/blockly-rc/core/interfaces/i_keyboard_accessible.ts +21 -0
  196. package/blockly-rc/core/interfaces/i_legacy_procedure_blocks.ts +50 -0
  197. package/blockly-rc/core/interfaces/i_metrics_manager.ts +149 -0
  198. package/blockly-rc/core/interfaces/i_movable.ts +19 -0
  199. package/blockly-rc/core/interfaces/i_observable.ts +24 -0
  200. package/blockly-rc/core/interfaces/i_parameter_model.ts +51 -0
  201. package/blockly-rc/core/interfaces/i_paster.ts +25 -0
  202. package/blockly-rc/core/interfaces/i_positionable.ts +33 -0
  203. package/blockly-rc/core/interfaces/i_procedure_block.ts +27 -0
  204. package/blockly-rc/core/interfaces/i_procedure_map.ts +18 -0
  205. package/blockly-rc/core/interfaces/i_procedure_model.ts +71 -0
  206. package/blockly-rc/core/interfaces/i_registrable.ts +12 -0
  207. package/blockly-rc/core/interfaces/i_rendered_element.ts +22 -0
  208. package/blockly-rc/core/interfaces/i_selectable.ts +34 -0
  209. package/blockly-rc/core/interfaces/i_selectable_toolbox_item.ts +63 -0
  210. package/blockly-rc/core/interfaces/i_serializable.ts +28 -0
  211. package/blockly-rc/core/interfaces/i_serializer.ts +55 -0
  212. package/blockly-rc/core/interfaces/i_styleable.ts +26 -0
  213. package/blockly-rc/core/interfaces/i_toolbox.ts +112 -0
  214. package/blockly-rc/core/interfaces/i_toolbox_item.ts +81 -0
  215. package/blockly-rc/core/interfaces/i_variable_backed_parameter_model.ts +23 -0
  216. package/blockly-rc/core/interfaces/i_variable_map.ts +65 -0
  217. package/blockly-rc/core/interfaces/i_variable_model.ts +57 -0
  218. package/blockly-rc/core/internal_constants.ts +47 -0
  219. package/blockly-rc/core/keyboard_nav/ast_node.ts +884 -0
  220. package/blockly-rc/core/keyboard_nav/basic_cursor.ts +223 -0
  221. package/blockly-rc/core/keyboard_nav/cursor.ts +138 -0
  222. package/blockly-rc/core/keyboard_nav/marker.ts +113 -0
  223. package/blockly-rc/core/keyboard_nav/tab_navigate_cursor.ts +46 -0
  224. package/blockly-rc/core/label_flyout_inflater.ts +59 -0
  225. package/blockly-rc/core/layer_manager.ts +186 -0
  226. package/blockly-rc/core/layers.ts +17 -0
  227. package/blockly-rc/core/main.ts +31 -0
  228. package/blockly-rc/core/marker_manager.ts +189 -0
  229. package/blockly-rc/core/menu.ts +463 -0
  230. package/blockly-rc/core/menuitem.ts +221 -0
  231. package/blockly-rc/core/metrics_manager.ts +486 -0
  232. package/blockly-rc/core/msg.ts +27 -0
  233. package/blockly-rc/core/names.ts +275 -0
  234. package/blockly-rc/core/observable_procedure_map.ts +66 -0
  235. package/blockly-rc/core/options.ts +377 -0
  236. package/blockly-rc/core/positionable_helpers.ts +186 -0
  237. package/blockly-rc/core/procedures.ts +510 -0
  238. package/blockly-rc/core/registry.ts +400 -0
  239. package/blockly-rc/core/render_management.ts +193 -0
  240. package/blockly-rc/core/rendered_connection.ts +571 -0
  241. package/blockly-rc/core/renderers/common/block_rendering.ts +120 -0
  242. package/blockly-rc/core/renderers/common/constants.ts +1198 -0
  243. package/blockly-rc/core/renderers/common/drawer.ts +518 -0
  244. package/blockly-rc/core/renderers/common/i_path_object.ts +137 -0
  245. package/blockly-rc/core/renderers/common/info.ts +767 -0
  246. package/blockly-rc/core/renderers/common/marker_svg.ts +765 -0
  247. package/blockly-rc/core/renderers/common/path_object.ts +324 -0
  248. package/blockly-rc/core/renderers/common/renderer.ts +281 -0
  249. package/blockly-rc/core/renderers/geras/constants.ts +46 -0
  250. package/blockly-rc/core/renderers/geras/drawer.ts +167 -0
  251. package/blockly-rc/core/renderers/geras/geras.ts +31 -0
  252. package/blockly-rc/core/renderers/geras/highlight_constants.ts +342 -0
  253. package/blockly-rc/core/renderers/geras/highlighter.ts +313 -0
  254. package/blockly-rc/core/renderers/geras/info.ts +478 -0
  255. package/blockly-rc/core/renderers/geras/measurables/inline_input.ts +37 -0
  256. package/blockly-rc/core/renderers/geras/measurables/statement_input.ts +36 -0
  257. package/blockly-rc/core/renderers/geras/path_object.ts +135 -0
  258. package/blockly-rc/core/renderers/geras/renderer.ts +124 -0
  259. package/blockly-rc/core/renderers/measurables/base.ts +41 -0
  260. package/blockly-rc/core/renderers/measurables/bottom_row.ts +104 -0
  261. package/blockly-rc/core/renderers/measurables/connection.ts +43 -0
  262. package/blockly-rc/core/renderers/measurables/external_value_input.ts +53 -0
  263. package/blockly-rc/core/renderers/measurables/field.ts +50 -0
  264. package/blockly-rc/core/renderers/measurables/hat.ts +33 -0
  265. package/blockly-rc/core/renderers/measurables/icon.ts +42 -0
  266. package/blockly-rc/core/renderers/measurables/in_row_spacer.ts +29 -0
  267. package/blockly-rc/core/renderers/measurables/inline_input.ts +63 -0
  268. package/blockly-rc/core/renderers/measurables/input_connection.ts +57 -0
  269. package/blockly-rc/core/renderers/measurables/input_row.ts +67 -0
  270. package/blockly-rc/core/renderers/measurables/jagged_edge.ts +28 -0
  271. package/blockly-rc/core/renderers/measurables/next_connection.ts +34 -0
  272. package/blockly-rc/core/renderers/measurables/output_connection.ts +43 -0
  273. package/blockly-rc/core/renderers/measurables/previous_connection.ts +34 -0
  274. package/blockly-rc/core/renderers/measurables/round_corner.ts +34 -0
  275. package/blockly-rc/core/renderers/measurables/row.ts +191 -0
  276. package/blockly-rc/core/renderers/measurables/spacer_row.ts +44 -0
  277. package/blockly-rc/core/renderers/measurables/square_corner.ts +32 -0
  278. package/blockly-rc/core/renderers/measurables/statement_input.ts +41 -0
  279. package/blockly-rc/core/renderers/measurables/top_row.ts +110 -0
  280. package/blockly-rc/core/renderers/measurables/types.ts +319 -0
  281. package/blockly-rc/core/renderers/thrasos/info.ts +328 -0
  282. package/blockly-rc/core/renderers/thrasos/renderer.ts +40 -0
  283. package/blockly-rc/core/renderers/thrasos/thrasos.ts +14 -0
  284. package/blockly-rc/core/renderers/zelos/constants.ts +877 -0
  285. package/blockly-rc/core/renderers/zelos/drawer.ts +274 -0
  286. package/blockly-rc/core/renderers/zelos/info.ts +652 -0
  287. package/blockly-rc/core/renderers/zelos/marker_svg.ts +145 -0
  288. package/blockly-rc/core/renderers/zelos/measurables/bottom_row.ts +44 -0
  289. package/blockly-rc/core/renderers/zelos/measurables/inputs.ts +41 -0
  290. package/blockly-rc/core/renderers/zelos/measurables/row_elements.ts +29 -0
  291. package/blockly-rc/core/renderers/zelos/measurables/top_row.ts +50 -0
  292. package/blockly-rc/core/renderers/zelos/path_object.ts +209 -0
  293. package/blockly-rc/core/renderers/zelos/renderer.ts +143 -0
  294. package/blockly-rc/core/renderers/zelos/zelos.ts +33 -0
  295. package/blockly-rc/core/scrollbar.ts +898 -0
  296. package/blockly-rc/core/scrollbar_pair.ts +349 -0
  297. package/blockly-rc/core/separator_flyout_inflater.ts +69 -0
  298. package/blockly-rc/core/serialization/blocks.ts +868 -0
  299. package/blockly-rc/core/serialization/exceptions.ts +112 -0
  300. package/blockly-rc/core/serialization/priorities.ts +25 -0
  301. package/blockly-rc/core/serialization/procedures.ts +158 -0
  302. package/blockly-rc/core/serialization/registry.ts +30 -0
  303. package/blockly-rc/core/serialization/variables.ts +68 -0
  304. package/blockly-rc/core/serialization/workspace_comments.ts +143 -0
  305. package/blockly-rc/core/serialization/workspaces.ts +94 -0
  306. package/blockly-rc/core/serialization.ts +32 -0
  307. package/blockly-rc/core/shortcut_items.ts +338 -0
  308. package/blockly-rc/core/shortcut_registry.ts +368 -0
  309. package/blockly-rc/core/sprites.ts +15 -0
  310. package/blockly-rc/core/theme/classic.ts +40 -0
  311. package/blockly-rc/core/theme/themes.ts +12 -0
  312. package/blockly-rc/core/theme/zelos.ts +80 -0
  313. package/blockly-rc/core/theme.ts +232 -0
  314. package/blockly-rc/core/theme_manager.ts +192 -0
  315. package/blockly-rc/core/toolbox/category.ts +739 -0
  316. package/blockly-rc/core/toolbox/collapsible_category.ts +288 -0
  317. package/blockly-rc/core/toolbox/separator.ts +105 -0
  318. package/blockly-rc/core/toolbox/toolbox.ts +1134 -0
  319. package/blockly-rc/core/toolbox/toolbox_item.ts +152 -0
  320. package/blockly-rc/core/tooltip.ts +466 -0
  321. package/blockly-rc/core/touch.ts +155 -0
  322. package/blockly-rc/core/trashcan.ts +748 -0
  323. package/blockly-rc/core/utils/aria.ts +144 -0
  324. package/blockly-rc/core/utils/array.ts +24 -0
  325. package/blockly-rc/core/utils/colour.ts +265 -0
  326. package/blockly-rc/core/utils/coordinate.ts +129 -0
  327. package/blockly-rc/core/utils/deprecation.ts +47 -0
  328. package/blockly-rc/core/utils/dom.ts +356 -0
  329. package/blockly-rc/core/utils/idgenerator.ts +70 -0
  330. package/blockly-rc/core/utils/keycodes.ts +154 -0
  331. package/blockly-rc/core/utils/math.ts +50 -0
  332. package/blockly-rc/core/utils/metrics.ts +86 -0
  333. package/blockly-rc/core/utils/object.ts +28 -0
  334. package/blockly-rc/core/utils/parsing.ts +287 -0
  335. package/blockly-rc/core/utils/rect.ts +69 -0
  336. package/blockly-rc/core/utils/size.ts +62 -0
  337. package/blockly-rc/core/utils/string.ts +289 -0
  338. package/blockly-rc/core/utils/style.ts +219 -0
  339. package/blockly-rc/core/utils/svg.ts +84 -0
  340. package/blockly-rc/core/utils/svg_math.ts +208 -0
  341. package/blockly-rc/core/utils/svg_paths.ts +133 -0
  342. package/blockly-rc/core/utils/toolbox.ts +419 -0
  343. package/blockly-rc/core/utils/useragent.ts +86 -0
  344. package/blockly-rc/core/utils/xml.ts +165 -0
  345. package/blockly-rc/core/utils.ts +59 -0
  346. package/blockly-rc/core/variable_map.ts +437 -0
  347. package/blockly-rc/core/variable_model.ts +149 -0
  348. package/blockly-rc/core/variables.ts +773 -0
  349. package/blockly-rc/core/variables_dynamic.ts +142 -0
  350. package/blockly-rc/core/widgetdiv.ts +319 -0
  351. package/blockly-rc/core/workspace.ts +957 -0
  352. package/blockly-rc/core/workspace_audio.ts +171 -0
  353. package/blockly-rc/core/workspace_dragger.ts +97 -0
  354. package/blockly-rc/core/workspace_svg.ts +2519 -0
  355. package/blockly-rc/core/xml.ts +1133 -0
  356. package/blockly-rc/core/zoom_controls.ts +492 -0
  357. package/blockly-rc/demos/blockfactory/analytics.js +195 -0
  358. package/blockly-rc/demos/blockfactory/app_controller.js +726 -0
  359. package/blockly-rc/demos/blockfactory/block_definition_extractor.js +742 -0
  360. package/blockly-rc/demos/blockfactory/block_exporter_controller.js +311 -0
  361. package/blockly-rc/demos/blockfactory/block_exporter_tools.js +212 -0
  362. package/blockly-rc/demos/blockfactory/block_exporter_view.js +101 -0
  363. package/blockly-rc/demos/blockfactory/block_library_controller.js +325 -0
  364. package/blockly-rc/demos/blockfactory/block_library_storage.js +149 -0
  365. package/blockly-rc/demos/blockfactory/block_library_view.js +178 -0
  366. package/blockly-rc/demos/blockfactory/block_option.js +151 -0
  367. package/blockly-rc/demos/blockfactory/blocks.js +916 -0
  368. package/blockly-rc/demos/blockfactory/cp.css +46 -0
  369. package/blockly-rc/demos/blockfactory/cp.js +179 -0
  370. package/blockly-rc/demos/blockfactory/factory.css +586 -0
  371. package/blockly-rc/demos/blockfactory/factory.js +337 -0
  372. package/blockly-rc/demos/blockfactory/factory_utils.js +1036 -0
  373. package/blockly-rc/demos/blockfactory/icon.png +0 -0
  374. package/blockly-rc/demos/blockfactory/index.html +767 -0
  375. package/blockly-rc/demos/blockfactory/link.png +0 -0
  376. package/blockly-rc/demos/blockfactory/standard_categories.js +384 -0
  377. package/blockly-rc/demos/blockfactory/workspacefactory/wfactory_controller.js +1332 -0
  378. package/blockly-rc/demos/blockfactory/workspacefactory/wfactory_generator.js +224 -0
  379. package/blockly-rc/demos/blockfactory/workspacefactory/wfactory_init.js +541 -0
  380. package/blockly-rc/demos/blockfactory/workspacefactory/wfactory_model.js +548 -0
  381. package/blockly-rc/demos/blockfactory/workspacefactory/wfactory_view.js +424 -0
  382. package/blockly-rc/demos/code/code.js +626 -0
  383. package/blockly-rc/demos/code/icon.png +0 -0
  384. package/blockly-rc/demos/code/icons.png +0 -0
  385. package/blockly-rc/demos/code/index.html +359 -0
  386. package/blockly-rc/demos/code/msg/ar.js +24 -0
  387. package/blockly-rc/demos/code/msg/be-tarask.js +24 -0
  388. package/blockly-rc/demos/code/msg/br.js +24 -0
  389. package/blockly-rc/demos/code/msg/ca.js +24 -0
  390. package/blockly-rc/demos/code/msg/cs.js +24 -0
  391. package/blockly-rc/demos/code/msg/da.js +24 -0
  392. package/blockly-rc/demos/code/msg/de.js +24 -0
  393. package/blockly-rc/demos/code/msg/el.js +24 -0
  394. package/blockly-rc/demos/code/msg/en.js +24 -0
  395. package/blockly-rc/demos/code/msg/es.js +24 -0
  396. package/blockly-rc/demos/code/msg/et.js +24 -0
  397. package/blockly-rc/demos/code/msg/fa.js +24 -0
  398. package/blockly-rc/demos/code/msg/fr.js +24 -0
  399. package/blockly-rc/demos/code/msg/he.js +24 -0
  400. package/blockly-rc/demos/code/msg/hr.js +24 -0
  401. package/blockly-rc/demos/code/msg/hrx.js +24 -0
  402. package/blockly-rc/demos/code/msg/hu.js +24 -0
  403. package/blockly-rc/demos/code/msg/ia.js +24 -0
  404. package/blockly-rc/demos/code/msg/is.js +24 -0
  405. package/blockly-rc/demos/code/msg/it.js +24 -0
  406. package/blockly-rc/demos/code/msg/ja.js +24 -0
  407. package/blockly-rc/demos/code/msg/kab.js +24 -0
  408. package/blockly-rc/demos/code/msg/ko.js +24 -0
  409. package/blockly-rc/demos/code/msg/mk.js +24 -0
  410. package/blockly-rc/demos/code/msg/ms.js +24 -0
  411. package/blockly-rc/demos/code/msg/nb.js +24 -0
  412. package/blockly-rc/demos/code/msg/nl.js +24 -0
  413. package/blockly-rc/demos/code/msg/oc.js +24 -0
  414. package/blockly-rc/demos/code/msg/pl.js +24 -0
  415. package/blockly-rc/demos/code/msg/pms.js +24 -0
  416. package/blockly-rc/demos/code/msg/pt-br.js +24 -0
  417. package/blockly-rc/demos/code/msg/ro.js +24 -0
  418. package/blockly-rc/demos/code/msg/ru.js +24 -0
  419. package/blockly-rc/demos/code/msg/sc.js +24 -0
  420. package/blockly-rc/demos/code/msg/sk.js +24 -0
  421. package/blockly-rc/demos/code/msg/sr.js +24 -0
  422. package/blockly-rc/demos/code/msg/sv.js +24 -0
  423. package/blockly-rc/demos/code/msg/ta.js +24 -0
  424. package/blockly-rc/demos/code/msg/th.js +24 -0
  425. package/blockly-rc/demos/code/msg/tlh.js +24 -0
  426. package/blockly-rc/demos/code/msg/tr.js +24 -0
  427. package/blockly-rc/demos/code/msg/uk.js +24 -0
  428. package/blockly-rc/demos/code/msg/vi.js +24 -0
  429. package/blockly-rc/demos/code/msg/zh-hans.js +24 -0
  430. package/blockly-rc/demos/code/msg/zh-hant.js +24 -0
  431. package/blockly-rc/demos/code/style.css +184 -0
  432. package/blockly-rc/demos/index.html +68 -0
  433. package/blockly-rc/demos/minimap/icon.png +0 -0
  434. package/blockly-rc/demos/minimap/index.html +91 -0
  435. package/blockly-rc/demos/minimap/minimap.js +302 -0
  436. package/blockly-rc/demos/mobile/README.md +53 -0
  437. package/blockly-rc/demos/mobile/android/README.md +45 -0
  438. package/blockly-rc/demos/mobile/android/app/build.gradle +64 -0
  439. package/blockly-rc/demos/mobile/android/app/proguard-rules.pro +21 -0
  440. package/blockly-rc/demos/mobile/android/app/src/androidTest/java/com/example/blocklywebview/ExampleInstrumentedTest.java +26 -0
  441. package/blockly-rc/demos/mobile/android/app/src/main/AndroidManifest.xml +21 -0
  442. package/blockly-rc/demos/mobile/android/app/src/main/java/com/google/blockly/android/webview/BlocklyWebViewFragment.java +40 -0
  443. package/blockly-rc/demos/mobile/android/app/src/main/java/com/google/blockly/android/webview/JsDialogHelper.java +150 -0
  444. package/blockly-rc/demos/mobile/android/app/src/main/java/com/google/blockly/android/webview/WebChromeClient.java +32 -0
  445. package/blockly-rc/demos/mobile/android/app/src/main/java/com/google/blockly/android/webview/demo/MainActivity.java +18 -0
  446. package/blockly-rc/demos/mobile/android/app/src/main/res/drawable/ic_launcher_background.xml +74 -0
  447. package/blockly-rc/demos/mobile/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml +34 -0
  448. package/blockly-rc/demos/mobile/android/app/src/main/res/layout/activity_main.xml +17 -0
  449. package/blockly-rc/demos/mobile/android/app/src/main/res/layout/js_prompt.xml +37 -0
  450. package/blockly-rc/demos/mobile/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +5 -0
  451. package/blockly-rc/demos/mobile/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +5 -0
  452. package/blockly-rc/demos/mobile/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  453. package/blockly-rc/demos/mobile/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
  454. package/blockly-rc/demos/mobile/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  455. package/blockly-rc/demos/mobile/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
  456. package/blockly-rc/demos/mobile/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  457. package/blockly-rc/demos/mobile/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
  458. package/blockly-rc/demos/mobile/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  459. package/blockly-rc/demos/mobile/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  460. package/blockly-rc/demos/mobile/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  461. package/blockly-rc/demos/mobile/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
  462. package/blockly-rc/demos/mobile/android/app/src/main/res/values/colors.xml +6 -0
  463. package/blockly-rc/demos/mobile/android/app/src/main/res/values/js_dialog_helper.xml +7 -0
  464. package/blockly-rc/demos/mobile/android/app/src/main/res/values/strings.xml +3 -0
  465. package/blockly-rc/demos/mobile/android/app/src/main/res/values/styles.xml +11 -0
  466. package/blockly-rc/demos/mobile/android/app/src/test/java/com/example/blocklywebview/ExampleUnitTest.java +17 -0
  467. package/blockly-rc/demos/mobile/android/build.gradle +27 -0
  468. package/blockly-rc/demos/mobile/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  469. package/blockly-rc/demos/mobile/android/gradle/wrapper/gradle-wrapper.properties +6 -0
  470. package/blockly-rc/demos/mobile/android/gradle.properties +13 -0
  471. package/blockly-rc/demos/mobile/android/gradlew +172 -0
  472. package/blockly-rc/demos/mobile/android/gradlew.bat +84 -0
  473. package/blockly-rc/demos/mobile/android/settings.gradle +1 -0
  474. package/blockly-rc/demos/mobile/html/index.html +31 -0
  475. package/blockly-rc/demos/mobile/html/ln_resources.sh +22 -0
  476. package/blockly-rc/demos/mobile/html/toolbox_standard.js +333 -0
  477. package/blockly-rc/demos/mobile/ios/Blockly WebView/AppDelegate.swift +46 -0
  478. package/blockly-rc/demos/mobile/ios/Blockly WebView/Assets.xcassets/AppIcon.appiconset/Contents.json +98 -0
  479. package/blockly-rc/demos/mobile/ios/Blockly WebView/Assets.xcassets/Contents.json +6 -0
  480. package/blockly-rc/demos/mobile/ios/Blockly WebView/Base.lproj/LaunchScreen.storyboard +25 -0
  481. package/blockly-rc/demos/mobile/ios/Blockly WebView/Base.lproj/Main.storyboard +44 -0
  482. package/blockly-rc/demos/mobile/ios/Blockly WebView/Info.plist +45 -0
  483. package/blockly-rc/demos/mobile/ios/Blockly WebView/ViewController.swift +110 -0
  484. package/blockly-rc/demos/mobile/ios/Blockly WebView.xcodeproj/project.pbxproj +390 -0
  485. package/blockly-rc/demos/mobile/ios/Blockly WebView.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  486. package/blockly-rc/demos/mobile/ios/Blockly WebView.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  487. package/blockly-rc/demos/mobile/ios/cp_resources.sh +21 -0
  488. package/blockly-rc/demos/storage/icon.png +0 -0
  489. package/blockly-rc/demos/storage/index.html +104 -0
  490. package/blockly-rc/generators/dart/dart_generator.ts +321 -0
  491. package/blockly-rc/generators/dart/lists.ts +525 -0
  492. package/blockly-rc/generators/dart/logic.ts +155 -0
  493. package/blockly-rc/generators/dart/loops.ts +217 -0
  494. package/blockly-rc/generators/dart/math.ts +559 -0
  495. package/blockly-rc/generators/dart/procedures.ts +138 -0
  496. package/blockly-rc/generators/dart/text.ts +405 -0
  497. package/blockly-rc/generators/dart/variables.ts +32 -0
  498. package/blockly-rc/generators/dart/variables_dynamic.ts +17 -0
  499. package/blockly-rc/generators/dart.ts +50 -0
  500. package/blockly-rc/generators/javascript/javascript_generator.ts +346 -0
  501. package/blockly-rc/generators/javascript/lists.ts +465 -0
  502. package/blockly-rc/generators/javascript/logic.ts +153 -0
  503. package/blockly-rc/generators/javascript/loops.ts +245 -0
  504. package/blockly-rc/generators/javascript/math.ts +450 -0
  505. package/blockly-rc/generators/javascript/procedures.ts +142 -0
  506. package/blockly-rc/generators/javascript/text.ts +418 -0
  507. package/blockly-rc/generators/javascript/variables.ts +32 -0
  508. package/blockly-rc/generators/javascript/variables_dynamic.ts +17 -0
  509. package/blockly-rc/generators/javascript.ts +46 -0
  510. package/blockly-rc/generators/lua/lists.ts +445 -0
  511. package/blockly-rc/generators/lua/logic.ts +142 -0
  512. package/blockly-rc/generators/lua/loops.ts +192 -0
  513. package/blockly-rc/generators/lua/lua_generator.ts +225 -0
  514. package/blockly-rc/generators/lua/math.ts +473 -0
  515. package/blockly-rc/generators/lua/procedures.ts +144 -0
  516. package/blockly-rc/generators/lua/text.ts +380 -0
  517. package/blockly-rc/generators/lua/variables.ts +31 -0
  518. package/blockly-rc/generators/lua/variables_dynamic.ts +17 -0
  519. package/blockly-rc/generators/lua.ts +44 -0
  520. package/blockly-rc/generators/php/lists.ts +585 -0
  521. package/blockly-rc/generators/php/logic.ts +155 -0
  522. package/blockly-rc/generators/php/loops.ts +218 -0
  523. package/blockly-rc/generators/php/math.ts +408 -0
  524. package/blockly-rc/generators/php/php_generator.ts +320 -0
  525. package/blockly-rc/generators/php/procedures.ts +159 -0
  526. package/blockly-rc/generators/php/text.ts +315 -0
  527. package/blockly-rc/generators/php/variables.ts +32 -0
  528. package/blockly-rc/generators/php/variables_dynamic.ts +17 -0
  529. package/blockly-rc/generators/php.ts +46 -0
  530. package/blockly-rc/generators/python/lists.ts +398 -0
  531. package/blockly-rc/generators/python/logic.ts +148 -0
  532. package/blockly-rc/generators/python/loops.ts +251 -0
  533. package/blockly-rc/generators/python/math.ts +434 -0
  534. package/blockly-rc/generators/python/procedures.ts +159 -0
  535. package/blockly-rc/generators/python/python_generator.ts +355 -0
  536. package/blockly-rc/generators/python/text.ts +338 -0
  537. package/blockly-rc/generators/python/variables.ts +31 -0
  538. package/blockly-rc/generators/python/variables_dynamic.ts +17 -0
  539. package/blockly-rc/generators/python.ts +51 -0
  540. package/blockly-rc/gulpfile.js +54 -0
  541. package/blockly-rc/jsconfig.json +7 -0
  542. package/blockly-rc/media/1x1.gif +0 -0
  543. package/blockly-rc/media/click.mp3 +0 -0
  544. package/blockly-rc/media/click.ogg +0 -0
  545. package/blockly-rc/media/click.wav +0 -0
  546. package/blockly-rc/media/delete-icon.svg +1 -0
  547. package/blockly-rc/media/delete.mp3 +0 -0
  548. package/blockly-rc/media/delete.ogg +0 -0
  549. package/blockly-rc/media/delete.wav +0 -0
  550. package/blockly-rc/media/disconnect.mp3 +0 -0
  551. package/blockly-rc/media/disconnect.ogg +0 -0
  552. package/blockly-rc/media/disconnect.wav +0 -0
  553. package/blockly-rc/media/dropdown-arrow.svg +1 -0
  554. package/blockly-rc/media/foldout-icon.svg +1 -0
  555. package/blockly-rc/media/handclosed.cur +0 -0
  556. package/blockly-rc/media/handdelete.cur +0 -0
  557. package/blockly-rc/media/handopen.cur +0 -0
  558. package/blockly-rc/media/pilcrow.png +0 -0
  559. package/blockly-rc/media/quote0.png +0 -0
  560. package/blockly-rc/media/quote1.png +0 -0
  561. package/blockly-rc/media/resize-handle.svg +3 -0
  562. package/blockly-rc/media/sprites.png +0 -0
  563. package/blockly-rc/media/sprites.svg +74 -0
  564. package/blockly-rc/msg/json/README.md +33 -0
  565. package/blockly-rc/msg/json/ab.json +222 -0
  566. package/blockly-rc/msg/json/ace.json +7 -0
  567. package/blockly-rc/msg/json/af.json +34 -0
  568. package/blockly-rc/msg/json/am.json +30 -0
  569. package/blockly-rc/msg/json/ar.json +355 -0
  570. package/blockly-rc/msg/json/ast.json +10 -0
  571. package/blockly-rc/msg/json/az.json +332 -0
  572. package/blockly-rc/msg/json/ba.json +211 -0
  573. package/blockly-rc/msg/json/bcc.json +290 -0
  574. package/blockly-rc/msg/json/be-tarask.json +334 -0
  575. package/blockly-rc/msg/json/be.json +324 -0
  576. package/blockly-rc/msg/json/bg.json +345 -0
  577. package/blockly-rc/msg/json/bn.json +189 -0
  578. package/blockly-rc/msg/json/br.json +334 -0
  579. package/blockly-rc/msg/json/bs.json +166 -0
  580. package/blockly-rc/msg/json/ca.json +341 -0
  581. package/blockly-rc/msg/json/cdo.json +6 -0
  582. package/blockly-rc/msg/json/ce.json +326 -0
  583. package/blockly-rc/msg/json/constants.json +12 -0
  584. package/blockly-rc/msg/json/cs.json +343 -0
  585. package/blockly-rc/msg/json/da.json +346 -0
  586. package/blockly-rc/msg/json/de.json +369 -0
  587. package/blockly-rc/msg/json/diq.json +258 -0
  588. package/blockly-rc/msg/json/dtp.json +198 -0
  589. package/blockly-rc/msg/json/dty.json +97 -0
  590. package/blockly-rc/msg/json/ee.json +160 -0
  591. package/blockly-rc/msg/json/el.json +356 -0
  592. package/blockly-rc/msg/json/en-gb.json +199 -0
  593. package/blockly-rc/msg/json/en.json +400 -0
  594. package/blockly-rc/msg/json/eo.json +337 -0
  595. package/blockly-rc/msg/json/es.json +358 -0
  596. package/blockly-rc/msg/json/et.json +326 -0
  597. package/blockly-rc/msg/json/eu.json +219 -0
  598. package/blockly-rc/msg/json/fa.json +341 -0
  599. package/blockly-rc/msg/json/fi.json +350 -0
  600. package/blockly-rc/msg/json/fo.json +46 -0
  601. package/blockly-rc/msg/json/fr.json +373 -0
  602. package/blockly-rc/msg/json/frr.json +6 -0
  603. package/blockly-rc/msg/json/gl.json +338 -0
  604. package/blockly-rc/msg/json/gn.json +54 -0
  605. package/blockly-rc/msg/json/gor.json +87 -0
  606. package/blockly-rc/msg/json/ha.json +313 -0
  607. package/blockly-rc/msg/json/hak.json +17 -0
  608. package/blockly-rc/msg/json/he.json +354 -0
  609. package/blockly-rc/msg/json/hi.json +318 -0
  610. package/blockly-rc/msg/json/hr.json +327 -0
  611. package/blockly-rc/msg/json/hrx.json +287 -0
  612. package/blockly-rc/msg/json/hsb.json +128 -0
  613. package/blockly-rc/msg/json/hu.json +349 -0
  614. package/blockly-rc/msg/json/hy.json +337 -0
  615. package/blockly-rc/msg/json/ia.json +337 -0
  616. package/blockly-rc/msg/json/id.json +335 -0
  617. package/blockly-rc/msg/json/ig.json +323 -0
  618. package/blockly-rc/msg/json/inh.json +80 -0
  619. package/blockly-rc/msg/json/is.json +331 -0
  620. package/blockly-rc/msg/json/it.json +346 -0
  621. package/blockly-rc/msg/json/ja.json +361 -0
  622. package/blockly-rc/msg/json/ka.json +14 -0
  623. package/blockly-rc/msg/json/kab.json +323 -0
  624. package/blockly-rc/msg/json/kbd-cyrl.json +84 -0
  625. package/blockly-rc/msg/json/km.json +29 -0
  626. package/blockly-rc/msg/json/kn.json +332 -0
  627. package/blockly-rc/msg/json/ko.json +372 -0
  628. package/blockly-rc/msg/json/ksh.json +43 -0
  629. package/blockly-rc/msg/json/ku-latn.json +41 -0
  630. package/blockly-rc/msg/json/ky.json +71 -0
  631. package/blockly-rc/msg/json/la.json +6 -0
  632. package/blockly-rc/msg/json/lb.json +156 -0
  633. package/blockly-rc/msg/json/lki.json +282 -0
  634. package/blockly-rc/msg/json/lo.json +92 -0
  635. package/blockly-rc/msg/json/lrc.json +123 -0
  636. package/blockly-rc/msg/json/lt.json +321 -0
  637. package/blockly-rc/msg/json/lv.json +324 -0
  638. package/blockly-rc/msg/json/mg.json +58 -0
  639. package/blockly-rc/msg/json/mk.json +178 -0
  640. package/blockly-rc/msg/json/ml.json +35 -0
  641. package/blockly-rc/msg/json/mnw.json +90 -0
  642. package/blockly-rc/msg/json/ms.json +300 -0
  643. package/blockly-rc/msg/json/my.json +57 -0
  644. package/blockly-rc/msg/json/mzn.json +6 -0
  645. package/blockly-rc/msg/json/nb.json +330 -0
  646. package/blockly-rc/msg/json/ne.json +247 -0
  647. package/blockly-rc/msg/json/nl.json +357 -0
  648. package/blockly-rc/msg/json/oc.json +194 -0
  649. package/blockly-rc/msg/json/olo.json +37 -0
  650. package/blockly-rc/msg/json/pa.json +69 -0
  651. package/blockly-rc/msg/json/pl.json +357 -0
  652. package/blockly-rc/msg/json/pms.json +324 -0
  653. package/blockly-rc/msg/json/ps.json +50 -0
  654. package/blockly-rc/msg/json/pt-br.json +369 -0
  655. package/blockly-rc/msg/json/pt.json +358 -0
  656. package/blockly-rc/msg/json/qqq.json +406 -0
  657. package/blockly-rc/msg/json/ro.json +333 -0
  658. package/blockly-rc/msg/json/ru.json +363 -0
  659. package/blockly-rc/msg/json/sc.json +283 -0
  660. package/blockly-rc/msg/json/sco.json +11 -0
  661. package/blockly-rc/msg/json/sd.json +158 -0
  662. package/blockly-rc/msg/json/shn.json +109 -0
  663. package/blockly-rc/msg/json/si.json +16 -0
  664. package/blockly-rc/msg/json/sk.json +332 -0
  665. package/blockly-rc/msg/json/skr-arab.json +117 -0
  666. package/blockly-rc/msg/json/sl.json +355 -0
  667. package/blockly-rc/msg/json/smn.json +133 -0
  668. package/blockly-rc/msg/json/sq.json +343 -0
  669. package/blockly-rc/msg/json/sr-latn.json +324 -0
  670. package/blockly-rc/msg/json/sr.json +348 -0
  671. package/blockly-rc/msg/json/sv.json +347 -0
  672. package/blockly-rc/msg/json/sw.json +12 -0
  673. package/blockly-rc/msg/json/synonyms.json +22 -0
  674. package/blockly-rc/msg/json/ta.json +306 -0
  675. package/blockly-rc/msg/json/tcy.json +316 -0
  676. package/blockly-rc/msg/json/tdd.json +109 -0
  677. package/blockly-rc/msg/json/te.json +101 -0
  678. package/blockly-rc/msg/json/th.json +333 -0
  679. package/blockly-rc/msg/json/ti.json +50 -0
  680. package/blockly-rc/msg/json/tl.json +129 -0
  681. package/blockly-rc/msg/json/tlh.json +179 -0
  682. package/blockly-rc/msg/json/tr.json +369 -0
  683. package/blockly-rc/msg/json/ug-arab.json +132 -0
  684. package/blockly-rc/msg/json/uk.json +345 -0
  685. package/blockly-rc/msg/json/ur.json +117 -0
  686. package/blockly-rc/msg/json/uz.json +36 -0
  687. package/blockly-rc/msg/json/vi.json +345 -0
  688. package/blockly-rc/msg/json/xmf.json +96 -0
  689. package/blockly-rc/msg/json/yo.json +316 -0
  690. package/blockly-rc/msg/json/zgh.json +83 -0
  691. package/blockly-rc/msg/json/zh-hans.json +372 -0
  692. package/blockly-rc/msg/json/zh-hant.json +362 -0
  693. package/blockly-rc/msg/messages.js +1616 -0
  694. package/blockly-rc/package-lock.json +12324 -0
  695. package/blockly-rc/package.json +149 -0
  696. package/blockly-rc/patches/@microsoft+api-documenter+7.22.4.patch +81 -0
  697. package/blockly-rc/scripts/goog_module/convert-file.sh +406 -0
  698. package/blockly-rc/scripts/gulpfiles/appengine_tasks.js +195 -0
  699. package/blockly-rc/scripts/gulpfiles/build_tasks.js +752 -0
  700. package/blockly-rc/scripts/gulpfiles/config.js +41 -0
  701. package/blockly-rc/scripts/gulpfiles/docs_tasks.js +147 -0
  702. package/blockly-rc/scripts/gulpfiles/git_tasks.js +181 -0
  703. package/blockly-rc/scripts/gulpfiles/helper_tasks.js +19 -0
  704. package/blockly-rc/scripts/gulpfiles/package_tasks.js +262 -0
  705. package/blockly-rc/scripts/gulpfiles/release_tasks.js +183 -0
  706. package/blockly-rc/scripts/gulpfiles/test_tasks.js +405 -0
  707. package/blockly-rc/scripts/helpers.js +74 -0
  708. package/blockly-rc/scripts/i18n/common.py +233 -0
  709. package/blockly-rc/scripts/i18n/create_messages.py +167 -0
  710. package/blockly-rc/scripts/i18n/dedup_json.py +72 -0
  711. package/blockly-rc/scripts/i18n/js_to_json.py +135 -0
  712. package/blockly-rc/scripts/i18n/tests.py +46 -0
  713. package/blockly-rc/scripts/migration/cjs2esm +162 -0
  714. package/blockly-rc/scripts/migration/js2ts +168 -0
  715. package/blockly-rc/scripts/migration/renamings.json5 +1599 -0
  716. package/blockly-rc/scripts/package/README.md +93 -0
  717. package/blockly-rc/scripts/package/core-node.js +31 -0
  718. package/blockly-rc/scripts/package/index.js +23 -0
  719. package/blockly-rc/scripts/package/templates/umd-msg.template +16 -0
  720. package/blockly-rc/scripts/package/templates/umd.template +13 -0
  721. package/blockly-rc/scripts/themes/blockStyles_example.json +11 -0
  722. package/blockly-rc/scripts/themes/create_blockStyles.py +181 -0
  723. package/blockly-rc/scripts/tsick.js +86 -0
  724. package/blockly-rc/tests/.eslintrc.json +10 -0
  725. package/blockly-rc/tests/browser/.eslintrc.json +29 -0
  726. package/blockly-rc/tests/browser/.mocharc.js +6 -0
  727. package/blockly-rc/tests/browser/test/basic_block_factory_test.mjs +44 -0
  728. package/blockly-rc/tests/browser/test/basic_block_test.mjs +39 -0
  729. package/blockly-rc/tests/browser/test/basic_playground_test.mjs +198 -0
  730. package/blockly-rc/tests/browser/test/block_undo_test.mjs +50 -0
  731. package/blockly-rc/tests/browser/test/delete_blocks_test.mjs +211 -0
  732. package/blockly-rc/tests/browser/test/extensive_test.mjs +195 -0
  733. package/blockly-rc/tests/browser/test/field_edits_test.mjs +61 -0
  734. package/blockly-rc/tests/browser/test/hooks.mjs +23 -0
  735. package/blockly-rc/tests/browser/test/mutator_test.mjs +88 -0
  736. package/blockly-rc/tests/browser/test/procedure_test.mjs +109 -0
  737. package/blockly-rc/tests/browser/test/test_setup.mjs +589 -0
  738. package/blockly-rc/tests/browser/test/toolbox_drag_test.mjs +207 -0
  739. package/blockly-rc/tests/browser/test/workspace_comment_test.mjs +224 -0
  740. package/blockly-rc/tests/compile/index.html +43 -0
  741. package/blockly-rc/tests/compile/main.js +53 -0
  742. package/blockly-rc/tests/compile/test_blocks.js +47 -0
  743. package/blockly-rc/tests/compile/webdriver.js +81 -0
  744. package/blockly-rc/tests/generators/functions.xml +561 -0
  745. package/blockly-rc/tests/generators/golden/generated.dart +1604 -0
  746. package/blockly-rc/tests/generators/golden/generated.js +1552 -0
  747. package/blockly-rc/tests/generators/golden/generated.lua +1828 -0
  748. package/blockly-rc/tests/generators/golden/generated.php +1611 -0
  749. package/blockly-rc/tests/generators/golden/generated.py +1407 -0
  750. package/blockly-rc/tests/generators/index.html +405 -0
  751. package/blockly-rc/tests/generators/lists.xml +8675 -0
  752. package/blockly-rc/tests/generators/logic.xml +1019 -0
  753. package/blockly-rc/tests/generators/loops1.xml +345 -0
  754. package/blockly-rc/tests/generators/loops2.xml +891 -0
  755. package/blockly-rc/tests/generators/loops3.xml +735 -0
  756. package/blockly-rc/tests/generators/math.xml +2077 -0
  757. package/blockly-rc/tests/generators/text.xml +4651 -0
  758. package/blockly-rc/tests/generators/unittest.js +103 -0
  759. package/blockly-rc/tests/generators/unittest_dart.js +163 -0
  760. package/blockly-rc/tests/generators/unittest_javascript.js +167 -0
  761. package/blockly-rc/tests/generators/unittest_lua.js +165 -0
  762. package/blockly-rc/tests/generators/unittest_php.js +154 -0
  763. package/blockly-rc/tests/generators/unittest_python.js +138 -0
  764. package/blockly-rc/tests/generators/variables.xml +68 -0
  765. package/blockly-rc/tests/generators/webdriver.js +123 -0
  766. package/blockly-rc/tests/media/200px.png +0 -0
  767. package/blockly-rc/tests/media/30px.png +0 -0
  768. package/blockly-rc/tests/media/50px.png +0 -0
  769. package/blockly-rc/tests/media/a.png +0 -0
  770. package/blockly-rc/tests/media/arrow.png +0 -0
  771. package/blockly-rc/tests/media/b.png +0 -0
  772. package/blockly-rc/tests/media/c.png +0 -0
  773. package/blockly-rc/tests/media/d.png +0 -0
  774. package/blockly-rc/tests/media/e.png +0 -0
  775. package/blockly-rc/tests/media/f.png +0 -0
  776. package/blockly-rc/tests/media/g.png +0 -0
  777. package/blockly-rc/tests/media/h.png +0 -0
  778. package/blockly-rc/tests/media/i.png +0 -0
  779. package/blockly-rc/tests/media/j.png +0 -0
  780. package/blockly-rc/tests/media/k.png +0 -0
  781. package/blockly-rc/tests/media/l.png +0 -0
  782. package/blockly-rc/tests/media/m.png +0 -0
  783. package/blockly-rc/tests/migration/renamings.schema.json +59 -0
  784. package/blockly-rc/tests/migration/validate-renamings.mjs +60 -0
  785. package/blockly-rc/tests/mocha/.eslintrc.json +21 -0
  786. package/blockly-rc/tests/mocha/.mocharc.js +6 -0
  787. package/blockly-rc/tests/mocha/astnode_test.js +850 -0
  788. package/blockly-rc/tests/mocha/block_json_test.js +777 -0
  789. package/blockly-rc/tests/mocha/block_test.js +2743 -0
  790. package/blockly-rc/tests/mocha/blocks/lists_test.js +196 -0
  791. package/blockly-rc/tests/mocha/blocks/logic_ternary_test.js +320 -0
  792. package/blockly-rc/tests/mocha/blocks/loops_test.js +56 -0
  793. package/blockly-rc/tests/mocha/blocks/procedures_test.js +2495 -0
  794. package/blockly-rc/tests/mocha/blocks/variables_test.js +311 -0
  795. package/blockly-rc/tests/mocha/clipboard_test.js +136 -0
  796. package/blockly-rc/tests/mocha/comment_deserialization_test.js +122 -0
  797. package/blockly-rc/tests/mocha/comment_test.js +170 -0
  798. package/blockly-rc/tests/mocha/comment_view_test.js +188 -0
  799. package/blockly-rc/tests/mocha/connection_checker_test.js +666 -0
  800. package/blockly-rc/tests/mocha/connection_db_test.js +362 -0
  801. package/blockly-rc/tests/mocha/connection_test.js +3738 -0
  802. package/blockly-rc/tests/mocha/contextmenu_items_test.js +488 -0
  803. package/blockly-rc/tests/mocha/contextmenu_test.js +71 -0
  804. package/blockly-rc/tests/mocha/cursor_test.js +134 -0
  805. package/blockly-rc/tests/mocha/dropdowndiv_test.js +116 -0
  806. package/blockly-rc/tests/mocha/event_block_change_test.js +126 -0
  807. package/blockly-rc/tests/mocha/event_block_create_test.js +109 -0
  808. package/blockly-rc/tests/mocha/event_block_delete_test.js +55 -0
  809. package/blockly-rc/tests/mocha/event_block_drag_test.js +36 -0
  810. package/blockly-rc/tests/mocha/event_block_field_intermediate_change_test.js +67 -0
  811. package/blockly-rc/tests/mocha/event_block_move_test.js +39 -0
  812. package/blockly-rc/tests/mocha/event_bubble_open_test.js +42 -0
  813. package/blockly-rc/tests/mocha/event_click_test.js +40 -0
  814. package/blockly-rc/tests/mocha/event_comment_change_test.js +39 -0
  815. package/blockly-rc/tests/mocha/event_comment_collapse_test.js +34 -0
  816. package/blockly-rc/tests/mocha/event_comment_create_test.js +38 -0
  817. package/blockly-rc/tests/mocha/event_comment_delete_test.js +38 -0
  818. package/blockly-rc/tests/mocha/event_comment_drag_test.js +35 -0
  819. package/blockly-rc/tests/mocha/event_comment_move_test.js +40 -0
  820. package/blockly-rc/tests/mocha/event_comment_resize_test.js +38 -0
  821. package/blockly-rc/tests/mocha/event_marker_move_test.js +44 -0
  822. package/blockly-rc/tests/mocha/event_selected_test.js +41 -0
  823. package/blockly-rc/tests/mocha/event_test.js +1578 -0
  824. package/blockly-rc/tests/mocha/event_theme_change_test.js +36 -0
  825. package/blockly-rc/tests/mocha/event_toolbox_item_select_test.js +64 -0
  826. package/blockly-rc/tests/mocha/event_trashcan_open_test.js +36 -0
  827. package/blockly-rc/tests/mocha/event_var_create_test.js +54 -0
  828. package/blockly-rc/tests/mocha/event_var_delete_test.js +54 -0
  829. package/blockly-rc/tests/mocha/event_var_rename_test.js +39 -0
  830. package/blockly-rc/tests/mocha/event_var_type_change_test.js +43 -0
  831. package/blockly-rc/tests/mocha/event_viewport_test.js +39 -0
  832. package/blockly-rc/tests/mocha/extensions_test.js +613 -0
  833. package/blockly-rc/tests/mocha/field_checkbox_test.js +299 -0
  834. package/blockly-rc/tests/mocha/field_colour_test.js +395 -0
  835. package/blockly-rc/tests/mocha/field_dropdown_test.js +282 -0
  836. package/blockly-rc/tests/mocha/field_image_test.js +241 -0
  837. package/blockly-rc/tests/mocha/field_label_serializable_test.js +252 -0
  838. package/blockly-rc/tests/mocha/field_label_test.js +226 -0
  839. package/blockly-rc/tests/mocha/field_number_test.js +505 -0
  840. package/blockly-rc/tests/mocha/field_registry_test.js +116 -0
  841. package/blockly-rc/tests/mocha/field_test.js +822 -0
  842. package/blockly-rc/tests/mocha/field_textinput_test.js +297 -0
  843. package/blockly-rc/tests/mocha/field_variable_test.js +611 -0
  844. package/blockly-rc/tests/mocha/flyout_test.js +638 -0
  845. package/blockly-rc/tests/mocha/generator_test.js +233 -0
  846. package/blockly-rc/tests/mocha/gesture_test.js +97 -0
  847. package/blockly-rc/tests/mocha/icon_test.js +369 -0
  848. package/blockly-rc/tests/mocha/index.html +229 -0
  849. package/blockly-rc/tests/mocha/input_test.js +296 -0
  850. package/blockly-rc/tests/mocha/insertion_marker_manager_test.js +443 -0
  851. package/blockly-rc/tests/mocha/insertion_marker_test.js +432 -0
  852. package/blockly-rc/tests/mocha/jso_deserialization_test.js +849 -0
  853. package/blockly-rc/tests/mocha/jso_serialization_test.js +1067 -0
  854. package/blockly-rc/tests/mocha/json_test.js +315 -0
  855. package/blockly-rc/tests/mocha/keydown_test.js +364 -0
  856. package/blockly-rc/tests/mocha/layering_test.js +95 -0
  857. package/blockly-rc/tests/mocha/metrics_test.js +671 -0
  858. package/blockly-rc/tests/mocha/mutator_test.js +87 -0
  859. package/blockly-rc/tests/mocha/names_test.js +97 -0
  860. package/blockly-rc/tests/mocha/old_workspace_comment_test.js +256 -0
  861. package/blockly-rc/tests/mocha/procedure_map_test.js +57 -0
  862. package/blockly-rc/tests/mocha/registry_test.js +281 -0
  863. package/blockly-rc/tests/mocha/render_management_test.js +127 -0
  864. package/blockly-rc/tests/mocha/serializer_test.js +2104 -0
  865. package/blockly-rc/tests/mocha/shortcut_registry_test.js +450 -0
  866. package/blockly-rc/tests/mocha/test_helpers/block_definitions.js +204 -0
  867. package/blockly-rc/tests/mocha/test_helpers/code_generation.js +115 -0
  868. package/blockly-rc/tests/mocha/test_helpers/common.js +106 -0
  869. package/blockly-rc/tests/mocha/test_helpers/events.js +290 -0
  870. package/blockly-rc/tests/mocha/test_helpers/fields.js +310 -0
  871. package/blockly-rc/tests/mocha/test_helpers/icon_mocks.js +81 -0
  872. package/blockly-rc/tests/mocha/test_helpers/procedures.js +302 -0
  873. package/blockly-rc/tests/mocha/test_helpers/serialization.js +124 -0
  874. package/blockly-rc/tests/mocha/test_helpers/setup_teardown.js +209 -0
  875. package/blockly-rc/tests/mocha/test_helpers/toolbox_definitions.js +271 -0
  876. package/blockly-rc/tests/mocha/test_helpers/user_input.js +62 -0
  877. package/blockly-rc/tests/mocha/test_helpers/variables.js +23 -0
  878. package/blockly-rc/tests/mocha/test_helpers/warnings.js +83 -0
  879. package/blockly-rc/tests/mocha/test_helpers/workspace.js +1691 -0
  880. package/blockly-rc/tests/mocha/theme_test.js +307 -0
  881. package/blockly-rc/tests/mocha/toolbox_test.js +761 -0
  882. package/blockly-rc/tests/mocha/tooltip_test.js +276 -0
  883. package/blockly-rc/tests/mocha/touch_test.js +109 -0
  884. package/blockly-rc/tests/mocha/trashcan_test.js +375 -0
  885. package/blockly-rc/tests/mocha/utils_test.js +536 -0
  886. package/blockly-rc/tests/mocha/variable_map_test.js +509 -0
  887. package/blockly-rc/tests/mocha/variable_model_test.js +85 -0
  888. package/blockly-rc/tests/mocha/webdriver.js +96 -0
  889. package/blockly-rc/tests/mocha/widget_div_test.js +272 -0
  890. package/blockly-rc/tests/mocha/workspace_comment_test.js +171 -0
  891. package/blockly-rc/tests/mocha/workspace_svg_test.js +414 -0
  892. package/blockly-rc/tests/mocha/workspace_test.js +27 -0
  893. package/blockly-rc/tests/mocha/xml_test.js +951 -0
  894. package/blockly-rc/tests/mocha/zoom_controls_test.js +81 -0
  895. package/blockly-rc/tests/multi_playground.html +482 -0
  896. package/blockly-rc/tests/node/.eslintrc.json +12 -0
  897. package/blockly-rc/tests/node/.mocharc.js +6 -0
  898. package/blockly-rc/tests/node/run_node_test.mjs +72 -0
  899. package/blockly-rc/tests/playground.html +1280 -0
  900. package/blockly-rc/tests/playgrounds/advanced_playground.html +158 -0
  901. package/blockly-rc/tests/playgrounds/iframe.html +40 -0
  902. package/blockly-rc/tests/playgrounds/screenshot.js +123 -0
  903. package/blockly-rc/tests/scripts/check_metadata.sh +166 -0
  904. package/blockly-rc/tests/scripts/compile_typings.sh +32 -0
  905. package/blockly-rc/tests/scripts/load.mjs +140 -0
  906. package/blockly-rc/tests/scripts/setup_linux_env.sh +7 -0
  907. package/blockly-rc/tests/scripts/update_metadata.sh +46 -0
  908. package/blockly-rc/tests/themes/test_themes.js +62 -0
  909. package/blockly-rc/tests/typescript/README.md +4 -0
  910. package/blockly-rc/tests/typescript/src/field/different_user_input.ts +81 -0
  911. package/blockly-rc/tests/typescript/src/generators/dart.ts +24 -0
  912. package/blockly-rc/tests/typescript/src/generators/javascript.ts +28 -0
  913. package/blockly-rc/tests/typescript/src/generators/lua.ts +24 -0
  914. package/blockly-rc/tests/typescript/src/generators/php.ts +24 -0
  915. package/blockly-rc/tests/typescript/src/generators/python.ts +24 -0
  916. package/blockly-rc/tests/typescript/src/generators.ts +31 -0
  917. package/blockly-rc/tests/typescript/src/msg.ts +20 -0
  918. package/blockly-rc/tests/typescript/tsconfig.json +20 -0
  919. package/blockly-rc/tests/xml/README.txt +11 -0
  920. package/blockly-rc/tests/xml/blockly.xsd +178 -0
  921. package/blockly-rc/tests/xml/invalid.xml +6 -0
  922. package/blockly-rc/tests/xml/toolbox.xml +311 -0
  923. package/blockly-rc/tests/xml/workspace.xml +114 -0
  924. package/blockly-rc/tsconfig.json +37 -0
  925. package/blockly-rc/tsdoc.json +35 -0
  926. package/blockly-rc/typings/README.md +5 -0
  927. package/blockly-rc/typings/blocks.d.ts +17 -0
  928. package/blockly-rc/typings/core.d.ts +7 -0
  929. package/blockly-rc/typings/dart.d.ts +7 -0
  930. package/blockly-rc/typings/index.d.ts +10 -0
  931. package/blockly-rc/typings/javascript.d.ts +7 -0
  932. package/blockly-rc/typings/lua.d.ts +7 -0
  933. package/blockly-rc/typings/msg/ab.d.ts +8 -0
  934. package/blockly-rc/typings/msg/ace.d.ts +8 -0
  935. package/blockly-rc/typings/msg/af.d.ts +8 -0
  936. package/blockly-rc/typings/msg/am.d.ts +8 -0
  937. package/blockly-rc/typings/msg/ar.d.ts +8 -0
  938. package/blockly-rc/typings/msg/ast.d.ts +8 -0
  939. package/blockly-rc/typings/msg/az.d.ts +8 -0
  940. package/blockly-rc/typings/msg/ba.d.ts +8 -0
  941. package/blockly-rc/typings/msg/bcc.d.ts +8 -0
  942. package/blockly-rc/typings/msg/be-tarask.d.ts +8 -0
  943. package/blockly-rc/typings/msg/be.d.ts +8 -0
  944. package/blockly-rc/typings/msg/bg.d.ts +8 -0
  945. package/blockly-rc/typings/msg/bn.d.ts +8 -0
  946. package/blockly-rc/typings/msg/br.d.ts +8 -0
  947. package/blockly-rc/typings/msg/bs.d.ts +8 -0
  948. package/blockly-rc/typings/msg/ca.d.ts +8 -0
  949. package/blockly-rc/typings/msg/cdo.d.ts +8 -0
  950. package/blockly-rc/typings/msg/ce.d.ts +8 -0
  951. package/blockly-rc/typings/msg/cs.d.ts +8 -0
  952. package/blockly-rc/typings/msg/da.d.ts +8 -0
  953. package/blockly-rc/typings/msg/de.d.ts +8 -0
  954. package/blockly-rc/typings/msg/diq.d.ts +8 -0
  955. package/blockly-rc/typings/msg/dtp.d.ts +8 -0
  956. package/blockly-rc/typings/msg/dty.d.ts +8 -0
  957. package/blockly-rc/typings/msg/ee.d.ts +8 -0
  958. package/blockly-rc/typings/msg/el.d.ts +8 -0
  959. package/blockly-rc/typings/msg/en-gb.d.ts +8 -0
  960. package/blockly-rc/typings/msg/en.d.ts +8 -0
  961. package/blockly-rc/typings/msg/eo.d.ts +8 -0
  962. package/blockly-rc/typings/msg/es.d.ts +8 -0
  963. package/blockly-rc/typings/msg/et.d.ts +8 -0
  964. package/blockly-rc/typings/msg/eu.d.ts +8 -0
  965. package/blockly-rc/typings/msg/fa.d.ts +8 -0
  966. package/blockly-rc/typings/msg/fi.d.ts +8 -0
  967. package/blockly-rc/typings/msg/fo.d.ts +8 -0
  968. package/blockly-rc/typings/msg/fr.d.ts +8 -0
  969. package/blockly-rc/typings/msg/frr.d.ts +8 -0
  970. package/blockly-rc/typings/msg/gl.d.ts +8 -0
  971. package/blockly-rc/typings/msg/gn.d.ts +8 -0
  972. package/blockly-rc/typings/msg/gor.d.ts +8 -0
  973. package/blockly-rc/typings/msg/ha.d.ts +8 -0
  974. package/blockly-rc/typings/msg/hak.d.ts +8 -0
  975. package/blockly-rc/typings/msg/he.d.ts +8 -0
  976. package/blockly-rc/typings/msg/hi.d.ts +8 -0
  977. package/blockly-rc/typings/msg/hr.d.ts +8 -0
  978. package/blockly-rc/typings/msg/hrx.d.ts +8 -0
  979. package/blockly-rc/typings/msg/hsb.d.ts +8 -0
  980. package/blockly-rc/typings/msg/hu.d.ts +8 -0
  981. package/blockly-rc/typings/msg/hy.d.ts +8 -0
  982. package/blockly-rc/typings/msg/ia.d.ts +8 -0
  983. package/blockly-rc/typings/msg/id.d.ts +8 -0
  984. package/blockly-rc/typings/msg/ig.d.ts +8 -0
  985. package/blockly-rc/typings/msg/inh.d.ts +8 -0
  986. package/blockly-rc/typings/msg/is.d.ts +8 -0
  987. package/blockly-rc/typings/msg/it.d.ts +8 -0
  988. package/blockly-rc/typings/msg/ja.d.ts +8 -0
  989. package/blockly-rc/typings/msg/ka.d.ts +8 -0
  990. package/blockly-rc/typings/msg/kab.d.ts +8 -0
  991. package/blockly-rc/typings/msg/kbd-cyrl.d.ts +8 -0
  992. package/blockly-rc/typings/msg/km.d.ts +8 -0
  993. package/blockly-rc/typings/msg/kn.d.ts +8 -0
  994. package/blockly-rc/typings/msg/ko.d.ts +8 -0
  995. package/blockly-rc/typings/msg/ksh.d.ts +8 -0
  996. package/blockly-rc/typings/msg/ku-latn.d.ts +8 -0
  997. package/blockly-rc/typings/msg/ky.d.ts +8 -0
  998. package/blockly-rc/typings/msg/la.d.ts +8 -0
  999. package/blockly-rc/typings/msg/lb.d.ts +8 -0
  1000. package/blockly-rc/typings/msg/lki.d.ts +8 -0
  1001. package/blockly-rc/typings/msg/lo.d.ts +8 -0
  1002. package/blockly-rc/typings/msg/lrc.d.ts +8 -0
  1003. package/blockly-rc/typings/msg/lt.d.ts +8 -0
  1004. package/blockly-rc/typings/msg/lv.d.ts +8 -0
  1005. package/blockly-rc/typings/msg/mg.d.ts +8 -0
  1006. package/blockly-rc/typings/msg/mk.d.ts +8 -0
  1007. package/blockly-rc/typings/msg/ml.d.ts +8 -0
  1008. package/blockly-rc/typings/msg/mnw.d.ts +8 -0
  1009. package/blockly-rc/typings/msg/ms.d.ts +8 -0
  1010. package/blockly-rc/typings/msg/msg.d.ts +440 -0
  1011. package/blockly-rc/typings/msg/my.d.ts +8 -0
  1012. package/blockly-rc/typings/msg/mzn.d.ts +8 -0
  1013. package/blockly-rc/typings/msg/nb.d.ts +8 -0
  1014. package/blockly-rc/typings/msg/ne.d.ts +8 -0
  1015. package/blockly-rc/typings/msg/nl.d.ts +8 -0
  1016. package/blockly-rc/typings/msg/oc.d.ts +8 -0
  1017. package/blockly-rc/typings/msg/olo.d.ts +8 -0
  1018. package/blockly-rc/typings/msg/pa.d.ts +8 -0
  1019. package/blockly-rc/typings/msg/pl.d.ts +8 -0
  1020. package/blockly-rc/typings/msg/pms.d.ts +8 -0
  1021. package/blockly-rc/typings/msg/ps.d.ts +8 -0
  1022. package/blockly-rc/typings/msg/pt-br.d.ts +8 -0
  1023. package/blockly-rc/typings/msg/pt.d.ts +8 -0
  1024. package/blockly-rc/typings/msg/ro.d.ts +8 -0
  1025. package/blockly-rc/typings/msg/ru.d.ts +8 -0
  1026. package/blockly-rc/typings/msg/sc.d.ts +8 -0
  1027. package/blockly-rc/typings/msg/sco.d.ts +8 -0
  1028. package/blockly-rc/typings/msg/sd.d.ts +8 -0
  1029. package/blockly-rc/typings/msg/shn.d.ts +8 -0
  1030. package/blockly-rc/typings/msg/si.d.ts +8 -0
  1031. package/blockly-rc/typings/msg/sk.d.ts +8 -0
  1032. package/blockly-rc/typings/msg/skr-arab.d.ts +8 -0
  1033. package/blockly-rc/typings/msg/sl.d.ts +8 -0
  1034. package/blockly-rc/typings/msg/smn.d.ts +8 -0
  1035. package/blockly-rc/typings/msg/sq.d.ts +8 -0
  1036. package/blockly-rc/typings/msg/sr-latn.d.ts +8 -0
  1037. package/blockly-rc/typings/msg/sr.d.ts +8 -0
  1038. package/blockly-rc/typings/msg/sv.d.ts +8 -0
  1039. package/blockly-rc/typings/msg/sw.d.ts +8 -0
  1040. package/blockly-rc/typings/msg/ta.d.ts +8 -0
  1041. package/blockly-rc/typings/msg/tcy.d.ts +8 -0
  1042. package/blockly-rc/typings/msg/tdd.d.ts +8 -0
  1043. package/blockly-rc/typings/msg/te.d.ts +8 -0
  1044. package/blockly-rc/typings/msg/th.d.ts +8 -0
  1045. package/blockly-rc/typings/msg/ti.d.ts +8 -0
  1046. package/blockly-rc/typings/msg/tl.d.ts +8 -0
  1047. package/blockly-rc/typings/msg/tlh.d.ts +8 -0
  1048. package/blockly-rc/typings/msg/tr.d.ts +8 -0
  1049. package/blockly-rc/typings/msg/ug-arab.d.ts +8 -0
  1050. package/blockly-rc/typings/msg/uk.d.ts +8 -0
  1051. package/blockly-rc/typings/msg/ur.d.ts +8 -0
  1052. package/blockly-rc/typings/msg/uz.d.ts +8 -0
  1053. package/blockly-rc/typings/msg/vi.d.ts +8 -0
  1054. package/blockly-rc/typings/msg/xmf.d.ts +8 -0
  1055. package/blockly-rc/typings/msg/yo.d.ts +8 -0
  1056. package/blockly-rc/typings/msg/zgh.d.ts +8 -0
  1057. package/blockly-rc/typings/msg/zh-hans.d.ts +8 -0
  1058. package/blockly-rc/typings/msg/zh-hant.d.ts +8 -0
  1059. package/blockly-rc/typings/php.d.ts +7 -0
  1060. package/blockly-rc/typings/python.d.ts +7 -0
  1061. package/blockly-rc/typings/templates/blockly-header.template +11 -0
  1062. package/blockly-rc/typings/templates/blockly-interfaces.template +83 -0
  1063. package/blockly-rc/typings/templates/msg.template +15 -0
  1064. package/blockly-rc/typings/tsconfig.json +23 -0
  1065. package/continuous-toolbox.d.ts +1 -0
  1066. package/dist/main.js +2 -0
  1067. package/dist/main.js.LICENSE.txt +163 -0
  1068. package/media/delete-icon.svg +10 -0
  1069. package/media/resize-handle.svg +3 -0
  1070. package/msg/scratch_msgs.js +184 -164
  1071. package/package.json +25 -40
  1072. package/release.config.js +8 -0
  1073. package/src/block_reporting.js +31 -0
  1074. package/src/blocks/colour.js +56 -0
  1075. package/src/blocks/control.js +492 -0
  1076. package/src/blocks/data.js +690 -0
  1077. package/src/blocks/event.js +305 -0
  1078. package/src/blocks/looks.js +537 -0
  1079. package/src/blocks/math.js +137 -0
  1080. package/src/blocks/matrix.js +47 -0
  1081. package/src/blocks/motion.js +513 -0
  1082. package/src/blocks/note.js +48 -0
  1083. package/src/blocks/operators.js +463 -0
  1084. package/src/blocks/procedures.js +1009 -0
  1085. package/src/blocks/sensing.js +441 -0
  1086. package/src/blocks/sound.js +205 -0
  1087. package/src/blocks/text.js +45 -0
  1088. package/src/blocks/vertical_extensions.js +309 -0
  1089. package/src/categories.js +15 -0
  1090. package/src/checkable_continuous_flyout.js +138 -0
  1091. package/src/checkbox_bubble.js +282 -0
  1092. package/src/colours.js +77 -0
  1093. package/src/constants.js +63 -0
  1094. package/src/context_menu_items.js +150 -0
  1095. package/src/css.js +1197 -0
  1096. package/src/data_category.js +556 -0
  1097. package/src/events/events_block_comment_base.js +35 -0
  1098. package/src/events/events_block_comment_change.js +43 -0
  1099. package/src/events/events_block_comment_collapse.js +43 -0
  1100. package/src/events/events_block_comment_create.js +52 -0
  1101. package/src/events/events_block_comment_delete.js +27 -0
  1102. package/src/events/events_block_comment_move.js +54 -0
  1103. package/src/events/events_block_comment_resize.js +52 -0
  1104. package/src/events/events_block_drag_end.js +33 -0
  1105. package/src/events/events_block_drag_outside.js +30 -0
  1106. package/src/events/events_scratch_variable_create.js +67 -0
  1107. package/src/fields/field_angle.js +433 -0
  1108. package/src/fields/field_colour_slider.js +388 -0
  1109. package/src/fields/field_dropdown.js +42 -0
  1110. package/src/fields/field_matrix.js +634 -0
  1111. package/src/fields/field_note.js +937 -0
  1112. package/src/fields/field_number.js +380 -0
  1113. package/src/fields/field_textinput_removable.js +107 -0
  1114. package/src/fields/field_variable.js +171 -0
  1115. package/src/fields/field_variable_getter.js +109 -0
  1116. package/src/fields/field_vertical_separator.js +139 -0
  1117. package/src/flyout_checkbox_icon.js +88 -0
  1118. package/src/glows.js +98 -0
  1119. package/src/index.ts +137 -0
  1120. package/src/procedures.js +425 -0
  1121. package/src/recyclable_block_flyout_inflater.js +194 -0
  1122. package/src/renderer/bowler_hat.js +17 -0
  1123. package/src/renderer/constants.js +45 -0
  1124. package/src/renderer/drawer.js +51 -0
  1125. package/src/renderer/path_object.js +35 -0
  1126. package/src/renderer/render_info.js +98 -0
  1127. package/src/renderer/renderer.js +74 -0
  1128. package/src/scratch_block_paster.js +46 -0
  1129. package/src/scratch_blocks_utils.js +148 -0
  1130. package/src/scratch_comment_bubble.js +169 -0
  1131. package/src/scratch_comment_icon.js +195 -0
  1132. package/src/scratch_connection_checker.js +29 -0
  1133. package/src/scratch_continuous_category.js +80 -0
  1134. package/src/scratch_continuous_toolbox.js +78 -0
  1135. package/src/scratch_dragger.js +142 -0
  1136. package/src/scratch_variable_map.js +25 -0
  1137. package/src/scratch_variable_model.js +24 -0
  1138. package/src/shadows.js +61 -0
  1139. package/src/status_indicator_label.js +186 -0
  1140. package/src/status_indicator_label_flyout_inflater.js +42 -0
  1141. package/src/variables.js +355 -0
  1142. package/temp-use-blockly-v12-rc.sh +26 -0
  1143. package/tsconfig.json +13 -0
  1144. package/blockly_compressed_horizontal.js +0 -2255
  1145. package/blockly_compressed_vertical.js +0 -2283
  1146. package/blockly_uncompressed_horizontal.js +0 -1210
  1147. package/blockly_uncompressed_vertical.js +0 -1210
  1148. package/blocks_common/colour.js +0 -61
  1149. package/blocks_common/math.js +0 -159
  1150. package/blocks_common/matrix.js +0 -54
  1151. package/blocks_common/note.js +0 -58
  1152. package/blocks_common/text.js +0 -57
  1153. package/blocks_compressed.js +0 -36
  1154. package/blocks_compressed_horizontal.js +0 -67
  1155. package/blocks_compressed_vertical.js +0 -208
  1156. package/blocks_horizontal/control.js +0 -212
  1157. package/blocks_horizontal/default_toolbox.js +0 -139
  1158. package/blocks_horizontal/event.js +0 -190
  1159. package/blocks_horizontal/wedo.js +0 -325
  1160. package/blocks_vertical/control.js +0 -532
  1161. package/blocks_vertical/data.js +0 -666
  1162. package/blocks_vertical/default_toolbox.js +0 -564
  1163. package/blocks_vertical/event.js +0 -329
  1164. package/blocks_vertical/extensions.js +0 -294
  1165. package/blocks_vertical/looks.js +0 -591
  1166. package/blocks_vertical/motion.js +0 -587
  1167. package/blocks_vertical/operators.js +0 -470
  1168. package/blocks_vertical/procedures.js +0 -973
  1169. package/blocks_vertical/sensing.js +0 -539
  1170. package/blocks_vertical/sound.js +0 -246
  1171. package/blocks_vertical/vertical_extensions.js +0 -266
  1172. package/build/gen_blocks.js +0 -1
  1173. package/build/test_expect.js +0 -1
  1174. package/build/test_input.js +0 -1
  1175. package/build.py +0 -636
  1176. package/cleanup.sh +0 -101
  1177. package/core/block.js +0 -1837
  1178. package/core/block_animations.js +0 -107
  1179. package/core/block_drag_surface.js +0 -299
  1180. package/core/block_dragger.js +0 -421
  1181. package/core/block_events.js +0 -531
  1182. package/core/block_render_svg_horizontal.js +0 -890
  1183. package/core/block_render_svg_vertical.js +0 -1732
  1184. package/core/block_svg.js +0 -1316
  1185. package/core/blockly.js +0 -622
  1186. package/core/blocks.js +0 -37
  1187. package/core/bubble.js +0 -664
  1188. package/core/bubble_dragger.js +0 -285
  1189. package/core/colours.js +0 -160
  1190. package/core/comment.js +0 -293
  1191. package/core/comment_events.js +0 -539
  1192. package/core/connection.js +0 -766
  1193. package/core/connection_db.js +0 -300
  1194. package/core/constants.js +0 -387
  1195. package/core/contextmenu.js +0 -519
  1196. package/core/css.js +0 -1351
  1197. package/core/data_category.js +0 -490
  1198. package/core/dragged_connection_manager.js +0 -260
  1199. package/core/dropdowndiv.js +0 -408
  1200. package/core/events.js +0 -429
  1201. package/core/events_abstract.js +0 -113
  1202. package/core/extensions.js +0 -450
  1203. package/core/field.js +0 -807
  1204. package/core/field_angle.js +0 -398
  1205. package/core/field_checkbox.js +0 -133
  1206. package/core/field_colour.js +0 -253
  1207. package/core/field_colour_slider.js +0 -387
  1208. package/core/field_date.js +0 -353
  1209. package/core/field_dropdown.js +0 -483
  1210. package/core/field_iconmenu.js +0 -309
  1211. package/core/field_image.js +0 -193
  1212. package/core/field_label.js +0 -136
  1213. package/core/field_label_serializable.js +0 -125
  1214. package/core/field_matrix.js +0 -566
  1215. package/core/field_note.js +0 -850
  1216. package/core/field_number.js +0 -366
  1217. package/core/field_numberdropdown.js +0 -77
  1218. package/core/field_textdropdown.js +0 -164
  1219. package/core/field_textinput.js +0 -675
  1220. package/core/field_textinput_removable.js +0 -105
  1221. package/core/field_variable.js +0 -385
  1222. package/core/field_variable_getter.js +0 -185
  1223. package/core/field_vertical_separator.js +0 -161
  1224. package/core/flyout_base.js +0 -923
  1225. package/core/flyout_button.js +0 -322
  1226. package/core/flyout_dragger.js +0 -83
  1227. package/core/flyout_extension_category_header.js +0 -159
  1228. package/core/flyout_horizontal.js +0 -475
  1229. package/core/flyout_vertical.js +0 -770
  1230. package/core/generator.js +0 -426
  1231. package/core/gesture.js +0 -1011
  1232. package/core/grid.js +0 -227
  1233. package/core/icon.js +0 -205
  1234. package/core/inject.js +0 -491
  1235. package/core/input.js +0 -285
  1236. package/core/insertion_marker_manager.js +0 -678
  1237. package/core/msg.js +0 -62
  1238. package/core/mutator.js +0 -426
  1239. package/core/names.js +0 -198
  1240. package/core/options.js +0 -244
  1241. package/core/procedures.js +0 -577
  1242. package/core/rendered_connection.js +0 -417
  1243. package/core/scratch_block_comment.js +0 -653
  1244. package/core/scratch_blocks_utils.js +0 -244
  1245. package/core/scratch_bubble.js +0 -696
  1246. package/core/scratch_events.js +0 -131
  1247. package/core/scratch_msgs.js +0 -85
  1248. package/core/scrollbar.js +0 -875
  1249. package/core/toolbox.js +0 -801
  1250. package/core/tooltip.js +0 -337
  1251. package/core/touch.js +0 -226
  1252. package/core/trashcan.js +0 -343
  1253. package/core/ui_events.js +0 -91
  1254. package/core/ui_menu_utils.js +0 -68
  1255. package/core/utils.js +0 -948
  1256. package/core/variable_events.js +0 -259
  1257. package/core/variable_map.js +0 -415
  1258. package/core/variable_model.js +0 -116
  1259. package/core/variables.js +0 -674
  1260. package/core/warning.js +0 -199
  1261. package/core/widgetdiv.js +0 -344
  1262. package/core/workspace.js +0 -673
  1263. package/core/workspace_audio.js +0 -170
  1264. package/core/workspace_comment.js +0 -432
  1265. package/core/workspace_comment_render_svg.js +0 -723
  1266. package/core/workspace_comment_svg.js +0 -611
  1267. package/core/workspace_drag_surface_svg.js +0 -195
  1268. package/core/workspace_dragger.js +0 -132
  1269. package/core/workspace_svg.js +0 -2267
  1270. package/core/xml.js +0 -919
  1271. package/core/zoom_controls.js +0 -301
  1272. package/dist/horizontal.js +0 -222
  1273. package/dist/vertical.js +0 -222
  1274. package/dist/web/horizontal.js +0 -232
  1275. package/dist/web/vertical.js +0 -232
  1276. package/local_build.sh +0 -70
  1277. package/pack/scratch-blocks-1.1.206.tgz +0 -0
  1278. package/pull_from_blockly.sh +0 -151
  1279. package/shim/blockly_compressed_horizontal-blocks_compressed.js +0 -1
  1280. package/shim/blockly_compressed_horizontal.Blockly.js +0 -1
  1281. package/shim/blockly_compressed_horizontal.goog.js +0 -1
  1282. package/shim/blockly_compressed_horizontal.js +0 -1
  1283. package/shim/blockly_compressed_vertical-blocks_compressed.js +0 -1
  1284. package/shim/blockly_compressed_vertical.Blockly.js +0 -1
  1285. package/shim/blockly_compressed_vertical.goog.js +0 -1
  1286. package/shim/blockly_compressed_vertical.js +0 -1
  1287. package/shim/blocks_compressed_horizontal-blockly_compressed_horizontal-messages.js +0 -1
  1288. package/shim/blocks_compressed_horizontal.js +0 -1
  1289. package/shim/blocks_compressed_vertical-blockly_compressed_vertical-messages.js +0 -1
  1290. package/shim/blocks_compressed_vertical.js +0 -1
  1291. package/shim/gh-pages.js +0 -1
  1292. package/shim/horizontal.js +0 -1
  1293. package/shim/index.js +0 -17
  1294. package/shim/vertical.js +0 -1
  1295. /package/media/{comment-arrow-down.svg → foldout-icon.svg} +0 -0
@@ -0,0 +1,1471 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2012 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ /**
8
+ * Field. Used for editable titles, variables, etc.
9
+ * This is an abstract class that defines the UI on the block. Actual
10
+ * instances would be FieldTextInput, FieldDropdown, etc.
11
+ *
12
+ * @class
13
+ */
14
+ // Former goog.module ID: Blockly.Field
15
+
16
+ // Unused import preserved for side-effects. Remove if unneeded.
17
+ import './events/events_block_change.js';
18
+
19
+ import type {Block} from './block.js';
20
+ import type {BlockSvg} from './block_svg.js';
21
+ import * as browserEvents from './browser_events.js';
22
+ import * as dropDownDiv from './dropdowndiv.js';
23
+ import * as eventUtils from './events/utils.js';
24
+ import type {Input} from './inputs/input.js';
25
+ import type {IASTNodeLocationSvg} from './interfaces/i_ast_node_location_svg.js';
26
+ import type {IASTNodeLocationWithBlock} from './interfaces/i_ast_node_location_with_block.js';
27
+ import type {IKeyboardAccessible} from './interfaces/i_keyboard_accessible.js';
28
+ import type {IRegistrable} from './interfaces/i_registrable.js';
29
+ import {MarkerManager} from './marker_manager.js';
30
+ import type {ConstantProvider} from './renderers/common/constants.js';
31
+ import type {KeyboardShortcut} from './shortcut_registry.js';
32
+ import * as Tooltip from './tooltip.js';
33
+ import type {Coordinate} from './utils/coordinate.js';
34
+ import * as dom from './utils/dom.js';
35
+ import * as parsing from './utils/parsing.js';
36
+ import {Rect} from './utils/rect.js';
37
+ import {Size} from './utils/size.js';
38
+ import * as style from './utils/style.js';
39
+ import {Svg} from './utils/svg.js';
40
+ import * as userAgent from './utils/useragent.js';
41
+ import * as utilsXml from './utils/xml.js';
42
+ import * as WidgetDiv from './widgetdiv.js';
43
+ import type {WorkspaceSvg} from './workspace_svg.js';
44
+ import {ISerializable} from './interfaces/i_serializable.js';
45
+
46
+ /**
47
+ * A function that is called to validate changes to the field's value before
48
+ * they are set.
49
+ *
50
+ * @see {@link https://developers.google.com/blockly/guides/create-custom-blocks/fields/validators#return_values}
51
+ * @param newValue The value to be validated.
52
+ * @returns One of three instructions for setting the new value: `T`, `null`,
53
+ * or `undefined`.
54
+ *
55
+ * - `T` to set this function's returned value instead of `newValue`.
56
+ *
57
+ * - `null` to invoke `doValueInvalid_` and not set a value.
58
+ *
59
+ * - `undefined` to set `newValue` as is.
60
+ */
61
+ export type FieldValidator<T = any> = (newValue: T) => T | null | undefined;
62
+
63
+ /**
64
+ * Abstract class for an editable field.
65
+ *
66
+ * @typeParam T - The value stored on the field.
67
+ */
68
+ export abstract class Field<T = any>
69
+ implements
70
+ IASTNodeLocationSvg,
71
+ IASTNodeLocationWithBlock,
72
+ IKeyboardAccessible,
73
+ IRegistrable,
74
+ ISerializable
75
+ {
76
+ /**
77
+ * To overwrite the default value which is set in **Field**, directly update
78
+ * the prototype.
79
+ *
80
+ * Example:
81
+ * `FieldImage.prototype.DEFAULT_VALUE = null;`
82
+ */
83
+ DEFAULT_VALUE: T | null = null;
84
+
85
+ /** Non-breaking space. */
86
+ static readonly NBSP = '\u00A0';
87
+
88
+ /**
89
+ * A value used to signal when a field's constructor should *not* set the
90
+ * field's value or run configure_, and should allow a subclass to do that
91
+ * instead.
92
+ */
93
+ static readonly SKIP_SETUP = Symbol('SKIP_SETUP');
94
+
95
+ /**
96
+ * Name of field. Unique within each block.
97
+ * Static labels are usually unnamed.
98
+ */
99
+ name?: string = undefined;
100
+ protected value_: T | null;
101
+
102
+ /** Validation function called when user edits an editable field. */
103
+ protected validator_: FieldValidator<T> | null = null;
104
+
105
+ /**
106
+ * Used to cache the field's tooltip value if setTooltip is called when the
107
+ * field is not yet initialized. Is *not* guaranteed to be accurate.
108
+ */
109
+ private tooltip_: Tooltip.TipInfo | null = null;
110
+ protected size_: Size;
111
+
112
+ /**
113
+ * Holds the cursors svg element when the cursor is attached to the field.
114
+ * This is null if there is no cursor on the field.
115
+ */
116
+ private cursorSvg_: SVGElement | null = null;
117
+
118
+ /**
119
+ * Holds the markers svg element when the marker is attached to the field.
120
+ * This is null if there is no marker on the field.
121
+ */
122
+ private markerSvg_: SVGElement | null = null;
123
+
124
+ /** The rendered field's SVG group element. */
125
+ protected fieldGroup_: SVGGElement | null = null;
126
+
127
+ /** The rendered field's SVG border element. */
128
+ protected borderRect_: SVGRectElement | null = null;
129
+
130
+ /** The rendered field's SVG text element. */
131
+ protected textElement_: SVGTextElement | null = null;
132
+
133
+ /** The rendered field's text content element. */
134
+ protected textContent_: Text | null = null;
135
+
136
+ /** Mouse down event listener data. */
137
+ private mouseDownWrapper_: browserEvents.Data | null = null;
138
+
139
+ /** Constants associated with the source block's renderer. */
140
+ protected constants_: ConstantProvider | null = null;
141
+
142
+ /**
143
+ * Has this field been disposed of?
144
+ *
145
+ * @internal
146
+ */
147
+ disposed = false;
148
+
149
+ /** Maximum characters of text to display before adding an ellipsis. */
150
+ maxDisplayLength = 50;
151
+
152
+ /** Block this field is attached to. Starts as null, then set in init. */
153
+ protected sourceBlock_: Block | null = null;
154
+
155
+ /** Does this block need to be re-rendered? */
156
+ protected isDirty_ = true;
157
+
158
+ /** Is the field visible, or hidden due to the block being collapsed? */
159
+ protected visible_ = true;
160
+
161
+ /**
162
+ * Can the field value be changed using the editor on an editable block?
163
+ */
164
+ protected enabled_ = true;
165
+
166
+ /** The element the click handler is bound to. */
167
+ protected clickTarget_: Element | null = null;
168
+
169
+ /**
170
+ * The prefix field.
171
+ *
172
+ * @internal
173
+ */
174
+ prefixField: string | null = null;
175
+
176
+ /**
177
+ * The suffix field.
178
+ *
179
+ * @internal
180
+ */
181
+ suffixField: string | null = null;
182
+
183
+ /**
184
+ * Editable fields usually show some sort of UI indicating they are
185
+ * editable. They will also be saved by the serializer.
186
+ */
187
+ EDITABLE = true;
188
+
189
+ /**
190
+ * Serializable fields are saved by the serializer, non-serializable fields
191
+ * are not. Editable fields should also be serializable. This is not the
192
+ * case by default so that SERIALIZABLE is backwards compatible.
193
+ */
194
+ SERIALIZABLE = false;
195
+
196
+ /** Mouse cursor style when over the hotspot that initiates the editor. */
197
+ CURSOR = '';
198
+
199
+ /**
200
+ * @param value The initial value of the field.
201
+ * Also accepts Field.SKIP_SETUP if you wish to skip setup (only used by
202
+ * subclasses that want to handle configuration and setting the field value
203
+ * after their own constructors have run).
204
+ * @param validator A function that is called to validate changes to the
205
+ * field's value. Takes in a value & returns a validated value, or null to
206
+ * abort the change.
207
+ * @param config A map of options used to configure the field.
208
+ * Refer to the individual field's documentation for a list of properties
209
+ * this parameter supports.
210
+ */
211
+ constructor(
212
+ value: T | typeof Field.SKIP_SETUP,
213
+ validator?: FieldValidator<T> | null,
214
+ config?: FieldConfig,
215
+ ) {
216
+ /**
217
+ * A generic value possessed by the field.
218
+ * Should generally be non-null, only null when the field is created.
219
+ */
220
+ this.value_ =
221
+ 'DEFAULT_VALUE' in new.target.prototype
222
+ ? new.target.prototype.DEFAULT_VALUE
223
+ : this.DEFAULT_VALUE;
224
+
225
+ /** The size of the area rendered by the field. */
226
+ this.size_ = new Size(0, 0);
227
+
228
+ if (value === Field.SKIP_SETUP) return;
229
+ if (config) {
230
+ this.configure_(config);
231
+ }
232
+ this.setValue(value);
233
+ if (validator) {
234
+ this.setValidator(validator);
235
+ }
236
+ }
237
+
238
+ /**
239
+ * Process the configuration map passed to the field.
240
+ *
241
+ * @param config A map of options used to configure the field. See the
242
+ * individual field's documentation for a list of properties this
243
+ * parameter supports.
244
+ */
245
+ protected configure_(config: FieldConfig) {
246
+ // TODO (#2884): Possibly add CSS class config option.
247
+ // TODO (#2885): Possibly add cursor config option.
248
+ if (config.tooltip) {
249
+ this.setTooltip(parsing.replaceMessageReferences(config.tooltip));
250
+ }
251
+ }
252
+
253
+ /**
254
+ * Attach this field to a block.
255
+ *
256
+ * @param block The block containing this field.
257
+ */
258
+ setSourceBlock(block: Block) {
259
+ if (this.sourceBlock_) {
260
+ throw Error('Field already bound to a block');
261
+ }
262
+ this.sourceBlock_ = block;
263
+ }
264
+
265
+ /**
266
+ * Get the renderer constant provider.
267
+ *
268
+ * @returns The renderer constant provider.
269
+ */
270
+ getConstants(): ConstantProvider | null {
271
+ if (
272
+ !this.constants_ &&
273
+ this.sourceBlock_ &&
274
+ !this.sourceBlock_.isDeadOrDying() &&
275
+ this.sourceBlock_.workspace.rendered
276
+ ) {
277
+ this.constants_ = (this.sourceBlock_.workspace as WorkspaceSvg)
278
+ .getRenderer()
279
+ .getConstants();
280
+ }
281
+ return this.constants_;
282
+ }
283
+
284
+ /**
285
+ * Get the block this field is attached to.
286
+ *
287
+ * @returns The block containing this field.
288
+ * @throws An error if the source block is not defined.
289
+ */
290
+ getSourceBlock(): Block | null {
291
+ return this.sourceBlock_;
292
+ }
293
+
294
+ /**
295
+ * Initialize everything to render this field. Override
296
+ * methods initModel and initView rather than this method.
297
+ *
298
+ * @sealed
299
+ * @internal
300
+ */
301
+ init() {
302
+ if (this.fieldGroup_) {
303
+ // Field has already been initialized once.
304
+ return;
305
+ }
306
+ this.fieldGroup_ = dom.createSvgElement(Svg.G, {});
307
+ if (!this.isVisible()) {
308
+ this.fieldGroup_.style.display = 'none';
309
+ }
310
+ const sourceBlockSvg = this.sourceBlock_ as BlockSvg;
311
+ sourceBlockSvg.getSvgRoot().appendChild(this.fieldGroup_);
312
+ this.initView();
313
+ this.updateEditable();
314
+ this.setTooltip(this.tooltip_);
315
+ this.bindEvents_();
316
+ this.initModel();
317
+ this.applyColour();
318
+ }
319
+
320
+ /**
321
+ * Create the block UI for this field.
322
+ */
323
+ protected initView() {
324
+ this.createBorderRect_();
325
+ this.createTextElement_();
326
+ if (this.fieldGroup_) {
327
+ dom.addClass(this.fieldGroup_, 'blocklyField');
328
+ }
329
+ }
330
+
331
+ /**
332
+ * Initializes the model of the field after it has been installed on a block.
333
+ * No-op by default.
334
+ */
335
+ initModel() {}
336
+
337
+ /**
338
+ * Defines whether this field should take up the full block or not.
339
+ *
340
+ * Be cautious when overriding this function. It may not work as you expect /
341
+ * intend because the behavior was kind of hacked in. If you are thinking
342
+ * about overriding this function, post on the forum with your intended
343
+ * behavior to see if there's another approach.
344
+ */
345
+ protected isFullBlockField(): boolean {
346
+ return !this.borderRect_;
347
+ }
348
+
349
+ /**
350
+ * Create a field border rect element. Not to be overridden by subclasses.
351
+ * Instead modify the result of the function inside initView, or create a
352
+ * separate function to call.
353
+ */
354
+ protected createBorderRect_() {
355
+ this.borderRect_ = dom.createSvgElement(
356
+ Svg.RECT,
357
+ {
358
+ 'rx': this.getConstants()!.FIELD_BORDER_RECT_RADIUS,
359
+ 'ry': this.getConstants()!.FIELD_BORDER_RECT_RADIUS,
360
+ 'x': 0,
361
+ 'y': 0,
362
+ 'height': this.size_.height,
363
+ 'width': this.size_.width,
364
+ 'class': 'blocklyFieldRect',
365
+ },
366
+ this.fieldGroup_,
367
+ );
368
+ }
369
+
370
+ /**
371
+ * Create a field text element. Not to be overridden by subclasses. Instead
372
+ * modify the result of the function inside initView, or create a separate
373
+ * function to call.
374
+ */
375
+ protected createTextElement_() {
376
+ this.textElement_ = dom.createSvgElement(
377
+ Svg.TEXT,
378
+ {
379
+ 'class': 'blocklyText blocklyFieldText',
380
+ },
381
+ this.fieldGroup_,
382
+ );
383
+ if (this.getConstants()!.FIELD_TEXT_BASELINE_CENTER) {
384
+ this.textElement_.setAttribute('dominant-baseline', 'central');
385
+ }
386
+ this.textContent_ = document.createTextNode('');
387
+ this.textElement_.appendChild(this.textContent_);
388
+ }
389
+
390
+ /**
391
+ * Bind events to the field. Can be overridden by subclasses if they need to
392
+ * do custom input handling.
393
+ */
394
+ protected bindEvents_() {
395
+ const clickTarget = this.getClickTarget_();
396
+ if (!clickTarget) throw new Error('A click target has not been set.');
397
+ Tooltip.bindMouseEvents(clickTarget);
398
+ this.mouseDownWrapper_ = browserEvents.conditionalBind(
399
+ clickTarget,
400
+ 'pointerdown',
401
+ this,
402
+ this.onMouseDown_,
403
+ );
404
+ }
405
+
406
+ /**
407
+ * Sets the field's value based on the given XML element. Should only be
408
+ * called by Blockly.Xml.
409
+ *
410
+ * @param fieldElement The element containing info about the field's state.
411
+ */
412
+ fromXml(fieldElement: Element) {
413
+ // Any because gremlins live here. No touchie!
414
+ this.setValue(fieldElement.textContent as any);
415
+ }
416
+
417
+ /**
418
+ * Serializes this field's value to XML. Should only be called by Blockly.Xml.
419
+ *
420
+ * @param fieldElement The element to populate with info about the field's
421
+ * state.
422
+ * @returns The element containing info about the field's state.
423
+ */
424
+ toXml(fieldElement: Element): Element {
425
+ // Any because gremlins live here. No touchie!
426
+ fieldElement.textContent = this.getValue() as any;
427
+ return fieldElement;
428
+ }
429
+
430
+ /**
431
+ * Saves this fields value as something which can be serialized to JSON.
432
+ * Should only be called by the serialization system.
433
+ *
434
+ * @param _doFullSerialization If true, this signals to the field that if it
435
+ * normally just saves a reference to some state (eg variable fields) it
436
+ * should instead serialize the full state of the thing being referenced.
437
+ * See the
438
+ * {@link https://developers.devsite.google.com/blockly/guides/create-custom-blocks/fields/customizing-fields/creating#full_serialization_and_backing_data | field serialization docs}
439
+ * for more information.
440
+ * @returns JSON serializable state.
441
+ */
442
+ saveState(_doFullSerialization?: boolean): AnyDuringMigration {
443
+ const legacyState = this.saveLegacyState(Field);
444
+ if (legacyState !== null) {
445
+ return legacyState;
446
+ }
447
+ return this.getValue();
448
+ }
449
+
450
+ /**
451
+ * Sets the field's state based on the given state value. Should only be
452
+ * called by the serialization system.
453
+ *
454
+ * @param state The state we want to apply to the field.
455
+ */
456
+ loadState(state: AnyDuringMigration) {
457
+ if (this.loadLegacyState(Field, state)) {
458
+ return;
459
+ }
460
+ this.setValue(state);
461
+ }
462
+
463
+ /**
464
+ * Returns a stringified version of the XML state, if it should be used.
465
+ * Otherwise this returns null, to signal the field should use its own
466
+ * serialization.
467
+ *
468
+ * @param callingClass The class calling this method.
469
+ * Used to see if `this` has overridden any relevant hooks.
470
+ * @returns The stringified version of the XML state, or null.
471
+ */
472
+ protected saveLegacyState(callingClass: FieldProto): string | null {
473
+ if (
474
+ callingClass.prototype.saveState === this.saveState &&
475
+ callingClass.prototype.toXml !== this.toXml
476
+ ) {
477
+ const elem = utilsXml.createElement('field');
478
+ elem.setAttribute('name', this.name || '');
479
+ const text = utilsXml.domToText(this.toXml(elem));
480
+ return text.replace(
481
+ ' xmlns="https://developers.google.com/blockly/xml"',
482
+ '',
483
+ );
484
+ }
485
+ // Either they called this on purpose from their saveState, or they have
486
+ // no implementations of either hook. Just do our thing.
487
+ return null;
488
+ }
489
+
490
+ /**
491
+ * Loads the given state using either the old XML hooks, if they should be
492
+ * used. Returns true to indicate loading has been handled, false otherwise.
493
+ *
494
+ * @param callingClass The class calling this method.
495
+ * Used to see if `this` has overridden any relevant hooks.
496
+ * @param state The state to apply to the field.
497
+ * @returns Whether the state was applied or not.
498
+ */
499
+ loadLegacyState(
500
+ callingClass: FieldProto,
501
+ state: AnyDuringMigration,
502
+ ): boolean {
503
+ if (
504
+ callingClass.prototype.loadState === this.loadState &&
505
+ callingClass.prototype.fromXml !== this.fromXml
506
+ ) {
507
+ this.fromXml(utilsXml.textToDom(state as string));
508
+ return true;
509
+ }
510
+ // Either they called this on purpose from their loadState, or they have
511
+ // no implementations of either hook. Just do our thing.
512
+ return false;
513
+ }
514
+
515
+ /**
516
+ * Dispose of all DOM objects and events belonging to this editable field.
517
+ */
518
+ dispose() {
519
+ dropDownDiv.hideIfOwner(this);
520
+ WidgetDiv.hideIfOwner(this);
521
+
522
+ if (!this.getSourceBlock()?.isDeadOrDying()) {
523
+ dom.removeNode(this.fieldGroup_);
524
+ }
525
+
526
+ this.disposed = true;
527
+ }
528
+
529
+ /** Add or remove the UI indicating if this field is editable or not. */
530
+ updateEditable() {
531
+ const group = this.fieldGroup_;
532
+ const block = this.getSourceBlock();
533
+ if (!this.EDITABLE || !group || !block) {
534
+ return;
535
+ }
536
+ if (this.enabled_ && block.isEditable()) {
537
+ dom.addClass(group, 'blocklyEditableField');
538
+ dom.removeClass(group, 'blocklyNonEditableField');
539
+ group.style.cursor = this.CURSOR;
540
+ } else {
541
+ dom.addClass(group, 'blocklyNonEditableField');
542
+ dom.removeClass(group, 'blocklyEditableField');
543
+ group.style.cursor = '';
544
+ }
545
+ }
546
+
547
+ /**
548
+ * Set whether this field's value can be changed using the editor when the
549
+ * source block is editable.
550
+ *
551
+ * @param enabled True if enabled.
552
+ */
553
+ setEnabled(enabled: boolean) {
554
+ this.enabled_ = enabled;
555
+ this.updateEditable();
556
+ }
557
+
558
+ /**
559
+ * Check whether this field's value can be changed using the editor when the
560
+ * source block is editable.
561
+ *
562
+ * @returns Whether this field is enabled.
563
+ */
564
+ isEnabled(): boolean {
565
+ return this.enabled_;
566
+ }
567
+
568
+ /**
569
+ * Check whether this field defines the showEditor_ function.
570
+ *
571
+ * @returns Whether this field is clickable.
572
+ */
573
+ isClickable(): boolean {
574
+ return (
575
+ this.enabled_ &&
576
+ !!this.sourceBlock_ &&
577
+ this.sourceBlock_.isEditable() &&
578
+ this.showEditor_ !== Field.prototype.showEditor_
579
+ );
580
+ }
581
+
582
+ /**
583
+ * Check whether the field should be clickable while the block is in a flyout.
584
+ * The default is that fields are clickable in always-open flyouts such as the
585
+ * simple toolbox, but not in autoclosing flyouts such as the category toolbox.
586
+ * Subclasses may override this function to change this behavior. Note that
587
+ * `isClickable` must also return true for this to have any effect.
588
+ *
589
+ * @param autoClosingFlyout true if the containing flyout is an auto-closing one.
590
+ * @returns Whether the field should be clickable while the block is in a flyout.
591
+ */
592
+ isClickableInFlyout(autoClosingFlyout: boolean): boolean {
593
+ return !autoClosingFlyout;
594
+ }
595
+
596
+ /**
597
+ * Check whether this field is currently editable. Some fields are never
598
+ * EDITABLE (e.g. text labels). Other fields may be EDITABLE but may exist on
599
+ * non-editable blocks or be currently disabled.
600
+ *
601
+ * @returns Whether this field is currently enabled, editable and on an
602
+ * editable block.
603
+ */
604
+ isCurrentlyEditable(): boolean {
605
+ return (
606
+ this.enabled_ &&
607
+ this.EDITABLE &&
608
+ !!this.sourceBlock_ &&
609
+ this.sourceBlock_.isEditable()
610
+ );
611
+ }
612
+
613
+ /**
614
+ * Check whether this field should be serialized by the XML renderer.
615
+ * Handles the logic for backwards compatibility and incongruous states.
616
+ *
617
+ * @returns Whether this field should be serialized or not.
618
+ */
619
+ isSerializable(): boolean {
620
+ let isSerializable = false;
621
+ if (this.name) {
622
+ if (this.SERIALIZABLE) {
623
+ isSerializable = true;
624
+ } else if (this.EDITABLE) {
625
+ console.warn(
626
+ 'Detected an editable field that was not serializable.' +
627
+ ' Please define SERIALIZABLE property as true on all editable custom' +
628
+ ' fields. Proceeding with serialization.',
629
+ );
630
+ isSerializable = true;
631
+ }
632
+ }
633
+ return isSerializable;
634
+ }
635
+
636
+ /**
637
+ * Gets whether this editable field is visible or not.
638
+ *
639
+ * @returns True if visible.
640
+ */
641
+ isVisible(): boolean {
642
+ return this.visible_;
643
+ }
644
+
645
+ /**
646
+ * Sets whether this editable field is visible or not. Should only be called
647
+ * by input.setVisible.
648
+ *
649
+ * @param visible True if visible.
650
+ * @internal
651
+ */
652
+ setVisible(visible: boolean) {
653
+ if (this.visible_ === visible) {
654
+ return;
655
+ }
656
+ this.visible_ = visible;
657
+ const root = this.fieldGroup_;
658
+ if (root) {
659
+ root.style.display = visible ? 'block' : 'none';
660
+ }
661
+ }
662
+
663
+ /**
664
+ * Sets a new validation function for editable fields, or clears a previously
665
+ * set validator.
666
+ *
667
+ * The validator function takes in the new field value, and returns
668
+ * validated value. The validated value could be the input value, a modified
669
+ * version of the input value, or null to abort the change.
670
+ *
671
+ * If the function does not return anything (or returns undefined) the new
672
+ * value is accepted as valid. This is to allow for fields using the
673
+ * validated function as a field-level change event notification.
674
+ *
675
+ * @param handler The validator function or null to clear a previous
676
+ * validator.
677
+ */
678
+ setValidator(handler: FieldValidator<T>) {
679
+ this.validator_ = handler;
680
+ }
681
+
682
+ /**
683
+ * Gets the validation function for editable fields, or null if not set.
684
+ *
685
+ * @returns Validation function, or null.
686
+ */
687
+ getValidator(): FieldValidator<T> | null {
688
+ return this.validator_;
689
+ }
690
+
691
+ /**
692
+ * Gets the group element for this editable field.
693
+ * Used for measuring the size and for positioning.
694
+ *
695
+ * @returns The group element.
696
+ */
697
+ getSvgRoot(): SVGGElement | null {
698
+ return this.fieldGroup_;
699
+ }
700
+
701
+ /**
702
+ * Gets the border rectangle element.
703
+ *
704
+ * @returns The border rectangle element.
705
+ * @throws An error if the border rectangle element is not defined.
706
+ */
707
+ protected getBorderRect(): SVGRectElement {
708
+ if (!this.borderRect_) {
709
+ throw new Error(`The border rectangle is ${this.borderRect_}.`);
710
+ }
711
+ return this.borderRect_;
712
+ }
713
+
714
+ /**
715
+ * Gets the text element.
716
+ *
717
+ * @returns The text element.
718
+ * @throws An error if the text element is not defined.
719
+ */
720
+ protected getTextElement(): SVGTextElement {
721
+ if (!this.textElement_) {
722
+ throw new Error(`The text element is ${this.textElement_}.`);
723
+ }
724
+ return this.textElement_;
725
+ }
726
+
727
+ /**
728
+ * Gets the text content.
729
+ *
730
+ * @returns The text content.
731
+ * @throws An error if the text content is not defined.
732
+ */
733
+ protected getTextContent(): Text {
734
+ if (!this.textContent_) {
735
+ throw new Error(`The text content is ${this.textContent_}.`);
736
+ }
737
+ return this.textContent_;
738
+ }
739
+
740
+ /**
741
+ * Updates the field to match the colour/style of the block.
742
+ *
743
+ * Non-abstract sub-classes may wish to implement this if the colour of the
744
+ * field depends on the colour of the block. It will automatically be called
745
+ * at relevant times, such as when the parent block or renderer changes.
746
+ *
747
+ * See {@link
748
+ * https://developers.google.com/blockly/guides/create-custom-blocks/fields/customizing-fields/creating#matching_block_colours
749
+ * | the field documentation} for more information, or FieldDropdown for an
750
+ * example.
751
+ */
752
+ applyColour() {}
753
+
754
+ /**
755
+ * Used by getSize() to move/resize any DOM elements, and get the new size.
756
+ *
757
+ * All rendering that has an effect on the size/shape of the block should be
758
+ * done here, and should be triggered by getSize().
759
+ */
760
+ protected render_() {
761
+ if (this.textContent_) {
762
+ this.textContent_.nodeValue = this.getDisplayText_();
763
+ }
764
+ this.updateSize_();
765
+ }
766
+
767
+ /**
768
+ * Calls showEditor_ when the field is clicked if the field is clickable.
769
+ * Do not override.
770
+ *
771
+ * @param e Optional mouse event that triggered the field to open, or
772
+ * undefined if triggered programmatically.
773
+ * @sealed
774
+ * @internal
775
+ */
776
+ showEditor(e?: Event) {
777
+ if (this.isClickable()) {
778
+ this.showEditor_(e);
779
+ }
780
+ }
781
+
782
+ /**
783
+ * A developer hook to create an editor for the field. This is no-op by
784
+ * default, and must be overriden to create an editor.
785
+ *
786
+ * @param _e Optional mouse event that triggered the field to open, or
787
+ * undefined if triggered programmatically.
788
+ */
789
+ protected showEditor_(_e?: Event): void {}
790
+ // NOP
791
+
792
+ /**
793
+ * A developer hook to reposition the WidgetDiv during a window resize. You
794
+ * need to define this hook if your field has a WidgetDiv that needs to
795
+ * reposition itself when the window is resized. For example, text input
796
+ * fields define this hook so that the input WidgetDiv can reposition itself
797
+ * on a window resize event. This is especially important when modal inputs
798
+ * have been disabled, as Android devices will fire a window resize event when
799
+ * the soft keyboard opens.
800
+ *
801
+ * If you want the WidgetDiv to hide itself instead of repositioning, return
802
+ * false. This is the default behavior.
803
+ *
804
+ * DropdownDivs already handle their own positioning logic, so you do not need
805
+ * to override this function if your field only has a DropdownDiv.
806
+ *
807
+ * @returns True if the field should be repositioned,
808
+ * false if the WidgetDiv should hide itself instead.
809
+ */
810
+ repositionForWindowResize(): boolean {
811
+ return false;
812
+ }
813
+
814
+ /**
815
+ * Updates the size of the field based on the text.
816
+ *
817
+ * @param margin margin to use when positioning the text element.
818
+ */
819
+ protected updateSize_(margin?: number) {
820
+ const constants = this.getConstants();
821
+ const xOffset =
822
+ margin !== undefined
823
+ ? margin
824
+ : !this.isFullBlockField()
825
+ ? this.getConstants()!.FIELD_BORDER_RECT_X_PADDING
826
+ : 0;
827
+ let totalWidth = xOffset * 2;
828
+ let totalHeight = constants!.FIELD_TEXT_HEIGHT;
829
+
830
+ let contentWidth = 0;
831
+ if (this.textElement_) {
832
+ contentWidth = dom.getTextWidth(this.textElement_);
833
+ totalWidth += contentWidth;
834
+ }
835
+ if (!this.isFullBlockField()) {
836
+ totalHeight = Math.max(totalHeight, constants!.FIELD_BORDER_RECT_HEIGHT);
837
+ }
838
+
839
+ this.size_.height = totalHeight;
840
+ this.size_.width = totalWidth;
841
+
842
+ this.positionTextElement_(xOffset, contentWidth);
843
+ this.positionBorderRect_();
844
+ }
845
+
846
+ /**
847
+ * Position a field's text element after a size change. This handles both LTR
848
+ * and RTL positioning.
849
+ *
850
+ * @param xOffset x offset to use when positioning the text element.
851
+ * @param contentWidth The content width.
852
+ */
853
+ protected positionTextElement_(xOffset: number, contentWidth: number) {
854
+ if (!this.textElement_) {
855
+ return;
856
+ }
857
+ const constants = this.getConstants();
858
+ const halfHeight = this.size_.height / 2;
859
+
860
+ this.textElement_.setAttribute(
861
+ 'x',
862
+ String(
863
+ this.getSourceBlock()?.RTL
864
+ ? this.size_.width - contentWidth - xOffset
865
+ : xOffset,
866
+ ),
867
+ );
868
+ this.textElement_.setAttribute(
869
+ 'y',
870
+ String(
871
+ constants!.FIELD_TEXT_BASELINE_CENTER
872
+ ? halfHeight
873
+ : halfHeight -
874
+ constants!.FIELD_TEXT_HEIGHT / 2 +
875
+ constants!.FIELD_TEXT_BASELINE,
876
+ ),
877
+ );
878
+ }
879
+
880
+ /** Position a field's border rect after a size change. */
881
+ protected positionBorderRect_() {
882
+ if (!this.borderRect_) {
883
+ return;
884
+ }
885
+ this.borderRect_.setAttribute('width', String(this.size_.width));
886
+ this.borderRect_.setAttribute('height', String(this.size_.height));
887
+ this.borderRect_.setAttribute(
888
+ 'rx',
889
+ String(this.getConstants()!.FIELD_BORDER_RECT_RADIUS),
890
+ );
891
+ this.borderRect_.setAttribute(
892
+ 'ry',
893
+ String(this.getConstants()!.FIELD_BORDER_RECT_RADIUS),
894
+ );
895
+ }
896
+
897
+ /**
898
+ * Returns the height and width of the field.
899
+ *
900
+ * This should *in general* be the only place render_ gets called from.
901
+ *
902
+ * @returns Height and width.
903
+ */
904
+ getSize(): Size {
905
+ if (!this.isVisible()) {
906
+ return new Size(0, 0);
907
+ }
908
+
909
+ if (this.isDirty_) {
910
+ this.render_();
911
+ this.isDirty_ = false;
912
+ } else if (this.visible_ && this.size_.width === 0) {
913
+ // If the field is not visible the width will be 0 as well, one of the
914
+ // problems with the old system.
915
+ this.render_();
916
+ // Don't issue a warning if the field is actually zero width.
917
+ if (this.size_.width !== 0) {
918
+ console.warn(
919
+ 'Deprecated use of setting size_.width to 0 to rerender a' +
920
+ ' field. Set field.isDirty_ to true instead.',
921
+ );
922
+ }
923
+ }
924
+ return this.size_;
925
+ }
926
+
927
+ /**
928
+ * Returns the bounding box of the rendered field, accounting for workspace
929
+ * scaling.
930
+ *
931
+ * @returns An object with top, bottom, left, and right in pixels relative to
932
+ * the top left corner of the page (window coordinates).
933
+ * @internal
934
+ */
935
+ getScaledBBox(): Rect {
936
+ let scaledWidth;
937
+ let scaledHeight;
938
+ let xy;
939
+ const block = this.getSourceBlock();
940
+ if (!block) {
941
+ throw new UnattachedFieldError();
942
+ }
943
+
944
+ if (this.isFullBlockField()) {
945
+ // Browsers are inconsistent in what they return for a bounding box.
946
+ // - Webkit / Blink: fill-box / object bounding box
947
+ // - Gecko: stroke-box
948
+ const bBox = (this.sourceBlock_ as BlockSvg).getHeightWidth();
949
+ const scale = (block.workspace as WorkspaceSvg).scale;
950
+ xy = this.getAbsoluteXY_();
951
+ scaledWidth = (bBox.width + 1) * scale;
952
+ scaledHeight = (bBox.height + 1) * scale;
953
+
954
+ if (userAgent.GECKO) {
955
+ xy.x += 1.5 * scale;
956
+ xy.y += 1.5 * scale;
957
+ } else {
958
+ xy.x -= 0.5 * scale;
959
+ xy.y -= 0.5 * scale;
960
+ }
961
+ } else {
962
+ const bBox = this.borderRect_!.getBoundingClientRect();
963
+ xy = style.getPageOffset(this.borderRect_!);
964
+ scaledWidth = bBox.width;
965
+ scaledHeight = bBox.height;
966
+ }
967
+ return new Rect(xy.y, xy.y + scaledHeight, xy.x, xy.x + scaledWidth);
968
+ }
969
+
970
+ /**
971
+ * Notifies the field that it has changed locations.
972
+ *
973
+ * @param _ The location of this field's block's top-start corner
974
+ * in workspace coordinates.
975
+ */
976
+ onLocationChange(_: Coordinate) {}
977
+
978
+ /**
979
+ * Get the text from this field to display on the block. May differ from
980
+ * `getText` due to ellipsis, and other formatting.
981
+ *
982
+ * @returns Text to display.
983
+ */
984
+ protected getDisplayText_(): string {
985
+ let text = this.getText();
986
+ if (!text) {
987
+ // Prevent the field from disappearing if empty.
988
+ return Field.NBSP;
989
+ }
990
+ if (text.length > this.maxDisplayLength) {
991
+ // Truncate displayed string and add an ellipsis ('...').
992
+ text = text.substring(0, this.maxDisplayLength - 2) + '…';
993
+ }
994
+ // Replace whitespace with non-breaking spaces so the text doesn't collapse.
995
+ text = text.replace(/\s/g, Field.NBSP);
996
+ if (this.sourceBlock_ && this.sourceBlock_.RTL) {
997
+ // The SVG is LTR, force text to be RTL by adding an RLM.
998
+ text += '\u200F';
999
+ }
1000
+ return text;
1001
+ }
1002
+
1003
+ /**
1004
+ * Get the text from this field.
1005
+ * Override getText_ to provide a different behavior than simply casting the
1006
+ * value to a string.
1007
+ *
1008
+ * @returns Current text.
1009
+ * @sealed
1010
+ */
1011
+ getText(): string {
1012
+ // this.getText_ was intended so that devs don't have to remember to call
1013
+ // super when overriding how the text of the field is generated. (#2910)
1014
+ const text = this.getText_();
1015
+ if (text !== null) {
1016
+ return String(text);
1017
+ }
1018
+ return String(this.getValue());
1019
+ }
1020
+
1021
+ /**
1022
+ * A developer hook to override the returned text of this field.
1023
+ * Override if the text representation of the value of this field
1024
+ * is not just a string cast of its value.
1025
+ * Return null to resort to a string cast.
1026
+ *
1027
+ * @returns Current text or null.
1028
+ */
1029
+ protected getText_(): string | null {
1030
+ return null;
1031
+ }
1032
+
1033
+ /**
1034
+ * Force a rerender of the block that this field is installed on, which will
1035
+ * rerender this field and adjust for any sizing changes.
1036
+ * Other fields on the same block will not rerender, because their sizes have
1037
+ * already been recorded.
1038
+ *
1039
+ * @internal
1040
+ */
1041
+ markDirty() {
1042
+ this.isDirty_ = true;
1043
+ this.constants_ = null;
1044
+ }
1045
+
1046
+ /**
1047
+ * Force a rerender of the block that this field is installed on, which will
1048
+ * rerender this field and adjust for any sizing changes.
1049
+ * Other fields on the same block will not rerender, because their sizes have
1050
+ * already been recorded.
1051
+ */
1052
+ forceRerender() {
1053
+ this.isDirty_ = true;
1054
+ if (this.sourceBlock_ && this.sourceBlock_.rendered) {
1055
+ (this.sourceBlock_ as BlockSvg).queueRender();
1056
+ }
1057
+ }
1058
+
1059
+ /**
1060
+ * Used to change the value of the field. Handles validation and events.
1061
+ * Subclasses should override doClassValidation_ and doValueUpdate_ rather
1062
+ * than this method.
1063
+ *
1064
+ * @param newValue New value.
1065
+ * @param fireChangeEvent Whether to fire a change event. Defaults to true.
1066
+ * Should usually be true unless the change will be reported some other
1067
+ * way, e.g. an intermediate field change event.
1068
+ * @sealed
1069
+ */
1070
+ setValue(newValue: AnyDuringMigration, fireChangeEvent = true) {
1071
+ const doLogging = false;
1072
+ if (newValue === null) {
1073
+ doLogging && console.log('null, return');
1074
+ // Not a valid value to check.
1075
+ return;
1076
+ }
1077
+
1078
+ const classValidation = this.doClassValidation_(newValue);
1079
+ const classValue = this.processValidation_(
1080
+ newValue,
1081
+ classValidation,
1082
+ fireChangeEvent,
1083
+ );
1084
+ if (classValue instanceof Error) {
1085
+ doLogging && console.log('invalid class validation, return');
1086
+ return;
1087
+ }
1088
+
1089
+ const localValidation = this.getValidator()?.call(this, classValue);
1090
+ const localValue = this.processValidation_(
1091
+ classValue,
1092
+ localValidation,
1093
+ fireChangeEvent,
1094
+ );
1095
+ if (localValue instanceof Error) {
1096
+ doLogging && console.log('invalid local validation, return');
1097
+ return;
1098
+ }
1099
+
1100
+ const source = this.sourceBlock_;
1101
+ if (source && source.disposed) {
1102
+ doLogging && console.log('source disposed, return');
1103
+ return;
1104
+ }
1105
+
1106
+ const oldValue = this.getValue();
1107
+ if (oldValue === localValue) {
1108
+ doLogging && console.log('same, doValueUpdate_, return');
1109
+ this.doValueUpdate_(localValue);
1110
+ return;
1111
+ }
1112
+
1113
+ this.doValueUpdate_(localValue);
1114
+ if (fireChangeEvent && source && eventUtils.isEnabled()) {
1115
+ eventUtils.fire(
1116
+ new (eventUtils.get(eventUtils.BLOCK_CHANGE))(
1117
+ source,
1118
+ 'field',
1119
+ this.name || null,
1120
+ oldValue,
1121
+ localValue,
1122
+ ),
1123
+ );
1124
+ }
1125
+ if (this.isDirty_) {
1126
+ this.forceRerender();
1127
+ }
1128
+ doLogging && console.log(this.value_);
1129
+ }
1130
+
1131
+ /**
1132
+ * Process the result of validation.
1133
+ *
1134
+ * @param newValue New value.
1135
+ * @param validatedValue Validated value.
1136
+ * @param fireChangeEvent Whether to fire a change event if the value changes.
1137
+ * @returns New value, or an Error object.
1138
+ */
1139
+ private processValidation_(
1140
+ newValue: AnyDuringMigration,
1141
+ validatedValue: T | null | undefined,
1142
+ fireChangeEvent: boolean,
1143
+ ): T | Error {
1144
+ if (validatedValue === null) {
1145
+ this.doValueInvalid_(newValue, fireChangeEvent);
1146
+ if (this.isDirty_) {
1147
+ this.forceRerender();
1148
+ }
1149
+ return Error();
1150
+ }
1151
+ return validatedValue === undefined ? (newValue as T) : validatedValue;
1152
+ }
1153
+
1154
+ /**
1155
+ * Get the current value of the field.
1156
+ *
1157
+ * @returns Current value.
1158
+ */
1159
+ getValue(): T | null {
1160
+ return this.value_;
1161
+ }
1162
+
1163
+ /**
1164
+ * Validate the changes to a field's value before they are set. See
1165
+ * **FieldDropdown** for an example of subclass implementation.
1166
+ *
1167
+ * **NOTE:** Validation returns one option between `T`, `null`, and
1168
+ * `undefined`. **Field**'s implementation will never return `undefined`, but
1169
+ * it is valid for a subclass to return `undefined` if the new value is
1170
+ * compatible with `T`.
1171
+ *
1172
+ * @see {@link https://developers.google.com/blockly/guides/create-custom-blocks/fields/validators#return_values}
1173
+ * @param newValue - The value to be validated.
1174
+ * @returns One of three instructions for setting the new value: `T`, `null`,
1175
+ * or `undefined`.
1176
+ *
1177
+ * - `T` to set this function's returned value instead of `newValue`.
1178
+ *
1179
+ * - `null` to invoke `doValueInvalid_` and not set a value.
1180
+ *
1181
+ * - `undefined` to set `newValue` as is.
1182
+ */
1183
+ protected doClassValidation_(newValue: T): T | null | undefined;
1184
+ protected doClassValidation_(newValue?: AnyDuringMigration): T | null;
1185
+ protected doClassValidation_(
1186
+ newValue?: T | AnyDuringMigration,
1187
+ ): T | null | undefined {
1188
+ if (newValue === null || newValue === undefined) {
1189
+ return null;
1190
+ }
1191
+
1192
+ return newValue as T;
1193
+ }
1194
+
1195
+ /**
1196
+ * Used to update the value of a field. Can be overridden by subclasses to do
1197
+ * custom storage of values/updating of external things.
1198
+ *
1199
+ * @param newValue The value to be saved.
1200
+ */
1201
+ protected doValueUpdate_(newValue: T) {
1202
+ this.value_ = newValue;
1203
+ this.isDirty_ = true;
1204
+ }
1205
+
1206
+ /**
1207
+ * Used to notify the field an invalid value was input. Can be overridden by
1208
+ * subclasses, see FieldTextInput.
1209
+ * No-op by default.
1210
+ *
1211
+ * @param _invalidValue The input value that was determined to be invalid.
1212
+ * @param _fireChangeEvent Whether to fire a change event if the value changes.
1213
+ */
1214
+ protected doValueInvalid_(
1215
+ _invalidValue: AnyDuringMigration,
1216
+ _fireChangeEvent: boolean = true,
1217
+ ) {}
1218
+ // NOP
1219
+
1220
+ /**
1221
+ * Handle a pointerdown event on a field.
1222
+ *
1223
+ * @param e Pointer down event.
1224
+ */
1225
+ protected onMouseDown_(e: PointerEvent) {
1226
+ if (!this.sourceBlock_ || this.sourceBlock_.isDeadOrDying()) {
1227
+ return;
1228
+ }
1229
+ const gesture = (this.sourceBlock_.workspace as WorkspaceSvg).getGesture(e);
1230
+ if (gesture) {
1231
+ gesture.setStartField(this);
1232
+ }
1233
+ }
1234
+
1235
+ /**
1236
+ * Sets the tooltip for this field.
1237
+ *
1238
+ * @param newTip The text for the tooltip, a function that returns the text
1239
+ * for the tooltip, a parent object whose tooltip will be used, or null to
1240
+ * display the tooltip of the parent block. To not display a tooltip pass
1241
+ * the empty string.
1242
+ */
1243
+ setTooltip(newTip: Tooltip.TipInfo | null) {
1244
+ if (!newTip && newTip !== '') {
1245
+ // If null or undefined.
1246
+ newTip = this.sourceBlock_;
1247
+ }
1248
+ const clickTarget = this.getClickTarget_();
1249
+ if (clickTarget) {
1250
+ (clickTarget as AnyDuringMigration).tooltip = newTip;
1251
+ } else {
1252
+ // Field has not been initialized yet.
1253
+ this.tooltip_ = newTip;
1254
+ }
1255
+ }
1256
+
1257
+ /**
1258
+ * Returns the tooltip text for this field.
1259
+ *
1260
+ * @returns The tooltip text for this field.
1261
+ */
1262
+ getTooltip(): string {
1263
+ const clickTarget = this.getClickTarget_();
1264
+ if (clickTarget) {
1265
+ return Tooltip.getTooltipOfObject(clickTarget);
1266
+ }
1267
+ // Field has not been initialized yet. Return stashed this.tooltip_ value.
1268
+ return Tooltip.getTooltipOfObject({tooltip: this.tooltip_});
1269
+ }
1270
+
1271
+ /**
1272
+ * The element to bind the click handler to. If not set explicitly, defaults
1273
+ * to the SVG root of the field. When this element is
1274
+ * clicked on an editable field, the editor will open.
1275
+ *
1276
+ * @returns Element to bind click handler to.
1277
+ */
1278
+ protected getClickTarget_(): Element | null {
1279
+ return this.clickTarget_ || this.getSvgRoot();
1280
+ }
1281
+
1282
+ /**
1283
+ * Return the absolute coordinates of the top-left corner of this field.
1284
+ * The origin (0,0) is the top-left corner of the page body.
1285
+ *
1286
+ * @returns Object with .x and .y properties.
1287
+ */
1288
+ protected getAbsoluteXY_(): Coordinate {
1289
+ return style.getPageOffset(this.getClickTarget_() as SVGRectElement);
1290
+ }
1291
+
1292
+ /**
1293
+ * Whether this field references any Blockly variables. If true it may need
1294
+ * to be handled differently during serialization and deserialization.
1295
+ * Subclasses may override this.
1296
+ *
1297
+ * @returns True if this field has any variable references.
1298
+ */
1299
+ referencesVariables(): boolean {
1300
+ return false;
1301
+ }
1302
+
1303
+ /**
1304
+ * Refresh the variable name referenced by this field if this field references
1305
+ * variables.
1306
+ */
1307
+ refreshVariableName() {}
1308
+ // NOP
1309
+
1310
+ /**
1311
+ * Search through the list of inputs and their fields in order to find the
1312
+ * parent input of a field.
1313
+ *
1314
+ * @returns The input that the field belongs to.
1315
+ * @internal
1316
+ */
1317
+ getParentInput(): Input {
1318
+ let parentInput = null;
1319
+ const block = this.getSourceBlock();
1320
+ if (!block) {
1321
+ throw new UnattachedFieldError();
1322
+ }
1323
+ const inputs = block.inputList;
1324
+
1325
+ for (let idx = 0; idx < block.inputList.length; idx++) {
1326
+ const input = inputs[idx];
1327
+ const fieldRows = input.fieldRow;
1328
+ for (let j = 0; j < fieldRows.length; j++) {
1329
+ if (fieldRows[j] === this) {
1330
+ parentInput = input;
1331
+ break;
1332
+ }
1333
+ }
1334
+ }
1335
+ return parentInput!;
1336
+ }
1337
+
1338
+ /**
1339
+ * Returns whether or not we should flip the field in RTL.
1340
+ *
1341
+ * @returns True if we should flip in RTL.
1342
+ */
1343
+ getFlipRtl(): boolean {
1344
+ return false;
1345
+ }
1346
+
1347
+ /**
1348
+ * Returns whether or not the field is tab navigable.
1349
+ *
1350
+ * @returns True if the field is tab navigable.
1351
+ */
1352
+ isTabNavigable(): boolean {
1353
+ return false;
1354
+ }
1355
+
1356
+ /**
1357
+ * Handles the given keyboard shortcut.
1358
+ *
1359
+ * @param _shortcut The shortcut to be handled.
1360
+ * @returns True if the shortcut has been handled, false otherwise.
1361
+ */
1362
+ onShortcut(_shortcut: KeyboardShortcut): boolean {
1363
+ return false;
1364
+ }
1365
+
1366
+ /**
1367
+ * Add the cursor SVG to this fields SVG group.
1368
+ *
1369
+ * @param cursorSvg The SVG root of the cursor to be added to the field group.
1370
+ * @internal
1371
+ */
1372
+ setCursorSvg(cursorSvg: SVGElement) {
1373
+ if (!cursorSvg) {
1374
+ this.cursorSvg_ = null;
1375
+ return;
1376
+ }
1377
+
1378
+ if (!this.fieldGroup_) {
1379
+ throw new Error(`The field group is ${this.fieldGroup_}.`);
1380
+ }
1381
+ this.fieldGroup_.appendChild(cursorSvg);
1382
+ this.cursorSvg_ = cursorSvg;
1383
+ }
1384
+
1385
+ /**
1386
+ * Add the marker SVG to this fields SVG group.
1387
+ *
1388
+ * @param markerSvg The SVG root of the marker to be added to the field group.
1389
+ * @internal
1390
+ */
1391
+ setMarkerSvg(markerSvg: SVGElement) {
1392
+ if (!markerSvg) {
1393
+ this.markerSvg_ = null;
1394
+ return;
1395
+ }
1396
+
1397
+ if (!this.fieldGroup_) {
1398
+ throw new Error(`The field group is ${this.fieldGroup_}.`);
1399
+ }
1400
+ this.fieldGroup_.appendChild(markerSvg);
1401
+ this.markerSvg_ = markerSvg;
1402
+ }
1403
+
1404
+ /**
1405
+ * Redraw any attached marker or cursor svgs if needed.
1406
+ *
1407
+ * @internal
1408
+ */
1409
+ updateMarkers_() {
1410
+ const block = this.getSourceBlock();
1411
+ if (!block) {
1412
+ throw new UnattachedFieldError();
1413
+ }
1414
+ const workspace = block.workspace as WorkspaceSvg;
1415
+ if (workspace.keyboardAccessibilityMode && this.cursorSvg_) {
1416
+ workspace.getCursor()!.draw();
1417
+ }
1418
+ if (workspace.keyboardAccessibilityMode && this.markerSvg_) {
1419
+ // TODO(#4592): Update all markers on the field.
1420
+ workspace.getMarker(MarkerManager.LOCAL_MARKER)!.draw();
1421
+ }
1422
+ }
1423
+
1424
+ /**
1425
+ * Subclasses should reimplement this method to construct their Field
1426
+ * subclass from a JSON arg object.
1427
+ *
1428
+ * It is an error to attempt to register a field subclass in the
1429
+ * FieldRegistry if that subclass has not overridden this method.
1430
+ *
1431
+ * @param _options JSON configuration object with properties needed
1432
+ * to configure a specific field.
1433
+ */
1434
+ static fromJson(_options: FieldConfig): Field {
1435
+ throw new Error(
1436
+ `Attempted to instantiate a field from the registry that hasn't defined a 'fromJson' method.`,
1437
+ );
1438
+ }
1439
+ }
1440
+
1441
+ /**
1442
+ * Extra configuration options for the base field.
1443
+ */
1444
+ export interface FieldConfig {
1445
+ tooltip?: string;
1446
+ }
1447
+
1448
+ /**
1449
+ * Represents an object that has all the prototype properties of the `Field`
1450
+ * class. This is necessary because constructors can change
1451
+ * in descendants, though they should contain all of Field's prototype methods.
1452
+ *
1453
+ * This type should only be used in places where we directly access the prototype
1454
+ * of a Field class or subclass.
1455
+ */
1456
+ type FieldProto = Pick<typeof Field, 'prototype'>;
1457
+
1458
+ /**
1459
+ * Represents an error where the field is trying to access its block or
1460
+ * information about its block before it has actually been attached to said
1461
+ * block.
1462
+ */
1463
+ export class UnattachedFieldError extends Error {
1464
+ /** @internal */
1465
+ constructor() {
1466
+ super(
1467
+ 'The field has not yet been attached to its input. ' +
1468
+ 'Call appendField to attach it.',
1469
+ );
1470
+ }
1471
+ }