blockly 7.20211209.4 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (262) hide show
  1. package/blockly.d.ts +18963 -18432
  2. package/blockly.min.js +852 -844
  3. package/blockly_compressed.js +669 -664
  4. package/blockly_compressed.js.map +1 -1
  5. package/blocks/blocks.js +47 -0
  6. package/blocks/colour.js +13 -3
  7. package/blocks/lists.js +22 -13
  8. package/blocks/logic.js +13 -3
  9. package/blocks/loops.js +24 -11
  10. package/blocks/math.js +12 -3
  11. package/blocks/procedures.js +41 -27
  12. package/blocks/text.js +22 -13
  13. package/blocks/variables.js +14 -3
  14. package/blocks/variables_dynamic.js +13 -3
  15. package/blocks_compressed.js +146 -141
  16. package/blocks_compressed.js.map +1 -1
  17. package/core/block.js +1869 -1814
  18. package/core/block_drag_surface.js +201 -200
  19. package/core/block_dragger.js +377 -373
  20. package/core/block_svg.js +1593 -1479
  21. package/core/blockly.js +8 -22
  22. package/core/blocks.js +9 -2
  23. package/core/browser_events.js +22 -5
  24. package/core/bubble.js +841 -797
  25. package/core/bubble_dragger.js +213 -206
  26. package/core/bump_objects.js +2 -2
  27. package/core/clipboard.js +9 -9
  28. package/core/comment.js +353 -332
  29. package/core/common.js +46 -17
  30. package/core/component_manager.js +181 -174
  31. package/core/config.js +87 -0
  32. package/core/connection.js +595 -584
  33. package/core/connection_checker.js +242 -244
  34. package/core/connection_db.js +235 -230
  35. package/core/contextmenu.js +9 -6
  36. package/core/contextmenu_items.js +1 -2
  37. package/core/contextmenu_registry.js +93 -89
  38. package/core/css.js +474 -474
  39. package/core/delete_area.js +45 -42
  40. package/core/drag_target.js +57 -56
  41. package/core/dropdowndiv.js +153 -163
  42. package/core/events/events.js +2 -2
  43. package/core/events/events_abstract.js +89 -77
  44. package/core/events/events_block_base.js +37 -36
  45. package/core/events/events_block_change.js +130 -124
  46. package/core/events/events_block_create.js +73 -71
  47. package/core/events/events_block_delete.js +84 -82
  48. package/core/events/events_block_drag.js +50 -49
  49. package/core/events/events_block_move.js +147 -140
  50. package/core/events/events_bubble_open.js +51 -50
  51. package/core/events/events_click.js +48 -44
  52. package/core/events/events_comment_base.js +72 -69
  53. package/core/events/events_comment_change.js +63 -61
  54. package/core/events/events_comment_create.js +44 -42
  55. package/core/events/events_comment_delete.js +42 -40
  56. package/core/events/events_comment_move.js +106 -104
  57. package/core/events/events_marker_move.js +65 -64
  58. package/core/events/events_selected.js +46 -45
  59. package/core/events/events_theme_change.js +36 -35
  60. package/core/events/events_toolbox_item_select.js +46 -45
  61. package/core/events/events_trashcan_open.js +37 -36
  62. package/core/events/events_ui.js +47 -46
  63. package/core/events/events_ui_base.js +30 -29
  64. package/core/events/events_var_base.js +37 -36
  65. package/core/events/events_var_create.js +50 -48
  66. package/core/events/events_var_delete.js +50 -48
  67. package/core/events/events_var_rename.js +51 -49
  68. package/core/events/events_viewport.js +66 -65
  69. package/core/events/utils.js +29 -14
  70. package/core/events/workspace_events.js +49 -55
  71. package/core/extensions.js +4 -3
  72. package/core/field.js +1061 -997
  73. package/core/field_angle.js +462 -442
  74. package/core/field_checkbox.js +194 -182
  75. package/core/field_colour.js +519 -505
  76. package/core/field_dropdown.js +617 -598
  77. package/core/field_image.js +229 -220
  78. package/core/field_label.js +102 -91
  79. package/core/field_label_serializable.js +42 -41
  80. package/core/field_multilineinput.js +372 -358
  81. package/core/field_number.js +272 -253
  82. package/core/field_textinput.js +499 -467
  83. package/core/field_variable.js +458 -420
  84. package/core/flyout_base.js +1005 -952
  85. package/core/flyout_button.js +277 -260
  86. package/core/flyout_horizontal.js +304 -302
  87. package/core/flyout_metrics_manager.js +64 -64
  88. package/core/flyout_vertical.js +306 -300
  89. package/core/generator.js +459 -446
  90. package/core/gesture.js +829 -813
  91. package/core/grid.js +166 -163
  92. package/core/icon.js +168 -159
  93. package/core/inject.js +7 -5
  94. package/core/input.js +257 -248
  95. package/core/insertion_marker_manager.js +655 -624
  96. package/core/internal_constants.js +0 -129
  97. package/core/keyboard_nav/ast_node.js +605 -596
  98. package/core/keyboard_nav/basic_cursor.js +166 -165
  99. package/core/keyboard_nav/cursor.js +99 -97
  100. package/core/keyboard_nav/marker.js +83 -79
  101. package/core/keyboard_nav/tab_navigate_cursor.js +18 -23
  102. package/core/marker_manager.js +153 -141
  103. package/core/menu.js +377 -372
  104. package/core/menuitem.js +223 -217
  105. package/core/metrics_manager.js +403 -390
  106. package/core/mutator.js +468 -437
  107. package/core/names.js +229 -188
  108. package/core/options.js +290 -284
  109. package/core/procedures.js +29 -17
  110. package/core/registry.js +19 -16
  111. package/core/rendered_connection.js +482 -463
  112. package/core/renderers/common/block_rendering.js +9 -3
  113. package/core/renderers/common/constants.js +1119 -1112
  114. package/core/renderers/common/debug.js +14 -0
  115. package/core/renderers/common/debugger.js +338 -316
  116. package/core/renderers/common/drawer.js +380 -370
  117. package/core/renderers/common/i_path_object.js +2 -2
  118. package/core/renderers/common/info.js +626 -618
  119. package/core/renderers/common/marker_svg.js +579 -541
  120. package/core/renderers/common/path_object.js +203 -200
  121. package/core/renderers/common/renderer.js +220 -218
  122. package/core/renderers/geras/constants.js +36 -36
  123. package/core/renderers/geras/drawer.js +155 -147
  124. package/core/renderers/geras/highlight_constants.js +244 -238
  125. package/core/renderers/geras/highlighter.js +231 -179
  126. package/core/renderers/geras/info.js +392 -369
  127. package/core/renderers/geras/measurables/inline_input.js +25 -19
  128. package/core/renderers/geras/measurables/statement_input.js +23 -17
  129. package/core/renderers/geras/path_object.js +106 -121
  130. package/core/renderers/geras/renderer.js +96 -98
  131. package/core/renderers/measurables/base.js +30 -18
  132. package/core/renderers/measurables/bottom_row.js +83 -80
  133. package/core/renderers/measurables/connection.js +22 -15
  134. package/core/renderers/measurables/external_value_input.js +35 -22
  135. package/core/renderers/measurables/field.js +35 -20
  136. package/core/renderers/measurables/hat.js +18 -13
  137. package/core/renderers/measurables/icon.js +24 -17
  138. package/core/renderers/measurables/in_row_spacer.js +15 -13
  139. package/core/renderers/measurables/inline_input.js +43 -33
  140. package/core/renderers/measurables/input_connection.js +41 -28
  141. package/core/renderers/measurables/input_row.js +50 -44
  142. package/core/renderers/measurables/jagged_edge.js +14 -12
  143. package/core/renderers/measurables/next_connection.js +16 -14
  144. package/core/renderers/measurables/output_connection.js +26 -20
  145. package/core/renderers/measurables/previous_connection.js +16 -15
  146. package/core/renderers/measurables/round_corner.js +20 -18
  147. package/core/renderers/measurables/row.js +184 -168
  148. package/core/renderers/measurables/spacer_row.js +38 -23
  149. package/core/renderers/measurables/square_corner.js +18 -16
  150. package/core/renderers/measurables/statement_input.js +23 -20
  151. package/core/renderers/measurables/top_row.js +88 -85
  152. package/core/renderers/minimalist/constants.js +8 -7
  153. package/core/renderers/minimalist/drawer.js +11 -10
  154. package/core/renderers/minimalist/info.js +18 -18
  155. package/core/renderers/minimalist/renderer.js +40 -39
  156. package/core/renderers/thrasos/info.js +258 -248
  157. package/core/renderers/thrasos/renderer.js +20 -20
  158. package/core/renderers/zelos/constants.js +898 -873
  159. package/core/renderers/zelos/drawer.js +186 -169
  160. package/core/renderers/zelos/info.js +502 -479
  161. package/core/renderers/zelos/marker_svg.js +129 -115
  162. package/core/renderers/zelos/measurables/bottom_row.js +31 -30
  163. package/core/renderers/zelos/measurables/inputs.js +22 -21
  164. package/core/renderers/zelos/measurables/row_elements.js +14 -13
  165. package/core/renderers/zelos/measurables/top_row.js +34 -33
  166. package/core/renderers/zelos/path_object.js +181 -180
  167. package/core/renderers/zelos/renderer.js +91 -92
  168. package/core/scrollbar.js +759 -713
  169. package/core/scrollbar_pair.js +250 -245
  170. package/core/serialization/blocks.js +19 -9
  171. package/core/serialization/workspaces.js +3 -2
  172. package/core/shortcut_registry.js +286 -277
  173. package/core/sprites.js +31 -0
  174. package/core/theme.js +135 -141
  175. package/core/theme_manager.js +147 -143
  176. package/core/toolbox/category.js +602 -576
  177. package/core/toolbox/collapsible_category.js +226 -227
  178. package/core/toolbox/separator.js +70 -61
  179. package/core/toolbox/toolbox.js +934 -927
  180. package/core/toolbox/toolbox_item.js +115 -99
  181. package/core/tooltip.js +108 -35
  182. package/core/touch.js +8 -3
  183. package/core/touch_gesture.js +254 -251
  184. package/core/trashcan.js +606 -595
  185. package/core/utils/coordinate.js +97 -95
  186. package/core/utils/dom.js +2 -2
  187. package/core/utils/global.js +2 -0
  188. package/core/utils/rect.js +41 -37
  189. package/core/utils/sentinel.js +25 -0
  190. package/core/utils/size.js +30 -27
  191. package/core/utils/svg.js +18 -16
  192. package/core/variable_map.js +325 -341
  193. package/core/variable_model.js +55 -54
  194. package/core/variables.js +9 -2
  195. package/core/variables_dynamic.js +3 -1
  196. package/core/warning.js +126 -120
  197. package/core/widgetdiv.js +4 -4
  198. package/core/workspace.js +685 -664
  199. package/core/workspace_audio.js +124 -118
  200. package/core/workspace_comment.js +308 -298
  201. package/core/workspace_comment_svg.js +1029 -951
  202. package/core/workspace_drag_surface_svg.js +147 -140
  203. package/core/workspace_dragger.js +70 -71
  204. package/core/workspace_svg.js +2322 -2297
  205. package/core/xml.js +30 -20
  206. package/core/zoom_controls.js +431 -439
  207. package/dart_compressed.js +40 -43
  208. package/dart_compressed.js.map +1 -1
  209. package/generators/dart/colour.js +56 -64
  210. package/generators/dart/lists.js +61 -50
  211. package/generators/dart/math.js +160 -148
  212. package/generators/dart/text.js +83 -61
  213. package/generators/javascript/colour.js +37 -34
  214. package/generators/javascript/lists.js +50 -43
  215. package/generators/javascript/math.js +123 -139
  216. package/generators/javascript/text.js +67 -81
  217. package/generators/lua/colour.js +25 -23
  218. package/generators/lua/lists.js +97 -69
  219. package/generators/lua/logic.js +1 -2
  220. package/generators/lua/math.js +182 -144
  221. package/generators/lua/text.js +116 -99
  222. package/generators/php/colour.js +38 -32
  223. package/generators/php/lists.js +109 -89
  224. package/generators/php/math.js +90 -81
  225. package/generators/php/text.js +63 -61
  226. package/generators/python/colour.js +18 -18
  227. package/generators/python/lists.js +38 -30
  228. package/generators/python/loops.js +12 -8
  229. package/generators/python/math.js +104 -106
  230. package/generators/python/text.js +34 -30
  231. package/javascript_compressed.js +37 -39
  232. package/javascript_compressed.js.map +1 -1
  233. package/lua_compressed.js +39 -42
  234. package/lua_compressed.js.map +1 -1
  235. package/msg/az.js +2 -2
  236. package/msg/be.js +4 -4
  237. package/msg/cs.js +15 -15
  238. package/msg/de.js +1 -1
  239. package/msg/diq.js +1 -1
  240. package/msg/eo.js +1 -1
  241. package/msg/es.js +1 -1
  242. package/msg/fa.js +1 -1
  243. package/msg/fr.js +4 -4
  244. package/msg/he.js +1 -1
  245. package/msg/hr.js +2 -2
  246. package/msg/hy.js +2 -2
  247. package/msg/id.js +12 -12
  248. package/msg/inh.js +14 -14
  249. package/msg/ja.js +7 -7
  250. package/msg/lv.js +29 -29
  251. package/msg/pa.js +3 -3
  252. package/msg/smn.js +436 -0
  253. package/msg/te.js +1 -1
  254. package/msg/yue.js +1 -1
  255. package/msg/zh-hans.js +3 -3
  256. package/msg/zh-hant.js +3 -3
  257. package/package.json +7 -6
  258. package/php_compressed.js +38 -42
  259. package/php_compressed.js.map +1 -1
  260. package/python_compressed.js +26 -25
  261. package/python_compressed.js.map +1 -1
  262. package/blocks/all.js +0 -23
@@ -28,204 +28,220 @@ const {Types} = goog.require('Blockly.blockRendering.Types');
28
28
  /**
29
29
  * An object representing a single row on a rendered block and all of its
30
30
  * subcomponents.
31
- * @param {!ConstantProvider} constants The rendering
32
- * constants provider.
33
- * @package
34
- * @constructor
35
31
  * @alias Blockly.blockRendering.Row
36
32
  */
37
- const Row = function(constants) {
33
+ class Row {
38
34
  /**
39
- * The type of this rendering object.
35
+ * @param {!ConstantProvider} constants The rendering
36
+ * constants provider.
40
37
  * @package
41
- * @type {number}
42
38
  */
43
- this.type = Types.ROW;
44
-
45
- /**
46
- * An array of elements contained in this row.
47
- * @package
48
- * @type {!Array<!Measurable>}
49
- */
50
- this.elements = [];
51
-
52
- /**
53
- * The height of the row.
54
- * @package
55
- * @type {number}
56
- */
57
- this.height = 0;
58
-
59
- /**
60
- * The width of the row, from the left edge of the block to the right.
61
- * Does not include child blocks unless they are inline.
62
- * @package
63
- * @type {number}
64
- */
65
- this.width = 0;
66
-
67
- /**
68
- * The minimum height of the row.
69
- * @package
70
- * @type {number}
71
- */
72
- this.minHeight = 0;
73
-
74
- /**
75
- * The minimum width of the row, from the left edge of the block to the right.
76
- * Does not include child blocks unless they are inline.
77
- * @package
78
- * @type {number}
79
- */
80
- this.minWidth = 0;
81
-
82
- /**
83
- * The width of the row, from the left edge of the block to the edge of the
84
- * block or any connected child blocks.
85
- * @package
86
- * @type {number}
87
- */
88
- this.widthWithConnectedBlocks = 0;
89
-
90
- /**
91
- * The Y position of the row relative to the origin of the block's svg group.
92
- * @package
93
- * @type {number}
94
- */
95
- this.yPos = 0;
96
-
97
- /**
98
- * The X position of the row relative to the origin of the block's svg group.
99
- * @package
100
- * @type {number}
101
- */
102
- this.xPos = 0;
39
+ constructor(constants) {
40
+ /**
41
+ * The type of this rendering object.
42
+ * @package
43
+ * @type {number}
44
+ */
45
+ this.type = Types.ROW;
46
+
47
+ /**
48
+ * An array of elements contained in this row.
49
+ * @package
50
+ * @type {!Array<!Measurable>}
51
+ */
52
+ this.elements = [];
53
+
54
+ /**
55
+ * The height of the row.
56
+ * @package
57
+ * @type {number}
58
+ */
59
+ this.height = 0;
60
+
61
+ /**
62
+ * The width of the row, from the left edge of the block to the right.
63
+ * Does not include child blocks unless they are inline.
64
+ * @package
65
+ * @type {number}
66
+ */
67
+ this.width = 0;
68
+
69
+ /**
70
+ * The minimum height of the row.
71
+ * @package
72
+ * @type {number}
73
+ */
74
+ this.minHeight = 0;
75
+
76
+ /**
77
+ * The minimum width of the row, from the left edge of the block to the
78
+ * right. Does not include child blocks unless they are inline.
79
+ * @package
80
+ * @type {number}
81
+ */
82
+ this.minWidth = 0;
83
+
84
+ /**
85
+ * The width of the row, from the left edge of the block to the edge of the
86
+ * block or any connected child blocks.
87
+ * @package
88
+ * @type {number}
89
+ */
90
+ this.widthWithConnectedBlocks = 0;
91
+
92
+ /**
93
+ * The Y position of the row relative to the origin of the block's svg
94
+ * group.
95
+ * @package
96
+ * @type {number}
97
+ */
98
+ this.yPos = 0;
99
+
100
+ /**
101
+ * The X position of the row relative to the origin of the block's svg
102
+ * group.
103
+ * @package
104
+ * @type {number}
105
+ */
106
+ this.xPos = 0;
107
+
108
+ /**
109
+ * Whether the row has any external inputs.
110
+ * @package
111
+ * @type {boolean}
112
+ */
113
+ this.hasExternalInput = false;
114
+
115
+ /**
116
+ * Whether the row has any statement inputs.
117
+ * @package
118
+ * @type {boolean}
119
+ */
120
+ this.hasStatement = false;
121
+
122
+ /**
123
+ * Where the left edge of all of the statement inputs on the block should
124
+ * be. This makes sure that statement inputs which are proceded by fields
125
+ * of varius widths are all aligned.
126
+ * @type {number}
127
+ */
128
+ this.statementEdge = 0;
129
+
130
+ /**
131
+ * Whether the row has any inline inputs.
132
+ * @package
133
+ * @type {boolean}
134
+ */
135
+ this.hasInlineInput = false;
136
+
137
+ /**
138
+ * Whether the row has any dummy inputs.
139
+ * @package
140
+ * @type {boolean}
141
+ */
142
+ this.hasDummyInput = false;
143
+
144
+ /**
145
+ * Whether the row has a jagged edge.
146
+ * @package
147
+ * @type {boolean}
148
+ */
149
+ this.hasJaggedEdge = false;
150
+
151
+ /**
152
+ * The renderer's constant provider.
153
+ * @type {!ConstantProvider}
154
+ * @protected
155
+ */
156
+ this.constants_ = constants;
157
+
158
+ /**
159
+ * @type {number}
160
+ */
161
+ this.notchOffset = this.constants_.NOTCH_OFFSET_LEFT;
162
+
163
+ /**
164
+ * Alignment of the row.
165
+ * @package
166
+ * @type {?number}
167
+ */
168
+ this.align = null;
169
+ }
103
170
 
104
171
  /**
105
- * Whether the row has any external inputs.
172
+ * Get the last input on this row, if it has one.
173
+ * @return {InputConnection} The last input on the row,
174
+ * or null.
106
175
  * @package
107
- * @type {boolean}
108
176
  */
109
- this.hasExternalInput = false;
177
+ getLastInput() {
178
+ // TODO: Consider moving this to InputRow, if possible.
179
+ for (let i = this.elements.length - 1; i >= 0; i--) {
180
+ const elem = this.elements[i];
181
+ if (Types.isInput(elem)) {
182
+ return /** @type {InputConnection} */ (elem);
183
+ }
184
+ }
185
+ return null;
186
+ }
110
187
 
111
188
  /**
112
- * Whether the row has any statement inputs.
189
+ * Inspect all subcomponents and populate all size properties on the row.
113
190
  * @package
114
- * @type {boolean}
115
191
  */
116
- this.hasStatement = false;
192
+ measure() {
193
+ throw Error('Unexpected attempt to measure a base Row.');
194
+ }
117
195
 
118
196
  /**
119
- * Whether the row has any inline inputs.
197
+ * Determines whether this row should start with an element spacer.
198
+ * @return {boolean} Whether the row should start with a spacer.
120
199
  * @package
121
- * @type {boolean}
122
200
  */
123
- this.hasInlineInput = false;
201
+ startsWithElemSpacer() {
202
+ return true;
203
+ }
124
204
 
125
205
  /**
126
- * Whether the row has any dummy inputs.
206
+ * Determines whether this row should end with an element spacer.
207
+ * @return {boolean} Whether the row should end with a spacer.
127
208
  * @package
128
- * @type {boolean}
129
209
  */
130
- this.hasDummyInput = false;
210
+ endsWithElemSpacer() {
211
+ return true;
212
+ }
131
213
 
132
214
  /**
133
- * Whether the row has a jagged edge.
215
+ * Convenience method to get the first spacer element on this row.
216
+ * @return {InRowSpacer} The first spacer element on
217
+ * this row.
134
218
  * @package
135
- * @type {boolean}
136
219
  */
137
- this.hasJaggedEdge = false;
138
-
139
- /**
140
- * The renderer's constant provider.
141
- * @type {!ConstantProvider}
142
- * @protected
143
- */
144
- this.constants_ = constants;
145
-
146
- this.notchOffset = this.constants_.NOTCH_OFFSET_LEFT;
220
+ getFirstSpacer() {
221
+ for (let i = 0; i < this.elements.length; i++) {
222
+ const elem = this.elements[i];
223
+ if (Types.isSpacer(elem)) {
224
+ return /** @type {InRowSpacer} */ (elem);
225
+ }
226
+ }
227
+ return null;
228
+ }
147
229
 
148
230
  /**
149
- * Alignment of the row.
231
+ * Convenience method to get the last spacer element on this row.
232
+ * @return {InRowSpacer} The last spacer element on
233
+ * this row.
150
234
  * @package
151
- * @type {?number}
152
235
  */
153
- this.align = null;
154
- };
155
-
156
- /**
157
- * Get the last input on this row, if it has one.
158
- * @return {InputConnection} The last input on the row,
159
- * or null.
160
- * @package
161
- */
162
- // TODO: Consider moving this to InputRow, if possible.
163
- Row.prototype.getLastInput = function() {
164
- for (let i = this.elements.length - 1; i >= 0; i--) {
165
- const elem = this.elements[i];
166
- if (Types.isInput(elem)) {
167
- return /** @type {InputConnection} */ (elem);
168
- }
169
- }
170
- return null;
171
- };
172
-
173
- /**
174
- * Inspect all subcomponents and populate all size properties on the row.
175
- * @package
176
- */
177
- Row.prototype.measure = function() {
178
- throw Error('Unexpected attempt to measure a base Row.');
179
- };
180
-
181
- /**
182
- * Determines whether this row should start with an element spacer.
183
- * @return {boolean} Whether the row should start with a spacer.
184
- * @package
185
- */
186
- Row.prototype.startsWithElemSpacer = function() {
187
- return true;
188
- };
189
-
190
- /**
191
- * Determines whether this row should end with an element spacer.
192
- * @return {boolean} Whether the row should end with a spacer.
193
- * @package
194
- */
195
- Row.prototype.endsWithElemSpacer = function() {
196
- return true;
197
- };
198
-
199
- /**
200
- * Convenience method to get the first spacer element on this row.
201
- * @return {InRowSpacer} The first spacer element on
202
- * this row.
203
- * @package
204
- */
205
- Row.prototype.getFirstSpacer = function() {
206
- for (let i = 0; i < this.elements.length; i++) {
207
- const elem = this.elements[i];
208
- if (Types.isSpacer(elem)) {
209
- return /** @type {InRowSpacer} */ (elem);
210
- }
211
- }
212
- return null;
213
- };
214
-
215
- /**
216
- * Convenience method to get the last spacer element on this row.
217
- * @return {InRowSpacer} The last spacer element on
218
- * this row.
219
- * @package
220
- */
221
- Row.prototype.getLastSpacer = function() {
222
- for (let i = this.elements.length - 1; i >= 0; i--) {
223
- const elem = this.elements[i];
224
- if (Types.isSpacer(elem)) {
225
- return /** @type {InRowSpacer} */ (elem);
236
+ getLastSpacer() {
237
+ for (let i = this.elements.length - 1; i >= 0; i--) {
238
+ const elem = this.elements[i];
239
+ if (Types.isSpacer(elem)) {
240
+ return /** @type {InRowSpacer} */ (elem);
241
+ }
226
242
  }
243
+ return null;
227
244
  }
228
- return null;
229
- };
245
+ }
230
246
 
231
247
  exports.Row = Row;
@@ -14,7 +14,6 @@
14
14
  */
15
15
  goog.module('Blockly.blockRendering.SpacerRow');
16
16
 
17
- const object = goog.require('Blockly.utils.object');
18
17
  /* eslint-disable-next-line no-unused-vars */
19
18
  const {ConstantProvider} = goog.requireType('Blockly.blockRendering.ConstantProvider');
20
19
  const {InRowSpacer} = goog.require('Blockly.blockRendering.InRowSpacer');
@@ -24,31 +23,47 @@ const {Types} = goog.require('Blockly.blockRendering.Types');
24
23
 
25
24
  /**
26
25
  * An object containing information about a spacer between two rows.
27
- * @param {!ConstantProvider} constants The rendering
28
- * constants provider.
29
- * @param {number} height The height of the spacer.
30
- * @param {number} width The width of the spacer.
31
- * @package
32
- * @constructor
33
26
  * @extends {Row}
27
+ * @struct
34
28
  * @alias Blockly.blockRendering.SpacerRow
35
29
  */
36
- const SpacerRow = function(constants, height, width) {
37
- SpacerRow.superClass_.constructor.call(this, constants);
38
- this.type |= Types.SPACER | Types.BETWEEN_ROW_SPACER;
39
- this.width = width;
40
- this.height = height;
41
- this.followsStatement = false;
42
- this.widthWithConnectedBlocks = 0;
43
- this.elements = [new InRowSpacer(this.constants_, width)];
44
- };
45
- object.inherits(SpacerRow, Row);
30
+ class SpacerRow extends Row {
31
+ /**
32
+ * @param {!ConstantProvider} constants The rendering
33
+ * constants provider.
34
+ * @param {number} height The height of the spacer.
35
+ * @param {number} width The width of the spacer.
36
+ * @package
37
+ */
38
+ constructor(constants, height, width) {
39
+ super(constants);
40
+ this.type |= Types.SPACER | Types.BETWEEN_ROW_SPACER;
46
41
 
47
- /**
48
- * @override
49
- */
50
- SpacerRow.prototype.measure = function() {
51
- // NOP. Width and height were set at creation.
52
- };
42
+ /** @type {number} */
43
+ this.width = width;
44
+
45
+ /** @type {number} */
46
+ this.height = height;
47
+
48
+ /** @type {boolean} */
49
+ this.followsStatement = false;
50
+
51
+ /** @type {boolean} */
52
+ this.precedesStatement = false;
53
+
54
+ /** @type {number} */
55
+ this.widthWithConnectedBlocks = 0;
56
+
57
+ /** @type {!Array.<!InRowSpacer>} */
58
+ this.elements = [new InRowSpacer(this.constants_, width)];
59
+ }
60
+
61
+ /**
62
+ * @override
63
+ */
64
+ measure() {
65
+ // NOP. Width and height were set at creation.
66
+ }
67
+ }
53
68
 
54
69
  exports.SpacerRow = SpacerRow;
@@ -16,7 +16,6 @@
16
16
  */
17
17
  goog.module('Blockly.blockRendering.SquareCorner');
18
18
 
19
- const object = goog.require('Blockly.utils.object');
20
19
  /* eslint-disable-next-line no-unused-vars */
21
20
  const {ConstantProvider} = goog.requireType('Blockly.blockRendering.ConstantProvider');
22
21
  const {Measurable} = goog.require('Blockly.blockRendering.Measurable');
@@ -26,23 +25,26 @@ const {Types} = goog.require('Blockly.blockRendering.Types');
26
25
  /**
27
26
  * An object containing information about the space a square corner takes up
28
27
  * during rendering.
29
- * @param {!ConstantProvider} constants The rendering
30
- * constants provider.
31
- * @param {string=} opt_position The position of this corner.
32
- * @package
33
- * @constructor
34
28
  * @extends {Measurable}
29
+ * @struct
35
30
  * @alias Blockly.blockRendering.SquareCorner
36
31
  */
37
- const SquareCorner = function(constants, opt_position) {
38
- SquareCorner.superClass_.constructor.call(this, constants);
39
- this.type =
40
- ((!opt_position || opt_position === 'left') ? Types.LEFT_SQUARE_CORNER :
41
- Types.RIGHT_SQUARE_CORNER) |
42
- Types.CORNER;
43
- this.height = this.constants_.NO_PADDING;
44
- this.width = this.constants_.NO_PADDING;
45
- };
46
- object.inherits(SquareCorner, Measurable);
32
+ class SquareCorner extends Measurable {
33
+ /**
34
+ * @param {!ConstantProvider} constants The rendering
35
+ * constants provider.
36
+ * @param {string=} opt_position The position of this corner.
37
+ * @package
38
+ */
39
+ constructor(constants, opt_position) {
40
+ super(constants);
41
+ this.type = ((!opt_position || opt_position === 'left') ?
42
+ Types.LEFT_SQUARE_CORNER :
43
+ Types.RIGHT_SQUARE_CORNER) |
44
+ Types.CORNER;
45
+ this.height = this.constants_.NO_PADDING;
46
+ this.width = this.constants_.NO_PADDING;
47
+ }
48
+ }
47
49
 
48
50
  exports.SquareCorner = SquareCorner;
@@ -16,7 +16,6 @@
16
16
  */
17
17
  goog.module('Blockly.blockRendering.StatementInput');
18
18
 
19
- const object = goog.require('Blockly.utils.object');
20
19
  /* eslint-disable-next-line no-unused-vars */
21
20
  const {ConstantProvider} = goog.requireType('Blockly.blockRendering.ConstantProvider');
22
21
  const {InputConnection} = goog.require('Blockly.blockRendering.InputConnection');
@@ -28,29 +27,33 @@ const {Types} = goog.require('Blockly.blockRendering.Types');
28
27
  /**
29
28
  * An object containing information about the space a statement input takes up
30
29
  * during rendering
31
- * @param {!ConstantProvider} constants The rendering
32
- * constants provider.
33
- * @param {!Input} input The statement input to measure and store
34
- * information for.
35
- * @package
36
- * @constructor
30
+ * @struct
37
31
  * @extends {InputConnection}
38
32
  * @alias Blockly.blockRendering.StatementInput
39
33
  */
40
- const StatementInput = function(constants, input) {
41
- StatementInput.superClass_.constructor.call(this, constants, input);
42
- this.type |= Types.STATEMENT_INPUT;
34
+ class StatementInput extends InputConnection {
35
+ /**
36
+ * @param {!ConstantProvider} constants The rendering
37
+ * constants provider.
38
+ * @param {!Input} input The statement input to measure and store
39
+ * information for.
40
+ * @package
41
+ */
42
+ constructor(constants, input) {
43
+ super(constants, input);
44
+ this.type |= Types.STATEMENT_INPUT;
43
45
 
44
- if (!this.connectedBlock) {
45
- this.height = this.constants_.EMPTY_STATEMENT_INPUT_HEIGHT;
46
- } else {
47
- // We allow the dark path to show on the parent block so that the child
48
- // block looks embossed. This takes up an extra pixel in both x and y.
49
- this.height =
50
- this.connectedBlockHeight + this.constants_.STATEMENT_BOTTOM_SPACER;
46
+ if (!this.connectedBlock) {
47
+ this.height = this.constants_.EMPTY_STATEMENT_INPUT_HEIGHT;
48
+ } else {
49
+ // We allow the dark path to show on the parent block so that the child
50
+ // block looks embossed. This takes up an extra pixel in both x and y.
51
+ this.height =
52
+ this.connectedBlockHeight + this.constants_.STATEMENT_BOTTOM_SPACER;
53
+ }
54
+ this.width =
55
+ this.constants_.STATEMENT_INPUT_NOTCH_OFFSET + this.shape.width;
51
56
  }
52
- this.width = this.constants_.STATEMENT_INPUT_NOTCH_OFFSET + this.shape.width;
53
- };
54
- object.inherits(StatementInput, InputConnection);
57
+ }
55
58
 
56
59
  exports.StatementInput = StatementInput;