From 51ff00b04601bff7fdb58621ec06823eb1d7ae4c Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Mon, 7 Oct 2019 11:08:45 -0700 Subject: [PATCH 01/21] Re-added resizeBubble_ call. Fixed resizeBubble_ JSDoc. (#3173) --- core/mutator.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/mutator.js b/core/mutator.js index 0f35789f3..b459cab58 100644 --- a/core/mutator.js +++ b/core/mutator.js @@ -202,8 +202,7 @@ Blockly.Mutator.prototype.updateEditable = function() { }; /** - * Callback function triggered when the bubble has resized. - * Resize the workspace accordingly. + * Resize the bubble to match the size of the workspace. * @private */ Blockly.Mutator.prototype.resizeBubble_ = function() { @@ -294,6 +293,7 @@ Blockly.Mutator.prototype.setVisible = function(visible) { }; this.block_.workspace.addChangeListener(this.sourceListener_); } + this.resizeBubble_(); // When the mutator's workspace changes, update the source block. this.workspace_.addChangeListener(this.workspaceChanged_.bind(this)); this.updateColour(); From 101bf3d94f25460c260da4c02ecc227960f143c2 Mon Sep 17 00:00:00 2001 From: alschmiedt Date: Mon, 7 Oct 2019 14:37:36 -0700 Subject: [PATCH 02/21] Fix capitalization (#3182) (#3189) --- demos/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/index.html b/demos/index.html index eb06f3d7c..1b22326a3 100644 --- a/demos/index.html +++ b/demos/index.html @@ -239,7 +239,7 @@ -
Keyboard Navigation
+
Keyboard Navigation
Demos keyboard navigation.
From 60d69b9dbaafd1d06c8a973a5e402c1e57d171a1 Mon Sep 17 00:00:00 2001 From: Sam El-Husseini Date: Mon, 7 Oct 2019 17:28:18 -0700 Subject: [PATCH 03/21] Add support for setting the direction in RTL. (#3192) --- core/dropdowndiv.js | 34 +++++++++++++++++++++------------- core/field_colour.js | 1 + 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/core/dropdowndiv.js b/core/dropdowndiv.js index 551aa03b9..5132b99a4 100644 --- a/core/dropdowndiv.js +++ b/core/dropdowndiv.js @@ -62,7 +62,7 @@ Blockly.DropDownDiv.owner_ = null; /** * Whether the dropdown was positioned to a field or the source block. - * @type {boolean} + * @type {?boolean} * @private */ Blockly.DropDownDiv.positionToField_ = null; @@ -119,15 +119,15 @@ Blockly.DropDownDiv.DEFAULT_DROPDOWN_COLOR = '#fff'; /** * Timer for animation out, to be cleared if we need to immediately hide * without disrupting new shows. - * @type {number} + * @type {?number} */ Blockly.DropDownDiv.animateOutTimer_ = null; /** * Callback for when the drop-down is hidden. - * @type {Function} + * @type {?Function} */ -Blockly.DropDownDiv.onHide_ = 0; +Blockly.DropDownDiv.onHide_ = null; /** * Create and insert the DOM element for this div. @@ -246,7 +246,7 @@ Blockly.DropDownDiv.showPositionedByBlock = function(field, block, Blockly.DropDownDiv.setBoundsElement( block.workspace.getParentSvg().parentNode); return Blockly.DropDownDiv.show( - field, primaryX, primaryY, secondaryX, secondaryY, opt_onHide); + field, block.RTL, primaryX, primaryY, secondaryX, secondaryY, opt_onHide); }; /** @@ -254,16 +254,16 @@ Blockly.DropDownDiv.showPositionedByBlock = function(field, block, * by a particular field. The primary position will be below the field, * and the secondary position above the field. Drop-down will be * constrained to the block's workspace. - * @param {!Object} owner The object showing the drop-down. + * @param {!Blockly.Field} field The field to position the dropdown against. * @param {Function=} opt_onHide Optional callback for when the drop-down is * hidden. * @param {number=} opt_secondaryYOffset Optional Y offset for above-block * positioning. * @return {boolean} True if the menu rendered below block; false if above. */ -Blockly.DropDownDiv.showPositionedByField = function(owner, +Blockly.DropDownDiv.showPositionedByField = function(field, opt_onHide, opt_secondaryYOffset) { - var position = owner.fieldGroup_.getBoundingClientRect(); + var position = field.fieldGroup_.getBoundingClientRect(); // If we can fit it, render below the block. var primaryX = position.left + position.width / 2; var primaryY = position.bottom; @@ -273,12 +273,14 @@ Blockly.DropDownDiv.showPositionedByField = function(owner, if (opt_secondaryYOffset) { secondaryY += opt_secondaryYOffset; } + var sourceBlock = field.getSourceBlock(); // Set bounds to workspace; show the drop-down. Blockly.DropDownDiv.positionToField_ = true; Blockly.DropDownDiv.setBoundsElement( - owner.getSourceBlock().workspace.getParentSvg().parentNode); + sourceBlock.workspace.getParentSvg().parentNode); return Blockly.DropDownDiv.show( - owner, primaryX, primaryY, secondaryX, secondaryY, opt_onHide); + field, sourceBlock.RTL, + primaryX, primaryY, secondaryX, secondaryY, opt_onHide); }; /** @@ -290,17 +292,19 @@ Blockly.DropDownDiv.showPositionedByField = function(owner, * If we can't maintain the container bounds at the primary point, fall-back to the * secondary point and position above. * @param {Object} owner The object showing the drop-down + * @param {boolean} rtl Right-to-left (true) or left-to-right (false). * @param {number} primaryX Desired origin point x, in absolute px * @param {number} primaryY Desired origin point y, in absolute px * @param {number} secondaryX Secondary/alternative origin point x, in absolute px * @param {number} secondaryY Secondary/alternative origin point y, in absolute px * @param {Function=} opt_onHide Optional callback for when the drop-down is hidden * @return {boolean} True if the menu rendered at the primary origin point. + * @package */ -Blockly.DropDownDiv.show = function(owner, primaryX, primaryY, +Blockly.DropDownDiv.show = function(owner, rtl, primaryX, primaryY, secondaryX, secondaryY, opt_onHide) { Blockly.DropDownDiv.owner_ = owner; - Blockly.DropDownDiv.onHide_ = opt_onHide; + Blockly.DropDownDiv.onHide_ = opt_onHide || null; var metrics = Blockly.DropDownDiv.getPositionMetrics(primaryX, primaryY, secondaryX, secondaryY); // Update arrow CSS. @@ -314,6 +318,9 @@ Blockly.DropDownDiv.show = function(owner, primaryX, primaryY, Blockly.DropDownDiv.arrow_.style.display = 'none'; } + // Set direction. + Blockly.DropDownDiv.DIV_.style.direction = rtl ? 'rtl' : 'ltr'; + // When we change `translate` multiple times in close succession, // Chrome may choose to wait and apply them all at once. // Since we want the translation to initial X, Y to be immediate, @@ -364,7 +371,8 @@ Blockly.DropDownDiv.getBoundsInfo_ = function() { Blockly.DropDownDiv.getPositionMetrics = function(primaryX, primaryY, secondaryX, secondaryY) { var boundsInfo = Blockly.DropDownDiv.getBoundsInfo_(); - var divSize = Blockly.utils.style.getSize(Blockly.DropDownDiv.DIV_); + var divSize = Blockly.utils.style.getSize( + /** @type {!Element} */ (Blockly.DropDownDiv.DIV_)); // Can we fit in-bounds below the target? if (primaryY + divSize.height < boundsInfo.bottom) { diff --git a/core/field_colour.js b/core/field_colour.js index 75c4e2c65..88c9891d4 100644 --- a/core/field_colour.js +++ b/core/field_colour.js @@ -507,6 +507,7 @@ Blockly.FieldColour.prototype.dropdownCreate_ = function() { var table = document.createElement('table'); table.className = 'blocklyColourTable'; table.tabIndex = 0; + table.dir = 'ltr'; Blockly.utils.aria.setRole(table, Blockly.utils.aria.Role.GRID); Blockly.utils.aria.setState(table, From cbf8b4b18d09af292a8f3382e15cbe58c32d71f5 Mon Sep 17 00:00:00 2001 From: Sam El-Husseini Date: Tue, 8 Oct 2019 11:12:29 -0700 Subject: [PATCH 04/21] Add setLocale to the Blockly typescript definition file. (#3197) --- gulpfile.js | 1 - typings/blockly.d.ts | 14 +++++++------- typings/parts/blockly-interfaces.d.ts | 7 +++++++ typings/parts/goog-closure.d.ts | 6 ------ 4 files changed, 14 insertions(+), 14 deletions(-) delete mode 100644 typings/parts/goog-closure.d.ts diff --git a/gulpfile.js b/gulpfile.js index aee799e8b..f4959161e 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -369,7 +369,6 @@ gulp.task('typings', function (cb) { const srcs = [ 'typings/parts/blockly-header.d.ts', 'typings/parts/blockly-interfaces.d.ts', - 'typings/parts/goog-closure.d.ts', `${tmpDir}/core/**`, `${tmpDir}/core/components/**`, `${tmpDir}/core/components/tree/**`, diff --git a/typings/blockly.d.ts b/typings/blockly.d.ts index 2043e6fd2..a8136d568 100644 --- a/typings/blockly.d.ts +++ b/typings/blockly.d.ts @@ -79,13 +79,13 @@ declare module Blockly { viewWidth: number; } -} - -declare namespace goog { - function require(name: string): void; - function provide(name: string): void; - function inherits(child: any, parent: any): void; - function isFunction(f: any): boolean; + /** + * Set the Blockly locale. + * Note: this method is only available in the npm release of Blockly. + * @param {!Object} msg An object of Blockly message strings in the desired + * language. + */ + function setLocale(msg: {[key: string]: string;}): void; } diff --git a/typings/parts/blockly-interfaces.d.ts b/typings/parts/blockly-interfaces.d.ts index 5241054c8..a7a7879bb 100644 --- a/typings/parts/blockly-interfaces.d.ts +++ b/typings/parts/blockly-interfaces.d.ts @@ -56,4 +56,11 @@ declare module Blockly { viewWidth: number; } + /** + * Set the Blockly locale. + * Note: this method is only available in the npm release of Blockly. + * @param {!Object} msg An object of Blockly message strings in the desired + * language. + */ + function setLocale(msg: {[key: string]: string;}): void; } diff --git a/typings/parts/goog-closure.d.ts b/typings/parts/goog-closure.d.ts deleted file mode 100644 index 367be8352..000000000 --- a/typings/parts/goog-closure.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -declare namespace goog { - function require(name: string): void; - function provide(name: string): void; - function inherits(child: any, parent: any): void; - function isFunction(f: any): boolean; -} From 6ff3ff2e851f2c9aa4c10314b9f2d25b5f88ca04 Mon Sep 17 00:00:00 2001 From: RoboErikG Date: Tue, 8 Oct 2019 11:31:48 -0700 Subject: [PATCH 05/21] Set correct defaults for Fields (#3179) (#3195) null was being converted to 0 by Number() when it should cause the default value to be set instead. This updates FieldNumber and FieldAngle to handle nulls correctly. Also update jsdoc. Fixes #3177 --- core/field.js | 2 +- core/field_angle.js | 30 ++++++++++++----- core/field_number.js | 57 ++++++++++++++++++++------------ core/field_textinput.js | 2 +- tests/mocha/field_angle_test.js | 33 ++++++++++++++++++ tests/mocha/field_number_test.js | 18 ++++++++++ 6 files changed, 109 insertions(+), 33 deletions(-) diff --git a/core/field.js b/core/field.js index ebc8813f6..ad7477830 100644 --- a/core/field.js +++ b/core/field.js @@ -39,7 +39,7 @@ goog.require('Blockly.utils.style'); /** * Abstract class for an editable field. * @param {*} value The initial value of the field. - * @param {Function=} opt_validator A function that is called to validate + * @param {?Function=} opt_validator A function that is called to validate * changes to the field's value. Takes in a value & returns a validated * value, or null to abort the change. * @param {Object=} opt_config A map of options used to configure the field. See diff --git a/core/field_angle.js b/core/field_angle.js index e383598d8..a8f9fb869 100644 --- a/core/field_angle.js +++ b/core/field_angle.js @@ -172,20 +172,32 @@ Blockly.FieldAngle.prototype.configure_ = function(config) { if (typeof clockwise == 'boolean') { this.clockwise_ = clockwise; } - var offset = Number(config['offset']); - if (!isNaN(offset)) { - this.offset_ = offset; + + var offset = config['offset']; + if (offset != null) { + offset = Number(offset); + if (!isNaN(offset)) { + this.offset_ = offset; + } } - var wrap = Number(config['wrap']); - if (!isNaN(wrap)) { - this.wrap_ = wrap; + var wrap = config['wrap']; + if (wrap != null) { + wrap = Number(wrap); + if (!isNaN(wrap)) { + this.wrap_ = wrap; + } } - var round = Number(config['round']); - if (!isNaN(round)) { - this.round_ = round; + var round = config['round']; + if (round != null) { + round = Number(round); + if (!isNaN(round)) { + this.round_ = round; + } } }; + + /** * Create the block UI for this field. * @package diff --git a/core/field_number.js b/core/field_number.js index bbe340896..396cac7f5 100644 --- a/core/field_number.js +++ b/core/field_number.js @@ -32,10 +32,10 @@ goog.require('Blockly.utils.object'); * Class for an editable number field. * @param {string|number=} opt_value The initial value of the field. Should cast * to a number. Defaults to 0. - * @param {(string|number)=} opt_min Minimum value. - * @param {(string|number)=} opt_max Maximum value. - * @param {(string|number)=} opt_precision Precision for value. - * @param {Function=} opt_validator A function that is called to validate + * @param {?(string|number)=} opt_min Minimum value. + * @param {?(string|number)=} opt_max Maximum value. + * @param {?(string|number)=} opt_precision Precision for value. + * @param {?Function=} opt_validator A function that is called to validate * changes to the field's value. Takes in a number & returns a validated * number, or null to abort the change. * @param {Object=} opt_config A map of options used to configure the field. @@ -124,9 +124,9 @@ Blockly.FieldNumber.prototype.configure_ = function(config) { * values. That is, the user's value will rounded to the closest multiple of * precision. The least significant digit place is inferred from the precision. * Integers values can be enforces by choosing an integer precision. - * @param {number|string|undefined} min Minimum value. - * @param {number|string|undefined} max Maximum value. - * @param {number|string|undefined} precision Precision for value. + * @param {?(number|string|undefined)} min Minimum value. + * @param {?(number|string|undefined)} max Maximum value. + * @param {?(number|string|undefined)} precision Precision for value. */ Blockly.FieldNumber.prototype.setConstraints = function(min, max, precision) { this.setMinInternal_(min); @@ -137,7 +137,7 @@ Blockly.FieldNumber.prototype.setConstraints = function(min, max, precision) { /** * Sets the minimum value this field can contain. Updates the value to reflect. - * @param {number|string|undefined} min Minimum value. + * @param {?(number|string|undefined)} min Minimum value. */ Blockly.FieldNumber.prototype.setMin = function(min) { this.setMinInternal_(min); @@ -147,13 +147,17 @@ Blockly.FieldNumber.prototype.setMin = function(min) { /** * Sets the minimum value this field can contain. Called internally to avoid * value updates. - * @param {number|string|undefined} min Minimum value. + * @param {?(number|string|undefined)} min Minimum value. * @private */ Blockly.FieldNumber.prototype.setMinInternal_ = function(min) { - min = Number(min); - if (!isNaN(min)) { - this.min_ = min; + if (min == null) { + this.min_ = -Infinity; + } else { + min = Number(min); + if (!isNaN(min)) { + this.min_ = min; + } } }; @@ -168,7 +172,7 @@ Blockly.FieldNumber.prototype.getMin = function() { /** * Sets the maximum value this field can contain. Updates the value to reflect. - * @param {number|string|undefined} max Maximum value. + * @param {?(number|string|undefined)} max Maximum value. */ Blockly.FieldNumber.prototype.setMax = function(max) { this.setMaxInternal_(max); @@ -178,13 +182,17 @@ Blockly.FieldNumber.prototype.setMax = function(max) { /** * Sets the maximum value this field can contain. Called internally to avoid * value updates. - * @param {number|string|undefined} max Maximum value. + * @param {?(number|string|undefined)} max Maximum value. * @private */ Blockly.FieldNumber.prototype.setMaxInternal_ = function(max) { - max = Number(max); - if (!isNaN(max)) { - this.max_ = max; + if (max == null) { + this.max_ = Infinity; + } else { + max = Number(max); + if (!isNaN(max)) { + this.max_ = max; + } } }; @@ -200,7 +208,7 @@ Blockly.FieldNumber.prototype.getMax = function() { /** * Sets the precision of this field's value, i.e. the number to which the * value is rounded. Updates the field to reflect. - * @param {number|string|undefined} precision The number to which the + * @param {?(number|string|undefined)} precision The number to which the * field's value is rounded. */ Blockly.FieldNumber.prototype.setPrecision = function(precision) { @@ -211,14 +219,19 @@ Blockly.FieldNumber.prototype.setPrecision = function(precision) { /** * Sets the precision of this field's value. Called internally to avoid * value updates. - * @param {number|string|undefined} precision The number to which the + * @param {?(number|string|undefined)} precision The number to which the * field's value is rounded. * @private */ Blockly.FieldNumber.prototype.setPrecisionInternal_ = function(precision) { - precision = Number(precision); - if (!isNaN(precision)) { - this.precision_ = precision; + if (precision == null) { + // Number(precision) would also be 0, but set explicitly to be clear. + this.precision_ = 0; + } else { + precision = Number(precision); + if (!isNaN(precision)) { + this.precision_ = precision; + } } var precisionString = this.precision_.toString(); diff --git a/core/field_textinput.js b/core/field_textinput.js index f6312ef3e..46bcb7bc5 100644 --- a/core/field_textinput.js +++ b/core/field_textinput.js @@ -42,7 +42,7 @@ goog.require('Blockly.utils.userAgent'); * Class for an editable text field. * @param {string=} opt_value The initial value of the field. Should cast to a * string. Defaults to an empty string if null or undefined. - * @param {Function=} opt_validator A function that is called to validate + * @param {?Function=} opt_validator A function that is called to validate * changes to the field's value. Takes in a string & returns a validated * string, or null to abort the change. * @param {Object=} opt_config A map of options used to configure the field. diff --git a/tests/mocha/field_angle_test.js b/tests/mocha/field_angle_test.js index 500c35599..aeb1f8930 100644 --- a/tests/mocha/field_angle_test.js +++ b/tests/mocha/field_angle_test.js @@ -305,6 +305,17 @@ suite('Angle Fields', function() { var field = new Blockly.FieldAngle(); chai.assert.equal(field.offset_, 90); }); + test('Null', function() { + // Note: Generally constants should be set at compile time, not + // runtime (since they are constants) but for testing purposes we + // can do this. + Blockly.FieldAngle.OFFSET = 90; + var field = Blockly.FieldAngle.fromJson({ + value: 0, + offset: null + }); + chai.assert.equal(field.offset_, 90); + }); }); suite('Wrap', function() { test('JS Configuration', function() { @@ -328,6 +339,17 @@ suite('Angle Fields', function() { var field = new Blockly.FieldAngle(); chai.assert.equal(field.wrap_, 180); }); + test('Null', function() { + // Note: Generally constants should be set at compile time, not + // runtime (since they are constants) but for testing purposes we + // can do this. + Blockly.FieldAngle.WRAP = 180; + var field = Blockly.FieldAngle.fromJson({ + value: 0, + wrap: null + }); + chai.assert.equal(field.wrap_, 180); + }); }); suite('Round', function() { test('JS Configuration', function() { @@ -351,6 +373,17 @@ suite('Angle Fields', function() { var field = new Blockly.FieldAngle(); chai.assert.equal(field.round_, 30); }); + test('Null', function() { + // Note: Generally constants should be set at compile time, not + // runtime (since they are constants) but for testing purposes we + // can do this. + Blockly.FieldAngle.ROUND = 30; + var field = Blockly.FieldAngle.fromJson({ + value: 0, + round: null + }); + chai.assert.equal(field.round_, 30); + }); }); suite('Mode', function() { suite('Compass', function() { diff --git a/tests/mocha/field_number_test.js b/tests/mocha/field_number_test.js index ca2a94dc3..1a4d9f700 100644 --- a/tests/mocha/field_number_test.js +++ b/tests/mocha/field_number_test.js @@ -247,6 +247,12 @@ suite('Number Fields', function() { numberField.setValue(123.456); assertValue(numberField, 123); }); + test('null', function() { + var numberField = new Blockly.FieldNumber + .fromJson({ precision: null}); + numberField.setValue(123.456); + assertValue(numberField, 123.456); + }); }); suite('Min', function() { test('-10', function() { @@ -276,6 +282,12 @@ suite('Number Fields', function() { numberField.setValue(20); assertValue(numberField, 20); }); + test('null', function() { + var numberField = new Blockly.FieldNumber + .fromJson({ min: null}); + numberField.setValue(-20); + assertValue(numberField, -20); + }); }); suite('Max', function() { test('-10', function() { @@ -305,6 +317,12 @@ suite('Number Fields', function() { numberField.setValue(20); assertValue(numberField, 10); }); + test('null', function() { + var numberField = new Blockly.FieldNumber + .fromJson({ max: null}); + numberField.setValue(20); + assertValue(numberField, 20); + }); }); }); }); From 032dfa70b38e2334007310a97de4ca15fb94af6a Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Tue, 8 Oct 2019 14:26:23 -0700 Subject: [PATCH 06/21] Version of #3199 for release --- core/rendered_connection.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/rendered_connection.js b/core/rendered_connection.js index 1b1a1348e..76c2fa278 100644 --- a/core/rendered_connection.js +++ b/core/rendered_connection.js @@ -84,10 +84,10 @@ Blockly.utils.object.inherits(Blockly.RenderedConnection, Blockly.Connection); * @override */ Blockly.RenderedConnection.prototype.dispose = function() { + Blockly.RenderedConnection.superClass_.dispose.call(this); if (this.inDB_) { this.db_.removeConnection_(this); } - Blockly.RenderedConnection.superClass_.dispose.call(this); }; /** From 31db570cd148e3569b065270127c59b45a4e4ca3 Mon Sep 17 00:00:00 2001 From: Sam El-Husseini Date: Wed, 9 Oct 2019 11:16:26 -0700 Subject: [PATCH 07/21] Fix #2811 (#3205) (#3207) --- core/field.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/field.js b/core/field.js index ad7477830..a9d7b919c 100644 --- a/core/field.js +++ b/core/field.js @@ -557,8 +557,10 @@ Blockly.Field.prototype.updateColour = function() { * @protected */ Blockly.Field.prototype.render_ = function() { - this.textContent_.nodeValue = this.getDisplayText_(); - this.updateSize_(); + if (this.textContent_) { + this.textContent_.nodeValue = this.getDisplayText_(); + this.updateSize_(); + } }; /** From 52a6992dfc2cee2acbb91360ae2104616e0f3b2f Mon Sep 17 00:00:00 2001 From: RoboErikG Date: Mon, 14 Oct 2019 11:22:08 -0700 Subject: [PATCH 08/21] Remove multi-line comments to avoid escaping (#3231) (#3232) Fixes #3230 by removing multi-line comments for procedures. --- generators/javascript.js | 11 +- generators/python.js | 9 +- tests/generators/golden/generated.js | 338 +++++++-------------------- tests/generators/golden/generated.py | 255 +++++++------------- 4 files changed, 176 insertions(+), 437 deletions(-) diff --git a/generators/javascript.js b/generators/javascript.js index fa71a5d5b..2dae1fa93 100644 --- a/generators/javascript.js +++ b/generators/javascript.js @@ -253,15 +253,8 @@ Blockly.JavaScript.scrub_ = function(block, code, opt_thisOnly) { var comment = block.getCommentText(); if (comment) { comment = Blockly.utils.string.wrap(comment, - Blockly.JavaScript.COMMENT_WRAP - 3); - if (block.getProcedureDef) { - // Use a comment block for function comments. - commentCode += '/**\n' + - Blockly.JavaScript.prefixLines(comment + '\n', ' * ') + - ' */\n'; - } else { - commentCode += Blockly.JavaScript.prefixLines(comment + '\n', '// '); - } + Blockly.JavaScript.COMMENT_WRAP - 3); + commentCode += Blockly.JavaScript.prefixLines(comment + '\n', '// '); } // Collect comments for all value arguments. // Don't collect comments for nested statements. diff --git a/generators/python.js b/generators/python.js index 6676fea2e..544cd29a2 100644 --- a/generators/python.js +++ b/generators/python.js @@ -267,13 +267,8 @@ Blockly.Python.scrub_ = function(block, code, opt_thisOnly) { var comment = block.getCommentText(); if (comment) { comment = Blockly.utils.string.wrap(comment, - Blockly.Python.COMMENT_WRAP - 3); - if (block.getProcedureDef) { - // Use a comment block for function comments. - commentCode += '"""' + comment + '\n"""\n'; - } else { - commentCode += Blockly.Python.prefixLines(comment + '\n', '# '); - } + Blockly.Python.COMMENT_WRAP - 3); + commentCode += Blockly.Python.prefixLines(comment + '\n', '# '); } // Collect comments for all value arguments. // Don't collect comments for nested statements. diff --git a/tests/generators/golden/generated.js b/tests/generators/golden/generated.js index a24dd0bdd..c9b80a7a7 100644 --- a/tests/generators/golden/generated.js +++ b/tests/generators/golden/generated.js @@ -69,9 +69,7 @@ function unittest_fail(message) { unittestResults.push([false, "Fail.", message]); } -/** - * Describe this function... - */ +// Describe this function... function test_if() { if (false) { unittest_fail('if false'); @@ -108,9 +106,7 @@ function test_if() { assertEquals(ok, true, 'elseif 4'); } -/** - * Describe this function... - */ +// Describe this function... function test_ifelse() { ok = false; if (true) { @@ -128,9 +124,7 @@ function test_ifelse() { assertEquals(ok, true, 'ifelse false'); } -/** - * Describe this function... - */ +// Describe this function... function test_equalities() { assertEquals(2 == 2, true, 'Equal yes'); assertEquals(3 == 4, false, 'Equal no'); @@ -146,9 +140,7 @@ function test_equalities() { assertEquals(15 >= 16, false, 'Greater-equal no'); } -/** - * Describe this function... - */ +// Describe this function... function test_and() { assertEquals(true && true, true, 'And true/true'); assertEquals(false && true, false, 'And false/true'); @@ -156,9 +148,7 @@ function test_and() { assertEquals(false && false, false, 'And false/false'); } -/** - * Describe this function... - */ +// Describe this function... function test_or() { assertEquals(true || true, true, 'Or true/true'); assertEquals(false || true, true, 'Or false/true'); @@ -166,17 +156,13 @@ function test_or() { assertEquals(false || false, false, 'Or false/false'); } -/** - * Describe this function... - */ +// Describe this function... function test_ternary() { assertEquals(true ? 42 : 99, 42, 'if true'); assertEquals(false ? 42 : 99, 99, 'if true'); } -/** - * Describe this function... - */ +// Describe this function... function test_foreach() { log = ''; var x_list = ['a', 'b', 'c']; @@ -187,9 +173,7 @@ function test_foreach() { assertEquals(log, 'abc', 'for loop'); } -/** - * Describe this function... - */ +// Describe this function... function test_repeat() { count = 0; for (var count2 = 0; count2 < 10; count2++) { @@ -198,9 +182,7 @@ function test_repeat() { assertEquals(count, 10, 'repeat 10'); } -/** - * Describe this function... - */ +// Describe this function... function test_while() { while (false) { unittest_fail('while 0'); @@ -220,9 +202,7 @@ function test_while() { assertEquals(count, 10, 'until 10'); } -/** - * Describe this function... - */ +// Describe this function... function test_repeat_ext() { count = 0; for (var count3 = 0; count3 < 10; count3++) { @@ -231,9 +211,7 @@ function test_repeat_ext() { assertEquals(count, 10, 'repeat 10'); } -/** - * Describe this function... - */ +// Describe this function... function test_count_by() { log = ''; for (x = 1; x <= 8; x += 2) { @@ -285,9 +263,7 @@ function test_count_by() { assertEquals(loglist, [5.5, 4.5, 3.5, 2.5, 1.5], 'count with floats'); } -/** - * Describe this function... - */ +// Describe this function... function test_count_loops() { log = ''; for (x = 1; x <= 8; x++) { @@ -323,9 +299,7 @@ function test_count_loops() { assertEquals(loglist, [4, 3, 2, 1], 'count down non-trivial'); } -/** - * Describe this function... - */ +// Describe this function... function test_continue() { log = ''; count = 0; @@ -367,9 +341,7 @@ function test_continue() { assertEquals(log, 'abd', 'for continue'); } -/** - * Describe this function... - */ +// Describe this function... function test_break() { count = 1; while (count != 10) { @@ -407,9 +379,7 @@ function test_break() { assertEquals(log, 'ab', 'for break'); } -/** - * Tests the "single" block. - */ +// Tests the "single" block. function test_single() { assertEquals(Math.sqrt(25), 5, 'sqrt'); assertEquals(Math.abs(-25), 25, 'abs'); @@ -420,10 +390,8 @@ function test_single() { assertEquals(Math.pow(10,2), 100, 'power10'); } -/** - * Tests the "arithmetic" block for all operations and checks - * parenthesis are properly generated for different orders. - */ +// Tests the "arithmetic" block for all operations and checks +// parenthesis are properly generated for different orders. function test_arithmetic() { assertEquals(1 + 2, 3, 'add'); assertEquals(1 - 2, -1, 'subtract'); @@ -437,9 +405,7 @@ function test_arithmetic() { assertEquals(Math.pow(10, 0 + 4), 10000, 'power order'); } -/** - * Tests the "trig" block. - */ +// Tests the "trig" block. function test_trig() { assertEquals(Math.sin(90 / 180 * Math.PI), 1, 'sin'); assertEquals(Math.cos(180 / 180 * Math.PI), -1, 'cos'); @@ -449,9 +415,7 @@ function test_trig() { assertEquals(Math.atan(1) / Math.PI * 180, 45, 'atan'); } -/** - * Tests the "constant" blocks. - */ +// Tests the "constant" blocks. function test_constant() { assertEquals(Math.floor(Math.PI * 1000), 3141, 'const pi'); assertEquals(Math.floor(Math.E * 1000), 2718, 'const e'); @@ -480,9 +444,7 @@ function mathIsPrime(n) { return true; } -/** - * Tests the "number property" blocks. - */ +// Tests the "number property" blocks. function test_number_properties() { assertEquals(42 % 2 == 0, true, 'even'); assertEquals(42.1 % 2 == 1, false, 'odd'); @@ -495,18 +457,14 @@ function test_number_properties() { assertEquals(42 % 2 == 0, true, 'divisible'); } -/** - * Tests the "round" block. - */ +// Tests the "round" block. function test_round() { assertEquals(Math.round(42.42), 42, 'round'); assertEquals(Math.ceil(-42.42), -42, 'round up'); assertEquals(Math.floor(42.42), 42, 'round down'); } -/** - * Tests the "change" block. - */ +// Tests the "change" block. function test_change() { varToChange = 100; varToChange = (typeof varToChange == 'number' ? varToChange : 0) + 42; @@ -574,9 +532,7 @@ function mathRandomList(list) { return list[x]; } -/** - * Tests the "list operation" blocks. - */ +// Tests the "list operation" blocks. function test_operations_on_list() { assertEquals([3, 4, 5].reduce(function(x, y) {return x + y;}), 12, 'sum'); assertEquals(Math.min.apply(null, [3, 4, 5]), 3, 'min'); @@ -589,16 +545,12 @@ function test_operations_on_list() { assertEquals([3, 4, 5].indexOf(mathRandomList([3, 4, 5])) + 1 > 0, true, 'random'); } -/** - * Tests the "mod" block. - */ +// Tests the "mod" block. function test_mod() { assertEquals(42 % 5, 2, 'mod'); } -/** - * Tests the "constrain" block. - */ +// Tests the "constrain" block. function test_constraint() { assertEquals(Math.min(Math.max(100, 0), 42), 42, 'constraint'); } @@ -613,43 +565,33 @@ function mathRandomInt(a, b) { return Math.floor(Math.random() * (b - a + 1) + a); } -/** - * Tests the "random integer" block. - */ +// Tests the "random integer" block. function test_random_integer() { rand = mathRandomInt(5, 10); assertEquals(rand >= 5 && rand <= 10, true, 'randRange'); assertEquals(rand % 1 == 0, true, 'randInteger'); } -/** - * Tests the "random fraction" block. - */ +// Tests the "random fraction" block. function test_random_fraction() { rand = Math.random(); assertEquals(rand >= 0 && rand <= 1, true, 'randFloat'); } -/** - * Describe this function... - */ +// Describe this function... function test_atan2() { assertEquals(Math.atan2(5, -5) / Math.PI * 180, 135, 'atan2'); assertEquals(Math.atan2(-12, 0) / Math.PI * 180, -90, 'atan2'); } -/** - * Checks that the number of calls is one in order - * to confirm that a function was only called once. - */ +// Checks that the number of calls is one in order +// to confirm that a function was only called once. function check_number_of_calls(test_name) { test_name += 'number of calls'; assertEquals(number_of_calls, 1, test_name); } -/** - * Tests the "create text with" block with varying number of inputs. - */ +// Tests the "create text with" block with varying number of inputs. function test_create_text() { assertEquals('', '', 'no text'); assertEquals('Hello', 'Hello', 'create single'); @@ -660,16 +602,12 @@ function test_create_text() { assertEquals([1,true ? 0 : null,'M'].join(''), '10M', 'create order'); } -/** - * Creates an empty string for use with the empty test. - */ +// Creates an empty string for use with the empty test. function get_empty() { return ''; } -/** - * Tests the "is empty" block". - */ +// Tests the "is empty" block". function test_empty_text() { assertEquals(!'Google'.length, false, 'not empty'); assertEquals(!''.length, true, 'empty'); @@ -677,18 +615,14 @@ function test_empty_text() { assertEquals(!(true ? '' : null).length, true, 'empty order'); } -/** - * Tests the "length" block. - */ +// Tests the "length" block. function test_text_length() { assertEquals(''.length, 0, 'zero length'); assertEquals('Google'.length, 6, 'non-zero length'); assertEquals((true ? 'car' : null).length, 3, 'length order'); } -/** - * Tests the "append text" block with different types of parameters. - */ +// Tests the "append text" block with different types of parameters. function test_append() { item = 'Miserable'; item += 'Failure'; @@ -701,9 +635,7 @@ function test_append() { assertEquals(item, 'Something Positive', 'append order'); } -/** - * Tests the "find" block with a variable. - */ +// Tests the "find" block with a variable. function test_find_text_simple() { text = 'Banana'; assertEquals(text.indexOf('an') + 1, 2, 'find first simple'); @@ -711,17 +643,13 @@ function test_find_text_simple() { assertEquals(text.indexOf('Peel') + 1, 0, 'find none simple'); } -/** - * Creates a string for use with the find test. - */ +// Creates a string for use with the find test. function get_fruit() { number_of_calls = (typeof number_of_calls == 'number' ? number_of_calls : 0) + 1; return 'Banana'; } -/** - * Tests the "find" block with a function call. - */ +// Tests the "find" block with a function call. function test_find_text_complex() { number_of_calls = 0; assertEquals(get_fruit().indexOf('an') + 1, 2, 'find first complex'); @@ -748,9 +676,7 @@ function textRandomLetter(text) { return text[x]; } -/** - * Tests the "get letter" block with a variable. - */ +// Tests the "get letter" block with a variable. function test_get_text_simple() { text = 'Blockly'; assertEquals(text.charAt(0), 'B', 'get first simple'); @@ -763,17 +689,13 @@ function test_get_text_simple() { assertEquals(text.slice((-(0 + 3))).charAt(0), 'k', 'get #-end order simple'); } -/** - * Creates a string for use with the get test. - */ +// Creates a string for use with the get test. function get_Blockly() { number_of_calls = (typeof number_of_calls == 'number' ? number_of_calls : 0) + 1; return 'Blockly'; } -/** - * Tests the "get letter" block with a function call. - */ +// Tests the "get letter" block with a function call. function test_get_text_complex() { text = 'Blockly'; number_of_calls = 0; @@ -809,17 +731,13 @@ function test_get_text_complex() { check_number_of_calls('get #-end order complex'); } -/** - * Creates a string for use with the substring test. - */ +// Creates a string for use with the substring test. function get_numbers() { number_of_calls = (typeof number_of_calls == 'number' ? number_of_calls : 0) + 1; return '123456789'; } -/** - * Tests the "get substring" block with a variable. - */ +// Tests the "get substring" block with a variable. function test_substring_simple() { text = '123456789'; assertEquals(text.slice(1, 3), '23', 'substring # simple'); @@ -876,9 +794,7 @@ function subsequenceFromEndLast(sequence, at1) { return sequence.slice(start, end); } -/** - * Tests the "get substring" block with a function call. - */ +// Tests the "get substring" block with a function call. function test_substring_complex() { number_of_calls = 0; assertEquals(get_numbers().slice(1, 3), '23', 'substring # complex'); @@ -931,9 +847,7 @@ function textToTitleCase(str) { function(txt) {return txt[0].toUpperCase() + txt.substring(1).toLowerCase();}); } -/** - * Tests the "change casing" block. - */ +// Tests the "change casing" block. function test_case() { text = 'Hello World'; assertEquals(text.toUpperCase(), 'HELLO WORLD', 'uppercase'); @@ -946,9 +860,7 @@ function test_case() { assertEquals(textToTitleCase(true ? text : null), 'Hello World', 'titlecase order'); } -/** - * Tests the "trim" block. - */ +// Tests the "trim" block. function test_trim() { text = ' abc def '; assertEquals(text.trim(), 'abc def', 'trim both'); @@ -967,9 +879,7 @@ function textCount(haystack, needle) { } } -/** - * Tests the "trim" block. - */ +// Tests the "trim" block. function test_count_text() { text = 'woolloomooloo'; assertEquals(textCount(text, 'o'), 8, 'len 1'); @@ -981,9 +891,7 @@ function test_count_text() { assertEquals(textCount('', 'chicken'), 0, 'empty source'); } -/** - * Tests the "trim" block. - */ +// Tests the "trim" block. function test_text_reverse() { assertEquals(''.split('').reverse().join(''), '', 'empty string'); assertEquals('a'.split('').reverse().join(''), 'a', 'len 1'); @@ -997,9 +905,7 @@ function textReplace(haystack, needle, replacement) { return haystack.replace(new RegExp(needle, 'g'), replacement); } -/** - * Tests the "trim" block. - */ +// Tests the "trim" block. function test_replace() { assertEquals(textReplace('woolloomooloo', 'oo', '123'), 'w123ll123m123l123', 'replace all instances 1'); assertEquals(textReplace('woolloomooloo', '.oo', 'X'), 'woolloomooloo', 'literal string replacement'); @@ -1010,10 +916,8 @@ function test_replace() { assertEquals(textReplace('', 'a', 'chicken'), '', 'empty source'); } -/** - * Checks that the number of calls is one in order - * to confirm that a function was only called once. - */ +// Checks that the number of calls is one in order +// to confirm that a function was only called once. function check_number_of_calls2(test_name) { test_name += 'number of calls'; assertEquals(number_of_calls, 1, test_name); @@ -1027,9 +931,7 @@ function listsRepeat(value, n) { return array; } -/** - * Tests the "create list with" and "create empty list" blocks. - */ +// Tests the "create list with" and "create empty list" blocks. function test_create_lists() { assertEquals([], [], 'create empty'); assertEquals([true, 'love'], [true, 'love'], 'create items'); @@ -1037,16 +939,12 @@ function test_create_lists() { assertEquals(listsRepeat('Eject', 0 + 3), ['Eject', 'Eject', 'Eject'], 'create repeated order'); } -/** - * Creates an empty list for use with the empty test. - */ +// Creates an empty list for use with the empty test. function get_empty_list() { return []; } -/** - * Tests the "is empty" block. - */ +// Tests the "is empty" block. function test_lists_empty() { assertEquals(![0].length, false, 'not empty'); assertEquals(![].length, true, 'empty'); @@ -1054,9 +952,7 @@ function test_lists_empty() { assertEquals(!(true ? [] : null).length, true, 'empty order'); } -/** - * Tests the "length" block. - */ +// Tests the "length" block. function test_lists_length() { assertEquals([].length, 0, 'zero length'); assertEquals(['cat'].length, 1, 'one length'); @@ -1064,9 +960,7 @@ function test_lists_length() { assertEquals((true ? ['cat', true] : null).length, 2, 'two length order'); } -/** - * Tests the "find" block with a variable. - */ +// Tests the "find" block with a variable. function test_find_lists_simple() { list = ['Alice', 'Eve', 'Bob', 'Eve']; assertEquals(list.indexOf('Eve') + 1, 2, 'find first simple'); @@ -1074,17 +968,13 @@ function test_find_lists_simple() { assertEquals(list.indexOf('Dave') + 1, 0, 'find none simple'); } -/** - * Creates a list for use with the find test. - */ +// Creates a list for use with the find test. function get_names() { number_of_calls = (typeof number_of_calls == 'number' ? number_of_calls : 0) + 1; return ['Alice', 'Eve', 'Bob', 'Eve']; } -/** - * Tests the "find" block with a function call. - */ +// Tests the "find" block with a function call. function test_find_lists_complex() { number_of_calls = 0; assertEquals(get_names().indexOf('Eve') + 1, 2, 'find first complex'); @@ -1115,9 +1005,7 @@ function listsGetRandomItem(list, remove) { } } -/** - * Tests the "get" block with a variable. - */ +// Tests the "get" block with a variable. function test_get_lists_simple() { list = ['Kirk', 'Spock', 'McCoy']; assertEquals(list[0], 'Kirk', 'get first simple'); @@ -1130,17 +1018,13 @@ function test_get_lists_simple() { assertEquals(list.slice((-(0 + 3)))[0], 'Kirk', 'get #-end order simple'); } -/** - * Creates a list for use with the get test. - */ +// Creates a list for use with the get test. function get_star_wars() { number_of_calls = (typeof number_of_calls == 'number' ? number_of_calls : 0) + 1; return ['Kirk', 'Spock', 'McCoy']; } -/** - * Tests the "get" block with a function call. - */ +// Tests the "get" block with a function call. function test_get_lists_complex() { list = ['Kirk', 'Spock', 'McCoy']; number_of_calls = 0; @@ -1176,9 +1060,7 @@ function test_get_lists_complex() { check_number_of_calls('get #-end order complex'); } -/** - * Tests the "get and remove" block. - */ +// Tests the "get and remove" block. function test_getRemove() { list = ['Kirk', 'Spock', 'McCoy']; assertEquals(list.shift(), 'Kirk', 'getremove first'); @@ -1213,9 +1095,7 @@ function test_getRemove() { assertEquals(list, ['Spock', 'McCoy'], 'getremove #-end order list'); } -/** - * Tests the "remove" block. - */ +// Tests the "remove" block. function test_remove() { list = ['Kirk', 'Spock', 'McCoy']; list.shift(); @@ -1249,9 +1129,7 @@ function test_remove() { (true ? list : null).splice((-(0 + 3)), 1);assertEquals(list, ['Spock', 'McCoy'], 'remove #-end order list'); } -/** - * Tests the "set" block. - */ +// Tests the "set" block. function test_set() { list = ['Picard', 'Riker', 'Crusher']; list[0] = 'Jean-Luc'; @@ -1292,9 +1170,7 @@ function test_set() { assertEquals(list, ['Picard', 'Pulaski', 'Crusher'], 'set #-end order list'); } -/** - * Tests the "insert" block. - */ +// Tests the "insert" block. function test_insert() { list = ['Picard', 'Riker', 'Crusher']; list.unshift('Data'); @@ -1334,9 +1210,7 @@ function test_insert() { assertEquals(list, ['Picard', 'Data', 'Riker', 'Crusher'], 'insert #-end order list'); } -/** - * Tests the "get sub-list" block with a variable. - */ +// Tests the "get sub-list" block with a variable. function test_sublist_simple() { list = ['Columbia', 'Challenger', 'Discovery', 'Atlantis', 'Endeavour']; assertEquals(list.slice(1, 3), ['Challenger', 'Discovery'], 'sublist # simple'); @@ -1361,17 +1235,13 @@ function test_sublist_simple() { assertEquals(list.slice(((0 + 1) - 1), list.length - ((0 + 1) - 1)), list, 'sublist all with # #-end math simple'); } -/** - * Creates a list for use with the sublist test. - */ +// Creates a list for use with the sublist test. function get_space_shuttles() { number_of_calls = (typeof number_of_calls == 'number' ? number_of_calls : 0) + 1; return ['Columbia', 'Challenger', 'Discovery', 'Atlantis', 'Endeavour']; } -/** - * Tests the "get sub-list" block with a function call. - */ +// Tests the "get sub-list" block with a function call. function test_sublist_complex() { number_of_calls = 0; assertEquals(get_space_shuttles().slice(1, 3), ['Challenger', 'Discovery'], 'sublist # start complex'); @@ -1419,18 +1289,14 @@ function test_sublist_complex() { check_number_of_calls('sublist all with # #-end math complex'); } -/** - * Tests the "join" block. - */ +// Tests the "join" block. function test_join() { list = ['Vulcan', 'Klingon', 'Borg']; assertEquals(list.join(','), 'Vulcan,Klingon,Borg', 'join'); assertEquals((true ? list : null).join(','), 'Vulcan,Klingon,Borg', 'join order'); } -/** - * Tests the "split" block. - */ +// Tests the "split" block. function test_split() { text = 'Vulcan,Klingon,Borg'; assertEquals(text.split(','), ['Vulcan', 'Klingon', 'Borg'], 'split'); @@ -1450,36 +1316,28 @@ function listsGetSortCompare(type, direction) { return function(a, b) { return compare(a, b) * direction; } } -/** - * Tests the "alphabetic sort" block. - */ +// Tests the "alphabetic sort" block. function test_sort_alphabetic() { list = ['Vulcan', 'klingon', 'Borg']; assertEquals(list.slice().sort(listsGetSortCompare("TEXT", 1)), ['Borg', 'Vulcan', 'klingon'], 'sort alphabetic ascending'); assertEquals((true ? list : null).slice().sort(listsGetSortCompare("TEXT", 1)), ['Borg', 'Vulcan', 'klingon'], 'sort alphabetic ascending order'); } -/** - * Tests the "alphabetic sort ignore case" block. - */ +// Tests the "alphabetic sort ignore case" block. function test_sort_ignoreCase() { list = ['Vulcan', 'klingon', 'Borg']; assertEquals(list.slice().sort(listsGetSortCompare("IGNORE_CASE", 1)), ['Borg', 'klingon', 'Vulcan'], 'sort ignore case ascending'); assertEquals((true ? list : null).slice().sort(listsGetSortCompare("IGNORE_CASE", 1)), ['Borg', 'klingon', 'Vulcan'], 'sort ignore case ascending order'); } -/** - * Tests the "numeric sort" block. - */ +// Tests the "numeric sort" block. function test_sort_numeric() { list = [8, 18, -1]; assertEquals(list.slice().sort(listsGetSortCompare("NUMERIC", -1)), [18, 8, -1], 'sort numeric descending'); assertEquals((true ? list : null).slice().sort(listsGetSortCompare("NUMERIC", -1)), [18, 8, -1], 'sort numeric descending order'); } -/** - * Tests the "list reverse" block. - */ +// Tests the "list reverse" block. function test_lists_reverse() { list = [8, 18, -1, 64]; assertEquals(list.slice().reverse(), [64, -1, 18, 8], 'reverse a copy'); @@ -1488,9 +1346,7 @@ function test_lists_reverse() { assertEquals(list.slice().reverse(), [], 'empty list'); } -/** - * Describe this function... - */ +// Describe this function... function test_colour_picker() { assertEquals('#ff6600', '#ff6600', 'static colour'); } @@ -1505,9 +1361,7 @@ function colourRgb(r, g, b) { return '#' + r + g + b; } -/** - * Describe this function... - */ +// Describe this function... function test_rgb() { assertEquals(colourRgb(100, 40, 0), '#ff6600', 'from rgb'); } @@ -1517,9 +1371,7 @@ function colourRandom() { return '#' + ('00000' + num.toString(16)).substr(-6); } -/** - * Describe this function... - */ +// Describe this function... function test_colour_random() { for (var count4 = 0; count4 < 100; count4++) { item = colourRandom(); @@ -1548,16 +1400,12 @@ function colourBlend(c1, c2, ratio) { return '#' + r + g + b; } -/** - * Describe this function... - */ +// Describe this function... function test_blend() { assertEquals(colourBlend('#ff0000', colourRgb(100, 40, 0), 0.4), '#ff2900', 'blend'); } -/** - * Describe this function... - */ +// Describe this function... function test_procedure() { procedure_1(8, 2); assertEquals(proc_z, 4, 'procedure with global'); @@ -1569,16 +1417,12 @@ function test_procedure() { assertEquals(proc_w, false, 'procedure return'); } -/** - * Describe this function... - */ +// Describe this function... function procedure_1(proc_x, proc_y) { proc_z = proc_x / proc_y; } -/** - * Describe this function... - */ +// Describe this function... function procedure_2(proc_x) { if (proc_x) { return; @@ -1586,9 +1430,7 @@ function procedure_2(proc_x) { proc_w = true; } -/** - * Describe this function... - */ +// Describe this function... function test_function() { assertEquals(function_1(2, 3), -1, 'function with arguments'); assertEquals(func_z, 'side effect', 'function with side effect'); @@ -1600,25 +1442,19 @@ function test_function() { assertEquals(function_3(false), false, 'function no return'); } -/** - * Describe this function... - */ +// Describe this function... function function_1(func_x, func_y) { func_z = 'side effect'; return func_x - func_y; } -/** - * Describe this function... - */ +// Describe this function... function function_2(func_a) { func_a = (typeof func_a == 'number' ? func_a : 0) + 1; return String(func_a) + String(func_c); } -/** - * Describe this function... - */ +// Describe this function... function function_3(func_a) { if (func_a) { return true; @@ -1626,9 +1462,7 @@ function function_3(func_a) { return false; } -/** - * Describe this function... - */ +// Describe this function... function recurse(n) { if (n > 0) { text = [recurse(n - 1),n,recurse(n - 1)].join(''); diff --git a/tests/generators/golden/generated.py b/tests/generators/golden/generated.py index 603a4ddd2..b20142bb6 100644 --- a/tests/generators/golden/generated.py +++ b/tests/generators/golden/generated.py @@ -71,8 +71,7 @@ def fail(message): raise Exception("Orphaned assert equals: " + message) unittestResults.append((False, "Fail.", message)) -"""Describe this function... -""" +# Describe this function... def test_if(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults if False: @@ -104,8 +103,7 @@ def test_if(): fail('elseif 3') assertEquals(ok, True, 'elseif 4') -"""Describe this function... -""" +# Describe this function... def test_ifelse(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults ok = False @@ -121,8 +119,7 @@ def test_ifelse(): ok = True assertEquals(ok, True, 'ifelse false') -"""Describe this function... -""" +# Describe this function... def test_equalities(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults assertEquals(2 == 2, True, 'Equal yes') @@ -138,8 +135,7 @@ def test_equalities(): assertEquals(14 >= 14, True, 'Greater-equal yes') assertEquals(15 >= 16, False, 'Greater-equal no') -"""Describe this function... -""" +# Describe this function... def test_and(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults assertEquals(True and True, True, 'And true/true') @@ -147,8 +143,7 @@ def test_and(): assertEquals(True and False, False, 'And true/false') assertEquals(False and False, False, 'And false/false') -"""Describe this function... -""" +# Describe this function... def test_or(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults assertEquals(True or True, True, 'Or true/true') @@ -156,15 +151,13 @@ def test_or(): assertEquals(True or False, True, 'Or true/false') assertEquals(False or False, False, 'Or false/false') -"""Describe this function... -""" +# Describe this function... def test_ternary(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults assertEquals(42 if True else 99, 42, 'if true') assertEquals(42 if False else 99, 99, 'if true') -"""Describe this function... -""" +# Describe this function... def test_foreach(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults log = '' @@ -172,8 +165,7 @@ def test_foreach(): log = str(log) + str(x) assertEquals(log, 'abc', 'for loop') -"""Describe this function... -""" +# Describe this function... def test_repeat(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults count = 0 @@ -181,8 +173,7 @@ def test_repeat(): count = (count if isinstance(count, Number) else 0) + 1 assertEquals(count, 10, 'repeat 10') -"""Describe this function... -""" +# Describe this function... def test_while(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults while False: @@ -198,8 +189,7 @@ def test_while(): count = (count if isinstance(count, Number) else 0) + 1 assertEquals(count, 10, 'until 10') -"""Describe this function... -""" +# Describe this function... def test_repeat_ext(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults count = 0 @@ -217,8 +207,7 @@ def downRange(start, stop, step): yield start start -= abs(step) -"""Describe this function... -""" +# Describe this function... def test_count_by(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults log = '' @@ -254,8 +243,7 @@ def test_count_by(): loglist.append(x) assertEquals(loglist, [5.5, 4.5, 3.5, 2.5, 1.5], 'count with floats') -"""Describe this function... -""" +# Describe this function... def test_count_loops(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults log = '' @@ -279,8 +267,7 @@ def test_count_loops(): loglist.append(x) assertEquals(loglist, [4, 3, 2, 1], 'count down non-trivial') -"""Describe this function... -""" +# Describe this function... def test_continue(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults log = '' @@ -312,8 +299,7 @@ def test_continue(): log = str(log) + str(x) assertEquals(log, 'abd', 'for continue') -"""Describe this function... -""" +# Describe this function... def test_break(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults count = 1 @@ -341,8 +327,7 @@ def test_break(): log = str(log) + str(x) assertEquals(log, 'ab', 'for break') -"""Tests the "single" block. -""" +# Tests the "single" block. def test_single(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults assertEquals(math.sqrt(25), 5, 'sqrt') @@ -353,9 +338,8 @@ def test_single(): assertEquals(math.exp(2), 7.38905609893065, 'exp') assertEquals(math.pow(10,2), 100, 'power10') -"""Tests the "arithmetic" block for all operations and checks -parenthesis are properly generated for different orders. -""" +# Tests the "arithmetic" block for all operations and checks +# parenthesis are properly generated for different orders. def test_arithmetic(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults assertEquals(1 + 2, 3, 'add') @@ -369,8 +353,7 @@ def test_arithmetic(): assertEquals(10 ** 4, 10000, 'power') assertEquals(10 ** (0 + 4), 10000, 'power order') -"""Tests the "trig" block. -""" +# Tests the "trig" block. def test_trig(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults assertEquals(math.sin(90 / 180.0 * math.pi), 1, 'sin') @@ -380,8 +363,7 @@ def test_trig(): assertEquals(math.acos(1) / math.pi * 180, 0, 'acos') assertEquals(math.atan(1) / math.pi * 180, 45, 'atan') -"""Tests the "constant" blocks. -""" +# Tests the "constant" blocks. def test_constant(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults assertEquals(math.floor(math.pi * 1000), 3141, 'const pi') @@ -410,8 +392,7 @@ def math_isPrime(n): return False return True -"""Tests the "number property" blocks. -""" +# Tests the "number property" blocks. def test_number_properties(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults assertEquals(42 % 2 == 0, True, 'even') @@ -424,16 +405,14 @@ def test_number_properties(): assertEquals(-42 < 0, True, 'negative') assertEquals(42 % 2 == 0, True, 'divisible') -"""Tests the "round" block. -""" +# Tests the "round" block. def test_round(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults assertEquals(round(42.42), 42, 'round') assertEquals(math.ceil(-42.42), -42, 'round up') assertEquals(math.floor(42.42), 42, 'round down') -"""Tests the "change" block. -""" +# Tests the "change" block. def test_change(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults varToChange = 100 @@ -485,8 +464,7 @@ def first_index(my_list, elem): except: index = 0 return index -"""Tests the "list operation" blocks. -""" +# Tests the "list operation" blocks. def test_operations_on_list(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults assertEquals(sum([3, 4, 5]), 12, 'sum') @@ -499,50 +477,43 @@ def test_operations_on_list(): assertEquals(math_standard_deviation([3, 3, 3]), 0, 'standard dev') assertEquals(first_index([3, 4, 5], random.choice([3, 4, 5])) > 0, True, 'random') -"""Tests the "mod" block. -""" +# Tests the "mod" block. def test_mod(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults assertEquals(42 % 5, 2, 'mod') -"""Tests the "constrain" block. -""" +# Tests the "constrain" block. def test_constraint(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults assertEquals(min(max(100, 0), 42), 42, 'constraint') -"""Tests the "random integer" block. -""" +# Tests the "random integer" block. def test_random_integer(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults rand = random.randint(5, 10) assertEquals(rand >= 5 and rand <= 10, True, 'randRange') assertEquals(rand % 1 == 0, True, 'randInteger') -"""Tests the "random fraction" block. -""" +# Tests the "random fraction" block. def test_random_fraction(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults rand = random.random() assertEquals(rand >= 0 and rand <= 1, True, 'randFloat') -"""Describe this function... -""" +# Describe this function... def test_atan2(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults assertEquals(math.atan2(5, -5) / math.pi * 180, 135, 'atan2') assertEquals(math.atan2(-12, 0) / math.pi * 180, -90, 'atan2') -"""Checks that the number of calls is one in order -to confirm that a function was only called once. -""" +# Checks that the number of calls is one in order +# to confirm that a function was only called once. def check_number_of_calls(test_name): global naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults test_name = str(test_name) + 'number of calls' assertEquals(number_of_calls, 1, test_name) -"""Tests the "create text with" block with varying number of inputs. -""" +# Tests the "create text with" block with varying number of inputs. def test_create_text(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults assertEquals('', '', 'no text') @@ -553,14 +524,12 @@ def test_create_text(): assertEquals(''.join([str(x2) for x2 in [1, 2, 3]]), '123', 'create triple') assertEquals(''.join([str(x3) for x3 in [1, 0 if True else None, 'M']]), '10M', 'create order') -"""Creates an empty string for use with the empty test. -""" +# Creates an empty string for use with the empty test. def get_empty(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults return '' -"""Tests the "is empty" block". -""" +# Tests the "is empty" block". def test_empty_text(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults assertEquals(not len('Google'), False, 'not empty') @@ -568,16 +537,14 @@ def test_empty_text(): assertEquals(not len(get_empty()), True, 'empty complex') assertEquals(not len('' if True else None), True, 'empty order') -"""Tests the "length" block. -""" +# Tests the "length" block. def test_text_length(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults assertEquals(len(''), 0, 'zero length') assertEquals(len('Google'), 6, 'non-zero length') assertEquals(len('car' if True else None), 3, 'length order') -"""Tests the "append text" block with different types of parameters. -""" +# Tests the "append text" block with different types of parameters. def test_append(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults item = 'Miserable' @@ -590,8 +557,7 @@ def test_append(): item = str(item) + str('Positive' if True else None) assertEquals(item, 'Something Positive', 'append order') -"""Tests the "find" block with a variable. -""" +# Tests the "find" block with a variable. def test_find_text_simple(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults text = 'Banana' @@ -599,15 +565,13 @@ def test_find_text_simple(): assertEquals(text.rfind('an') + 1, 4, 'find last simple') assertEquals(text.find('Peel') + 1, 0, 'find none simple') -"""Creates a string for use with the find test. -""" +# Creates a string for use with the find test. def get_fruit(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults number_of_calls = (number_of_calls if isinstance(number_of_calls, Number) else 0) + 1 return 'Banana' -"""Tests the "find" block with a function call. -""" +# Tests the "find" block with a function call. def test_find_text_complex(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults number_of_calls = 0 @@ -633,8 +597,7 @@ def text_random_letter(text): x = int(random.random() * len(text)) return text[x]; -"""Tests the "get letter" block with a variable. -""" +# Tests the "get letter" block with a variable. def test_get_text_simple(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults text = 'Blockly' @@ -647,15 +610,13 @@ def test_get_text_simple(): # The order for index for #-end is addition because this will catch errors in generators where most perform the operation ... - index. assertEquals(text[-int(0 + 3)], 'k', 'get #-end order simple') -"""Creates a string for use with the get test. -""" +# Creates a string for use with the get test. def get_Blockly(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults number_of_calls = (number_of_calls if isinstance(number_of_calls, Number) else 0) + 1 return 'Blockly' -"""Tests the "get letter" block with a function call. -""" +# Tests the "get letter" block with a function call. def test_get_text_complex(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults text = 'Blockly' @@ -691,15 +652,13 @@ def test_get_text_complex(): assertEquals((get_Blockly() if True else None)[-int(0 + 3)], 'k', 'get #-end order complex') check_number_of_calls('get #-end order complex') -"""Creates a string for use with the substring test. -""" +# Creates a string for use with the substring test. def get_numbers(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults number_of_calls = (number_of_calls if isinstance(number_of_calls, Number) else 0) + 1 return '123456789' -"""Tests the "get substring" block with a variable. -""" +# Tests the "get substring" block with a variable. def test_substring_simple(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults text = '123456789' @@ -720,8 +679,7 @@ def test_substring_simple(): # Checks that the whole string is properly retrieved even if the value for start and end is not a simple number. This is especially important in generators where substring uses [x:length - y] for # #-end. assertEquals(text[int((0 + 1) - 1) : -int((0 + 1) - 1) or sys.maxsize], '123456789', 'substring all with # #-end math simple') -"""Tests the "get substring" block with a function call. -""" +# Tests the "get substring" block with a function call. def test_substring_complex(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults number_of_calls = 0 @@ -769,8 +727,7 @@ def test_substring_complex(): assertEquals(get_numbers()[int((0 + 1) - 1) : -int((0 + 1) - 1) or sys.maxsize], '123456789', 'substring all with # #-end math complex') check_number_of_calls('substring all with # #-end math complex') -"""Tests the "change casing" block. -""" +# Tests the "change casing" block. def test_case(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults text = 'Hello World' @@ -783,8 +740,7 @@ def test_case(): assertEquals(text.title(), 'Hello World', 'titlecase') assertEquals((text if True else None).title(), 'Hello World', 'titlecase order') -"""Tests the "trim" block. -""" +# Tests the "trim" block. def test_trim(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults text = ' abc def ' @@ -795,8 +751,7 @@ def test_trim(): assertEquals(text.rstrip(), ' abc def', 'trim right') assertEquals((text if True else None).rstrip(), ' abc def', 'trim right order') -"""Tests the "trim" block. -""" +# Tests the "trim" block. def test_count_text(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults text = 'woolloomooloo' @@ -808,8 +763,7 @@ def test_count_text(): assertEquals(text.count(''), 14, 'empty needle') assertEquals(''.count('chicken'), 0, 'empty source') -"""Tests the "trim" block. -""" +# Tests the "trim" block. def test_text_reverse(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults assertEquals(''[::-1], '', 'empty string') @@ -817,8 +771,7 @@ def test_text_reverse(): assertEquals('ab'[::-1], 'ba', 'len 2') assertEquals('woolloomooloo'[::-1], 'ooloomoolloow', 'longer') -"""Tests the "trim" block. -""" +# Tests the "trim" block. def test_replace(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults assertEquals('woolloomooloo'.replace('oo', '123'), 'w123ll123m123l123', 'replace all instances 1') @@ -829,16 +782,14 @@ def test_replace(): assertEquals('aaaaa'.replace('a', ''), '', 'empty replacement 3') assertEquals(''.replace('a', 'chicken'), '', 'empty source') -"""Checks that the number of calls is one in order -to confirm that a function was only called once. -""" +# Checks that the number of calls is one in order +# to confirm that a function was only called once. def check_number_of_calls2(test_name): global naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults test_name = str(test_name) + 'number of calls' assertEquals(number_of_calls, 1, test_name) -"""Tests the "create list with" and "create empty list" blocks. -""" +# Tests the "create list with" and "create empty list" blocks. def test_create_lists(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults assertEquals([], [], 'create empty') @@ -846,14 +797,12 @@ def test_create_lists(): assertEquals(['Eject'] * 3, ['Eject', 'Eject', 'Eject'], 'create repeated') assertEquals(['Eject'] * (0 + 3), ['Eject', 'Eject', 'Eject'], 'create repeated order') -"""Creates an empty list for use with the empty test. -""" +# Creates an empty list for use with the empty test. def get_empty_list(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults return [] -"""Tests the "is empty" block. -""" +# Tests the "is empty" block. def test_lists_empty(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults assertEquals(not len([0]), False, 'not empty') @@ -861,8 +810,7 @@ def test_lists_empty(): assertEquals(not len(get_empty_list()), True, 'empty complex') assertEquals(not len([] if True else None), True, 'empty order') -"""Tests the "length" block. -""" +# Tests the "length" block. def test_lists_length(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults assertEquals(len([]), 0, 'zero length') @@ -875,8 +823,7 @@ def last_index(my_list, elem): except: index = 0 return index -"""Tests the "find" block with a variable. -""" +# Tests the "find" block with a variable. def test_find_lists_simple(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults list2 = ['Alice', 'Eve', 'Bob', 'Eve'] @@ -884,15 +831,13 @@ def test_find_lists_simple(): assertEquals(last_index(list2, 'Eve'), 4, 'find last simple') assertEquals(first_index(list2, 'Dave'), 0, 'find none simple') -"""Creates a list for use with the find test. -""" +# Creates a list for use with the find test. def get_names(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults number_of_calls = (number_of_calls if isinstance(number_of_calls, Number) else 0) + 1 return ['Alice', 'Eve', 'Bob', 'Eve'] -"""Tests the "find" block with a function call. -""" +# Tests the "find" block with a function call. def test_find_lists_complex(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults number_of_calls = 0 @@ -914,8 +859,7 @@ def test_find_lists_complex(): assertEquals(first_index(get_names() if True else None, 'Dave'), 0, 'find none order complex') check_number_of_calls('find none order complex') -"""Tests the "get" block with a variable. -""" +# Tests the "get" block with a variable. def test_get_lists_simple(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults list2 = ['Kirk', 'Spock', 'McCoy'] @@ -928,15 +872,13 @@ def test_get_lists_simple(): # The order for index for #-end is addition because this will catch errors in generators where most perform the operation ... - index. assertEquals(list2[-int(0 + 3)], 'Kirk', 'get #-end order simple') -"""Creates a list for use with the get test. -""" +# Creates a list for use with the get test. def get_star_wars(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults number_of_calls = (number_of_calls if isinstance(number_of_calls, Number) else 0) + 1 return ['Kirk', 'Spock', 'McCoy'] -"""Tests the "get" block with a function call. -""" +# Tests the "get" block with a function call. def test_get_lists_complex(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults list2 = ['Kirk', 'Spock', 'McCoy'] @@ -976,8 +918,7 @@ def lists_remove_random_item(myList): x = int(random.random() * len(myList)) return myList.pop(x) -"""Tests the "get and remove" block. -""" +# Tests the "get and remove" block. def test_getRemove(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults list2 = ['Kirk', 'Spock', 'McCoy'] @@ -1012,8 +953,7 @@ def test_getRemove(): assertEquals((list2 if True else None).pop(-int(0 + 3)), 'Kirk', 'getremove #-end order') assertEquals(list2, ['Spock', 'McCoy'], 'getremove #-end order list') -"""Tests the "remove" block. -""" +# Tests the "remove" block. def test_remove(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults list2 = ['Kirk', 'Spock', 'McCoy'] @@ -1049,8 +989,7 @@ def test_remove(): (list2 if True else None).pop(-int(0 + 3)) assertEquals(list2, ['Spock', 'McCoy'], 'remove #-end order list') -"""Tests the "set" block. -""" +# Tests the "set" block. def test_set(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults list2 = ['Picard', 'Riker', 'Crusher'] @@ -1089,8 +1028,7 @@ def test_set(): (list2 if True else None)[-int(0 + 2)] = 'Pulaski' assertEquals(list2, ['Picard', 'Pulaski', 'Crusher'], 'set #-end order list') -"""Tests the "insert" block. -""" +# Tests the "insert" block. def test_insert(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults list2 = ['Picard', 'Riker', 'Crusher'] @@ -1129,8 +1067,7 @@ def test_insert(): (list2 if True else None).insert(-int(0 + 2), 'Data') assertEquals(list2, ['Picard', 'Data', 'Riker', 'Crusher'], 'insert #-end order list') -"""Tests the "get sub-list" block with a variable. -""" +# Tests the "get sub-list" block with a variable. def test_sublist_simple(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults list2 = ['Columbia', 'Challenger', 'Discovery', 'Atlantis', 'Endeavour'] @@ -1155,15 +1092,13 @@ def test_sublist_simple(): # Checks that the whole list is properly retrieved even if the value for start and end is not a simple number. This is especially important in generators where sublist uses [x:length - y] for # #-end. assertEquals(list2[int((0 + 1) - 1) : -int((0 + 1) - 1) or sys.maxsize], list2, 'sublist all with # #-end math simple') -"""Creates a list for use with the sublist test. -""" +# Creates a list for use with the sublist test. def get_space_shuttles(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults number_of_calls = (number_of_calls if isinstance(number_of_calls, Number) else 0) + 1 return ['Columbia', 'Challenger', 'Discovery', 'Atlantis', 'Endeavour'] -"""Tests the "get sub-list" block with a function call. -""" +# Tests the "get sub-list" block with a function call. def test_sublist_complex(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults number_of_calls = 0 @@ -1211,16 +1146,14 @@ def test_sublist_complex(): assertEquals(get_space_shuttles()[int((0 + 1) - 1) : -int((0 + 1) - 1) or sys.maxsize], list2, 'sublist all with # #-end math complex') check_number_of_calls('sublist all with # #-end math complex') -"""Tests the "join" block. -""" +# Tests the "join" block. def test_join(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults list2 = ['Vulcan', 'Klingon', 'Borg'] assertEquals(','.join(list2), 'Vulcan,Klingon,Borg', 'join') assertEquals(','.join(list2 if True else None), 'Vulcan,Klingon,Borg', 'join order') -"""Tests the "split" block. -""" +# Tests the "split" block. def test_split(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults text = 'Vulcan,Klingon,Borg' @@ -1242,32 +1175,28 @@ def lists_sort(my_list, type, reverse): list_cpy = list(my_list) return sorted(list_cpy, key=key_func, reverse=reverse) -"""Tests the "alphabetic sort" block. -""" +# Tests the "alphabetic sort" block. def test_sort_alphabetic(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults list2 = ['Vulcan', 'klingon', 'Borg'] assertEquals(lists_sort(list2, "TEXT", False), ['Borg', 'Vulcan', 'klingon'], 'sort alphabetic ascending') assertEquals(lists_sort(list2 if True else None, "TEXT", False), ['Borg', 'Vulcan', 'klingon'], 'sort alphabetic ascending order') -"""Tests the "alphabetic sort ignore case" block. -""" +# Tests the "alphabetic sort ignore case" block. def test_sort_ignoreCase(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults list2 = ['Vulcan', 'klingon', 'Borg'] assertEquals(lists_sort(list2, "IGNORE_CASE", False), ['Borg', 'klingon', 'Vulcan'], 'sort ignore case ascending') assertEquals(lists_sort(list2 if True else None, "IGNORE_CASE", False), ['Borg', 'klingon', 'Vulcan'], 'sort ignore case ascending order') -"""Tests the "numeric sort" block. -""" +# Tests the "numeric sort" block. def test_sort_numeric(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults list2 = [8, 18, -1] assertEquals(lists_sort(list2, "NUMERIC", True), [18, 8, -1], 'sort numeric descending') assertEquals(lists_sort(list2 if True else None, "NUMERIC", True), [18, 8, -1], 'sort numeric descending order') -"""Tests the "list reverse" block. -""" +# Tests the "list reverse" block. def test_lists_reverse(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults list2 = [8, 18, -1, 64] @@ -1276,8 +1205,7 @@ def test_lists_reverse(): list2 = [] assertEquals(list(reversed(list2)), [], 'empty list') -"""Describe this function... -""" +# Describe this function... def test_colour_picker(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults assertEquals('#ff6600', '#ff6600', 'static colour') @@ -1288,14 +1216,12 @@ def colour_rgb(r, g, b): b = round(min(100, max(0, b)) * 2.55) return '#%02x%02x%02x' % (r, g, b) -"""Describe this function... -""" +# Describe this function... def test_rgb(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults assertEquals(colour_rgb(100, 40, 0), '#ff6600', 'from rgb') -"""Describe this function... -""" +# Describe this function... def test_colour_random(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults for count4 in range(100): @@ -1315,14 +1241,12 @@ def colour_blend(colour1, colour2, ratio): b = round(b1 * (1 - ratio) + b2 * ratio) return '#%02x%02x%02x' % (r, g, b) -"""Describe this function... -""" +# Describe this function... def test_blend(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults assertEquals(colour_blend('#ff0000', colour_rgb(100, 40, 0), 0.4), '#ff2900', 'blend') -"""Describe this function... -""" +# Describe this function... def test_procedure(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults procedure_1(8, 2) @@ -1334,22 +1258,19 @@ def test_procedure(): procedure_2(True) assertEquals(proc_w, False, 'procedure return') -"""Describe this function... -""" +# Describe this function... def procedure_1(proc_x, proc_y): global test_name, naked, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults proc_z = proc_x / proc_y -"""Describe this function... -""" +# Describe this function... def procedure_2(proc_x): global test_name, naked, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults if proc_x: return proc_w = True -"""Describe this function... -""" +# Describe this function... def test_function(): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults assertEquals(function_1(2, 3), -1, 'function with arguments') @@ -1361,30 +1282,26 @@ def test_function(): assertEquals(function_3(True), True, 'function return') assertEquals(function_3(False), False, 'function no return') -"""Describe this function... -""" +# Describe this function... def function_1(func_x, func_y): global test_name, naked, proc_x, proc_y, func_a, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults func_z = 'side effect' return func_x - func_y -"""Describe this function... -""" +# Describe this function... def function_2(func_a): global test_name, naked, proc_x, proc_y, func_x, func_y, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults func_a = (func_a if isinstance(func_a, Number) else 0) + 1 return str(func_a) + str(func_c) -"""Describe this function... -""" +# Describe this function... def function_3(func_a): global test_name, naked, proc_x, proc_y, func_x, func_y, n, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults if func_a: return True return False -"""Describe this function... -""" +# Describe this function... def recurse(n): global test_name, naked, proc_x, proc_y, func_x, func_y, func_a, ok, log, count, varToChange, rand, item, text, number_of_calls, list2, proc_z, func_z, x, proc_w, func_c, if2, i, loglist, changing_list, list_copy, unittestResults if n > 0: From ae111744b666373a9aedefa81eddd97475b678b9 Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Mon, 14 Oct 2019 12:55:48 -0600 Subject: [PATCH 09/21] Rebuild --- blockly_compressed.js | 28 ++++++++++++++-------------- blockly_uncompressed.js | 1 + javascript_compressed.js | 4 ++-- python_compressed.js | 4 ++-- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/blockly_compressed.js b/blockly_compressed.js index a0bebe1e1..0f0c07000 100644 --- a/blockly_compressed.js +++ b/blockly_compressed.js @@ -330,7 +330,7 @@ Blockly.Field.prototype.updateEditable=function(){var a=this.getClickTarget_();t Blockly.Field.prototype.isClickable=function(){return!!this.sourceBlock_&&this.sourceBlock_.isEditable()&&!!this.showEditor_&&"function"===typeof this.showEditor_};Blockly.Field.prototype.isCurrentlyEditable=function(){return this.EDITABLE&&!!this.sourceBlock_&&this.sourceBlock_.isEditable()}; Blockly.Field.prototype.isSerializable=function(){var a=!1;this.name&&(this.SERIALIZABLE?a=!0:this.EDITABLE&&(console.warn("Detected an editable field that was not serializable. Please define SERIALIZABLE property as true on all editable custom fields. Proceeding with serialization."),a=!0));return a};Blockly.Field.prototype.isVisible=function(){return this.visible_}; Blockly.Field.prototype.setVisible=function(a){if(this.visible_!=a){this.visible_=a;var b=this.getSvgRoot();b&&(b.style.display=a?"block":"none")}};Blockly.Field.prototype.setValidator=function(a){this.validator_=a};Blockly.Field.prototype.getValidator=function(){return this.validator_};Blockly.Field.prototype.classValidator=function(a){return a}; -Blockly.Field.prototype.callValidator=function(a){var b=this.classValidator(a);if(null===b)return null;void 0!==b&&(a=b);if(b=this.getValidator()){b=b.call(this,a);if(null===b)return null;void 0!==b&&(a=b)}return a};Blockly.Field.prototype.getSvgRoot=function(){return this.fieldGroup_};Blockly.Field.prototype.updateColour=function(){};Blockly.Field.prototype.render_=function(){this.textContent_.nodeValue=this.getDisplayText_();this.updateSize_()}; +Blockly.Field.prototype.callValidator=function(a){var b=this.classValidator(a);if(null===b)return null;void 0!==b&&(a=b);if(b=this.getValidator()){b=b.call(this,a);if(null===b)return null;void 0!==b&&(a=b)}return a};Blockly.Field.prototype.getSvgRoot=function(){return this.fieldGroup_};Blockly.Field.prototype.updateColour=function(){};Blockly.Field.prototype.render_=function(){this.textContent_&&(this.textContent_.nodeValue=this.getDisplayText_(),this.updateSize_())}; Blockly.Field.prototype.updateWidth=function(){console.warn("Deprecated call to updateWidth, call Blockly.Field.updateSize_ to force an update to the size of the field, or Blockly.utils.dom.getTextWidth() to check the size of the field.");this.updateSize_()};Blockly.Field.prototype.updateSize_=function(){var a=Blockly.utils.dom.getTextWidth(this.textElement_);this.borderRect_&&(a+=Blockly.Field.X_PADDING,this.borderRect_.setAttribute("width",a));this.size_.width=a}; Blockly.Field.prototype.getSize=function(){if(!this.isVisible())return new Blockly.utils.Size(0,0);this.isDirty_?(this.render_(),this.isDirty_=!1):this.visible_&&0==this.size_.width&&(console.warn("Deprecated use of setting size_.width to 0 to rerender a field. Set field.isDirty_ to true instead."),this.render_());return this.size_}; Blockly.Field.prototype.getScaledBBox_=function(){var a=this.borderRect_.getBBox(),b=a.height*this.sourceBlock_.workspace.scale;a=a.width*this.sourceBlock_.workspace.scale;var c=this.getAbsoluteXY_();return{top:c.y,bottom:c.y+b,left:c.x,right:c.x+a}}; @@ -448,8 +448,8 @@ Blockly.ContextMenu.blockDeleteOption=function(a){var b=a.getDescendants(!1).len Blockly.ContextMenu.blockDuplicateOption=function(a){var b=a.isDuplicatable();return{text:Blockly.Msg.DUPLICATE_BLOCK,enabled:b,callback:function(){Blockly.duplicate_(a)}}};Blockly.ContextMenu.blockCommentOption=function(a){var b={enabled:!Blockly.utils.userAgent.IE};a.comment?(b.text=Blockly.Msg.REMOVE_COMMENT,b.callback=function(){a.setCommentText(null)}):(b.text=Blockly.Msg.ADD_COMMENT,b.callback=function(){a.setCommentText("")});return b}; Blockly.ContextMenu.commentDeleteOption=function(a){return{text:Blockly.Msg.REMOVE_COMMENT,enabled:!0,callback:function(){Blockly.Events.setGroup(!0);a.dispose(!0,!0);Blockly.Events.setGroup(!1)}}};Blockly.ContextMenu.commentDuplicateOption=function(a){return{text:Blockly.Msg.DUPLICATE_COMMENT,enabled:!0,callback:function(){Blockly.duplicate_(a)}}}; Blockly.ContextMenu.workspaceCommentOption=function(a,b){if(!Blockly.WorkspaceCommentSvg)throw Error("Missing require for Blockly.WorkspaceCommentSvg");var c={enabled:!Blockly.utils.userAgent.IE};c.text=Blockly.Msg.ADD_COMMENT;c.callback=function(){var c=new Blockly.WorkspaceCommentSvg(a,Blockly.Msg.WORKSPACE_COMMENT_DEFAULT_TEXT,Blockly.WorkspaceCommentSvg.DEFAULT_SIZE,Blockly.WorkspaceCommentSvg.DEFAULT_SIZE),e=a.getInjectionDiv().getBoundingClientRect();e=new Blockly.utils.Coordinate(b.clientX- -e.left,b.clientY-e.top);var f=a.getOriginOffsetInPixels();e=Blockly.utils.Coordinate.difference(e,f);e.scale(1/a.scale);c.moveBy(e.x,e.y);a.rendered&&(c.initSvg(),c.render(),c.select())};return c};Blockly.RenderedConnection=function(a,b){Blockly.RenderedConnection.superClass_.constructor.call(this,a,b);this.db_=a.workspace.connectionDBList[b];this.dbOpposite_=a.workspace.connectionDBList[Blockly.OPPOSITE_TYPE[b]];this.offsetInBlock_=new Blockly.utils.Coordinate(0,0);this.inDB_=!1;this.hidden_=!this.db_};Blockly.utils.object.inherits(Blockly.RenderedConnection,Blockly.Connection);Blockly.RenderedConnection.prototype.dispose=function(){this.inDB_&&this.db_.removeConnection_(this);Blockly.RenderedConnection.superClass_.dispose.call(this)}; -Blockly.RenderedConnection.prototype.distanceFrom=function(a){var b=this.x_-a.x_;a=this.y_-a.y_;return Math.sqrt(b*b+a*a)}; +e.left,b.clientY-e.top);var f=a.getOriginOffsetInPixels();e=Blockly.utils.Coordinate.difference(e,f);e.scale(1/a.scale);c.moveBy(e.x,e.y);a.rendered&&(c.initSvg(),c.render(),c.select())};return c};Blockly.RenderedConnection=function(a,b){Blockly.RenderedConnection.superClass_.constructor.call(this,a,b);this.db_=a.workspace.connectionDBList[b];this.dbOpposite_=a.workspace.connectionDBList[Blockly.OPPOSITE_TYPE[b]];this.offsetInBlock_=new Blockly.utils.Coordinate(0,0);this.inDB_=!1;this.hidden_=!this.db_};Blockly.utils.object.inherits(Blockly.RenderedConnection,Blockly.Connection); +Blockly.RenderedConnection.prototype.dispose=function(){Blockly.RenderedConnection.superClass_.dispose.call(this);this.inDB_&&this.db_.removeConnection_(this)};Blockly.RenderedConnection.prototype.distanceFrom=function(a){var b=this.x_-a.x_;a=this.y_-a.y_;return Math.sqrt(b*b+a*a)}; Blockly.RenderedConnection.prototype.bumpAwayFrom_=function(a){if(!this.sourceBlock_.workspace.isDragging()){var b=this.sourceBlock_.getRootBlock();if(!b.isInFlyout){var c=!1;if(!b.isMovable()){b=a.getSourceBlock().getRootBlock();if(!b.isMovable())return;a=this;c=!0}var d=Blockly.selected==b;d||b.addSelect();var e=a.x_+Blockly.SNAP_RADIUS+Math.floor(Math.random()*Blockly.BUMP_RANDOMNESS)-this.x_,f=a.y_+Blockly.SNAP_RADIUS+Math.floor(Math.random()*Blockly.BUMP_RANDOMNESS)-this.y_;c&&(f=-f);b.RTL&& (e=a.x_-Blockly.SNAP_RADIUS-Math.floor(Math.random()*Blockly.BUMP_RANDOMNESS)-this.x_);b.moveBy(e,f);d||b.removeSelect()}}};Blockly.RenderedConnection.prototype.moveTo=function(a,b){this.inDB_&&this.db_.removeConnection_(this);this.x_=a;this.y_=b;this.hidden_||this.db_.addConnection(this)};Blockly.RenderedConnection.prototype.moveBy=function(a,b){this.moveTo(this.x_+a,this.y_+b)};Blockly.RenderedConnection.prototype.moveToOffset=function(a){this.moveTo(a.x+this.offsetInBlock_.x,a.y+this.offsetInBlock_.y)}; Blockly.RenderedConnection.prototype.setOffsetInBlock=function(a,b){this.offsetInBlock_.x=a;this.offsetInBlock_.y=b};Blockly.RenderedConnection.prototype.getOffsetInBlock=function(){return this.offsetInBlock_}; @@ -546,14 +546,14 @@ Blockly.Css.CONTENT=[".blocklySvg {","background-color: #fff;","outline: none;", "background-repeat: no-repeat;","height: 16px;","left: 6px;","position: absolute;","right: auto;","vertical-align: middle;","width: 16px;","}",".blocklyWidgetDiv .goog-menuitem-rtl .goog-menuitem-checkbox,",".blocklyWidgetDiv .goog-menuitem-rtl .goog-menuitem-icon,",".blocklyDropDownDiv .goog-menuitem-rtl .goog-menuitem-checkbox,",".blocklyDropDownDiv .goog-menuitem-rtl .goog-menuitem-icon {","left: auto;","right: 6px;","}",".blocklyWidgetDiv .goog-option-selected .goog-menuitem-checkbox,",".blocklyWidgetDiv .goog-option-selected .goog-menuitem-icon,", ".blocklyDropDownDiv .goog-option-selected .goog-menuitem-checkbox,",".blocklyDropDownDiv .goog-option-selected .goog-menuitem-icon {","position: static;","float: left;","margin-left: -24px;","}",".blocklyWidgetDiv .goog-menuitem-rtl .goog-menuitem-checkbox,",".blocklyWidgetDiv .goog-menuitem-rtl .goog-menuitem-icon,",".blocklyDropDownDiv .goog-menuitem-rtl .goog-menuitem-checkbox,",".blocklyDropDownDiv .goog-menuitem-rtl .goog-menuitem-icon {","float: right;","margin-right: -24px;","}"]; Blockly.DropDownDiv=function(){};Blockly.DropDownDiv.DIV_=null;Blockly.DropDownDiv.boundsElement_=null;Blockly.DropDownDiv.owner_=null;Blockly.DropDownDiv.positionToField_=null;Blockly.DropDownDiv.ARROW_SIZE=16;Blockly.DropDownDiv.BORDER_SIZE=1;Blockly.DropDownDiv.ARROW_HORIZONTAL_PADDING=12;Blockly.DropDownDiv.PADDING_Y=16;Blockly.DropDownDiv.ANIMATION_TIME=.25;Blockly.DropDownDiv.DEFAULT_DROPDOWN_BORDER_COLOR="#dadce0";Blockly.DropDownDiv.DEFAULT_DROPDOWN_COLOR="#fff"; -Blockly.DropDownDiv.animateOutTimer_=null;Blockly.DropDownDiv.onHide_=0; +Blockly.DropDownDiv.animateOutTimer_=null;Blockly.DropDownDiv.onHide_=null; Blockly.DropDownDiv.createDom=function(){if(!Blockly.DropDownDiv.DIV_){var a=document.createElement("div");a.className="blocklyDropDownDiv";a.style.backgroundColor=Blockly.DropDownDiv.DEFAULT_DROPDOWN_COLOR;a.style.borderColor=Blockly.DropDownDiv.DEFAULT_DROPDOWN_BORDER_COLOR;document.body.appendChild(a);Blockly.DropDownDiv.DIV_=a;var b=document.createElement("div");b.className="blocklyDropDownContent";a.appendChild(b);Blockly.DropDownDiv.content_=b;b=document.createElement("div");b.className="blocklyDropDownArrow"; a.appendChild(b);Blockly.DropDownDiv.arrow_=b;Blockly.DropDownDiv.DIV_.style.opacity=0;Blockly.DropDownDiv.DIV_.style.transition="transform "+Blockly.DropDownDiv.ANIMATION_TIME+"s, opacity "+Blockly.DropDownDiv.ANIMATION_TIME+"s";a.addEventListener("focusin",function(){Blockly.utils.dom.addClass(a,"focused")});a.addEventListener("focusout",function(){Blockly.utils.dom.removeClass(a,"focused")})}};Blockly.DropDownDiv.setBoundsElement=function(a){Blockly.DropDownDiv.boundsElement_=a}; Blockly.DropDownDiv.getContentDiv=function(){return Blockly.DropDownDiv.content_};Blockly.DropDownDiv.clearContent=function(){Blockly.DropDownDiv.content_.innerHTML="";Blockly.DropDownDiv.content_.style.width=""};Blockly.DropDownDiv.setColour=function(a,b){Blockly.DropDownDiv.DIV_.style.backgroundColor=a;Blockly.DropDownDiv.DIV_.style.borderColor=b};Blockly.DropDownDiv.setCategory=function(a){Blockly.DropDownDiv.DIV_.setAttribute("data-category",a)}; -Blockly.DropDownDiv.showPositionedByBlock=function(a,b,c,d){var e=b.workspace.scale,f=b.width,g=b.height;f*=e;g*=e;e=b.getSvgRoot().getBoundingClientRect();f=e.left+f/2;g=e.top+g;e=e.top;d&&(e+=d);Blockly.DropDownDiv.setBoundsElement(b.workspace.getParentSvg().parentNode);return Blockly.DropDownDiv.show(a,f,g,f,e,c)}; -Blockly.DropDownDiv.showPositionedByField=function(a,b,c){var d=a.fieldGroup_.getBoundingClientRect(),e=d.left+d.width/2,f=d.bottom;d=d.top;c&&(d+=c);Blockly.DropDownDiv.positionToField_=!0;Blockly.DropDownDiv.setBoundsElement(a.getSourceBlock().workspace.getParentSvg().parentNode);return Blockly.DropDownDiv.show(a,e,f,e,d,b)}; -Blockly.DropDownDiv.show=function(a,b,c,d,e,f){Blockly.DropDownDiv.owner_=a;Blockly.DropDownDiv.onHide_=f;a=Blockly.DropDownDiv.getPositionMetrics(b,c,d,e);a.arrowVisible?(Blockly.DropDownDiv.arrow_.style.display="",Blockly.DropDownDiv.arrow_.style.transform="translate("+a.arrowX+"px,"+a.arrowY+"px) rotate(45deg)",Blockly.DropDownDiv.arrow_.setAttribute("class",a.arrowAtTop?"blocklyDropDownArrow arrowTop":"blocklyDropDownArrow arrowBottom")):Blockly.DropDownDiv.arrow_.style.display="none";Blockly.DropDownDiv.positionInternal_(a.initialX, -a.initialY,a.finalX,a.finalY);return a.arrowAtTop};Blockly.DropDownDiv.getBoundsInfo_=function(){var a=Blockly.DropDownDiv.boundsElement_.getBoundingClientRect(),b=Blockly.utils.style.getSize(Blockly.DropDownDiv.boundsElement_);return{left:a.left,right:a.left+b.width,top:a.top,bottom:a.top+b.height,width:b.width,height:b.height}}; +Blockly.DropDownDiv.showPositionedByBlock=function(a,b,c,d){var e=b.workspace.scale,f=b.width,g=b.height;f*=e;g*=e;e=b.getSvgRoot().getBoundingClientRect();f=e.left+f/2;g=e.top+g;e=e.top;d&&(e+=d);Blockly.DropDownDiv.setBoundsElement(b.workspace.getParentSvg().parentNode);return Blockly.DropDownDiv.show(a,b.RTL,f,g,f,e,c)}; +Blockly.DropDownDiv.showPositionedByField=function(a,b,c){var d=a.fieldGroup_.getBoundingClientRect(),e=d.left+d.width/2,f=d.bottom;d=d.top;c&&(d+=c);c=a.getSourceBlock();Blockly.DropDownDiv.positionToField_=!0;Blockly.DropDownDiv.setBoundsElement(c.workspace.getParentSvg().parentNode);return Blockly.DropDownDiv.show(a,c.RTL,e,f,e,d,b)}; +Blockly.DropDownDiv.show=function(a,b,c,d,e,f,g){Blockly.DropDownDiv.owner_=a;Blockly.DropDownDiv.onHide_=g||null;a=Blockly.DropDownDiv.getPositionMetrics(c,d,e,f);a.arrowVisible?(Blockly.DropDownDiv.arrow_.style.display="",Blockly.DropDownDiv.arrow_.style.transform="translate("+a.arrowX+"px,"+a.arrowY+"px) rotate(45deg)",Blockly.DropDownDiv.arrow_.setAttribute("class",a.arrowAtTop?"blocklyDropDownArrow arrowTop":"blocklyDropDownArrow arrowBottom")):Blockly.DropDownDiv.arrow_.style.display="none"; +Blockly.DropDownDiv.DIV_.style.direction=b?"rtl":"ltr";Blockly.DropDownDiv.positionInternal_(a.initialX,a.initialY,a.finalX,a.finalY);return a.arrowAtTop};Blockly.DropDownDiv.getBoundsInfo_=function(){var a=Blockly.DropDownDiv.boundsElement_.getBoundingClientRect(),b=Blockly.utils.style.getSize(Blockly.DropDownDiv.boundsElement_);return{left:a.left,right:a.left+b.width,top:a.top,bottom:a.top+b.height,width:b.width,height:b.height}}; Blockly.DropDownDiv.getPositionMetrics=function(a,b,c,d){var e=Blockly.DropDownDiv.getBoundsInfo_(),f=Blockly.utils.style.getSize(Blockly.DropDownDiv.DIV_);return b+f.heighte.top?Blockly.DropDownDiv.getPositionAboveMetrics(c,d,e,f):b+f.heightdocument.documentElement.clientTop?Blockly.DropDownDiv.getPositionAboveMetrics(c,d, e,f):Blockly.DropDownDiv.getPositionTopOfPageMetrics(a,e,f)};Blockly.DropDownDiv.getPositionBelowMetrics=function(a,b,c,d){a=Blockly.DropDownDiv.getPositionX(a,c.left,c.right,d.width);return{initialX:a.divX,initialY:b,finalX:a.divX,finalY:b+Blockly.DropDownDiv.PADDING_Y,arrowX:a.arrowX,arrowY:-(Blockly.DropDownDiv.ARROW_SIZE/2+Blockly.DropDownDiv.BORDER_SIZE),arrowAtTop:!0,arrowVisible:!0}}; Blockly.DropDownDiv.getPositionAboveMetrics=function(a,b,c,d){a=Blockly.DropDownDiv.getPositionX(a,c.left,c.right,d.width);return{initialX:a.divX,initialY:b-d.height,finalX:a.divX,finalY:b-d.height-Blockly.DropDownDiv.PADDING_Y,arrowX:a.arrowX,arrowY:d.height-2*Blockly.DropDownDiv.BORDER_SIZE-Blockly.DropDownDiv.ARROW_SIZE/2,arrowAtTop:!1,arrowVisible:!0}}; @@ -847,7 +847,7 @@ Blockly.FieldTextInput.prototype.resizeEditor_=function(){var a=Blockly.WidgetDi Blockly.FieldTextInput.numberValidator=function(a){console.warn("Blockly.FieldTextInput.numberValidator is deprecated. Use Blockly.FieldNumber instead.");if(null===a)return null;a=String(a);a=a.replace(/O/ig,"0");a=a.replace(/,/g,"");a=Number(a||0);return isNaN(a)?null:String(a)};Blockly.FieldTextInput.nonnegativeIntegerValidator=function(a){(a=Blockly.FieldTextInput.numberValidator(a))&&(a=String(Math.max(0,Math.floor(a))));return a};Blockly.FieldTextInput.prototype.isTabNavigable=function(){return!0}; Blockly.FieldTextInput.prototype.getText_=function(){return this.isBeingEdited_&&this.htmlInput_?this.htmlInput_.value:null};Blockly.FieldTextInput.prototype.getEditorText_=function(a){return String(a)};Blockly.FieldTextInput.prototype.getValueFromEditorText_=function(a){return a};Blockly.fieldRegistry.register("field_input",Blockly.FieldTextInput);Blockly.FieldAngle=function(a,b,c){this.clockwise_=Blockly.FieldAngle.CLOCKWISE;this.offset_=Blockly.FieldAngle.OFFSET;this.wrap_=Blockly.FieldAngle.WRAP;this.round_=Blockly.FieldAngle.ROUND;Blockly.FieldAngle.superClass_.constructor.call(this,a||0,b,c)};Blockly.utils.object.inherits(Blockly.FieldAngle,Blockly.FieldTextInput);Blockly.FieldAngle.fromJson=function(a){return new Blockly.FieldAngle(a.angle,void 0,a)};Blockly.FieldAngle.prototype.SERIALIZABLE=!0;Blockly.FieldAngle.ROUND=15; Blockly.FieldAngle.HALF=50;Blockly.FieldAngle.CLOCKWISE=!1;Blockly.FieldAngle.OFFSET=0;Blockly.FieldAngle.WRAP=360;Blockly.FieldAngle.RADIUS=Blockly.FieldAngle.HALF-1; -Blockly.FieldAngle.prototype.configure_=function(a){Blockly.FieldAngle.superClass_.configure_.call(this,a);switch(a.mode){case "compass":this.clockwise_=!0;this.offset_=90;break;case "protractor":this.clockwise_=!1,this.offset_=0}var b=a.clockwise;"boolean"==typeof b&&(this.clockwise_=b);b=Number(a.offset);isNaN(b)||(this.offset_=b);b=Number(a.wrap);isNaN(b)||(this.wrap_=b);a=Number(a.round);isNaN(a)||(this.round_=a)}; +Blockly.FieldAngle.prototype.configure_=function(a){Blockly.FieldAngle.superClass_.configure_.call(this,a);switch(a.mode){case "compass":this.clockwise_=!0;this.offset_=90;break;case "protractor":this.clockwise_=!1,this.offset_=0}var b=a.clockwise;"boolean"==typeof b&&(this.clockwise_=b);b=a.offset;null!=b&&(b=Number(b),isNaN(b)||(this.offset_=b));b=a.wrap;null!=b&&(b=Number(b),isNaN(b)||(this.wrap_=b));a=a.round;null!=a&&(a=Number(a),isNaN(a)||(this.round_=a))}; Blockly.FieldAngle.prototype.initView=function(){Blockly.FieldAngle.superClass_.initView.call(this);this.symbol_=Blockly.utils.dom.createSvgElement("tspan",{},null);this.symbol_.appendChild(document.createTextNode("\u00b0"));this.textElement_.appendChild(this.symbol_)};Blockly.FieldAngle.prototype.render_=function(){Blockly.FieldAngle.superClass_.render_.call(this);this.updateGraph_()}; Blockly.FieldAngle.prototype.showEditor_=function(){Blockly.FieldAngle.superClass_.showEditor_.call(this,Blockly.utils.userAgent.MOBILE||Blockly.utils.userAgent.ANDROID||Blockly.utils.userAgent.IPAD);var a=this.dropdownCreate_();Blockly.DropDownDiv.getContentDiv().appendChild(a);a=this.sourceBlock_.getColourBorder();a=a.colourBorder||a.colourLight;Blockly.DropDownDiv.setColour(this.sourceBlock_.getColour(),a);Blockly.DropDownDiv.showPositionedByField(this,this.dropdownDispose_.bind(this));this.updateGraph_()}; Blockly.FieldAngle.prototype.dropdownCreate_=function(){var a=Blockly.utils.dom.createSvgElement("svg",{xmlns:Blockly.utils.dom.SVG_NS,"xmlns:html":Blockly.utils.dom.HTML_NS,"xmlns:xlink":Blockly.utils.dom.XLINK_NS,version:"1.1",height:2*Blockly.FieldAngle.HALF+"px",width:2*Blockly.FieldAngle.HALF+"px",style:"touch-action: none"},null),b=Blockly.utils.dom.createSvgElement("circle",{cx:Blockly.FieldAngle.HALF,cy:Blockly.FieldAngle.HALF,r:Blockly.FieldAngle.RADIUS,"class":"blocklyAngleCircle"},a);this.gauge_= @@ -876,7 +876,7 @@ Blockly.FieldColour.prototype.moveHighlightBy_=function(a,b){var c=this.colours_ Blockly.FieldColour.prototype.onMouseMove_=function(a){var b=(a=a.target)&&a.getAttribute("data-index");null!==b&&b!==this.highlightedIndex_&&this.setHighlightedCell_(a,Number(b))};Blockly.FieldColour.prototype.onMouseEnter_=function(){this.picker_.focus()};Blockly.FieldColour.prototype.onMouseLeave_=function(){this.picker_.blur();var a=this.getHighlighted_();a&&Blockly.utils.dom.removeClass(a,"blocklyColourHighlighted")}; Blockly.FieldColour.prototype.getHighlighted_=function(){var a=this.columns_||Blockly.FieldColour.COLUMNS,b=this.picker_.childNodes[Math.floor(this.highlightedIndex_/a)];return b?b.childNodes[this.highlightedIndex_%a]:null}; Blockly.FieldColour.prototype.setHighlightedCell_=function(a,b){var c=this.getHighlighted_();c&&Blockly.utils.dom.removeClass(c,"blocklyColourHighlighted");Blockly.utils.dom.addClass(a,"blocklyColourHighlighted");this.highlightedIndex_=b;Blockly.utils.aria.setState(this.picker_,Blockly.utils.aria.State.ACTIVEDESCENDANT,a.getAttribute("id"))}; -Blockly.FieldColour.prototype.dropdownCreate_=function(){var a=this.columns_||Blockly.FieldColour.COLUMNS,b=this.colours_||Blockly.FieldColour.COLOURS,c=this.titles_||Blockly.FieldColour.TITLES,d=this.getValue(),e=document.createElement("table");e.className="blocklyColourTable";e.tabIndex=0;Blockly.utils.aria.setRole(e,Blockly.utils.aria.Role.GRID);Blockly.utils.aria.setState(e,Blockly.utils.aria.State.EXPANDED,!0);Blockly.utils.aria.setState(e,"rowcount",Math.floor(b.length/a));Blockly.utils.aria.setState(e, +Blockly.FieldColour.prototype.dropdownCreate_=function(){var a=this.columns_||Blockly.FieldColour.COLUMNS,b=this.colours_||Blockly.FieldColour.COLOURS,c=this.titles_||Blockly.FieldColour.TITLES,d=this.getValue(),e=document.createElement("table");e.className="blocklyColourTable";e.tabIndex=0;e.dir="ltr";Blockly.utils.aria.setRole(e,Blockly.utils.aria.Role.GRID);Blockly.utils.aria.setState(e,Blockly.utils.aria.State.EXPANDED,!0);Blockly.utils.aria.setState(e,"rowcount",Math.floor(b.length/a));Blockly.utils.aria.setState(e, "colcount",a);for(var f,g=0;gthis.max_&&Blockly.utils.aria.setState(a,Blockly.utils.aria.State.VALUEMAX,this.max_);return a};Blockly.fieldRegistry.register("field_number",Blockly.FieldNumber);Blockly.FieldVariable=function(a,b,c,d,e){this.menuGenerator_=Blockly.FieldVariable.dropdownCreate;this.defaultVariableName=a||"";this.size_=new Blockly.utils.Size(0,Blockly.BlockSvg.MIN_BLOCK_Y);e&&this.configure_(e);b&&this.setValidator(b);e||this.setTypes_(c,d)};Blockly.utils.object.inherits(Blockly.FieldVariable,Blockly.FieldDropdown);Blockly.FieldVariable.fromJson=function(a){var b=Blockly.utils.replaceMessageReferences(a.variable);return new Blockly.FieldVariable(b,void 0,void 0,void 0,a)}; Blockly.FieldVariable.prototype.workspace_=null;Blockly.FieldVariable.prototype.SERIALIZABLE=!0;Blockly.FieldVariable.prototype.configure_=function(a){Blockly.FieldVariable.superClass_.configure_.call(this,a);this.setTypes_(a.variableTypes,a.defaultType)}; @@ -1024,8 +1024,8 @@ b.insertBefore(a,this.workspace_.svgBlockCanvas_);this.svgDialog_.appendChild(b) Blockly.Mutator.prototype.resizeBubble_=function(){var a=2*Blockly.Bubble.BORDER_WIDTH,b=this.workspace_.getCanvas().getBBox();var c=this.block_.RTL?-b.x:b.width+b.x;b=b.height+3*a;if(this.workspace_.flyout_){var d=this.workspace_.flyout_.getMetrics_();b=Math.max(b,d.contentHeight+20)}c+=3*a;if(Math.abs(this.workspaceWidth_-c)>a||Math.abs(this.workspaceHeight_-b)>a)this.workspaceWidth_=c,this.workspaceHeight_=b,this.bubble_.setBubbleSize(c+a,b+a),this.svgDialog_.setAttribute("width",this.workspaceWidth_), this.svgDialog_.setAttribute("height",this.workspaceHeight_);this.block_.RTL&&(a="translate("+this.workspaceWidth_+",0)",this.workspace_.getCanvas().setAttribute("transform",a));this.workspace_.resize()}; Blockly.Mutator.prototype.setVisible=function(a){if(a!=this.isVisible())if(Blockly.Events.fire(new Blockly.Events.Ui(this.block_,"mutatorOpen",!a,a)),a){this.bubble_=new Blockly.Bubble(this.block_.workspace,this.createEditor_(),this.block_.svgPath_,this.iconXY_,null,null);this.bubble_.setSvgId(this.block_.id);if(a=this.workspace_.options.languageTree)this.workspace_.flyout_.init(this.workspace_),this.workspace_.flyout_.show(a.childNodes);this.rootBlock_=this.block_.decompose(this.workspace_);a=this.rootBlock_.getDescendants(!1); -for(var b=0,c;c=a[b];b++)c.render();this.rootBlock_.setMovable(!1);this.rootBlock_.setDeletable(!1);this.workspace_.flyout_?(a=2*this.workspace_.flyout_.CORNER_RADIUS,b=this.workspace_.getFlyout().getWidth()+a):b=a=16;this.block_.RTL&&(b=-b);this.rootBlock_.moveBy(b,a);if(this.block_.saveConnections){var d=this;this.block_.saveConnections(this.rootBlock_);this.sourceListener_=function(){d.block_.saveConnections(d.rootBlock_)};this.block_.workspace.addChangeListener(this.sourceListener_)}this.workspace_.addChangeListener(this.workspaceChanged_.bind(this)); -this.updateColour()}else this.svgDialog_=null,this.workspace_.dispose(),this.rootBlock_=this.workspace_=null,this.bubble_.dispose(),this.bubble_=null,this.workspaceHeight_=this.workspaceWidth_=0,this.sourceListener_&&(this.block_.workspace.removeChangeListener(this.sourceListener_),this.sourceListener_=null)}; +for(var b=0,c;c=a[b];b++)c.render();this.rootBlock_.setMovable(!1);this.rootBlock_.setDeletable(!1);this.workspace_.flyout_?(a=2*this.workspace_.flyout_.CORNER_RADIUS,b=this.workspace_.getFlyout().getWidth()+a):b=a=16;this.block_.RTL&&(b=-b);this.rootBlock_.moveBy(b,a);if(this.block_.saveConnections){var d=this;this.block_.saveConnections(this.rootBlock_);this.sourceListener_=function(){d.block_.saveConnections(d.rootBlock_)};this.block_.workspace.addChangeListener(this.sourceListener_)}this.resizeBubble_(); +this.workspace_.addChangeListener(this.workspaceChanged_.bind(this));this.updateColour()}else this.svgDialog_=null,this.workspace_.dispose(),this.rootBlock_=this.workspace_=null,this.bubble_.dispose(),this.bubble_=null,this.workspaceHeight_=this.workspaceWidth_=0,this.sourceListener_&&(this.block_.workspace.removeChangeListener(this.sourceListener_),this.sourceListener_=null)}; Blockly.Mutator.prototype.workspaceChanged_=function(a){if(a.type!=Blockly.Events.UI&&(a.type!=Blockly.Events.CHANGE||"disabled"!=a.element)){if(!this.workspace_.isDragging()){a=this.workspace_.getTopBlocks(!1);for(var b=0,c;c=a[b];b++){var d=c.getRelativeToSurfaceXY(),e=c.getHeightWidth();20>d.y+e.height&&c.moveBy(0,20-e.height-d.y)}}if(this.rootBlock_.workspace==this.workspace_){Blockly.Events.setGroup(!0);c=this.block_;a=(a=c.mutationToDom())&&Blockly.Xml.domToText(a);b=c.rendered;c.rendered=!1; c.compose(this.rootBlock_);c.rendered=b;c.initSvg();b=(b=c.mutationToDom())&&Blockly.Xml.domToText(b);if(a!=b){Blockly.Events.fire(new Blockly.Events.BlockChange(c,"mutation",null,a,b));var f=Blockly.Events.getGroup();setTimeout(function(){Blockly.Events.setGroup(f);c.bumpNeighbours();Blockly.Events.setGroup(!1)},Blockly.BUMP_DELAY)}c.rendered&&c.render();a!=b&&Blockly.keyboardAccessibilityMode&&Blockly.navigation.moveCursorOnBlockMutation(c);this.workspace_.isDragging()||this.resizeBubble_();Blockly.Events.setGroup(!1)}}}; Blockly.Mutator.prototype.getFlyoutMetrics_=function(){return{viewHeight:this.workspaceHeight_,viewWidth:this.workspaceWidth_-this.workspace_.getFlyout().getWidth(),absoluteTop:0,absoluteLeft:this.workspace_.RTL?0:this.workspace_.getFlyout().getWidth()}};Blockly.Mutator.prototype.dispose=function(){this.block_.mutator=null;Blockly.Icon.prototype.dispose.call(this)}; diff --git a/blockly_uncompressed.js b/blockly_uncompressed.js index 2165245fa..7b9849e60 100644 --- a/blockly_uncompressed.js +++ b/blockly_uncompressed.js @@ -87,6 +87,7 @@ goog.addDependency("../../core/names.js", ['Blockly.Names'], ['Blockly.Msg']); goog.addDependency("../../core/options.js", ['Blockly.Options'], ['Blockly.utils.userAgent', 'Blockly.Xml']); goog.addDependency("../../core/procedures.js", ['Blockly.Procedures'], ['Blockly.Blocks', 'Blockly.constants', 'Blockly.Events', 'Blockly.Events.BlockChange', 'Blockly.Field', 'Blockly.Msg', 'Blockly.Names', 'Blockly.utils.xml', 'Blockly.Workspace', 'Blockly.Xml']); goog.addDependency("../../core/rendered_connection.js", ['Blockly.RenderedConnection'], ['Blockly.Connection', 'Blockly.Events', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.dom', 'Blockly.utils.object']); +goog.addDependency("../../core/renderers/common/block_paths.js", ['Blockly.Colourer'], []); goog.addDependency("../../core/renderers/common/block_rendering.js", ['Blockly.blockRendering'], ['Blockly.utils.object']); goog.addDependency("../../core/renderers/common/constants.js", ['Blockly.blockRendering.ConstantProvider'], ['Blockly.utils.svgPaths']); goog.addDependency("../../core/renderers/common/debugger.js", ['Blockly.blockRendering.Debug'], ['Blockly.blockRendering.BottomRow', 'Blockly.blockRendering.InputRow', 'Blockly.blockRendering.Measurable', 'Blockly.blockRendering.RenderInfo', 'Blockly.blockRendering.Row', 'Blockly.blockRendering.SpacerRow', 'Blockly.blockRendering.TopRow', 'Blockly.blockRendering.Types']); diff --git a/javascript_compressed.js b/javascript_compressed.js index 98df22838..682ce285b 100644 --- a/javascript_compressed.js +++ b/javascript_compressed.js @@ -12,8 +12,8 @@ Blockly.JavaScript.init=function(a){Blockly.JavaScript.definitions_=Object.creat a=Blockly.Variables.allUsedVarModels(a);for(d=0;dc?Blockly.JavaScript.valueToCode(a,b,Blockly.JavaScript.ORDER_SUBTRACTION)||f:d?Blockly.JavaScript.valueToCode(a,b,Blockly.JavaScript.ORDER_UNARY_NEGATION)||f:Blockly.JavaScript.valueToCode(a,b,e)||f;if(Blockly.isNumber(a))a=Number(a)+c,d&& (a=-a);else{if(0c&&(a=a+" - "+-c,g=Blockly.JavaScript.ORDER_SUBTRACTION);d&&(a=c?"-("+a+")":"-"+a,g=Blockly.JavaScript.ORDER_UNARY_NEGATION);g=Math.floor(g);e=Math.floor(e);g&&e>=g&&(a="("+a+")")}return a};Blockly.JavaScript.colour={};Blockly.JavaScript.colour_picker=function(a){return[Blockly.JavaScript.quote_(a.getFieldValue("COLOUR")),Blockly.JavaScript.ORDER_ATOMIC]};Blockly.JavaScript.colour_random=function(a){return[Blockly.JavaScript.provideFunction_("colourRandom",["function "+Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_+"() {"," var num = Math.floor(Math.random() * Math.pow(2, 24));"," return '#' + ('00000' + num.toString(16)).substr(-6);","}"])+"()",Blockly.JavaScript.ORDER_FUNCTION_CALL]}; Blockly.JavaScript.colour_rgb=function(a){var b=Blockly.JavaScript.valueToCode(a,"RED",Blockly.JavaScript.ORDER_COMMA)||0,c=Blockly.JavaScript.valueToCode(a,"GREEN",Blockly.JavaScript.ORDER_COMMA)||0;a=Blockly.JavaScript.valueToCode(a,"BLUE",Blockly.JavaScript.ORDER_COMMA)||0;return[Blockly.JavaScript.provideFunction_("colourRgb",["function "+Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_+"(r, g, b) {"," r = Math.max(Math.min(Number(r), 100), 0) * 2.55;"," g = Math.max(Math.min(Number(g), 100), 0) * 2.55;", diff --git a/python_compressed.js b/python_compressed.js index 80c5e3ea8..c59970012 100644 --- a/python_compressed.js +++ b/python_compressed.js @@ -10,8 +10,8 @@ Blockly.Python.init=function(a){Blockly.Python.PASS=this.INDENT+"pass\n";Blockly " = None");a=Blockly.Variables.allUsedVarModels(a);for(d=0;dc?"int("+a+" - "+-c+")":"int("+a+")",d&&(a="-"+a));return a};Blockly.Python.colour={};Blockly.Python.colour_picker=function(a){return[Blockly.Python.quote_(a.getFieldValue("COLOUR")),Blockly.Python.ORDER_ATOMIC]};Blockly.Python.colour_random=function(a){Blockly.Python.definitions_.import_random="import random";return["'#%06x' % random.randint(0, 2**24 - 1)",Blockly.Python.ORDER_FUNCTION_CALL]}; +Blockly.Python.scrub_=function(a,b,c){var d="";if(!a.outputConnection||!a.outputConnection.targetConnection){var e=a.getCommentText();e&&(e=Blockly.utils.string.wrap(e,Blockly.Python.COMMENT_WRAP-3),d+=Blockly.Python.prefixLines(e+"\n","# "));for(var f=0;fc?"int("+a+" - "+-c+")":"int("+a+")",d&&(a="-"+a));return a};Blockly.Python.colour={};Blockly.Python.colour_picker=function(a){return[Blockly.Python.quote_(a.getFieldValue("COLOUR")),Blockly.Python.ORDER_ATOMIC]};Blockly.Python.colour_random=function(a){Blockly.Python.definitions_.import_random="import random";return["'#%06x' % random.randint(0, 2**24 - 1)",Blockly.Python.ORDER_FUNCTION_CALL]}; Blockly.Python.colour_rgb=function(a){var b=Blockly.Python.provideFunction_("colour_rgb",["def "+Blockly.Python.FUNCTION_NAME_PLACEHOLDER_+"(r, g, b):"," r = round(min(100, max(0, r)) * 2.55)"," g = round(min(100, max(0, g)) * 2.55)"," b = round(min(100, max(0, b)) * 2.55)"," return '#%02x%02x%02x' % (r, g, b)"]),c=Blockly.Python.valueToCode(a,"RED",Blockly.Python.ORDER_NONE)||0,d=Blockly.Python.valueToCode(a,"GREEN",Blockly.Python.ORDER_NONE)||0;a=Blockly.Python.valueToCode(a,"BLUE",Blockly.Python.ORDER_NONE)|| 0;return[b+"("+c+", "+d+", "+a+")",Blockly.Python.ORDER_FUNCTION_CALL]}; Blockly.Python.colour_blend=function(a){var b=Blockly.Python.provideFunction_("colour_blend",["def "+Blockly.Python.FUNCTION_NAME_PLACEHOLDER_+"(colour1, colour2, ratio):"," r1, r2 = int(colour1[1:3], 16), int(colour2[1:3], 16)"," g1, g2 = int(colour1[3:5], 16), int(colour2[3:5], 16)"," b1, b2 = int(colour1[5:7], 16), int(colour2[5:7], 16)"," ratio = min(1, max(0, ratio))"," r = round(r1 * (1 - ratio) + r2 * ratio)"," g = round(g1 * (1 - ratio) + g2 * ratio)"," b = round(b1 * (1 - ratio) + b2 * ratio)", From cffb126f371d4a9b4572c7c9c84e2064e1c9b0d0 Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Mon, 14 Oct 2019 14:01:14 -0600 Subject: [PATCH 10/21] Update version numbers --- appengine/app.yaml | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/appengine/app.yaml b/appengine/app.yaml index 887349dc1..d5d1bb0a0 100644 --- a/appengine/app.yaml +++ b/appengine/app.yaml @@ -1,5 +1,5 @@ application: blockly-demo -version: 20190722 +version: 20191014 runtime: python27 api_version: 1 threadsafe: no diff --git a/package.json b/package.json index 20f3e4789..54b5a1842 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "blockly", - "version": "2.20190722.0-develop", + "version": "3.20191014.0", "description": "Blockly is a library for building visual programming editors.", "keywords": [ "blockly" From fc6e1bd529237a48d337a2c7e1093e9b0c74edcf Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Mon, 14 Oct 2019 14:16:38 -0600 Subject: [PATCH 11/21] Rebuild to pull in new version number --- blockly_compressed.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blockly_compressed.js b/blockly_compressed.js index 0f0c07000..1f853df66 100644 --- a/blockly_compressed.js +++ b/blockly_compressed.js @@ -769,7 +769,7 @@ Blockly.Variables.createVariable_=function(a,b,c,d){var e=a.getPotentialVariable Blockly.WidgetDiv.show=function(a,b,c){Blockly.WidgetDiv.hide();Blockly.WidgetDiv.owner_=a;Blockly.WidgetDiv.dispose_=c;a=Blockly.utils.style.getViewportPageOffset();Blockly.WidgetDiv.DIV.style.top=a.y+"px";Blockly.WidgetDiv.DIV.style.direction=b?"rtl":"ltr";Blockly.WidgetDiv.DIV.style.display="block"}; Blockly.WidgetDiv.hide=function(){Blockly.WidgetDiv.owner_&&(Blockly.WidgetDiv.owner_=null,Blockly.WidgetDiv.DIV.style.display="none",Blockly.WidgetDiv.DIV.style.left="",Blockly.WidgetDiv.DIV.style.top="",Blockly.WidgetDiv.dispose_&&Blockly.WidgetDiv.dispose_(),Blockly.WidgetDiv.dispose_=null,Blockly.WidgetDiv.DIV.innerHTML="")};Blockly.WidgetDiv.isVisible=function(){return!!Blockly.WidgetDiv.owner_};Blockly.WidgetDiv.hideIfOwner=function(a){Blockly.WidgetDiv.owner_==a&&Blockly.WidgetDiv.hide()}; Blockly.WidgetDiv.positionInternal_=function(a,b,c){Blockly.WidgetDiv.DIV.style.left=a+"px";Blockly.WidgetDiv.DIV.style.top=b+"px";Blockly.WidgetDiv.DIV.style.height=c+"px"};Blockly.WidgetDiv.positionWithAnchor=function(a,b,c,d){var e=Blockly.WidgetDiv.calculateY_(a,b,c);a=Blockly.WidgetDiv.calculateX_(a,b,c,d);0>e?Blockly.WidgetDiv.positionInternal_(a,0,c.height+e):Blockly.WidgetDiv.positionInternal_(a,e,c.height)}; -Blockly.WidgetDiv.calculateX_=function(a,b,c,d){if(d)return b=Math.max(b.right-c.width,a.left),Math.min(b,a.right-c.width);b=Math.min(b.left,a.right-c.width);return Math.max(b,a.left)};Blockly.WidgetDiv.calculateY_=function(a,b,c){return b.bottom+c.height>=a.bottom?b.top-c.height:b.bottom};Blockly.VERSION="2.20190722.0-develop";Blockly.mainWorkspace=null;Blockly.selected=null;Blockly.cursor=null;Blockly.keyboardAccessibilityMode=!1;Blockly.draggingConnections_=[];Blockly.clipboardXml_=null;Blockly.clipboardSource_=null;Blockly.clipboardTypeCounts_=null;Blockly.cache3dSupported_=null;Blockly.svgSize=function(a){return{width:a.cachedWidth_,height:a.cachedHeight_}};Blockly.resizeSvgContents=function(a){a.resizeContents()}; +Blockly.WidgetDiv.calculateX_=function(a,b,c,d){if(d)return b=Math.max(b.right-c.width,a.left),Math.min(b,a.right-c.width);b=Math.min(b.left,a.right-c.width);return Math.max(b,a.left)};Blockly.WidgetDiv.calculateY_=function(a,b,c){return b.bottom+c.height>=a.bottom?b.top-c.height:b.bottom};Blockly.VERSION="3.20191014.0";Blockly.mainWorkspace=null;Blockly.selected=null;Blockly.cursor=null;Blockly.keyboardAccessibilityMode=!1;Blockly.draggingConnections_=[];Blockly.clipboardXml_=null;Blockly.clipboardSource_=null;Blockly.clipboardTypeCounts_=null;Blockly.cache3dSupported_=null;Blockly.svgSize=function(a){return{width:a.cachedWidth_,height:a.cachedHeight_}};Blockly.resizeSvgContents=function(a){a.resizeContents()}; Blockly.svgResize=function(a){for(;a.options.parentWorkspace;)a=a.options.parentWorkspace;var b=a.getParentSvg(),c=b.parentNode;if(c){var d=c.offsetWidth;c=c.offsetHeight;b.cachedWidth_!=d&&(b.setAttribute("width",d+"px"),b.cachedWidth_=d);b.cachedHeight_!=c&&(b.setAttribute("height",c+"px"),b.cachedHeight_=c);a.resize()}}; Blockly.onKeyDown_=function(a){var b=Blockly.mainWorkspace;if(!(Blockly.utils.isTargetInput(a)||b.rendered&&!b.isVisible()))if(b.options.readOnly)Blockly.navigation.onKeyPress(a);else{var c=!1;if(a.keyCode==Blockly.utils.KeyCodes.ESC)Blockly.hideChaff(),Blockly.navigation.onBlocklyAction(Blockly.navigation.ACTION_EXIT);else{if(Blockly.navigation.onKeyPress(a))return;if(a.keyCode==Blockly.utils.KeyCodes.BACKSPACE||a.keyCode==Blockly.utils.KeyCodes.DELETE){a.preventDefault();if(Blockly.Gesture.inProgress())return; Blockly.selected&&Blockly.selected.isDeletable()&&(c=!0)}else if(a.altKey||a.ctrlKey||a.metaKey){if(Blockly.Gesture.inProgress())return;Blockly.selected&&Blockly.selected.isDeletable()&&Blockly.selected.isMovable()&&(a.keyCode==Blockly.utils.KeyCodes.C?(Blockly.hideChaff(),Blockly.copy_(Blockly.selected)):a.keyCode!=Blockly.utils.KeyCodes.X||Blockly.selected.workspace.isFlyout||(Blockly.copy_(Blockly.selected),c=!0));a.keyCode==Blockly.utils.KeyCodes.V?Blockly.clipboardXml_&&(a=Blockly.clipboardSource_, From 8874e58f912ec2ed58e7c4216751dd6caf2ccbb1 Mon Sep 17 00:00:00 2001 From: alschmiedt Date: Mon, 14 Oct 2019 14:22:09 -0700 Subject: [PATCH 12/21] Fix jsdoc syntax (#3242) --- core/components/component.js | 21 ++++++++---- core/components/tree/basenode.js | 50 ++++++++++++++++++++++------- core/components/tree/treecontrol.js | 3 +- 3 files changed, 54 insertions(+), 20 deletions(-) diff --git a/core/components/component.js b/core/components/component.js index f64e161aa..82507405c 100644 --- a/core/components/component.js +++ b/core/components/component.js @@ -40,7 +40,8 @@ Blockly.Component = function() { /** * Whether the component is rendered right-to-left. - * @private {boolean} + * @type {boolean} + * @private */ this.rightToLeft_ = Blockly.Component.defaultRightToLeft; @@ -48,26 +49,30 @@ Blockly.Component = function() { * Unique ID of the component, lazily initialized in {@link * Blockly.Component#getId} if needed. This property is strictly private and * must not be accessed directly outside of this class! - * @private {?string} + * @type {?string} + * @private */ this.id_ = null; /** * Whether the component is in the document. - * @private {boolean} + * @type {boolean} + * @private */ this.inDocument_ = false; /** * The DOM element for the component. - * @private {?Element} + * @type {?Element} + * @private */ this.element_ = null; /** * Parent component to which events will be propagated. This property is * strictly private and must not be accessed directly outside of this class! - * @private {?Blockly.Component} + * @type {?Blockly.Component} + * @private */ this.parent_ = null; @@ -75,7 +80,8 @@ Blockly.Component = function() { * Array of child components. * Must be kept in sync with `childIndex_`. This property is strictly * private and must not be accessed directly outside of this class! - * @private {?Array.} + * @type {?Array.} + * @private */ this.children_ = []; @@ -85,7 +91,8 @@ Blockly.Component = function() { * Must be kept in sync with `children_`. This property is strictly * private and must not be accessed directly outside of this class! * - * @private {?Object} + * @type {?Object} + * @private */ this.childIndex_ = {}; }; diff --git a/core/components/tree/basenode.js b/core/components/tree/basenode.js index f1e846c82..9127dbe32 100644 --- a/core/components/tree/basenode.js +++ b/core/components/tree/basenode.js @@ -58,55 +58,81 @@ Blockly.tree.BaseNode = function(content, config) { */ this.content_ = content; - /** @private {string} */ + /** + * @type {string} + * @private + */ this.iconClass_; - /** @private {string} */ + /** + * @type {string} + * @private + */ this.expandedIconClass_; - /** @protected {Blockly.tree.TreeControl} */ + /** + * @type {Blockly.tree.TreeControl} + * @protected + */ this.tree; - /** @private {Blockly.tree.BaseNode} */ + /** + * @type {Blockly.tree.BaseNode} + * @private + */ this.previousSibling_; - /** @private {Blockly.tree.BaseNode} */ + /** + * @type {Blockly.tree.BaseNode} + * @private + */ this.nextSibling_; - /** @private {Blockly.tree.BaseNode} */ + /** + * @type {Blockly.tree.BaseNode} + * @private + */ this.firstChild_; - /** @private {Blockly.tree.BaseNode} */ + /** + * @type {Blockly.tree.BaseNode} + * @private + */ this.lastChild_; /** * Whether the tree item is selected. - * @private {boolean} + * @type {boolean} + * @private */ this.selected_ = false; /** * Whether the tree node is expanded. - * @private {boolean} + * @type {boolean} + * @private */ this.expanded_ = false; /** * Tooltip for the tree item - * @private {?string} + * @type {?string} + * @private */ this.toolTip_ = null; /** * Whether to allow user to collapse this node. - * @private {boolean} + * @type {boolean} + * @private */ this.isUserCollapsible_ = true; /** * Nesting depth of this node; cached result of computeDepth_. * -1 if value has not been cached. - * @private {number} + * @type {number} + * @private */ this.depth_ = -1; }; diff --git a/core/components/tree/treecontrol.js b/core/components/tree/treecontrol.js index cfd0b01cf..7e9a58659 100644 --- a/core/components/tree/treecontrol.js +++ b/core/components/tree/treecontrol.js @@ -52,7 +52,8 @@ Blockly.tree.TreeControl = function(toolbox, config) { /** * Currently selected item. - * @private {Blockly.tree.BaseNode} + * @type {Blockly.tree.BaseNode} + * @private */ this.selectedItem_ = this; }; From af72df58aecc89e1be90dcb3ea196d9078109a53 Mon Sep 17 00:00:00 2001 From: alschmiedt Date: Mon, 14 Oct 2019 19:39:26 -0700 Subject: [PATCH 13/21] Update todos so they are no longer in jsdocs (#3250) --- core/block_svg.js | 8 ++++---- core/gesture.js | 2 +- core/icon.js | 2 +- core/renderers/common/info.js | 2 +- core/renderers/measurables/rows.js | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/core/block_svg.js b/core/block_svg.js index 42183cbf8..c34e05894 100644 --- a/core/block_svg.js +++ b/core/block_svg.js @@ -178,34 +178,34 @@ Blockly.BlockSvg.COLLAPSED_WARNING_ID = 'TEMP_COLLAPSED_WARNING_'; // Leftover UI constants from block_render_svg.js. /** * Vertical space between elements. - * TODO (#3142): Remove. * @const * @package */ +// TODO (#3142): Remove. Blockly.BlockSvg.SEP_SPACE_Y = 10; /** * Minimum height of a block. - * TODO (#3142): Remove. * @const * @package */ +// TODO (#3142): Remove. Blockly.BlockSvg.MIN_BLOCK_Y = 25; /** * Width of horizontal puzzle tab. - * TODO (#3142): Remove. * @const * @package */ +// TODO (#3142): Remove. Blockly.BlockSvg.TAB_WIDTH = 8; /** * Do blocks with no previous or output connections have a 'hat' on top? - * TODO (#3142): Remove. * @const * @package */ +// TODO (#3142): Remove. Blockly.BlockSvg.START_HAT = false; /** diff --git a/core/gesture.js b/core/gesture.js index f27dfa982..7308f278a 100644 --- a/core/gesture.js +++ b/core/gesture.js @@ -456,9 +456,9 @@ Blockly.Gesture.prototype.startDraggingBlock_ = function() { /** * Create a bubble dragger and start dragging the selected bubble. - * TODO (fenichel): Possibly combine this and startDraggingBlock_. * @private */ +// TODO (fenichel): Possibly combine this and startDraggingBlock_. Blockly.Gesture.prototype.startDraggingBubble_ = function() { this.bubbleDragger_ = new Blockly.BubbleDragger(this.startBubble_, this.startWorkspace_); diff --git a/core/icon.js b/core/icon.js index 084df886c..cd76e888c 100644 --- a/core/icon.js +++ b/core/icon.js @@ -185,9 +185,9 @@ Blockly.Icon.prototype.getIconLocation = function() { * Get the size of the icon as used for rendering. * This differs from the actual size of the icon, because it bulges slightly * out of its row rather than increasing the height of its row. - * TODO (#2562): Remove getCorrectedSize. * @return {!Blockly.utils.Size} Height and width. */ +// TODO (#2562): Remove getCorrectedSize. Blockly.Icon.prototype.getCorrectedSize = function() { return new Blockly.utils.Size( Blockly.Icon.prototype.SIZE, Blockly.Icon.prototype.SIZE - 2); diff --git a/core/renderers/common/info.js b/core/renderers/common/info.js index 2819623d7..5e5530274 100644 --- a/core/renderers/common/info.js +++ b/core/renderers/common/info.js @@ -457,9 +457,9 @@ Blockly.blockRendering.RenderInfo.prototype.getInRowSpacing_ = function(prev, ne /** * Figure out where the right edge of the block and right edge of statement inputs * should be placed. - * TODO: More cleanup. * @protected */ +// TODO: More cleanup. Blockly.blockRendering.RenderInfo.prototype.computeBounds_ = function() { var widestStatementRowFields = 0; var blockWidth = 0; diff --git a/core/renderers/measurables/rows.js b/core/renderers/measurables/rows.js index 3783a0f4c..7b85ae0f0 100644 --- a/core/renderers/measurables/rows.js +++ b/core/renderers/measurables/rows.js @@ -166,11 +166,11 @@ Blockly.blockRendering.Row.prototype.measure = function() { /** * Get the last input on this row, if it has one. - * TODO: Consider moving this to InputRow, if possible. * @return {Blockly.blockRendering.InputConnection} The last input on the row, * or null. * @package */ +// TODO: Consider moving this to InputRow, if possible. Blockly.blockRendering.Row.prototype.getLastInput = function() { for (var i = this.elements.length - 1, elem; (elem = this.elements[i]); i--) { if (Blockly.blockRendering.Types.isInput(elem)) { From 15a6fa7cb491cd7562cbf6c9b71946b8d7913cf1 Mon Sep 17 00:00:00 2001 From: Noah Glaser Date: Mon, 14 Oct 2019 22:53:15 -0700 Subject: [PATCH 14/21] Fix capitolization error --- demos/blockfactory/factory_utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/blockfactory/factory_utils.js b/demos/blockfactory/factory_utils.js index 048760567..dfed4578e 100644 --- a/demos/blockfactory/factory_utils.js +++ b/demos/blockfactory/factory_utils.js @@ -490,7 +490,7 @@ FactoryUtils.getFieldsJs_ = function(block) { var width = Number(block.getFieldValue('WIDTH')); var height = Number(block.getFieldValue('HEIGHT')); var alt = JSON.stringify(block.getFieldValue('ALT')); - var flipRtl = Json.stringify(block.getFieldValue('FLIP_RTL')); + var flipRtl = JSON.stringify(block.getFieldValue('FLIP_RTL')); fields.push('new Blockly.FieldImage(' + src + ', ' + width + ', ' + height + ', { alt: ' + alt + ', flipRtl: ' + flipRtl + ' })'); From 863a4a52d9f0d4f6b828302a24f3deeb0f41f241 Mon Sep 17 00:00:00 2001 From: Sam El-Husseini Date: Wed, 9 Oct 2019 11:16:16 -0700 Subject: [PATCH 15/21] Revert calling onHide before the animation is complete to avoid double click issues. (#3202) --- core/dropdowndiv.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/core/dropdowndiv.js b/core/dropdowndiv.js index 5132b99a4..cb403bcbd 100644 --- a/core/dropdowndiv.js +++ b/core/dropdowndiv.js @@ -263,7 +263,7 @@ Blockly.DropDownDiv.showPositionedByBlock = function(field, block, */ Blockly.DropDownDiv.showPositionedByField = function(field, opt_onHide, opt_secondaryYOffset) { - var position = field.fieldGroup_.getBoundingClientRect(); + var position = field.getSvgRoot().getBoundingClientRect(); // If we can fit it, render below the block. var primaryX = position.left + position.width / 2; var primaryY = position.bottom; @@ -574,11 +574,11 @@ Blockly.DropDownDiv.hide = function() { Blockly.DropDownDiv.animateOutTimer_ = setTimeout(function() { Blockly.DropDownDiv.hideWithoutAnimation(); - if (Blockly.DropDownDiv.onHide_) { - Blockly.DropDownDiv.onHide_(); - Blockly.DropDownDiv.onHide_ = null; - } }, Blockly.DropDownDiv.ANIMATION_TIME * 1000); + if (Blockly.DropDownDiv.onHide_) { + Blockly.DropDownDiv.onHide_(); + Blockly.DropDownDiv.onHide_ = null; + } }; /** From 09687cb3877c6c7c91e5149347b1a17cf57a30a7 Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Tue, 15 Oct 2019 10:10:42 -0600 Subject: [PATCH 16/21] Rebuild and bump patch number --- blockly_compressed.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/blockly_compressed.js b/blockly_compressed.js index 1f853df66..df434f923 100644 --- a/blockly_compressed.js +++ b/blockly_compressed.js @@ -551,7 +551,7 @@ Blockly.DropDownDiv.createDom=function(){if(!Blockly.DropDownDiv.DIV_){var a=doc a.appendChild(b);Blockly.DropDownDiv.arrow_=b;Blockly.DropDownDiv.DIV_.style.opacity=0;Blockly.DropDownDiv.DIV_.style.transition="transform "+Blockly.DropDownDiv.ANIMATION_TIME+"s, opacity "+Blockly.DropDownDiv.ANIMATION_TIME+"s";a.addEventListener("focusin",function(){Blockly.utils.dom.addClass(a,"focused")});a.addEventListener("focusout",function(){Blockly.utils.dom.removeClass(a,"focused")})}};Blockly.DropDownDiv.setBoundsElement=function(a){Blockly.DropDownDiv.boundsElement_=a}; Blockly.DropDownDiv.getContentDiv=function(){return Blockly.DropDownDiv.content_};Blockly.DropDownDiv.clearContent=function(){Blockly.DropDownDiv.content_.innerHTML="";Blockly.DropDownDiv.content_.style.width=""};Blockly.DropDownDiv.setColour=function(a,b){Blockly.DropDownDiv.DIV_.style.backgroundColor=a;Blockly.DropDownDiv.DIV_.style.borderColor=b};Blockly.DropDownDiv.setCategory=function(a){Blockly.DropDownDiv.DIV_.setAttribute("data-category",a)}; Blockly.DropDownDiv.showPositionedByBlock=function(a,b,c,d){var e=b.workspace.scale,f=b.width,g=b.height;f*=e;g*=e;e=b.getSvgRoot().getBoundingClientRect();f=e.left+f/2;g=e.top+g;e=e.top;d&&(e+=d);Blockly.DropDownDiv.setBoundsElement(b.workspace.getParentSvg().parentNode);return Blockly.DropDownDiv.show(a,b.RTL,f,g,f,e,c)}; -Blockly.DropDownDiv.showPositionedByField=function(a,b,c){var d=a.fieldGroup_.getBoundingClientRect(),e=d.left+d.width/2,f=d.bottom;d=d.top;c&&(d+=c);c=a.getSourceBlock();Blockly.DropDownDiv.positionToField_=!0;Blockly.DropDownDiv.setBoundsElement(c.workspace.getParentSvg().parentNode);return Blockly.DropDownDiv.show(a,c.RTL,e,f,e,d,b)}; +Blockly.DropDownDiv.showPositionedByField=function(a,b,c){var d=a.getSvgRoot().getBoundingClientRect(),e=d.left+d.width/2,f=d.bottom;d=d.top;c&&(d+=c);c=a.getSourceBlock();Blockly.DropDownDiv.positionToField_=!0;Blockly.DropDownDiv.setBoundsElement(c.workspace.getParentSvg().parentNode);return Blockly.DropDownDiv.show(a,c.RTL,e,f,e,d,b)}; Blockly.DropDownDiv.show=function(a,b,c,d,e,f,g){Blockly.DropDownDiv.owner_=a;Blockly.DropDownDiv.onHide_=g||null;a=Blockly.DropDownDiv.getPositionMetrics(c,d,e,f);a.arrowVisible?(Blockly.DropDownDiv.arrow_.style.display="",Blockly.DropDownDiv.arrow_.style.transform="translate("+a.arrowX+"px,"+a.arrowY+"px) rotate(45deg)",Blockly.DropDownDiv.arrow_.setAttribute("class",a.arrowAtTop?"blocklyDropDownArrow arrowTop":"blocklyDropDownArrow arrowBottom")):Blockly.DropDownDiv.arrow_.style.display="none"; Blockly.DropDownDiv.DIV_.style.direction=b?"rtl":"ltr";Blockly.DropDownDiv.positionInternal_(a.initialX,a.initialY,a.finalX,a.finalY);return a.arrowAtTop};Blockly.DropDownDiv.getBoundsInfo_=function(){var a=Blockly.DropDownDiv.boundsElement_.getBoundingClientRect(),b=Blockly.utils.style.getSize(Blockly.DropDownDiv.boundsElement_);return{left:a.left,right:a.left+b.width,top:a.top,bottom:a.top+b.height,width:b.width,height:b.height}}; Blockly.DropDownDiv.getPositionMetrics=function(a,b,c,d){var e=Blockly.DropDownDiv.getBoundsInfo_(),f=Blockly.utils.style.getSize(Blockly.DropDownDiv.DIV_);return b+f.heighte.top?Blockly.DropDownDiv.getPositionAboveMetrics(c,d,e,f):b+f.heightdocument.documentElement.clientTop?Blockly.DropDownDiv.getPositionAboveMetrics(c,d, @@ -559,7 +559,7 @@ e,f):Blockly.DropDownDiv.getPositionTopOfPageMetrics(a,e,f)};Blockly.DropDownDiv Blockly.DropDownDiv.getPositionAboveMetrics=function(a,b,c,d){a=Blockly.DropDownDiv.getPositionX(a,c.left,c.right,d.width);return{initialX:a.divX,initialY:b-d.height,finalX:a.divX,finalY:b-d.height-Blockly.DropDownDiv.PADDING_Y,arrowX:a.arrowX,arrowY:d.height-2*Blockly.DropDownDiv.BORDER_SIZE-Blockly.DropDownDiv.ARROW_SIZE/2,arrowAtTop:!1,arrowVisible:!0}}; Blockly.DropDownDiv.getPositionTopOfPageMetrics=function(a,b,c){a=Blockly.DropDownDiv.getPositionX(a,b.left,b.right,c.width);return{initialX:a.divX,initialY:0,finalX:a.divX,finalY:0,arrowVisible:!1}};Blockly.DropDownDiv.getPositionX=function(a,b,c,d){var e=a;a=Blockly.utils.math.clamp(b,a-d/2,c-d);e-=Blockly.DropDownDiv.ARROW_SIZE/2;b=Blockly.DropDownDiv.ARROW_HORIZONTAL_PADDING;d=Blockly.utils.math.clamp(b,e-a,d-b-Blockly.DropDownDiv.ARROW_SIZE);return{arrowX:d,divX:a}}; Blockly.DropDownDiv.isVisible=function(){return!!Blockly.DropDownDiv.owner_};Blockly.DropDownDiv.hideIfOwner=function(a,b){return Blockly.DropDownDiv.owner_===a?(b?Blockly.DropDownDiv.hideWithoutAnimation():Blockly.DropDownDiv.hide(),!0):!1}; -Blockly.DropDownDiv.hide=function(){var a=Blockly.DropDownDiv.DIV_;a.style.transform="translate(0, 0)";a.style.opacity=0;Blockly.DropDownDiv.animateOutTimer_=setTimeout(function(){Blockly.DropDownDiv.hideWithoutAnimation();Blockly.DropDownDiv.onHide_&&(Blockly.DropDownDiv.onHide_(),Blockly.DropDownDiv.onHide_=null)},1E3*Blockly.DropDownDiv.ANIMATION_TIME)}; +Blockly.DropDownDiv.hide=function(){var a=Blockly.DropDownDiv.DIV_;a.style.transform="translate(0, 0)";a.style.opacity=0;Blockly.DropDownDiv.animateOutTimer_=setTimeout(function(){Blockly.DropDownDiv.hideWithoutAnimation()},1E3*Blockly.DropDownDiv.ANIMATION_TIME);Blockly.DropDownDiv.onHide_&&(Blockly.DropDownDiv.onHide_(),Blockly.DropDownDiv.onHide_=null)}; Blockly.DropDownDiv.hideWithoutAnimation=function(){if(Blockly.DropDownDiv.isVisible()){Blockly.DropDownDiv.animateOutTimer_&&clearTimeout(Blockly.DropDownDiv.animateOutTimer_);var a=Blockly.DropDownDiv.DIV_;a.style.transform="";a.style.left="";a.style.top="";a.style.opacity=0;a.style.display="none";a.style.backgroundColor=Blockly.DropDownDiv.DEFAULT_DROPDOWN_COLOR;a.style.borderColor=Blockly.DropDownDiv.DEFAULT_DROPDOWN_BORDER_COLOR;Blockly.DropDownDiv.onHide_&&(Blockly.DropDownDiv.onHide_(),Blockly.DropDownDiv.onHide_= null);Blockly.DropDownDiv.clearContent();Blockly.DropDownDiv.owner_=null}};Blockly.DropDownDiv.positionInternal_=function(a,b,c,d){a=Math.floor(a);b=Math.floor(b);c=Math.floor(c);d=Math.floor(d);var e=Blockly.DropDownDiv.DIV_;e.style.left=a+"px";e.style.top=b+"px";e.style.display="block";e.style.opacity=1;e.style.transform="translate("+(c-a)+"px,"+(d-b)+"px)"}; Blockly.DropDownDiv.repositionForWindowResize=function(){if(Blockly.DropDownDiv.owner_){var a=Blockly.DropDownDiv.owner_.getSourceBlock(),b=a.workspace.scale,c=Blockly.DropDownDiv.positionToField_?Blockly.DropDownDiv.owner_.size_.width:a.width,d=Blockly.DropDownDiv.positionToField_?Blockly.DropDownDiv.owner_.size_.height:a.height;c*=b;d*=b;a=Blockly.DropDownDiv.positionToField_?Blockly.DropDownDiv.owner_.fieldGroup_.getBoundingClientRect():a.getSvgRoot().getBoundingClientRect();c=a.left+c/2;d=Blockly.DropDownDiv.getPositionMetrics(c, @@ -769,7 +769,7 @@ Blockly.Variables.createVariable_=function(a,b,c,d){var e=a.getPotentialVariable Blockly.WidgetDiv.show=function(a,b,c){Blockly.WidgetDiv.hide();Blockly.WidgetDiv.owner_=a;Blockly.WidgetDiv.dispose_=c;a=Blockly.utils.style.getViewportPageOffset();Blockly.WidgetDiv.DIV.style.top=a.y+"px";Blockly.WidgetDiv.DIV.style.direction=b?"rtl":"ltr";Blockly.WidgetDiv.DIV.style.display="block"}; Blockly.WidgetDiv.hide=function(){Blockly.WidgetDiv.owner_&&(Blockly.WidgetDiv.owner_=null,Blockly.WidgetDiv.DIV.style.display="none",Blockly.WidgetDiv.DIV.style.left="",Blockly.WidgetDiv.DIV.style.top="",Blockly.WidgetDiv.dispose_&&Blockly.WidgetDiv.dispose_(),Blockly.WidgetDiv.dispose_=null,Blockly.WidgetDiv.DIV.innerHTML="")};Blockly.WidgetDiv.isVisible=function(){return!!Blockly.WidgetDiv.owner_};Blockly.WidgetDiv.hideIfOwner=function(a){Blockly.WidgetDiv.owner_==a&&Blockly.WidgetDiv.hide()}; Blockly.WidgetDiv.positionInternal_=function(a,b,c){Blockly.WidgetDiv.DIV.style.left=a+"px";Blockly.WidgetDiv.DIV.style.top=b+"px";Blockly.WidgetDiv.DIV.style.height=c+"px"};Blockly.WidgetDiv.positionWithAnchor=function(a,b,c,d){var e=Blockly.WidgetDiv.calculateY_(a,b,c);a=Blockly.WidgetDiv.calculateX_(a,b,c,d);0>e?Blockly.WidgetDiv.positionInternal_(a,0,c.height+e):Blockly.WidgetDiv.positionInternal_(a,e,c.height)}; -Blockly.WidgetDiv.calculateX_=function(a,b,c,d){if(d)return b=Math.max(b.right-c.width,a.left),Math.min(b,a.right-c.width);b=Math.min(b.left,a.right-c.width);return Math.max(b,a.left)};Blockly.WidgetDiv.calculateY_=function(a,b,c){return b.bottom+c.height>=a.bottom?b.top-c.height:b.bottom};Blockly.VERSION="3.20191014.0";Blockly.mainWorkspace=null;Blockly.selected=null;Blockly.cursor=null;Blockly.keyboardAccessibilityMode=!1;Blockly.draggingConnections_=[];Blockly.clipboardXml_=null;Blockly.clipboardSource_=null;Blockly.clipboardTypeCounts_=null;Blockly.cache3dSupported_=null;Blockly.svgSize=function(a){return{width:a.cachedWidth_,height:a.cachedHeight_}};Blockly.resizeSvgContents=function(a){a.resizeContents()}; +Blockly.WidgetDiv.calculateX_=function(a,b,c,d){if(d)return b=Math.max(b.right-c.width,a.left),Math.min(b,a.right-c.width);b=Math.min(b.left,a.right-c.width);return Math.max(b,a.left)};Blockly.WidgetDiv.calculateY_=function(a,b,c){return b.bottom+c.height>=a.bottom?b.top-c.height:b.bottom};Blockly.VERSION="3.20191014.1";Blockly.mainWorkspace=null;Blockly.selected=null;Blockly.cursor=null;Blockly.keyboardAccessibilityMode=!1;Blockly.draggingConnections_=[];Blockly.clipboardXml_=null;Blockly.clipboardSource_=null;Blockly.clipboardTypeCounts_=null;Blockly.cache3dSupported_=null;Blockly.svgSize=function(a){return{width:a.cachedWidth_,height:a.cachedHeight_}};Blockly.resizeSvgContents=function(a){a.resizeContents()}; Blockly.svgResize=function(a){for(;a.options.parentWorkspace;)a=a.options.parentWorkspace;var b=a.getParentSvg(),c=b.parentNode;if(c){var d=c.offsetWidth;c=c.offsetHeight;b.cachedWidth_!=d&&(b.setAttribute("width",d+"px"),b.cachedWidth_=d);b.cachedHeight_!=c&&(b.setAttribute("height",c+"px"),b.cachedHeight_=c);a.resize()}}; Blockly.onKeyDown_=function(a){var b=Blockly.mainWorkspace;if(!(Blockly.utils.isTargetInput(a)||b.rendered&&!b.isVisible()))if(b.options.readOnly)Blockly.navigation.onKeyPress(a);else{var c=!1;if(a.keyCode==Blockly.utils.KeyCodes.ESC)Blockly.hideChaff(),Blockly.navigation.onBlocklyAction(Blockly.navigation.ACTION_EXIT);else{if(Blockly.navigation.onKeyPress(a))return;if(a.keyCode==Blockly.utils.KeyCodes.BACKSPACE||a.keyCode==Blockly.utils.KeyCodes.DELETE){a.preventDefault();if(Blockly.Gesture.inProgress())return; Blockly.selected&&Blockly.selected.isDeletable()&&(c=!0)}else if(a.altKey||a.ctrlKey||a.metaKey){if(Blockly.Gesture.inProgress())return;Blockly.selected&&Blockly.selected.isDeletable()&&Blockly.selected.isMovable()&&(a.keyCode==Blockly.utils.KeyCodes.C?(Blockly.hideChaff(),Blockly.copy_(Blockly.selected)):a.keyCode!=Blockly.utils.KeyCodes.X||Blockly.selected.workspace.isFlyout||(Blockly.copy_(Blockly.selected),c=!0));a.keyCode==Blockly.utils.KeyCodes.V?Blockly.clipboardXml_&&(a=Blockly.clipboardSource_, diff --git a/package.json b/package.json index 54b5a1842..276aa0f37 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "blockly", - "version": "3.20191014.0", + "version": "3.20191014.1", "description": "Blockly is a library for building visual programming editors.", "keywords": [ "blockly" From 874cef65f6fc029863175e4471697663abf3fe17 Mon Sep 17 00:00:00 2001 From: Sam El-Husseini Date: Thu, 17 Oct 2019 14:08:06 -0500 Subject: [PATCH 17/21] Only add a hat if there's no output connection or previous connection (#3280) * Only add a hat if there's no output connection or previous connection --- core/renderers/common/info.js | 5 +++-- core/renderers/measurables/rows.js | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/core/renderers/common/info.js b/core/renderers/common/info.js index 5e5530274..ed64db840 100644 --- a/core/renderers/common/info.js +++ b/core/renderers/common/info.js @@ -253,9 +253,10 @@ Blockly.blockRendering.RenderInfo.prototype.createRows_ = function() { * @package */ Blockly.blockRendering.RenderInfo.prototype.populateTopRow_ = function() { - var hasHat = this.block_.hat ? - this.block_.hat === 'cap' : Blockly.BlockSvg.START_HAT; var hasPrevious = !!this.block_.previousConnection; + var hasHat = (this.block_.hat ? + this.block_.hat === 'cap' : Blockly.BlockSvg.START_HAT) && + !this.outputConnection && !hasPrevious; var leftSquareCorner = this.topRow.hasLeftSquareCorner(this.block_); if (leftSquareCorner) { diff --git a/core/renderers/measurables/rows.js b/core/renderers/measurables/rows.js index 7b85ae0f0..2797cb7e8 100644 --- a/core/renderers/measurables/rows.js +++ b/core/renderers/measurables/rows.js @@ -283,7 +283,8 @@ Blockly.utils.object.inherits(Blockly.blockRendering.TopRow, * @returns {boolean} Whether or not the top row has a left square corner. */ Blockly.blockRendering.TopRow.prototype.hasLeftSquareCorner = function(block) { - var hasHat = block.hat ? block.hat === 'cap' : Blockly.BlockSvg.START_HAT; + var hasHat = (block.hat ? block.hat === 'cap' : Blockly.BlockSvg.START_HAT) && + !block.outputConnection && !block.previousConnection; var prevBlock = block.getPreviousBlock(); return !!block.outputConnection || From e9f6eed0e797e8441e23789e41e467629d85b606 Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Thu, 17 Oct 2019 15:17:15 -0700 Subject: [PATCH 18/21] Bump patch version and rebuild --- blockly_compressed.js | 8 ++++---- blockly_uncompressed.js | 1 - package.json | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/blockly_compressed.js b/blockly_compressed.js index df434f923..34e39bba5 100644 --- a/blockly_compressed.js +++ b/blockly_compressed.js @@ -769,7 +769,7 @@ Blockly.Variables.createVariable_=function(a,b,c,d){var e=a.getPotentialVariable Blockly.WidgetDiv.show=function(a,b,c){Blockly.WidgetDiv.hide();Blockly.WidgetDiv.owner_=a;Blockly.WidgetDiv.dispose_=c;a=Blockly.utils.style.getViewportPageOffset();Blockly.WidgetDiv.DIV.style.top=a.y+"px";Blockly.WidgetDiv.DIV.style.direction=b?"rtl":"ltr";Blockly.WidgetDiv.DIV.style.display="block"}; Blockly.WidgetDiv.hide=function(){Blockly.WidgetDiv.owner_&&(Blockly.WidgetDiv.owner_=null,Blockly.WidgetDiv.DIV.style.display="none",Blockly.WidgetDiv.DIV.style.left="",Blockly.WidgetDiv.DIV.style.top="",Blockly.WidgetDiv.dispose_&&Blockly.WidgetDiv.dispose_(),Blockly.WidgetDiv.dispose_=null,Blockly.WidgetDiv.DIV.innerHTML="")};Blockly.WidgetDiv.isVisible=function(){return!!Blockly.WidgetDiv.owner_};Blockly.WidgetDiv.hideIfOwner=function(a){Blockly.WidgetDiv.owner_==a&&Blockly.WidgetDiv.hide()}; Blockly.WidgetDiv.positionInternal_=function(a,b,c){Blockly.WidgetDiv.DIV.style.left=a+"px";Blockly.WidgetDiv.DIV.style.top=b+"px";Blockly.WidgetDiv.DIV.style.height=c+"px"};Blockly.WidgetDiv.positionWithAnchor=function(a,b,c,d){var e=Blockly.WidgetDiv.calculateY_(a,b,c);a=Blockly.WidgetDiv.calculateX_(a,b,c,d);0>e?Blockly.WidgetDiv.positionInternal_(a,0,c.height+e):Blockly.WidgetDiv.positionInternal_(a,e,c.height)}; -Blockly.WidgetDiv.calculateX_=function(a,b,c,d){if(d)return b=Math.max(b.right-c.width,a.left),Math.min(b,a.right-c.width);b=Math.min(b.left,a.right-c.width);return Math.max(b,a.left)};Blockly.WidgetDiv.calculateY_=function(a,b,c){return b.bottom+c.height>=a.bottom?b.top-c.height:b.bottom};Blockly.VERSION="3.20191014.1";Blockly.mainWorkspace=null;Blockly.selected=null;Blockly.cursor=null;Blockly.keyboardAccessibilityMode=!1;Blockly.draggingConnections_=[];Blockly.clipboardXml_=null;Blockly.clipboardSource_=null;Blockly.clipboardTypeCounts_=null;Blockly.cache3dSupported_=null;Blockly.svgSize=function(a){return{width:a.cachedWidth_,height:a.cachedHeight_}};Blockly.resizeSvgContents=function(a){a.resizeContents()}; +Blockly.WidgetDiv.calculateX_=function(a,b,c,d){if(d)return b=Math.max(b.right-c.width,a.left),Math.min(b,a.right-c.width);b=Math.min(b.left,a.right-c.width);return Math.max(b,a.left)};Blockly.WidgetDiv.calculateY_=function(a,b,c){return b.bottom+c.height>=a.bottom?b.top-c.height:b.bottom};Blockly.VERSION="3.20191014.2";Blockly.mainWorkspace=null;Blockly.selected=null;Blockly.cursor=null;Blockly.keyboardAccessibilityMode=!1;Blockly.draggingConnections_=[];Blockly.clipboardXml_=null;Blockly.clipboardSource_=null;Blockly.clipboardTypeCounts_=null;Blockly.cache3dSupported_=null;Blockly.svgSize=function(a){return{width:a.cachedWidth_,height:a.cachedHeight_}};Blockly.resizeSvgContents=function(a){a.resizeContents()}; Blockly.svgResize=function(a){for(;a.options.parentWorkspace;)a=a.options.parentWorkspace;var b=a.getParentSvg(),c=b.parentNode;if(c){var d=c.offsetWidth;c=c.offsetHeight;b.cachedWidth_!=d&&(b.setAttribute("width",d+"px"),b.cachedWidth_=d);b.cachedHeight_!=c&&(b.setAttribute("height",c+"px"),b.cachedHeight_=c);a.resize()}}; Blockly.onKeyDown_=function(a){var b=Blockly.mainWorkspace;if(!(Blockly.utils.isTargetInput(a)||b.rendered&&!b.isVisible()))if(b.options.readOnly)Blockly.navigation.onKeyPress(a);else{var c=!1;if(a.keyCode==Blockly.utils.KeyCodes.ESC)Blockly.hideChaff(),Blockly.navigation.onBlocklyAction(Blockly.navigation.ACTION_EXIT);else{if(Blockly.navigation.onKeyPress(a))return;if(a.keyCode==Blockly.utils.KeyCodes.BACKSPACE||a.keyCode==Blockly.utils.KeyCodes.DELETE){a.preventDefault();if(Blockly.Gesture.inProgress())return; Blockly.selected&&Blockly.selected.isDeletable()&&(c=!0)}else if(a.altKey||a.ctrlKey||a.metaKey){if(Blockly.Gesture.inProgress())return;Blockly.selected&&Blockly.selected.isDeletable()&&Blockly.selected.isMovable()&&(a.keyCode==Blockly.utils.KeyCodes.C?(Blockly.hideChaff(),Blockly.copy_(Blockly.selected)):a.keyCode!=Blockly.utils.KeyCodes.X||Blockly.selected.workspace.isFlyout||(Blockly.copy_(Blockly.selected),c=!0));a.keyCode==Blockly.utils.KeyCodes.V?Blockly.clipboardXml_&&(a=Blockly.clipboardSource_, @@ -1066,7 +1066,7 @@ Blockly.blockRendering.RoundCorner=function(a,b){Blockly.blockRendering.RoundCor Blockly.blockRendering.InRowSpacer=function(a,b){Blockly.blockRendering.InRowSpacer.superClass_.constructor.call(this,a);this.type=this.type|Blockly.blockRendering.Types.SPACER|Blockly.blockRendering.Types.IN_ROW_SPACER;this.width=b;this.height=this.constants_.SPACER_DEFAULT_HEIGHT};Blockly.utils.object.inherits(Blockly.blockRendering.InRowSpacer,Blockly.blockRendering.Measurable);Blockly.blockRendering.Row=function(a){this.type=Blockly.blockRendering.Types.ROW;this.elements=[];this.xPos=this.yPos=this.widthWithConnectedBlocks=this.minWidth=this.minHeight=this.width=this.height=0;this.hasJaggedEdge=this.hasDummyInput=this.hasInlineInput=this.hasStatement=this.hasExternalInput=!1;this.constants_=a;this.notchOffset=this.constants_.NOTCH_OFFSET_LEFT};Blockly.blockRendering.Row.prototype.measure=function(){throw Error("Unexpected attempt to measure a base Row.");}; Blockly.blockRendering.Row.prototype.getLastInput=function(){for(var a=this.elements.length-1,b;b=this.elements[a];a--)if(Blockly.blockRendering.Types.isInput(b))return b;return null};Blockly.blockRendering.Row.prototype.startsWithElemSpacer=function(){return!0};Blockly.blockRendering.Row.prototype.endsWithElemSpacer=function(){return!0};Blockly.blockRendering.Row.prototype.getFirstSpacer=function(){for(var a=0,b;b=this.elements[a];a++)if(Blockly.blockRendering.Types.isSpacer(b))return b;return null}; Blockly.blockRendering.Row.prototype.getLastSpacer=function(){for(var a=this.elements.length-1,b;b=this.elements[a];a--)if(Blockly.blockRendering.Types.isSpacer(b))return b;return null};Blockly.blockRendering.TopRow=function(a){Blockly.blockRendering.TopRow.superClass_.constructor.call(this,a);this.type|=Blockly.blockRendering.Types.TOP_ROW;this.ascenderHeight=this.capline=0;this.hasPreviousConnection=!1;this.connection=null};Blockly.utils.object.inherits(Blockly.blockRendering.TopRow,Blockly.blockRendering.Row); -Blockly.blockRendering.TopRow.prototype.hasLeftSquareCorner=function(a){var b=a.hat?"cap"===a.hat:Blockly.BlockSvg.START_HAT,c=a.getPreviousBlock();return!!a.outputConnection||b||(c?c.getNextBlock()==a:!1)}; +Blockly.blockRendering.TopRow.prototype.hasLeftSquareCorner=function(a){var b=(a.hat?"cap"===a.hat:Blockly.BlockSvg.START_HAT)&&!a.outputConnection&&!a.previousConnection,c=a.getPreviousBlock();return!!a.outputConnection||b||(c?c.getNextBlock()==a:!1)}; Blockly.blockRendering.TopRow.prototype.measure=function(){for(var a=0,b=0,c=0,d=0,e;e=this.elements[d];d++)b+=e.width,Blockly.blockRendering.Types.isSpacer(e)||(Blockly.blockRendering.Types.isHat(e)?c=Math.max(c,e.ascenderHeight):a=Math.max(a,e.height));this.width=Math.max(this.minWidth,b);this.height=Math.max(this.minHeight,a)+c;this.capline=this.ascenderHeight=c;this.widthWithConnectedBlocks=this.width};Blockly.blockRendering.TopRow.prototype.startsWithElemSpacer=function(){return!1}; Blockly.blockRendering.BottomRow=function(a){Blockly.blockRendering.BottomRow.superClass_.constructor.call(this,a);this.type|=Blockly.blockRendering.Types.BOTTOM_ROW;this.hasNextConnection=!1;this.connection=null;this.baseline=this.descenderHeight=0};Blockly.utils.object.inherits(Blockly.blockRendering.BottomRow,Blockly.blockRendering.Row);Blockly.blockRendering.BottomRow.prototype.hasLeftSquareCorner=function(a){return!!a.outputConnection||!!a.getNextBlock()}; Blockly.blockRendering.BottomRow.prototype.measure=function(){for(var a=0,b=0,c=0,d=0,e;e=this.elements[d];d++)b+=e.width,Blockly.blockRendering.Types.isSpacer(e)||(Blockly.blockRendering.Types.isNextConnection(e)?c=Math.max(c,e.height):a=Math.max(a,e.height));this.width=Math.max(this.minWidth,b);this.height=Math.max(this.minHeight,a)+c;this.descenderHeight=c;this.widthWithConnectedBlocks=this.width};Blockly.blockRendering.BottomRow.prototype.startsWithElemSpacer=function(){return!1}; @@ -1077,8 +1077,8 @@ a;this.widthWithConnectedBlocks=this.width+a};Blockly.blockRendering.InputRow.pr new Blockly.blockRendering.TopRow(this.constants_);this.bottomRow=new Blockly.blockRendering.BottomRow(this.constants_);this.startY=this.startX=0};Blockly.blockRendering.RenderInfo.prototype.getRenderer=function(){return this.renderer_};Blockly.blockRendering.RenderInfo.prototype.measure=function(){this.createRows_();this.addElemSpacing_();this.computeBounds_();this.alignRowElements_();this.addRowSpacing_();this.finalize_()}; Blockly.blockRendering.RenderInfo.prototype.createRows_=function(){this.populateTopRow_();this.rows.push(this.topRow);var a=new Blockly.blockRendering.InputRow(this.constants_),b=this.block_.getIcons();if(b.length)for(var c=0,d;d=b[c];c++){var e=new Blockly.blockRendering.Icon(this.constants_,d);this.isCollapsed&&d.collapseHidden?this.hiddenIcons.push(e):a.elements.push(e)}d=null;for(c=0;b=this.block_.inputList[c];c++)if(b.isVisible()){this.shouldStartNewRow_(b,d)&&(this.rows.push(a),a=new Blockly.blockRendering.InputRow(this.constants_)); for(d=0;e=b.fieldRow[d];d++)a.elements.push(new Blockly.blockRendering.Field(this.constants_,e,b));this.addInput_(b,a);d=b}this.isCollapsed&&(a.hasJaggedEdge=!0,a.elements.push(new Blockly.blockRendering.JaggedEdge(this.constants_)));(a.elements.length||a.hasDummyInput)&&this.rows.push(a);this.populateBottomRow_();this.rows.push(this.bottomRow)}; -Blockly.blockRendering.RenderInfo.prototype.populateTopRow_=function(){var a=this.block_.hat?"cap"===this.block_.hat:Blockly.BlockSvg.START_HAT,b=!!this.block_.previousConnection;this.topRow.hasLeftSquareCorner(this.block_)?this.topRow.elements.push(new Blockly.blockRendering.SquareCorner(this.constants_)):this.topRow.elements.push(new Blockly.blockRendering.RoundCorner(this.constants_));a?(a=new Blockly.blockRendering.Hat(this.constants_),this.topRow.elements.push(a),this.topRow.capline=a.ascenderHeight): -b&&(this.topRow.hasPreviousConnection=!0,this.topRow.connection=new Blockly.blockRendering.PreviousConnection(this.constants_,this.block_.previousConnection),this.topRow.elements.push(this.topRow.connection));this.block_.inputList.length&&this.block_.inputList[0].type==Blockly.NEXT_STATEMENT&&!this.block_.isCollapsed()?this.topRow.minHeight=this.constants_.LARGE_PADDING:this.topRow.minHeight=this.constants_.MEDIUM_PADDING}; +Blockly.blockRendering.RenderInfo.prototype.populateTopRow_=function(){var a=!!this.block_.previousConnection,b=(this.block_.hat?"cap"===this.block_.hat:Blockly.BlockSvg.START_HAT)&&!this.outputConnection&&!a;this.topRow.hasLeftSquareCorner(this.block_)?this.topRow.elements.push(new Blockly.blockRendering.SquareCorner(this.constants_)):this.topRow.elements.push(new Blockly.blockRendering.RoundCorner(this.constants_));b?(a=new Blockly.blockRendering.Hat(this.constants_),this.topRow.elements.push(a), +this.topRow.capline=a.ascenderHeight):a&&(this.topRow.hasPreviousConnection=!0,this.topRow.connection=new Blockly.blockRendering.PreviousConnection(this.constants_,this.block_.previousConnection),this.topRow.elements.push(this.topRow.connection));this.block_.inputList.length&&this.block_.inputList[0].type==Blockly.NEXT_STATEMENT&&!this.block_.isCollapsed()?this.topRow.minHeight=this.constants_.LARGE_PADDING:this.topRow.minHeight=this.constants_.MEDIUM_PADDING}; Blockly.blockRendering.RenderInfo.prototype.populateBottomRow_=function(){this.bottomRow.hasNextConnection=!!this.block_.nextConnection;this.bottomRow.minHeight=this.block_.inputList.length&&this.block_.inputList[this.block_.inputList.length-1].type==Blockly.NEXT_STATEMENT?this.constants_.LARGE_PADDING:this.constants_.MEDIUM_PADDING-1;this.bottomRow.hasLeftSquareCorner(this.block_)?this.bottomRow.elements.push(new Blockly.blockRendering.SquareCorner(this.constants_)):this.bottomRow.elements.push(new Blockly.blockRendering.RoundCorner(this.constants_)); this.bottomRow.hasNextConnection&&(this.bottomRow.connection=new Blockly.blockRendering.NextConnection(this.constants_,this.block_.nextConnection),this.bottomRow.elements.push(this.bottomRow.connection))}; Blockly.blockRendering.RenderInfo.prototype.addInput_=function(a,b){this.isInline&&a.type==Blockly.INPUT_VALUE?(b.elements.push(new Blockly.blockRendering.InlineInput(this.constants_,a)),b.hasInlineInput=!0):a.type==Blockly.NEXT_STATEMENT?(b.elements.push(new Blockly.blockRendering.StatementInput(this.constants_,a)),b.hasStatement=!0):a.type==Blockly.INPUT_VALUE?(b.elements.push(new Blockly.blockRendering.ExternalValueInput(this.constants_,a)),b.hasExternalInput=!0):a.type==Blockly.DUMMY_INPUT&&(b.hasDummyInput= diff --git a/blockly_uncompressed.js b/blockly_uncompressed.js index 7b9849e60..2165245fa 100644 --- a/blockly_uncompressed.js +++ b/blockly_uncompressed.js @@ -87,7 +87,6 @@ goog.addDependency("../../core/names.js", ['Blockly.Names'], ['Blockly.Msg']); goog.addDependency("../../core/options.js", ['Blockly.Options'], ['Blockly.utils.userAgent', 'Blockly.Xml']); goog.addDependency("../../core/procedures.js", ['Blockly.Procedures'], ['Blockly.Blocks', 'Blockly.constants', 'Blockly.Events', 'Blockly.Events.BlockChange', 'Blockly.Field', 'Blockly.Msg', 'Blockly.Names', 'Blockly.utils.xml', 'Blockly.Workspace', 'Blockly.Xml']); goog.addDependency("../../core/rendered_connection.js", ['Blockly.RenderedConnection'], ['Blockly.Connection', 'Blockly.Events', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.dom', 'Blockly.utils.object']); -goog.addDependency("../../core/renderers/common/block_paths.js", ['Blockly.Colourer'], []); goog.addDependency("../../core/renderers/common/block_rendering.js", ['Blockly.blockRendering'], ['Blockly.utils.object']); goog.addDependency("../../core/renderers/common/constants.js", ['Blockly.blockRendering.ConstantProvider'], ['Blockly.utils.svgPaths']); goog.addDependency("../../core/renderers/common/debugger.js", ['Blockly.blockRendering.Debug'], ['Blockly.blockRendering.BottomRow', 'Blockly.blockRendering.InputRow', 'Blockly.blockRendering.Measurable', 'Blockly.blockRendering.RenderInfo', 'Blockly.blockRendering.Row', 'Blockly.blockRendering.SpacerRow', 'Blockly.blockRendering.TopRow', 'Blockly.blockRendering.Types']); diff --git a/package.json b/package.json index 276aa0f37..9e5c9b1ad 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "blockly", - "version": "3.20191014.1", + "version": "3.20191014.2", "description": "Blockly is a library for building visual programming editors.", "keywords": [ "blockly" From fc304ab930319329f1ab240a5aa2ef75bfe9f27f Mon Sep 17 00:00:00 2001 From: Sam El-Husseini Date: Wed, 23 Oct 2019 13:28:00 -0400 Subject: [PATCH 19/21] Fix for #3313 (#3316) (#3320) * Account for output connection with when aligning statement row --- core/renderers/common/info.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/renderers/common/info.js b/core/renderers/common/info.js index ed64db840..60bd66e86 100644 --- a/core/renderers/common/info.js +++ b/core/renderers/common/info.js @@ -545,7 +545,7 @@ Blockly.blockRendering.RenderInfo.prototype.addAlignmentPadding_ = function(row, Blockly.blockRendering.RenderInfo.prototype.alignStatementRow_ = function(row) { var statementInput = row.getLastInput(); var currentWidth = row.width - statementInput.width; - var desiredWidth = this.statementEdge - this.startX; + var desiredWidth = this.statementEdge; // Add padding before the statement input. var missingSpace = desiredWidth - currentWidth; if (missingSpace) { From 1a4c3219dec05cdd94c6c03205704231df296181 Mon Sep 17 00:00:00 2001 From: Sam El-Husseini Date: Wed, 23 Oct 2019 13:39:15 -0400 Subject: [PATCH 20/21] Release v3.20191014.3 (#3321) --- blockly_compressed.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/blockly_compressed.js b/blockly_compressed.js index 34e39bba5..062911108 100644 --- a/blockly_compressed.js +++ b/blockly_compressed.js @@ -1089,7 +1089,7 @@ Blockly.blockRendering.RenderInfo.prototype.getInRowSpacing_=function(a,b){if(a& b.notchOffset:a&&Blockly.blockRendering.Types.isLeftRoundedCorner(a)&&b&&(Blockly.blockRendering.Types.isPreviousConnection(b)||Blockly.blockRendering.Types.isNextConnection(b))?b.notchOffset-this.constants_.CORNER_RADIUS:this.constants_.MEDIUM_PADDING}; Blockly.blockRendering.RenderInfo.prototype.computeBounds_=function(){for(var a=0,b=0,c=0,d=0,e;e=this.rows[d];d++){e.measure();b=Math.max(b,e.width);if(e.hasStatement){var f=e.getLastInput();a=Math.max(a,e.width-f.width)}c=Math.max(c,e.widthWithConnectedBlocks)}this.statementEdge=a;this.width=b;for(d=0;e=this.rows[d];d++)e.hasStatement&&(e.statementEdge=this.statementEdge);this.widthWithChildren=Math.max(b,c);this.outputConnection&&(this.startX=this.outputConnection.width,this.width+=this.outputConnection.width, this.widthWithChildren+=this.outputConnection.width)};Blockly.blockRendering.RenderInfo.prototype.alignRowElements_=function(){for(var a=0,b;b=this.rows[a];a++)if(b.hasStatement)this.alignStatementRow_(b);else{var c=this.width-this.startX-b.width;c&&this.addAlignmentPadding_(b,c)}};Blockly.blockRendering.RenderInfo.prototype.addAlignmentPadding_=function(a,b){var c=a.getLastSpacer();c&&(c.width+=b,a.width+=b)}; -Blockly.blockRendering.RenderInfo.prototype.alignStatementRow_=function(a){var b=a.getLastInput(),c=a.width-b.width,d=this.statementEdge-this.startX;(c=d-c)&&this.addAlignmentPadding_(a,c);c=a.width;d=this.width-this.startX-(this.constants_.INSIDE_CORNERS.rightWidth||0);b.width+=d-c;a.width+=d-c;a.widthWithConnectedBlocks=Math.max(a.width,this.statementEdge+a.connectedBlockWidths)}; +Blockly.blockRendering.RenderInfo.prototype.alignStatementRow_=function(a){var b=a.getLastInput(),c=a.width-b.width,d=this.statementEdge;(c=d-c)&&this.addAlignmentPadding_(a,c);c=a.width;d=this.width-this.startX-(this.constants_.INSIDE_CORNERS.rightWidth||0);b.width+=d-c;a.width+=d-c;a.widthWithConnectedBlocks=Math.max(a.width,this.statementEdge+a.connectedBlockWidths)}; Blockly.blockRendering.RenderInfo.prototype.addRowSpacing_=function(){var a=this.rows;this.rows=[];for(var b=0;b Date: Mon, 28 Oct 2019 16:50:21 -0700 Subject: [PATCH 21/21] Release v3.20191014.4 #3342 (#3358) * Dummy input right alignment (#3342) * Fix dummy input alignment in geras. * Rebuild --- blockly_compressed.js | 19 ++++--- core/renderers/common/constants.js | 6 +++ core/renderers/common/info.js | 3 ++ core/renderers/geras/info.js | 71 ++++++++++++++++++++------ core/renderers/thrasos/info.js | 69 ++++++++++++++++++------- package.json | 2 +- tests/blocks/test_blocks.js | 81 ++++++++++++++++++++++++++++++ tests/playground.html | 7 +++ 8 files changed, 217 insertions(+), 41 deletions(-) diff --git a/blockly_compressed.js b/blockly_compressed.js index 062911108..9de0658d8 100644 --- a/blockly_compressed.js +++ b/blockly_compressed.js @@ -769,7 +769,7 @@ Blockly.Variables.createVariable_=function(a,b,c,d){var e=a.getPotentialVariable Blockly.WidgetDiv.show=function(a,b,c){Blockly.WidgetDiv.hide();Blockly.WidgetDiv.owner_=a;Blockly.WidgetDiv.dispose_=c;a=Blockly.utils.style.getViewportPageOffset();Blockly.WidgetDiv.DIV.style.top=a.y+"px";Blockly.WidgetDiv.DIV.style.direction=b?"rtl":"ltr";Blockly.WidgetDiv.DIV.style.display="block"}; Blockly.WidgetDiv.hide=function(){Blockly.WidgetDiv.owner_&&(Blockly.WidgetDiv.owner_=null,Blockly.WidgetDiv.DIV.style.display="none",Blockly.WidgetDiv.DIV.style.left="",Blockly.WidgetDiv.DIV.style.top="",Blockly.WidgetDiv.dispose_&&Blockly.WidgetDiv.dispose_(),Blockly.WidgetDiv.dispose_=null,Blockly.WidgetDiv.DIV.innerHTML="")};Blockly.WidgetDiv.isVisible=function(){return!!Blockly.WidgetDiv.owner_};Blockly.WidgetDiv.hideIfOwner=function(a){Blockly.WidgetDiv.owner_==a&&Blockly.WidgetDiv.hide()}; Blockly.WidgetDiv.positionInternal_=function(a,b,c){Blockly.WidgetDiv.DIV.style.left=a+"px";Blockly.WidgetDiv.DIV.style.top=b+"px";Blockly.WidgetDiv.DIV.style.height=c+"px"};Blockly.WidgetDiv.positionWithAnchor=function(a,b,c,d){var e=Blockly.WidgetDiv.calculateY_(a,b,c);a=Blockly.WidgetDiv.calculateX_(a,b,c,d);0>e?Blockly.WidgetDiv.positionInternal_(a,0,c.height+e):Blockly.WidgetDiv.positionInternal_(a,e,c.height)}; -Blockly.WidgetDiv.calculateX_=function(a,b,c,d){if(d)return b=Math.max(b.right-c.width,a.left),Math.min(b,a.right-c.width);b=Math.min(b.left,a.right-c.width);return Math.max(b,a.left)};Blockly.WidgetDiv.calculateY_=function(a,b,c){return b.bottom+c.height>=a.bottom?b.top-c.height:b.bottom};Blockly.VERSION="3.20191014.2";Blockly.mainWorkspace=null;Blockly.selected=null;Blockly.cursor=null;Blockly.keyboardAccessibilityMode=!1;Blockly.draggingConnections_=[];Blockly.clipboardXml_=null;Blockly.clipboardSource_=null;Blockly.clipboardTypeCounts_=null;Blockly.cache3dSupported_=null;Blockly.svgSize=function(a){return{width:a.cachedWidth_,height:a.cachedHeight_}};Blockly.resizeSvgContents=function(a){a.resizeContents()}; +Blockly.WidgetDiv.calculateX_=function(a,b,c,d){if(d)return b=Math.max(b.right-c.width,a.left),Math.min(b,a.right-c.width);b=Math.min(b.left,a.right-c.width);return Math.max(b,a.left)};Blockly.WidgetDiv.calculateY_=function(a,b,c){return b.bottom+c.height>=a.bottom?b.top-c.height:b.bottom};Blockly.VERSION="3.20191014.4";Blockly.mainWorkspace=null;Blockly.selected=null;Blockly.cursor=null;Blockly.keyboardAccessibilityMode=!1;Blockly.draggingConnections_=[];Blockly.clipboardXml_=null;Blockly.clipboardSource_=null;Blockly.clipboardTypeCounts_=null;Blockly.cache3dSupported_=null;Blockly.svgSize=function(a){return{width:a.cachedWidth_,height:a.cachedHeight_}};Blockly.resizeSvgContents=function(a){a.resizeContents()}; Blockly.svgResize=function(a){for(;a.options.parentWorkspace;)a=a.options.parentWorkspace;var b=a.getParentSvg(),c=b.parentNode;if(c){var d=c.offsetWidth;c=c.offsetHeight;b.cachedWidth_!=d&&(b.setAttribute("width",d+"px"),b.cachedWidth_=d);b.cachedHeight_!=c&&(b.setAttribute("height",c+"px"),b.cachedHeight_=c);a.resize()}}; Blockly.onKeyDown_=function(a){var b=Blockly.mainWorkspace;if(!(Blockly.utils.isTargetInput(a)||b.rendered&&!b.isVisible()))if(b.options.readOnly)Blockly.navigation.onKeyPress(a);else{var c=!1;if(a.keyCode==Blockly.utils.KeyCodes.ESC)Blockly.hideChaff(),Blockly.navigation.onBlocklyAction(Blockly.navigation.ACTION_EXIT);else{if(Blockly.navigation.onKeyPress(a))return;if(a.keyCode==Blockly.utils.KeyCodes.BACKSPACE||a.keyCode==Blockly.utils.KeyCodes.DELETE){a.preventDefault();if(Blockly.Gesture.inProgress())return; Blockly.selected&&Blockly.selected.isDeletable()&&(c=!0)}else if(a.altKey||a.ctrlKey||a.metaKey){if(Blockly.Gesture.inProgress())return;Blockly.selected&&Blockly.selected.isDeletable()&&Blockly.selected.isMovable()&&(a.keyCode==Blockly.utils.KeyCodes.C?(Blockly.hideChaff(),Blockly.copy_(Blockly.selected)):a.keyCode!=Blockly.utils.KeyCodes.X||Blockly.selected.workspace.isFlyout||(Blockly.copy_(Blockly.selected),c=!0));a.keyCode==Blockly.utils.KeyCodes.V?Blockly.clipboardXml_&&(a=Blockly.clipboardSource_, @@ -1031,8 +1031,8 @@ c.compose(this.rootBlock_);c.rendered=b;c.initSvg();b=(b=c.mutationToDom())&&Blo Blockly.Mutator.prototype.getFlyoutMetrics_=function(){return{viewHeight:this.workspaceHeight_,viewWidth:this.workspaceWidth_-this.workspace_.getFlyout().getWidth(),absoluteTop:0,absoluteLeft:this.workspace_.RTL?0:this.workspace_.getFlyout().getWidth()}};Blockly.Mutator.prototype.dispose=function(){this.block_.mutator=null;Blockly.Icon.prototype.dispose.call(this)}; Blockly.Mutator.prototype.updateBlockStyle=function(){var a=this.workspace_;if(a&&a.getAllBlocks()){for(var b=a.getAllBlocks(),c=0;c + + @@ -1361,6 +1363,11 @@ var spaghettiXml = [ + + + + +