blockly 7.20211209.2 → 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.
- package/blockly.d.ts +18963 -18432
- package/blockly.min.js +852 -844
- package/blockly_compressed.js +669 -664
- package/blockly_compressed.js.map +1 -1
- package/blocks/blocks.js +47 -0
- package/blocks/colour.js +13 -3
- package/blocks/lists.js +22 -13
- package/blocks/logic.js +13 -3
- package/blocks/loops.js +24 -11
- package/blocks/math.js +12 -3
- package/blocks/procedures.js +41 -27
- package/blocks/text.js +22 -13
- package/blocks/variables.js +14 -3
- package/blocks/variables_dynamic.js +13 -3
- package/blocks_compressed.js +146 -141
- package/blocks_compressed.js.map +1 -1
- package/core/block.js +1869 -1814
- package/core/block_drag_surface.js +201 -200
- package/core/block_dragger.js +377 -373
- package/core/block_svg.js +1593 -1479
- package/core/blockly.js +8 -22
- package/core/blocks.js +9 -2
- package/core/browser_events.js +22 -5
- package/core/bubble.js +841 -797
- package/core/bubble_dragger.js +213 -206
- package/core/bump_objects.js +2 -2
- package/core/clipboard.js +9 -9
- package/core/comment.js +353 -332
- package/core/common.js +46 -17
- package/core/component_manager.js +181 -174
- package/core/config.js +87 -0
- package/core/connection.js +595 -584
- package/core/connection_checker.js +242 -244
- package/core/connection_db.js +235 -230
- package/core/contextmenu.js +9 -6
- package/core/contextmenu_items.js +1 -2
- package/core/contextmenu_registry.js +93 -89
- package/core/css.js +474 -474
- package/core/delete_area.js +45 -42
- package/core/drag_target.js +57 -56
- package/core/dropdowndiv.js +153 -163
- package/core/events/events.js +2 -2
- package/core/events/events_abstract.js +89 -77
- package/core/events/events_block_base.js +37 -36
- package/core/events/events_block_change.js +130 -124
- package/core/events/events_block_create.js +73 -71
- package/core/events/events_block_delete.js +84 -82
- package/core/events/events_block_drag.js +50 -49
- package/core/events/events_block_move.js +147 -140
- package/core/events/events_bubble_open.js +51 -50
- package/core/events/events_click.js +48 -44
- package/core/events/events_comment_base.js +72 -69
- package/core/events/events_comment_change.js +63 -61
- package/core/events/events_comment_create.js +44 -42
- package/core/events/events_comment_delete.js +42 -40
- package/core/events/events_comment_move.js +106 -104
- package/core/events/events_marker_move.js +65 -64
- package/core/events/events_selected.js +46 -45
- package/core/events/events_theme_change.js +36 -35
- package/core/events/events_toolbox_item_select.js +46 -45
- package/core/events/events_trashcan_open.js +37 -36
- package/core/events/events_ui.js +47 -46
- package/core/events/events_ui_base.js +30 -29
- package/core/events/events_var_base.js +37 -36
- package/core/events/events_var_create.js +50 -48
- package/core/events/events_var_delete.js +50 -48
- package/core/events/events_var_rename.js +51 -49
- package/core/events/events_viewport.js +66 -65
- package/core/events/utils.js +29 -14
- package/core/events/workspace_events.js +49 -55
- package/core/extensions.js +4 -3
- package/core/field.js +1061 -997
- package/core/field_angle.js +462 -442
- package/core/field_checkbox.js +194 -182
- package/core/field_colour.js +519 -505
- package/core/field_dropdown.js +617 -598
- package/core/field_image.js +229 -220
- package/core/field_label.js +102 -91
- package/core/field_label_serializable.js +42 -41
- package/core/field_multilineinput.js +372 -358
- package/core/field_number.js +272 -253
- package/core/field_textinput.js +499 -467
- package/core/field_variable.js +458 -420
- package/core/flyout_base.js +1005 -952
- package/core/flyout_button.js +277 -260
- package/core/flyout_horizontal.js +304 -302
- package/core/flyout_metrics_manager.js +64 -64
- package/core/flyout_vertical.js +306 -300
- package/core/generator.js +459 -446
- package/core/gesture.js +829 -813
- package/core/grid.js +166 -163
- package/core/icon.js +168 -159
- package/core/inject.js +7 -5
- package/core/input.js +257 -248
- package/core/insertion_marker_manager.js +655 -624
- package/core/internal_constants.js +0 -129
- package/core/keyboard_nav/ast_node.js +605 -596
- package/core/keyboard_nav/basic_cursor.js +166 -165
- package/core/keyboard_nav/cursor.js +99 -97
- package/core/keyboard_nav/marker.js +83 -79
- package/core/keyboard_nav/tab_navigate_cursor.js +18 -23
- package/core/marker_manager.js +153 -141
- package/core/menu.js +377 -372
- package/core/menuitem.js +223 -217
- package/core/metrics_manager.js +403 -390
- package/core/mutator.js +468 -437
- package/core/names.js +229 -188
- package/core/options.js +290 -284
- package/core/procedures.js +29 -17
- package/core/registry.js +19 -16
- package/core/rendered_connection.js +482 -463
- package/core/renderers/common/block_rendering.js +9 -3
- package/core/renderers/common/constants.js +1119 -1112
- package/core/renderers/common/debug.js +14 -0
- package/core/renderers/common/debugger.js +338 -316
- package/core/renderers/common/drawer.js +380 -370
- package/core/renderers/common/i_path_object.js +2 -2
- package/core/renderers/common/info.js +626 -618
- package/core/renderers/common/marker_svg.js +579 -541
- package/core/renderers/common/path_object.js +203 -200
- package/core/renderers/common/renderer.js +220 -218
- package/core/renderers/geras/constants.js +36 -36
- package/core/renderers/geras/drawer.js +155 -147
- package/core/renderers/geras/highlight_constants.js +244 -238
- package/core/renderers/geras/highlighter.js +231 -179
- package/core/renderers/geras/info.js +392 -369
- package/core/renderers/geras/measurables/inline_input.js +25 -19
- package/core/renderers/geras/measurables/statement_input.js +23 -17
- package/core/renderers/geras/path_object.js +106 -121
- package/core/renderers/geras/renderer.js +96 -98
- package/core/renderers/measurables/base.js +30 -18
- package/core/renderers/measurables/bottom_row.js +83 -80
- package/core/renderers/measurables/connection.js +22 -15
- package/core/renderers/measurables/external_value_input.js +35 -22
- package/core/renderers/measurables/field.js +35 -20
- package/core/renderers/measurables/hat.js +18 -13
- package/core/renderers/measurables/icon.js +24 -17
- package/core/renderers/measurables/in_row_spacer.js +15 -13
- package/core/renderers/measurables/inline_input.js +43 -33
- package/core/renderers/measurables/input_connection.js +41 -28
- package/core/renderers/measurables/input_row.js +50 -44
- package/core/renderers/measurables/jagged_edge.js +14 -12
- package/core/renderers/measurables/next_connection.js +16 -14
- package/core/renderers/measurables/output_connection.js +26 -20
- package/core/renderers/measurables/previous_connection.js +16 -15
- package/core/renderers/measurables/round_corner.js +20 -18
- package/core/renderers/measurables/row.js +184 -168
- package/core/renderers/measurables/spacer_row.js +38 -23
- package/core/renderers/measurables/square_corner.js +18 -16
- package/core/renderers/measurables/statement_input.js +23 -20
- package/core/renderers/measurables/top_row.js +88 -85
- package/core/renderers/minimalist/constants.js +8 -7
- package/core/renderers/minimalist/drawer.js +11 -10
- package/core/renderers/minimalist/info.js +18 -18
- package/core/renderers/minimalist/renderer.js +40 -39
- package/core/renderers/thrasos/info.js +258 -248
- package/core/renderers/thrasos/renderer.js +20 -20
- package/core/renderers/zelos/constants.js +898 -873
- package/core/renderers/zelos/drawer.js +186 -169
- package/core/renderers/zelos/info.js +502 -479
- package/core/renderers/zelos/marker_svg.js +129 -115
- package/core/renderers/zelos/measurables/bottom_row.js +31 -30
- package/core/renderers/zelos/measurables/inputs.js +22 -21
- package/core/renderers/zelos/measurables/row_elements.js +14 -13
- package/core/renderers/zelos/measurables/top_row.js +34 -33
- package/core/renderers/zelos/path_object.js +181 -180
- package/core/renderers/zelos/renderer.js +91 -92
- package/core/scrollbar.js +759 -713
- package/core/scrollbar_pair.js +250 -245
- package/core/serialization/blocks.js +19 -9
- package/core/serialization/workspaces.js +3 -2
- package/core/shortcut_registry.js +286 -277
- package/core/sprites.js +31 -0
- package/core/theme.js +135 -141
- package/core/theme_manager.js +147 -143
- package/core/toolbox/category.js +602 -576
- package/core/toolbox/collapsible_category.js +226 -227
- package/core/toolbox/separator.js +70 -61
- package/core/toolbox/toolbox.js +934 -927
- package/core/toolbox/toolbox_item.js +115 -99
- package/core/tooltip.js +108 -35
- package/core/touch.js +8 -3
- package/core/touch_gesture.js +254 -251
- package/core/trashcan.js +606 -595
- package/core/utils/coordinate.js +97 -95
- package/core/utils/dom.js +2 -2
- package/core/utils/global.js +2 -0
- package/core/utils/rect.js +41 -37
- package/core/utils/sentinel.js +25 -0
- package/core/utils/size.js +30 -27
- package/core/utils/svg.js +18 -16
- package/core/variable_map.js +325 -341
- package/core/variable_model.js +55 -54
- package/core/variables.js +9 -2
- package/core/variables_dynamic.js +3 -1
- package/core/warning.js +126 -120
- package/core/widgetdiv.js +4 -4
- package/core/workspace.js +685 -664
- package/core/workspace_audio.js +124 -118
- package/core/workspace_comment.js +308 -298
- package/core/workspace_comment_svg.js +1029 -951
- package/core/workspace_drag_surface_svg.js +147 -140
- package/core/workspace_dragger.js +70 -71
- package/core/workspace_svg.js +2322 -2297
- package/core/xml.js +30 -20
- package/core/zoom_controls.js +431 -439
- package/dart_compressed.js +40 -43
- package/dart_compressed.js.map +1 -1
- package/generators/dart/colour.js +56 -64
- package/generators/dart/lists.js +61 -50
- package/generators/dart/math.js +160 -148
- package/generators/dart/text.js +83 -61
- package/generators/javascript/colour.js +37 -34
- package/generators/javascript/lists.js +50 -43
- package/generators/javascript/math.js +123 -139
- package/generators/javascript/text.js +67 -81
- package/generators/lua/colour.js +25 -23
- package/generators/lua/lists.js +97 -69
- package/generators/lua/logic.js +1 -2
- package/generators/lua/math.js +182 -144
- package/generators/lua/text.js +116 -99
- package/generators/php/colour.js +38 -32
- package/generators/php/lists.js +109 -89
- package/generators/php/math.js +90 -81
- package/generators/php/text.js +63 -61
- package/generators/python/colour.js +18 -18
- package/generators/python/lists.js +38 -30
- package/generators/python/loops.js +12 -8
- package/generators/python/math.js +104 -106
- package/generators/python/text.js +34 -30
- package/javascript_compressed.js +37 -39
- package/javascript_compressed.js.map +1 -1
- package/lua_compressed.js +39 -42
- package/lua_compressed.js.map +1 -1
- package/msg/az.js +2 -2
- package/msg/be.js +4 -4
- package/msg/cs.js +15 -15
- package/msg/de.js +1 -1
- package/msg/diq.js +1 -1
- package/msg/eo.js +1 -1
- package/msg/es.js +1 -1
- package/msg/fa.js +1 -1
- package/msg/fr.js +4 -4
- package/msg/he.js +1 -1
- package/msg/hr.js +2 -2
- package/msg/hy.js +2 -2
- package/msg/id.js +12 -12
- package/msg/inh.js +14 -14
- package/msg/ja.js +7 -7
- package/msg/lv.js +29 -29
- package/msg/pa.js +3 -3
- package/msg/smn.js +436 -0
- package/msg/te.js +1 -1
- package/msg/yue.js +1 -1
- package/msg/zh-hans.js +3 -3
- package/msg/zh-hant.js +3 -3
- package/package.json +7 -6
- package/php_compressed.js +38 -42
- package/php_compressed.js.map +1 -1
- package/python_compressed.js +26 -25
- package/python_compressed.js.map +1 -1
- package/blocks/all.js +0 -23
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
'use strict';
|
|
11
11
|
|
|
12
|
+
|
|
12
13
|
/**
|
|
13
14
|
* Methods for rendering debug graphics.
|
|
14
15
|
* @class
|
|
@@ -21,7 +22,9 @@ const {BlockSvg} = goog.requireType('Blockly.BlockSvg');
|
|
|
21
22
|
const {ConnectionType} = goog.require('Blockly.ConnectionType');
|
|
22
23
|
/* eslint-disable-next-line no-unused-vars */
|
|
23
24
|
const {ConstantProvider} = goog.requireType('Blockly.blockRendering.ConstantProvider');
|
|
25
|
+
const {Field} = goog.require('Blockly.blockRendering.Field');
|
|
24
26
|
const {FieldLabel} = goog.require('Blockly.FieldLabel');
|
|
27
|
+
const {InputConnection} = goog.require('Blockly.blockRendering.InputConnection');
|
|
25
28
|
/* eslint-disable-next-line no-unused-vars */
|
|
26
29
|
const {InRowSpacer} = goog.requireType('Blockly.blockRendering.InRowSpacer');
|
|
27
30
|
/* eslint-disable-next-line no-unused-vars */
|
|
@@ -29,6 +32,8 @@ const {Measurable} = goog.requireType('Blockly.blockRendering.Measurable');
|
|
|
29
32
|
/* eslint-disable-next-line no-unused-vars */
|
|
30
33
|
const {RenderInfo} = goog.requireType('Blockly.blockRendering.RenderInfo');
|
|
31
34
|
/* eslint-disable-next-line no-unused-vars */
|
|
35
|
+
const {RenderInfo: ZelosInfo} = goog.requireType('Blockly.zelos.RenderInfo');
|
|
36
|
+
/* eslint-disable-next-line no-unused-vars */
|
|
32
37
|
const {RenderedConnection} = goog.requireType('Blockly.RenderedConnection');
|
|
33
38
|
/* eslint-disable-next-line no-unused-vars */
|
|
34
39
|
const {Row} = goog.requireType('Blockly.blockRendering.Row');
|
|
@@ -38,398 +43,415 @@ const {Types} = goog.require('Blockly.blockRendering.Types');
|
|
|
38
43
|
|
|
39
44
|
/**
|
|
40
45
|
* An object that renders rectangles and dots for debugging rendering code.
|
|
41
|
-
* @param {!ConstantProvider} constants The renderer's
|
|
42
|
-
* constants.
|
|
43
|
-
* @package
|
|
44
|
-
* @constructor
|
|
45
46
|
* @alias Blockly.blockRendering.Debug
|
|
46
47
|
*/
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* An array of SVG elements that have been created by this object.
|
|
50
|
-
* @type {Array<!SVGElement>}
|
|
51
|
-
* @private
|
|
52
|
-
*/
|
|
53
|
-
this.debugElements_ = [];
|
|
54
|
-
|
|
48
|
+
class Debug {
|
|
55
49
|
/**
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* @
|
|
59
|
-
* @private
|
|
50
|
+
* @param {!ConstantProvider} constants The renderer's
|
|
51
|
+
* constants.
|
|
52
|
+
* @package
|
|
60
53
|
*/
|
|
61
|
-
|
|
54
|
+
constructor(constants) {
|
|
55
|
+
/**
|
|
56
|
+
* An array of SVG elements that have been created by this object.
|
|
57
|
+
* @type {Array<!SVGElement>}
|
|
58
|
+
* @private
|
|
59
|
+
*/
|
|
60
|
+
this.debugElements_ = [];
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* The SVG root of the block that is being rendered. Debug elements will
|
|
64
|
+
* be attached to this root.
|
|
65
|
+
* @type {SVGElement}
|
|
66
|
+
* @private
|
|
67
|
+
*/
|
|
68
|
+
this.svgRoot_ = null;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The renderer's constant provider.
|
|
72
|
+
* @type {!ConstantProvider}
|
|
73
|
+
* @private
|
|
74
|
+
*/
|
|
75
|
+
this.constants_ = constants;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @type {string}
|
|
79
|
+
* @private
|
|
80
|
+
*/
|
|
81
|
+
this.randomColour_ = '';
|
|
82
|
+
}
|
|
62
83
|
|
|
63
84
|
/**
|
|
64
|
-
*
|
|
65
|
-
* @
|
|
66
|
-
* @private
|
|
85
|
+
* Remove all elements the this object created on the last pass.
|
|
86
|
+
* @package
|
|
67
87
|
*/
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
* rendering of specific rendering components.
|
|
74
|
-
* @type {!Object<string, boolean>}
|
|
75
|
-
*/
|
|
76
|
-
Debug.config = {
|
|
77
|
-
rowSpacers: true,
|
|
78
|
-
elemSpacers: true,
|
|
79
|
-
rows: true,
|
|
80
|
-
elems: true,
|
|
81
|
-
connections: true,
|
|
82
|
-
blockBounds: true,
|
|
83
|
-
connectedBlockBounds: true,
|
|
84
|
-
render: true,
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Remove all elements the this object created on the last pass.
|
|
89
|
-
* @package
|
|
90
|
-
*/
|
|
91
|
-
Debug.prototype.clearElems = function() {
|
|
92
|
-
for (let i = 0; i < this.debugElements_.length; i++) {
|
|
93
|
-
const elem = this.debugElements_[i];
|
|
94
|
-
dom.removeNode(elem);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
this.debugElements_ = [];
|
|
98
|
-
};
|
|
88
|
+
clearElems() {
|
|
89
|
+
for (let i = 0; i < this.debugElements_.length; i++) {
|
|
90
|
+
const elem = this.debugElements_[i];
|
|
91
|
+
dom.removeNode(elem);
|
|
92
|
+
}
|
|
99
93
|
|
|
100
|
-
|
|
101
|
-
* Draw a debug rectangle for a spacer (empty) row.
|
|
102
|
-
* @param {!Row} row The row to render.
|
|
103
|
-
* @param {number} cursorY The y position of the top of the row.
|
|
104
|
-
* @param {boolean} isRtl Whether the block is rendered RTL.
|
|
105
|
-
* @package
|
|
106
|
-
*/
|
|
107
|
-
Debug.prototype.drawSpacerRow = function(row, cursorY, isRtl) {
|
|
108
|
-
if (!Debug.config.rowSpacers) {
|
|
109
|
-
return;
|
|
94
|
+
this.debugElements_ = [];
|
|
110
95
|
}
|
|
111
96
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
97
|
+
/**
|
|
98
|
+
* Draw a debug rectangle for a spacer (empty) row.
|
|
99
|
+
* @param {!Row} row The row to render.
|
|
100
|
+
* @param {number} cursorY The y position of the top of the row.
|
|
101
|
+
* @param {boolean} isRtl Whether the block is rendered RTL.
|
|
102
|
+
* @package
|
|
103
|
+
*/
|
|
104
|
+
drawSpacerRow(row, cursorY, isRtl) {
|
|
105
|
+
if (!Debug.config.rowSpacers) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
117
108
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
'width': row.width,
|
|
124
|
-
'height': height,
|
|
125
|
-
'stroke': isNegativeSpacing ? 'black' : 'blue',
|
|
126
|
-
'fill': 'blue',
|
|
127
|
-
'fill-opacity': '0.5',
|
|
128
|
-
'stroke-width': '1px',
|
|
129
|
-
},
|
|
130
|
-
this.svgRoot_));
|
|
131
|
-
};
|
|
109
|
+
const height = Math.abs(row.height);
|
|
110
|
+
const isNegativeSpacing = row.height < 0;
|
|
111
|
+
if (isNegativeSpacing) {
|
|
112
|
+
cursorY -= height;
|
|
113
|
+
}
|
|
132
114
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
115
|
+
this.debugElements_.push(dom.createSvgElement(
|
|
116
|
+
Svg.RECT, {
|
|
117
|
+
'class': 'rowSpacerRect blockRenderDebug',
|
|
118
|
+
'x': isRtl ? -(row.xPos + row.width) : row.xPos,
|
|
119
|
+
'y': cursorY,
|
|
120
|
+
'width': row.width,
|
|
121
|
+
'height': height,
|
|
122
|
+
'stroke': isNegativeSpacing ? 'black' : 'blue',
|
|
123
|
+
'fill': 'blue',
|
|
124
|
+
'fill-opacity': '0.5',
|
|
125
|
+
'stroke-width': '1px',
|
|
126
|
+
},
|
|
127
|
+
this.svgRoot_));
|
|
143
128
|
}
|
|
144
129
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
'y': yPos,
|
|
157
|
-
'width': width,
|
|
158
|
-
'height': elem.height,
|
|
159
|
-
'stroke': 'pink',
|
|
160
|
-
'fill': isNegativeSpacing ? 'black' : 'pink',
|
|
161
|
-
'fill-opacity': '0.5',
|
|
162
|
-
'stroke-width': '1px',
|
|
163
|
-
},
|
|
164
|
-
this.svgRoot_));
|
|
165
|
-
};
|
|
130
|
+
/**
|
|
131
|
+
* Draw a debug rectangle for a horizontal spacer.
|
|
132
|
+
* @param {!InRowSpacer} elem The spacer to render.
|
|
133
|
+
* @param {number} rowHeight The height of the container row.
|
|
134
|
+
* @param {boolean} isRtl Whether the block is rendered RTL.
|
|
135
|
+
* @package
|
|
136
|
+
*/
|
|
137
|
+
drawSpacerElem(elem, rowHeight, isRtl) {
|
|
138
|
+
if (!Debug.config.elemSpacers) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
166
141
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
* @param {boolean} isRtl Whether the block is rendered RTL.
|
|
171
|
-
* @package
|
|
172
|
-
*/
|
|
173
|
-
Debug.prototype.drawRenderedElem = function(elem, isRtl) {
|
|
174
|
-
if (Debug.config.elems) {
|
|
175
|
-
let xPos = elem.xPos;
|
|
142
|
+
const width = Math.abs(elem.width);
|
|
143
|
+
const isNegativeSpacing = elem.width < 0;
|
|
144
|
+
let xPos = isNegativeSpacing ? elem.xPos - width : elem.xPos;
|
|
176
145
|
if (isRtl) {
|
|
177
|
-
xPos = -(xPos +
|
|
146
|
+
xPos = -(xPos + width);
|
|
178
147
|
}
|
|
179
148
|
const yPos = elem.centerline - elem.height / 2;
|
|
180
149
|
this.debugElements_.push(dom.createSvgElement(
|
|
181
150
|
Svg.RECT, {
|
|
182
|
-
'class': '
|
|
151
|
+
'class': 'elemSpacerRect blockRenderDebug',
|
|
183
152
|
'x': xPos,
|
|
184
153
|
'y': yPos,
|
|
185
|
-
'width':
|
|
154
|
+
'width': width,
|
|
186
155
|
'height': elem.height,
|
|
187
|
-
'stroke': '
|
|
188
|
-
'fill': '
|
|
156
|
+
'stroke': 'pink',
|
|
157
|
+
'fill': isNegativeSpacing ? 'black' : 'pink',
|
|
158
|
+
'fill-opacity': '0.5',
|
|
189
159
|
'stroke-width': '1px',
|
|
190
160
|
},
|
|
191
161
|
this.svgRoot_));
|
|
162
|
+
}
|
|
192
163
|
|
|
193
|
-
|
|
194
|
-
|
|
164
|
+
/**
|
|
165
|
+
* Draw a debug rectangle for an in-row element.
|
|
166
|
+
* @param {!Measurable} elem The element to render.
|
|
167
|
+
* @param {boolean} isRtl Whether the block is rendered RTL.
|
|
168
|
+
* @package
|
|
169
|
+
*/
|
|
170
|
+
drawRenderedElem(elem, isRtl) {
|
|
171
|
+
if (Debug.config.elems) {
|
|
172
|
+
let xPos = elem.xPos;
|
|
173
|
+
if (isRtl) {
|
|
174
|
+
xPos = -(xPos + elem.width);
|
|
175
|
+
}
|
|
176
|
+
const yPos = elem.centerline - elem.height / 2;
|
|
195
177
|
this.debugElements_.push(dom.createSvgElement(
|
|
196
178
|
Svg.RECT, {
|
|
197
179
|
'class': 'rowRenderingRect blockRenderDebug',
|
|
198
180
|
'x': xPos,
|
|
199
|
-
'y': yPos
|
|
181
|
+
'y': yPos,
|
|
200
182
|
'width': elem.width,
|
|
201
|
-
'height':
|
|
202
|
-
'stroke': '
|
|
183
|
+
'height': elem.height,
|
|
184
|
+
'stroke': 'black',
|
|
203
185
|
'fill': 'none',
|
|
204
|
-
'stroke-width': '
|
|
186
|
+
'stroke-width': '1px',
|
|
205
187
|
},
|
|
206
188
|
this.svgRoot_));
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
189
|
|
|
190
|
+
if (Types.isField(elem) && elem instanceof Field &&
|
|
191
|
+
elem.field instanceof FieldLabel) {
|
|
192
|
+
const baseline = this.constants_.FIELD_TEXT_BASELINE;
|
|
193
|
+
this.debugElements_.push(dom.createSvgElement(
|
|
194
|
+
Svg.RECT, {
|
|
195
|
+
'class': 'rowRenderingRect blockRenderDebug',
|
|
196
|
+
'x': xPos,
|
|
197
|
+
'y': yPos + baseline,
|
|
198
|
+
'width': elem.width,
|
|
199
|
+
'height': '0.1px',
|
|
200
|
+
'stroke': 'red',
|
|
201
|
+
'fill': 'none',
|
|
202
|
+
'stroke-width': '0.5px',
|
|
203
|
+
},
|
|
204
|
+
this.svgRoot_));
|
|
205
|
+
}
|
|
206
|
+
}
|
|
210
207
|
|
|
211
|
-
if (Types.isInput(elem) && Debug.config.connections) {
|
|
212
|
-
this.drawConnection(elem.connectionModel);
|
|
213
|
-
}
|
|
214
|
-
};
|
|
215
208
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
* @param {RenderedConnection} conn The connection to circle.
|
|
221
|
-
* @suppress {visibility} Suppress visibility of conn.offsetInBlock_ since this
|
|
222
|
-
* is a debug module.
|
|
223
|
-
* @package
|
|
224
|
-
*/
|
|
225
|
-
Debug.prototype.drawConnection = function(conn) {
|
|
226
|
-
if (!Debug.config.connections) {
|
|
227
|
-
return;
|
|
209
|
+
if (Types.isInput(elem) && elem instanceof InputConnection &&
|
|
210
|
+
Debug.config.connections) {
|
|
211
|
+
this.drawConnection(elem.connectionModel);
|
|
212
|
+
}
|
|
228
213
|
}
|
|
229
214
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
colour = 'goldenrod';
|
|
244
|
-
fill = 'none';
|
|
245
|
-
} else if (conn.type === ConnectionType.PREVIOUS_STATEMENT) {
|
|
246
|
-
size = 2;
|
|
247
|
-
colour = 'goldenrod';
|
|
248
|
-
fill = colour;
|
|
249
|
-
}
|
|
250
|
-
this.debugElements_.push(dom.createSvgElement(
|
|
251
|
-
Svg.CIRCLE, {
|
|
252
|
-
'class': 'blockRenderDebug',
|
|
253
|
-
'cx': conn.offsetInBlock_.x,
|
|
254
|
-
'cy': conn.offsetInBlock_.y,
|
|
255
|
-
'r': size,
|
|
256
|
-
'fill': fill,
|
|
257
|
-
'stroke': colour,
|
|
258
|
-
},
|
|
259
|
-
this.svgRoot_));
|
|
260
|
-
};
|
|
215
|
+
/**
|
|
216
|
+
* Draw a circle at the location of the given connection. Inputs and outputs
|
|
217
|
+
* share the same colours, as do previous and next. When positioned correctly
|
|
218
|
+
* a connected pair will look like a bullseye.
|
|
219
|
+
* @param {RenderedConnection} conn The connection to circle.
|
|
220
|
+
* @suppress {visibility} Suppress visibility of conn.offsetInBlock_ since
|
|
221
|
+
* this is a debug module.
|
|
222
|
+
* @package
|
|
223
|
+
*/
|
|
224
|
+
drawConnection(conn) {
|
|
225
|
+
if (!Debug.config.connections) {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
261
228
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
229
|
+
let colour;
|
|
230
|
+
let size;
|
|
231
|
+
let fill;
|
|
232
|
+
if (conn.type === ConnectionType.INPUT_VALUE) {
|
|
233
|
+
size = 4;
|
|
234
|
+
colour = 'magenta';
|
|
235
|
+
fill = 'none';
|
|
236
|
+
} else if (conn.type === ConnectionType.OUTPUT_VALUE) {
|
|
237
|
+
size = 2;
|
|
238
|
+
colour = 'magenta';
|
|
239
|
+
fill = colour;
|
|
240
|
+
} else if (conn.type === ConnectionType.NEXT_STATEMENT) {
|
|
241
|
+
size = 4;
|
|
242
|
+
colour = 'goldenrod';
|
|
243
|
+
fill = 'none';
|
|
244
|
+
} else if (conn.type === ConnectionType.PREVIOUS_STATEMENT) {
|
|
245
|
+
size = 2;
|
|
246
|
+
colour = 'goldenrod';
|
|
247
|
+
fill = colour;
|
|
248
|
+
}
|
|
249
|
+
this.debugElements_.push(dom.createSvgElement(
|
|
250
|
+
Svg.CIRCLE, {
|
|
251
|
+
'class': 'blockRenderDebug',
|
|
252
|
+
'cx': conn.offsetInBlock_.x,
|
|
253
|
+
'cy': conn.offsetInBlock_.y,
|
|
254
|
+
'r': size,
|
|
255
|
+
'fill': fill,
|
|
256
|
+
'stroke': colour,
|
|
257
|
+
},
|
|
258
|
+
this.svgRoot_));
|
|
288
259
|
}
|
|
289
260
|
|
|
290
|
-
|
|
261
|
+
/**
|
|
262
|
+
* Draw a debug rectangle for a non-empty row.
|
|
263
|
+
* @param {!Row} row The non-empty row to render.
|
|
264
|
+
* @param {number} cursorY The y position of the top of the row.
|
|
265
|
+
* @param {boolean} isRtl Whether the block is rendered RTL.
|
|
266
|
+
* @package
|
|
267
|
+
*/
|
|
268
|
+
drawRenderedRow(row, cursorY, isRtl) {
|
|
269
|
+
if (!Debug.config.rows) {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
291
272
|
this.debugElements_.push(dom.createSvgElement(
|
|
292
273
|
Svg.RECT, {
|
|
293
|
-
'class': '
|
|
294
|
-
'x': isRtl ? -(row.xPos + row.
|
|
274
|
+
'class': 'elemRenderingRect blockRenderDebug',
|
|
275
|
+
'x': isRtl ? -(row.xPos + row.width) : row.xPos,
|
|
295
276
|
'y': row.yPos,
|
|
296
|
-
'width': row.
|
|
277
|
+
'width': row.width,
|
|
297
278
|
'height': row.height,
|
|
298
|
-
'stroke':
|
|
279
|
+
'stroke': 'red',
|
|
299
280
|
'fill': 'none',
|
|
300
281
|
'stroke-width': '1px',
|
|
301
|
-
'stroke-dasharray': '3,3',
|
|
302
282
|
},
|
|
303
283
|
this.svgRoot_));
|
|
304
|
-
}
|
|
305
|
-
};
|
|
306
284
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
* @param {!Row} row The non-empty row to render.
|
|
310
|
-
* @param {number} cursorY The y position of the top of the row.
|
|
311
|
-
* @param {boolean} isRtl Whether the block is rendered RTL.
|
|
312
|
-
* @package
|
|
313
|
-
*/
|
|
314
|
-
Debug.prototype.drawRowWithElements = function(row, cursorY, isRtl) {
|
|
315
|
-
for (let i = 0; i < row.elements.length; i++) {
|
|
316
|
-
const elem = row.elements[i];
|
|
317
|
-
if (!elem) {
|
|
318
|
-
console.warn('A row has an undefined or null element.', row, elem);
|
|
319
|
-
continue;
|
|
285
|
+
if (Types.isTopOrBottomRow(row)) {
|
|
286
|
+
return;
|
|
320
287
|
}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
288
|
+
|
|
289
|
+
if (Debug.config.connectedBlockBounds) {
|
|
290
|
+
this.debugElements_.push(dom.createSvgElement(
|
|
291
|
+
Svg.RECT, {
|
|
292
|
+
'class': 'connectedBlockWidth blockRenderDebug',
|
|
293
|
+
'x': isRtl ? -(row.xPos + row.widthWithConnectedBlocks) : row.xPos,
|
|
294
|
+
'y': row.yPos,
|
|
295
|
+
'width': row.widthWithConnectedBlocks,
|
|
296
|
+
'height': row.height,
|
|
297
|
+
'stroke': this.randomColour_,
|
|
298
|
+
'fill': 'none',
|
|
299
|
+
'stroke-width': '1px',
|
|
300
|
+
'stroke-dasharray': '3,3',
|
|
301
|
+
},
|
|
302
|
+
this.svgRoot_));
|
|
326
303
|
}
|
|
327
304
|
}
|
|
328
|
-
this.drawRenderedRow(row, cursorY, isRtl);
|
|
329
|
-
};
|
|
330
305
|
|
|
331
|
-
/**
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
306
|
+
/**
|
|
307
|
+
* Draw debug rectangles for a non-empty row and all of its subcomponents.
|
|
308
|
+
* @param {!Row} row The non-empty row to render.
|
|
309
|
+
* @param {number} cursorY The y position of the top of the row.
|
|
310
|
+
* @param {boolean} isRtl Whether the block is rendered RTL.
|
|
311
|
+
* @package
|
|
312
|
+
*/
|
|
313
|
+
drawRowWithElements(row, cursorY, isRtl) {
|
|
314
|
+
for (let i = 0; i < row.elements.length; i++) {
|
|
315
|
+
const elem = row.elements[i];
|
|
316
|
+
if (!elem) {
|
|
317
|
+
console.warn('A row has an undefined or null element.', row, elem);
|
|
318
|
+
continue;
|
|
319
|
+
}
|
|
320
|
+
if (Types.isSpacer(elem)) {
|
|
321
|
+
this.drawSpacerElem(
|
|
322
|
+
/** @type {!InRowSpacer} */ (elem), row.height, isRtl);
|
|
323
|
+
} else {
|
|
324
|
+
this.drawRenderedElem(elem, isRtl);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
this.drawRenderedRow(row, cursorY, isRtl);
|
|
340
328
|
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
},
|
|
356
|
-
this.svgRoot_));
|
|
357
|
-
|
|
358
|
-
if (Debug.config.connectedBlockBounds) {
|
|
359
|
-
// Bounding box with children.
|
|
360
|
-
xPos = info.RTL ? -info.widthWithChildren : 0;
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Draw a debug rectangle around the entire block.
|
|
332
|
+
* @param {!RenderInfo} info Rendering information about
|
|
333
|
+
* the block to debug.
|
|
334
|
+
* @package
|
|
335
|
+
*/
|
|
336
|
+
drawBoundingBox(info) {
|
|
337
|
+
if (!Debug.config.blockBounds) {
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
// Bounding box without children.
|
|
341
|
+
let xPos = info.RTL ? -info.width : 0;
|
|
342
|
+
const yPos = 0;
|
|
361
343
|
this.debugElements_.push(dom.createSvgElement(
|
|
362
344
|
Svg.RECT, {
|
|
363
|
-
'class': 'blockRenderDebug',
|
|
345
|
+
'class': 'blockBoundingBox blockRenderDebug',
|
|
364
346
|
'x': xPos,
|
|
365
347
|
'y': yPos,
|
|
366
|
-
'width': info.
|
|
348
|
+
'width': info.width,
|
|
367
349
|
'height': info.height,
|
|
368
|
-
'stroke': '
|
|
350
|
+
'stroke': 'black',
|
|
369
351
|
'fill': 'none',
|
|
370
352
|
'stroke-width': '1px',
|
|
371
|
-
'stroke-dasharray': '
|
|
353
|
+
'stroke-dasharray': '5,5',
|
|
372
354
|
},
|
|
373
355
|
this.svgRoot_));
|
|
374
|
-
}
|
|
375
|
-
};
|
|
376
356
|
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
if (Types.isBetweenRowSpacer(row)) {
|
|
394
|
-
this.drawSpacerRow(row, cursorY, info.RTL);
|
|
395
|
-
} else {
|
|
396
|
-
this.drawRowWithElements(row, cursorY, info.RTL);
|
|
357
|
+
if (Debug.config.connectedBlockBounds) {
|
|
358
|
+
// Bounding box with children.
|
|
359
|
+
xPos = info.RTL ? -info.widthWithChildren : 0;
|
|
360
|
+
this.debugElements_.push(dom.createSvgElement(
|
|
361
|
+
Svg.RECT, {
|
|
362
|
+
'class': 'blockRenderDebug',
|
|
363
|
+
'x': xPos,
|
|
364
|
+
'y': yPos,
|
|
365
|
+
'width': info.widthWithChildren,
|
|
366
|
+
'height': info.height,
|
|
367
|
+
'stroke': '#DF57BC',
|
|
368
|
+
'fill': 'none',
|
|
369
|
+
'stroke-width': '1px',
|
|
370
|
+
'stroke-dasharray': '3,3',
|
|
371
|
+
},
|
|
372
|
+
this.svgRoot_));
|
|
397
373
|
}
|
|
398
|
-
cursorY += row.height;
|
|
399
374
|
}
|
|
400
375
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
376
|
+
/**
|
|
377
|
+
* Do all of the work to draw debug information for the whole block.
|
|
378
|
+
* @param {!BlockSvg} block The block to draw debug information for.
|
|
379
|
+
* @param {!RenderInfo} info Rendering information about
|
|
380
|
+
* the block to debug.
|
|
381
|
+
* @package
|
|
382
|
+
*/
|
|
383
|
+
drawDebug(block, info) {
|
|
384
|
+
this.clearElems();
|
|
385
|
+
this.svgRoot_ = block.getSvgRoot();
|
|
386
|
+
|
|
387
|
+
this.randomColour_ =
|
|
388
|
+
'#' + Math.floor(Math.random() * 16777215).toString(16);
|
|
389
|
+
|
|
390
|
+
let cursorY = 0;
|
|
391
|
+
for (let i = 0; i < info.rows.length; i++) {
|
|
392
|
+
const row = info.rows[i];
|
|
393
|
+
if (Types.isBetweenRowSpacer(row)) {
|
|
394
|
+
this.drawSpacerRow(row, cursorY, info.RTL);
|
|
395
|
+
} else {
|
|
396
|
+
this.drawRowWithElements(row, cursorY, info.RTL);
|
|
397
|
+
}
|
|
398
|
+
cursorY += row.height;
|
|
399
|
+
}
|
|
413
400
|
|
|
414
|
-
|
|
401
|
+
if (block.previousConnection) {
|
|
402
|
+
this.drawConnection(block.previousConnection);
|
|
403
|
+
}
|
|
404
|
+
if (block.nextConnection) {
|
|
405
|
+
this.drawConnection(block.nextConnection);
|
|
406
|
+
}
|
|
407
|
+
if (block.outputConnection) {
|
|
408
|
+
this.drawConnection(block.outputConnection);
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* TODO: Find a better way to do this check without pulling in all of
|
|
412
|
+
* zelos, or just delete this line or the whole debug renderer.
|
|
413
|
+
*/
|
|
414
|
+
const maybeZelosInfo = /** @type {!ZelosInfo} */ (info);
|
|
415
|
+
if (maybeZelosInfo.rightSide) {
|
|
416
|
+
this.drawRenderedElem(maybeZelosInfo.rightSide, info.RTL);
|
|
417
|
+
}
|
|
415
418
|
|
|
416
|
-
|
|
417
|
-
|
|
419
|
+
this.drawBoundingBox(info);
|
|
420
|
+
|
|
421
|
+
this.drawRender(block.pathObject.svgPath);
|
|
422
|
+
}
|
|
418
423
|
|
|
424
|
+
/**
|
|
425
|
+
* Show a debug filter to highlight that a block has been rendered.
|
|
426
|
+
* @param {!SVGElement} svgPath The block's SVG path.
|
|
427
|
+
* @package
|
|
428
|
+
*/
|
|
429
|
+
drawRender(svgPath) {
|
|
430
|
+
if (!Debug.config.render) {
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
svgPath.setAttribute(
|
|
434
|
+
'filter', 'url(#' + this.constants_.debugFilterId + ')');
|
|
435
|
+
setTimeout(function() {
|
|
436
|
+
svgPath.setAttribute('filter', '');
|
|
437
|
+
}, 100);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
419
440
|
|
|
420
441
|
/**
|
|
421
|
-
*
|
|
422
|
-
*
|
|
423
|
-
* @
|
|
442
|
+
* Configuration object containing booleans to enable and disable debug
|
|
443
|
+
* rendering of specific rendering components.
|
|
444
|
+
* @type {!Object<string, boolean>}
|
|
424
445
|
*/
|
|
425
|
-
Debug.
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
446
|
+
Debug.config = {
|
|
447
|
+
rowSpacers: true,
|
|
448
|
+
elemSpacers: true,
|
|
449
|
+
rows: true,
|
|
450
|
+
elems: true,
|
|
451
|
+
connections: true,
|
|
452
|
+
blockBounds: true,
|
|
453
|
+
connectedBlockBounds: true,
|
|
454
|
+
render: true,
|
|
433
455
|
};
|
|
434
456
|
|
|
435
457
|
exports.Debug = Debug;
|