From d897cdcf1d972f3af7804f7f4f9b5874ffb17f9c Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Wed, 22 Mar 2023 21:43:57 +0000 Subject: [PATCH 001/161] fix: remove forced rerender from mutator --- core/mutator.ts | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/core/mutator.ts b/core/mutator.ts index 30b613d50..91b0d82b8 100644 --- a/core/mutator.ts +++ b/core/mutator.ts @@ -458,21 +458,7 @@ export class Mutator extends Icon { const block = this.getBlock(); const oldExtraState = BlockChange.getExtraBlockState_(block); - // Switch off rendering while the source block is rebuilt. - const savedRendered = block.rendered; - // TODO(#4288): We should not be setting the rendered property to false. - block.rendered = false; - - // Allow the source block to rebuild itself. block.compose!(this.rootBlock); - // Restore rendering and show the changes. - block.rendered = savedRendered; - // Mutation may have added some elements that need initializing. - block.initSvg(); - - if (block.rendered) { - block.render(); - } const newExtraState = BlockChange.getExtraBlockState_(block); if (oldExtraState !== newExtraState) { From 69afe5b60fe43b5ed911db91ae62058d66ffe5ec Mon Sep 17 00:00:00 2001 From: Maribeth Bottorff Date: Thu, 30 Mar 2023 13:32:57 -0700 Subject: [PATCH 002/161] fix: allow splicing into shadow block stacks (#6939) * fix: allow splicing into shadow block stacks * chore: format --- core/connection_checker.ts | 5 +++-- tests/mocha/connection_checker_test.js | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/core/connection_checker.ts b/core/connection_checker.ts index 599da547f..662037a93 100644 --- a/core/connection_checker.ts +++ b/core/connection_checker.ts @@ -250,8 +250,9 @@ export class ConnectionChecker implements IConnectionChecker { } // Don't offer to splice into a stack where the connected block is - // immovable. - if (b.targetBlock() && !b.targetBlock()!.isMovable()) { + // immovable, unless the block is a shadow block. + if (b.targetBlock() && !b.targetBlock()!.isMovable() && + !b.targetBlock()!.isShadow()) { return false; } break; diff --git a/tests/mocha/connection_checker_test.js b/tests/mocha/connection_checker_test.js index 11b9545c1..918476ece 100644 --- a/tests/mocha/connection_checker_test.js +++ b/tests/mocha/connection_checker_test.js @@ -367,6 +367,31 @@ suite('Connection checker', function() { 'Should connect two compatible stack blocks'); }); + test('Connect to unmovable shadow block', function() { + // Remove original test blocks. + this.workspace.clear(); + + // Add the same test blocks, but this time block B is a shadow block. + Blockly.Xml.domToWorkspace(Blockly.utils.xml.textToDom(` + + + + + + + + `), this.workspace); + [this.blockA, this.blockB, this.blockC] = this.workspace.getAllBlocks(true); + + // Try to connect blockC into the input connection of blockA, replacing blockB. + // This is allowed because shadow blocks can always be replaced, even though + // they are unmovable. + chai.assert.isTrue( + this.checker.doDragChecks( + this.blockC.previousConnection, this.blockA.nextConnection, 9000), + 'Should connect in place of a shadow block'); + }); + test('Do not splice into unmovable stack', function() { // Try to connect blockC above blockB. It shouldn't work because B is not movable // and is already connected to A's nextConnection. From 3996d8f250b0b5eadcf4fd3f9ac3d3c94cad01e3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Apr 2023 08:44:09 -0700 Subject: [PATCH 003/161] chore(deps): bump concurrently from 7.6.0 to 8.0.1 (#6949) Bumps [concurrently](https://github.com/open-cli-tools/concurrently) from 7.6.0 to 8.0.1. - [Release notes](https://github.com/open-cli-tools/concurrently/releases) - [Commits](https://github.com/open-cli-tools/concurrently/compare/v7.6.0...v8.0.1) --- updated-dependencies: - dependency-name: concurrently dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package-lock.json | 89 ++++++++++++++++++++++++----------------------- package.json | 2 +- 2 files changed, 47 insertions(+), 44 deletions(-) diff --git a/package-lock.json b/package-lock.json index 312e2a9e0..3b892cf95 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,7 +25,7 @@ "chai": "^4.2.0", "clang-format": "^1.6.0", "closure-calculate-chunks": "^3.0.2", - "concurrently": "^7.4.0", + "concurrently": "^8.0.1", "eslint": "^8.4.1", "eslint-config-google": "^0.14.0", "eslint-plugin-jsdoc": "^40.0.0", @@ -3395,27 +3395,27 @@ } }, "node_modules/concurrently": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/concurrently/-/concurrently-7.6.0.tgz", - "integrity": "sha512-BKtRgvcJGeZ4XttiDiNcFiRlxoAeZOseqUvyYRUp/Vtd+9p1ULmeoSqGsDA+2ivdeDFpqrJvGvmI+StKfKl5hw==", + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/concurrently/-/concurrently-8.0.1.tgz", + "integrity": "sha512-Sh8bGQMEL0TAmAm2meAXMjcASHZa7V0xXQVDBLknCPa9TPtkY9yYs+0cnGGgfdkW0SV1Mlg+hVGfXcoI8d3MJA==", "dev": true, "dependencies": { - "chalk": "^4.1.0", - "date-fns": "^2.29.1", + "chalk": "^4.1.2", + "date-fns": "^2.29.3", "lodash": "^4.17.21", - "rxjs": "^7.0.0", - "shell-quote": "^1.7.3", - "spawn-command": "^0.0.2-1", - "supports-color": "^8.1.0", + "rxjs": "^7.8.0", + "shell-quote": "^1.8.0", + "spawn-command": "0.0.2-1", + "supports-color": "^8.1.1", "tree-kill": "^1.2.2", - "yargs": "^17.3.1" + "yargs": "^17.7.1" }, "bin": { "conc": "dist/bin/concurrently.js", "concurrently": "dist/bin/concurrently.js" }, "engines": { - "node": "^12.20.0 || ^14.13.0 || >=16.0.0" + "node": "^14.13.0 || >=16.0.0" }, "funding": { "url": "https://github.com/open-cli-tools/concurrently?sponsor=1" @@ -10456,18 +10456,18 @@ } }, "node_modules/rxjs": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.4.0.tgz", - "integrity": "sha512-7SQDi7xeTMCJpqViXh8gL/lebcwlp3d831F05+9B44A4B0WfsEwUQHR64gsH1kvJ+Ep/J9K2+n1hVl1CsGN23w==", + "version": "7.8.0", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.0.tgz", + "integrity": "sha512-F2+gxDshqmIub1KdvZkaEfGDwLNpPvk9Fs6LD/MyQxNgMds/WH9OdDDXOmxUZpME+iSK3rQCctkL0DYyytUqMg==", "dev": true, "dependencies": { - "tslib": "~2.1.0" + "tslib": "^2.1.0" } }, "node_modules/rxjs/node_modules/tslib": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.1.0.tgz", - "integrity": "sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", + "integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==", "dev": true }, "node_modules/safe-buffer": { @@ -10736,10 +10736,13 @@ } }, "node_modules/shell-quote": { - "version": "1.7.3", - "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.7.3.tgz", - "integrity": "sha512-Vpfqwm4EnqGdlsBFNmHhxhElJYrdfcxPThu+ryKS5J8L/fhAwLazFZtq+S+TWZ9ANj2piSQLGj6NQg+lKPmxrw==", - "dev": true + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.8.0.tgz", + "integrity": "sha512-QHsz8GgQIGKlRi24yFc6a6lN69Idnx634w49ay6+jA5yFh7a1UY+4Rp6HPx/L/1zcEDPEij8cIsiqR6bQsE5VQ==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } }, "node_modules/sigma": { "version": "1.2.1", @@ -15363,20 +15366,20 @@ } }, "concurrently": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/concurrently/-/concurrently-7.6.0.tgz", - "integrity": "sha512-BKtRgvcJGeZ4XttiDiNcFiRlxoAeZOseqUvyYRUp/Vtd+9p1ULmeoSqGsDA+2ivdeDFpqrJvGvmI+StKfKl5hw==", + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/concurrently/-/concurrently-8.0.1.tgz", + "integrity": "sha512-Sh8bGQMEL0TAmAm2meAXMjcASHZa7V0xXQVDBLknCPa9TPtkY9yYs+0cnGGgfdkW0SV1Mlg+hVGfXcoI8d3MJA==", "dev": true, "requires": { - "chalk": "^4.1.0", - "date-fns": "^2.29.1", + "chalk": "^4.1.2", + "date-fns": "^2.29.3", "lodash": "^4.17.21", - "rxjs": "^7.0.0", - "shell-quote": "^1.7.3", - "spawn-command": "^0.0.2-1", - "supports-color": "^8.1.0", + "rxjs": "^7.8.0", + "shell-quote": "^1.8.0", + "spawn-command": "0.0.2-1", + "supports-color": "^8.1.1", "tree-kill": "^1.2.2", - "yargs": "^17.3.1" + "yargs": "^17.7.1" }, "dependencies": { "supports-color": { @@ -20964,18 +20967,18 @@ } }, "rxjs": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.4.0.tgz", - "integrity": "sha512-7SQDi7xeTMCJpqViXh8gL/lebcwlp3d831F05+9B44A4B0WfsEwUQHR64gsH1kvJ+Ep/J9K2+n1hVl1CsGN23w==", + "version": "7.8.0", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.0.tgz", + "integrity": "sha512-F2+gxDshqmIub1KdvZkaEfGDwLNpPvk9Fs6LD/MyQxNgMds/WH9OdDDXOmxUZpME+iSK3rQCctkL0DYyytUqMg==", "dev": true, "requires": { - "tslib": "~2.1.0" + "tslib": "^2.1.0" }, "dependencies": { "tslib": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.1.0.tgz", - "integrity": "sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", + "integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==", "dev": true } } @@ -21186,9 +21189,9 @@ "dev": true }, "shell-quote": { - "version": "1.7.3", - "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.7.3.tgz", - "integrity": "sha512-Vpfqwm4EnqGdlsBFNmHhxhElJYrdfcxPThu+ryKS5J8L/fhAwLazFZtq+S+TWZ9ANj2piSQLGj6NQg+lKPmxrw==", + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.8.0.tgz", + "integrity": "sha512-QHsz8GgQIGKlRi24yFc6a6lN69Idnx634w49ay6+jA5yFh7a1UY+4Rp6HPx/L/1zcEDPEij8cIsiqR6bQsE5VQ==", "dev": true }, "sigma": { diff --git a/package.json b/package.json index 956162a95..f11af8b17 100644 --- a/package.json +++ b/package.json @@ -80,7 +80,7 @@ "chai": "^4.2.0", "clang-format": "^1.6.0", "closure-calculate-chunks": "^3.0.2", - "concurrently": "^7.4.0", + "concurrently": "^8.0.1", "eslint": "^8.4.1", "eslint-config-google": "^0.14.0", "eslint-plugin-jsdoc": "^40.0.0", From ce4260c373d466c912ec2adf3f9202338e589533 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 6 Apr 2023 15:59:23 +0100 Subject: [PATCH 004/161] chore(deps): bump eslint from 8.34.0 to 8.37.0 (#6946) Bumps [eslint](https://github.com/eslint/eslint) from 8.34.0 to 8.37.0. - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md) - [Commits](https://github.com/eslint/eslint/compare/v8.34.0...v8.37.0) --- updated-dependencies: - dependency-name: eslint dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package-lock.json | 186 ++++++++++++++++++---------------------------- 1 file changed, 72 insertions(+), 114 deletions(-) diff --git a/package-lock.json b/package-lock.json index 33608504a..333fb4b77 100644 --- a/package-lock.json +++ b/package-lock.json @@ -300,14 +300,14 @@ } }, "node_modules/@eslint/eslintrc": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.4.1.tgz", - "integrity": "sha512-XXrH9Uarn0stsyldqDYq8r++mROmWRI1xKMXa640Bb//SY1+ECYX6VzT6Lcx5frD0V30XieqJ0oX9I2Xj5aoMA==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.0.2.tgz", + "integrity": "sha512-3W4f5tDUra+pA+FzgugqL2pRimUTDJWKr7BINqOpkZrC0uYI0NIc0/JFgBROCU07HR6GieA5m3/rsPIhDmCXTQ==", "dev": true, "dependencies": { "ajv": "^6.12.4", "debug": "^4.3.2", - "espree": "^9.4.0", + "espree": "^9.5.1", "globals": "^13.19.0", "ignore": "^5.2.0", "import-fresh": "^3.2.1", @@ -322,6 +322,15 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/@eslint/js": { + "version": "8.37.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.37.0.tgz", + "integrity": "sha512-x5vzdtOOGgFVDCUs81QRB2+liax8rFg3+7hqM+QhBG0/G3F1ZsoYl97UrqgHgQ9KKT7G6c4V+aTUCgu/n22v1A==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, "node_modules/@gulp-sourcemaps/identity-map": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/@gulp-sourcemaps/identity-map/-/identity-map-2.0.1.tgz", @@ -4255,12 +4264,15 @@ } }, "node_modules/eslint": { - "version": "8.34.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.34.0.tgz", - "integrity": "sha512-1Z8iFsucw+7kSqXNZVslXS8Ioa4u2KM7GPwuKtkTFAqZ/cHMcEaR+1+Br0wLlot49cNxIiZk5wp8EAbPcYZxTg==", + "version": "8.37.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.37.0.tgz", + "integrity": "sha512-NU3Ps9nI05GUoVMxcZx1J8CNR6xOvUT4jAUMH5+z8lpp3aEdPVCImKw6PWG4PY+Vfkpr+jvMpxs/qoE7wq0sPw==", "dev": true, "dependencies": { - "@eslint/eslintrc": "^1.4.1", + "@eslint-community/eslint-utils": "^4.2.0", + "@eslint-community/regexpp": "^4.4.0", + "@eslint/eslintrc": "^2.0.2", + "@eslint/js": "8.37.0", "@humanwhocodes/config-array": "^0.11.8", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", @@ -4271,10 +4283,9 @@ "doctrine": "^3.0.0", "escape-string-regexp": "^4.0.0", "eslint-scope": "^7.1.1", - "eslint-utils": "^3.0.0", - "eslint-visitor-keys": "^3.3.0", - "espree": "^9.4.0", - "esquery": "^1.4.0", + "eslint-visitor-keys": "^3.4.0", + "espree": "^9.5.1", + "esquery": "^1.4.2", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", "file-entry-cache": "^6.0.1", @@ -4295,7 +4306,6 @@ "minimatch": "^3.1.2", "natural-compare": "^1.4.0", "optionator": "^0.9.1", - "regexpp": "^3.2.0", "strip-ansi": "^6.0.1", "strip-json-comments": "^3.1.0", "text-table": "^0.2.0" @@ -4365,40 +4375,16 @@ "node": ">=4.0" } }, - "node_modules/eslint-utils": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-3.0.0.tgz", - "integrity": "sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==", - "dev": true, - "dependencies": { - "eslint-visitor-keys": "^2.0.0" - }, - "engines": { - "node": "^10.0.0 || ^12.0.0 || >= 14.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/mysticatea" - }, - "peerDependencies": { - "eslint": ">=5" - } - }, - "node_modules/eslint-utils/node_modules/eslint-visitor-keys": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", - "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", - "dev": true, - "engines": { - "node": ">=10" - } - }, "node_modules/eslint-visitor-keys": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz", - "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.0.tgz", + "integrity": "sha512-HPpKPUBQcAsZOsHAFwTtIKcYlCje62XB7SEAcxjtmW6TD1WVpkS6i6/hOVtTZIl4zGj/mBqpFVGvaDneik+VoQ==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" } }, "node_modules/eslint/node_modules/glob-parent": { @@ -4414,14 +4400,14 @@ } }, "node_modules/espree": { - "version": "9.4.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.4.1.tgz", - "integrity": "sha512-XwctdmTO6SIvCzd9810yyNzIrOrqNYV9Koizx4C/mRhf9uq0o4yHoCEU/670pOxOL/MSraektvSAji79kX90Vg==", + "version": "9.5.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.5.1.tgz", + "integrity": "sha512-5yxtHSZXRSW5pvv3hAlXM5+/Oswi1AUFqBmbibKb5s6bp3rGIDkyXU6xCoyuuLhijr4SFwPrXRoZjz0AZDN9tg==", "dev": true, "dependencies": { "acorn": "^8.8.0", "acorn-jsx": "^5.3.2", - "eslint-visitor-keys": "^3.3.0" + "eslint-visitor-keys": "^3.4.0" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -4443,9 +4429,9 @@ } }, "node_modules/esquery": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.4.0.tgz", - "integrity": "sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.5.0.tgz", + "integrity": "sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg==", "dev": true, "dependencies": { "estraverse": "^5.1.0" @@ -5633,9 +5619,9 @@ } }, "node_modules/globals": { - "version": "13.19.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.19.0.tgz", - "integrity": "sha512-dkQ957uSRWHw7CFXLUtUHQI3g3aWApYhfNR2O6jn/907riyTYKVBmxYVROkBcY614FSSeSJh7Xm7SrUWCxvJMQ==", + "version": "13.20.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.20.0.tgz", + "integrity": "sha512-Qg5QtVkCy/kv3FUSlu4ukeZDVf9ee0iXLAUYX13gbR17bnejFTzr4iS9bY7kwCf1NztRNm1t91fjOiyx4CSwPQ==", "dev": true, "dependencies": { "type-fest": "^0.20.2" @@ -10139,18 +10125,6 @@ "node": ">=0.10.0" } }, - "node_modules/regexpp": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz", - "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==", - "dev": true, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/mysticatea" - } - }, "node_modules/registry-auth-token": { "version": "4.2.2", "resolved": "https://registry.npmjs.org/registry-auth-token/-/registry-auth-token-4.2.2.tgz", @@ -13018,14 +12992,14 @@ "dev": true }, "@eslint/eslintrc": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.4.1.tgz", - "integrity": "sha512-XXrH9Uarn0stsyldqDYq8r++mROmWRI1xKMXa640Bb//SY1+ECYX6VzT6Lcx5frD0V30XieqJ0oX9I2Xj5aoMA==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.0.2.tgz", + "integrity": "sha512-3W4f5tDUra+pA+FzgugqL2pRimUTDJWKr7BINqOpkZrC0uYI0NIc0/JFgBROCU07HR6GieA5m3/rsPIhDmCXTQ==", "dev": true, "requires": { "ajv": "^6.12.4", "debug": "^4.3.2", - "espree": "^9.4.0", + "espree": "^9.5.1", "globals": "^13.19.0", "ignore": "^5.2.0", "import-fresh": "^3.2.1", @@ -13034,6 +13008,12 @@ "strip-json-comments": "^3.1.1" } }, + "@eslint/js": { + "version": "8.37.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.37.0.tgz", + "integrity": "sha512-x5vzdtOOGgFVDCUs81QRB2+liax8rFg3+7hqM+QhBG0/G3F1ZsoYl97UrqgHgQ9KKT7G6c4V+aTUCgu/n22v1A==", + "dev": true + }, "@gulp-sourcemaps/identity-map": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/@gulp-sourcemaps/identity-map/-/identity-map-2.0.1.tgz", @@ -16054,12 +16034,15 @@ } }, "eslint": { - "version": "8.34.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.34.0.tgz", - "integrity": "sha512-1Z8iFsucw+7kSqXNZVslXS8Ioa4u2KM7GPwuKtkTFAqZ/cHMcEaR+1+Br0wLlot49cNxIiZk5wp8EAbPcYZxTg==", + "version": "8.37.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.37.0.tgz", + "integrity": "sha512-NU3Ps9nI05GUoVMxcZx1J8CNR6xOvUT4jAUMH5+z8lpp3aEdPVCImKw6PWG4PY+Vfkpr+jvMpxs/qoE7wq0sPw==", "dev": true, "requires": { - "@eslint/eslintrc": "^1.4.1", + "@eslint-community/eslint-utils": "^4.2.0", + "@eslint-community/regexpp": "^4.4.0", + "@eslint/eslintrc": "^2.0.2", + "@eslint/js": "8.37.0", "@humanwhocodes/config-array": "^0.11.8", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", @@ -16070,10 +16053,9 @@ "doctrine": "^3.0.0", "escape-string-regexp": "^4.0.0", "eslint-scope": "^7.1.1", - "eslint-utils": "^3.0.0", - "eslint-visitor-keys": "^3.3.0", - "espree": "^9.4.0", - "esquery": "^1.4.0", + "eslint-visitor-keys": "^3.4.0", + "espree": "^9.5.1", + "esquery": "^1.4.2", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", "file-entry-cache": "^6.0.1", @@ -16094,7 +16076,6 @@ "minimatch": "^3.1.2", "natural-compare": "^1.4.0", "optionator": "^0.9.1", - "regexpp": "^3.2.0", "strip-ansi": "^6.0.1", "strip-json-comments": "^3.1.0", "text-table": "^0.2.0" @@ -16151,38 +16132,21 @@ } } }, - "eslint-utils": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-3.0.0.tgz", - "integrity": "sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==", - "dev": true, - "requires": { - "eslint-visitor-keys": "^2.0.0" - }, - "dependencies": { - "eslint-visitor-keys": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", - "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", - "dev": true - } - } - }, "eslint-visitor-keys": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz", - "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.0.tgz", + "integrity": "sha512-HPpKPUBQcAsZOsHAFwTtIKcYlCje62XB7SEAcxjtmW6TD1WVpkS6i6/hOVtTZIl4zGj/mBqpFVGvaDneik+VoQ==", "dev": true }, "espree": { - "version": "9.4.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.4.1.tgz", - "integrity": "sha512-XwctdmTO6SIvCzd9810yyNzIrOrqNYV9Koizx4C/mRhf9uq0o4yHoCEU/670pOxOL/MSraektvSAji79kX90Vg==", + "version": "9.5.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.5.1.tgz", + "integrity": "sha512-5yxtHSZXRSW5pvv3hAlXM5+/Oswi1AUFqBmbibKb5s6bp3rGIDkyXU6xCoyuuLhijr4SFwPrXRoZjz0AZDN9tg==", "dev": true, "requires": { "acorn": "^8.8.0", "acorn-jsx": "^5.3.2", - "eslint-visitor-keys": "^3.3.0" + "eslint-visitor-keys": "^3.4.0" } }, "esprima": { @@ -16191,9 +16155,9 @@ "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" }, "esquery": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.4.0.tgz", - "integrity": "sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.5.0.tgz", + "integrity": "sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg==", "dev": true, "requires": { "estraverse": "^5.1.0" @@ -17153,9 +17117,9 @@ } }, "globals": { - "version": "13.19.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.19.0.tgz", - "integrity": "sha512-dkQ957uSRWHw7CFXLUtUHQI3g3aWApYhfNR2O6jn/907riyTYKVBmxYVROkBcY614FSSeSJh7Xm7SrUWCxvJMQ==", + "version": "13.20.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.20.0.tgz", + "integrity": "sha512-Qg5QtVkCy/kv3FUSlu4ukeZDVf9ee0iXLAUYX13gbR17bnejFTzr4iS9bY7kwCf1NztRNm1t91fjOiyx4CSwPQ==", "dev": true, "requires": { "type-fest": "^0.20.2" @@ -20726,12 +20690,6 @@ "safe-regex": "^1.1.0" } }, - "regexpp": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz", - "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==", - "dev": true - }, "registry-auth-token": { "version": "4.2.2", "resolved": "https://registry.npmjs.org/registry-auth-token/-/registry-auth-token-4.2.2.tgz", From 7c17ab9931627802e2261a07fb71ee4e73c360a6 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Thu, 6 Apr 2023 09:09:34 -0700 Subject: [PATCH 005/161] fix: collapsed toolbox categories being expanded (#6942) --- core/toolbox/collapsible_category.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/core/toolbox/collapsible_category.ts b/core/toolbox/collapsible_category.ts index 0cb3df7b4..6f7156f8d 100644 --- a/core/toolbox/collapsible_category.ts +++ b/core/toolbox/collapsible_category.ts @@ -113,7 +113,7 @@ export class CollapsibleToolboxCategory extends ToolboxCategory implements this.setExpanded( this.toolboxItemDef_['expanded'] === 'true' || - !!this.toolboxItemDef_['expanded']); + this.toolboxItemDef_['expanded'] === true); } override createDom_() { @@ -123,6 +123,8 @@ export class CollapsibleToolboxCategory extends ToolboxCategory implements this.subcategoriesDiv_ = this.createSubCategoriesDom_(subCategories); aria.setRole(this.subcategoriesDiv_, aria.Role.GROUP); this.htmlDiv_!.appendChild(this.subcategoriesDiv_); + this.closeIcon_(this.iconDom_); + aria.setState(this.htmlDiv_ as HTMLDivElement, aria.State.EXPANDED, false); return this.htmlDiv_!; } @@ -150,6 +152,7 @@ export class CollapsibleToolboxCategory extends ToolboxCategory implements protected createSubCategoriesDom_(subcategories: IToolboxItem[]): HTMLDivElement { const contentsContainer = document.createElement('div'); + contentsContainer.style.display = 'none'; const className = this.cssConfig_['contents']; if (className) { dom.addClass(contentsContainer, className); @@ -173,9 +176,8 @@ export class CollapsibleToolboxCategory extends ToolboxCategory implements * @param isExpanded True to expand the category, false to close. */ setExpanded(isExpanded: boolean) { - if (this.expanded_ === isExpanded) { - return; - } + if (this.expanded_ === isExpanded) return; + this.expanded_ = isExpanded; if (isExpanded) { this.subcategoriesDiv_!.style.display = 'block'; From 2167afab8508df666071d82154752d49ee891d1d Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Thu, 6 Apr 2023 11:41:12 -0700 Subject: [PATCH 006/161] fix: disposing during dragging (#6954) --- core/block_dragger.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/core/block_dragger.ts b/core/block_dragger.ts index 5809f7484..0a2cb0f33 100644 --- a/core/block_dragger.ts +++ b/core/block_dragger.ts @@ -346,6 +346,7 @@ export class BlockDragger implements IBlockDragger { /** Fire a move event at the end of a block drag. */ protected fireMoveEvent_() { + if (this.draggingBlock_.isDeadOrDying()) return; const event = new (eventUtils.get(eventUtils.BLOCK_MOVE))( this.draggingBlock_) as BlockMove; event.oldCoordinate = this.startXY_; From 8378eddd17428e20d10d24211f12b3a9f9df1763 Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Fri, 7 Apr 2023 14:51:35 -0700 Subject: [PATCH 007/161] chore: remove underscores from properties and methods in trashcan (#6959) --- core/trashcan.ts | 164 ++++++++++---------- tests/mocha/comment_deserialization_test.js | 2 +- tests/mocha/trashcan_test.js | 48 +++--- 3 files changed, 105 insertions(+), 109 deletions(-) diff --git a/core/trashcan.ts b/core/trashcan.ts index 5d4d87f58..941850855 100644 --- a/core/trashcan.ts +++ b/core/trashcan.ts @@ -55,7 +55,7 @@ export class Trashcan extends DeleteArea implements IAutoHideable, /** * A list of JSON (stored as strings) representing blocks in the trashcan. */ - private readonly contents_: string[] = []; + private readonly contents: string[] = []; /** * The trashcan flyout. @@ -71,28 +71,28 @@ export class Trashcan extends DeleteArea implements IAutoHideable, * The minimum openness of the lid. Used to indicate if the trashcan * contains blocks. */ - private minOpenness_ = 0; + private minOpenness = 0; /** The SVG group containing the trash can. */ - private svgGroup_: SVGElement|null = null; + private svgGroup: SVGElement|null = null; /** The SVG image element of the trash can lid. */ - private svgLid_: SVGElement|null = null; + private svgLid: SVGElement|null = null; /** Task ID of opening/closing animation. */ - private lidTask_: ReturnType|null = null; + private lidTask: ReturnType|null = null; /** Current state of lid opening (0.0 = closed, 1.0 = open). */ - private lidOpen_ = 0; + private lidOpen = 0; /** Left coordinate of the trash can. */ - private left_ = 0; + private left = 0; /** Top coordinate of the trash can. */ - private top_ = 0; + private top = 0; /** Whether this trash can has been initialized. */ - private initialized_ = false; + private initialized = false; /** @param workspace The workspace to sit in. */ constructor(private workspace: WorkspaceSvg) { @@ -133,7 +133,7 @@ export class Trashcan extends DeleteArea implements IAutoHideable, registry.Type.FLYOUTS_VERTICAL_TOOLBOX, this.workspace.options, true); this.flyout = new VerticalFlyout!(flyoutWorkspaceOptions); } - this.workspace.addChangeListener(this.onDelete_.bind(this)); + this.workspace.addChangeListener(this.onDelete.bind(this)); } /** @@ -156,11 +156,11 @@ export class Trashcan extends DeleteArea implements IAutoHideable, clip-path="url(#blocklyTrashLidClipPath837493)"> */ - this.svgGroup_ = dom.createSvgElement(Svg.G, {'class': 'blocklyTrash'}); + this.svgGroup = dom.createSvgElement(Svg.G, {'class': 'blocklyTrash'}); let clip; const rnd = String(Math.random()).substring(2); clip = dom.createSvgElement( - Svg.CLIPPATH, {'id': 'blocklyTrashBodyClipPath' + rnd}, this.svgGroup_); + Svg.CLIPPATH, {'id': 'blocklyTrashBodyClipPath' + rnd}, this.svgGroup); dom.createSvgElement( Svg.RECT, {'width': WIDTH, 'height': BODY_HEIGHT, 'y': LID_HEIGHT}, clip); @@ -172,16 +172,16 @@ export class Trashcan extends DeleteArea implements IAutoHideable, 'y': -SPRITE_TOP, 'clip-path': 'url(#blocklyTrashBodyClipPath' + rnd + ')', }, - this.svgGroup_); + this.svgGroup); body.setAttributeNS( dom.XLINK_NS, 'xlink:href', this.workspace.options.pathToMedia + SPRITE.url); clip = dom.createSvgElement( - Svg.CLIPPATH, {'id': 'blocklyTrashLidClipPath' + rnd}, this.svgGroup_); + Svg.CLIPPATH, {'id': 'blocklyTrashLidClipPath' + rnd}, this.svgGroup); dom.createSvgElement( Svg.RECT, {'width': WIDTH, 'height': LID_HEIGHT}, clip); - this.svgLid_ = dom.createSvgElement( + this.svgLid = dom.createSvgElement( Svg.IMAGE, { 'width': SPRITE.width, 'x': -SPRITE_LEFT, @@ -189,8 +189,8 @@ export class Trashcan extends DeleteArea implements IAutoHideable, 'y': -SPRITE_TOP, 'clip-path': 'url(#blocklyTrashLidClipPath' + rnd + ')', }, - this.svgGroup_); - this.svgLid_.setAttributeNS( + this.svgGroup); + this.svgLid.setAttributeNS( dom.XLINK_NS, 'xlink:href', this.workspace.options.pathToMedia + SPRITE.url); @@ -199,13 +199,13 @@ export class Trashcan extends DeleteArea implements IAutoHideable, // Using bindEventWithChecks_ for blocking mousedown causes issue in mobile. // See #4303 browserEvents.bind( - this.svgGroup_, 'pointerdown', this, this.blockMouseDownWhenOpenable_); - browserEvents.bind(this.svgGroup_, 'pointerup', this, this.click); - // Bind to body instead of this.svgGroup_ so that we don't get lid jitters - browserEvents.bind(body, 'pointerover', this, this.mouseOver_); - browserEvents.bind(body, 'pointerout', this, this.mouseOut_); - this.animateLid_(); - return this.svgGroup_; + this.svgGroup, 'pointerdown', this, this.blockMouseDownWhenOpenable); + browserEvents.bind(this.svgGroup, 'pointerup', this, this.click); + // Bind to body instead of this.svgGroup so that we don't get lid jitters + browserEvents.bind(body, 'pointerover', this, this.mouseOver); + browserEvents.bind(body, 'pointerout', this, this.mouseOut); + this.animateLid(); + return this.svgGroup; } /** Initializes the trash can. */ @@ -225,25 +225,21 @@ export class Trashcan extends DeleteArea implements IAutoHideable, ComponentManager.Capability.POSITIONABLE, ], }); - this.initialized_ = true; + this.initialized = true; this.setLidOpen(false); } /** * Dispose of this trash can. * Unlink from all DOM elements to prevent memory leaks. - * - * @suppress {checkTypes} */ dispose() { this.workspace.getComponentManager().removeComponent('trashcan'); - if (this.svgGroup_) { - dom.removeNode(this.svgGroup_); - this.svgGroup_ = null; + if (this.svgGroup) { + dom.removeNode(this.svgGroup); } - this.svgLid_ = null; - if (this.lidTask_) { - clearTimeout(this.lidTask_); + if (this.lidTask) { + clearTimeout(this.lidTask); } } @@ -252,8 +248,8 @@ export class Trashcan extends DeleteArea implements IAutoHideable, * * @returns True if the trashcan has contents. */ - private hasContents_(): boolean { - return !!this.contents_.length; + private hasContents(): boolean { + return !!this.contents.length; } /** @@ -270,7 +266,7 @@ export class Trashcan extends DeleteArea implements IAutoHideable, if (this.contentsIsOpen()) { return; } - const contents = this.contents_.map(function(string) { + const contents = this.contents.map(function(string) { return JSON.parse(string); }); // Trashcans with lots of blocks can take a second to render. @@ -280,7 +276,7 @@ export class Trashcan extends DeleteArea implements IAutoHideable, this.flyout?.show(contents); blocklyStyle.cursor = ''; }, 10); - this.fireUiEvent_(true); + this.fireUiEvent(true); } /** Closes the trashcan flyout. */ @@ -289,7 +285,7 @@ export class Trashcan extends DeleteArea implements IAutoHideable, return; } this.flyout?.hide(); - this.fireUiEvent_(false); + this.fireUiEvent(false); this.workspace.recordDragTargets(); } @@ -312,11 +308,11 @@ export class Trashcan extends DeleteArea implements IAutoHideable, * it will be closed. */ emptyContents() { - if (!this.hasContents_()) { + if (!this.hasContents()) { return; } - this.contents_.length = 0; - this.setMinOpenness_(0); + this.contents.length = 0; + this.setMinOpenness(0); this.closeFlyout(); } @@ -330,7 +326,7 @@ export class Trashcan extends DeleteArea implements IAutoHideable, */ position(metrics: UiMetrics, savedPositions: Rect[]) { // Not yet initialized. - if (!this.initialized_) { + if (!this.initialized) { return; } @@ -349,10 +345,10 @@ export class Trashcan extends DeleteArea implements IAutoHideable, const positionRect = uiPosition.bumpPositionRect( startRect, MARGIN_VERTICAL, bumpDirection, savedPositions); - this.top_ = positionRect.top; - this.left_ = positionRect.left; - this.svgGroup_?.setAttribute( - 'transform', 'translate(' + this.left_ + ',' + this.top_ + ')'); + this.top = positionRect.top; + this.left = positionRect.left; + this.svgGroup?.setAttribute( + 'transform', 'translate(' + this.left + ',' + this.top + ')'); } /** @@ -363,9 +359,9 @@ export class Trashcan extends DeleteArea implements IAutoHideable, * ignored by other UI elements. */ getBoundingRectangle(): Rect|null { - const bottom = this.top_ + BODY_HEIGHT + LID_HEIGHT; - const right = this.left_ + WIDTH; - return new Rect(this.top_, bottom, this.left_, right); + const bottom = this.top + BODY_HEIGHT + LID_HEIGHT; + const right = this.left + WIDTH; + return new Rect(this.top, bottom, this.left, right); } /** @@ -376,11 +372,11 @@ export class Trashcan extends DeleteArea implements IAutoHideable, * ignored. */ override getClientRect(): Rect|null { - if (!this.svgGroup_) { + if (!this.svgGroup) { return null; } - const trashRect = this.svgGroup_.getBoundingClientRect(); + const trashRect = this.svgGroup.getBoundingClientRect(); const top = trashRect.top + SPRITE_TOP - MARGIN_HOTSPOT; const bottom = top + LID_HEIGHT + BODY_HEIGHT + 2 * MARGIN_HOTSPOT; const left = trashRect.left + SPRITE_LEFT - MARGIN_HOTSPOT; @@ -427,32 +423,32 @@ export class Trashcan extends DeleteArea implements IAutoHideable, if (this.isLidOpen === state) { return; } - if (this.lidTask_) { - clearTimeout(this.lidTask_); + if (this.lidTask) { + clearTimeout(this.lidTask); } this.isLidOpen = state; - this.animateLid_(); + this.animateLid(); } /** Rotate the lid open or closed by one step. Then wait and recurse. */ - private animateLid_() { + private animateLid() { const frames = ANIMATION_FRAMES; const delta = 1 / (frames + 1); - this.lidOpen_ += this.isLidOpen ? delta : -delta; - this.lidOpen_ = Math.min(Math.max(this.lidOpen_, this.minOpenness_), 1); + this.lidOpen += this.isLidOpen ? delta : -delta; + this.lidOpen = Math.min(Math.max(this.lidOpen, this.minOpenness), 1); - this.setLidAngle_(this.lidOpen_ * MAX_LID_ANGLE); + this.setLidAngle(this.lidOpen * MAX_LID_ANGLE); // Linear interpolation between min and max. - const opacity = OPACITY_MIN + this.lidOpen_ * (OPACITY_MAX - OPACITY_MIN); - if (this.svgGroup_) { - this.svgGroup_.style.opacity = `${opacity}`; + const opacity = OPACITY_MIN + this.lidOpen * (OPACITY_MAX - OPACITY_MIN); + if (this.svgGroup) { + this.svgGroup.style.opacity = `${opacity}`; } - if (this.lidOpen_ > this.minOpenness_ && this.lidOpen_ < 1) { - this.lidTask_ = - setTimeout(this.animateLid_.bind(this), ANIMATION_LENGTH / frames); + if (this.lidOpen > this.minOpenness && this.lidOpen < 1) { + this.lidTask = + setTimeout(this.animateLid.bind(this), ANIMATION_LENGTH / frames); } } @@ -461,11 +457,11 @@ export class Trashcan extends DeleteArea implements IAutoHideable, * * @param lidAngle The angle at which to set the lid. */ - private setLidAngle_(lidAngle: number) { + private setLidAngle(lidAngle: number) { const openAtRight = this.workspace.toolboxPosition === toolbox.Position.RIGHT || this.workspace.horizontalLayout && this.workspace.RTL; - this.svgLid_?.setAttribute( + this.svgLid?.setAttribute( 'transform', 'rotate(' + (openAtRight ? -lidAngle : lidAngle) + ',' + (openAtRight ? 4 : WIDTH - 4) + ',' + (LID_HEIGHT - 2) + ')'); @@ -478,10 +474,10 @@ export class Trashcan extends DeleteArea implements IAutoHideable, * @param newMin The new minimum openness of the lid. Should be between 0 * and 1. */ - private setMinOpenness_(newMin: number) { - this.minOpenness_ = newMin; + private setMinOpenness(newMin: number) { + this.minOpenness = newMin; if (!this.isLidOpen) { - this.setLidAngle_(newMin * MAX_LID_ANGLE); + this.setLidAngle(newMin * MAX_LID_ANGLE); } } @@ -495,7 +491,7 @@ export class Trashcan extends DeleteArea implements IAutoHideable, /** Inspect the contents of the trash. */ click() { - if (!this.hasContents_()) { + if (!this.hasContents()) { return; } this.openFlyout(); @@ -506,7 +502,7 @@ export class Trashcan extends DeleteArea implements IAutoHideable, * * @param trashcanOpen Whether the flyout is opening. */ - private fireUiEvent_(trashcanOpen: boolean) { + private fireUiEvent(trashcanOpen: boolean) { const uiEvent = new (eventUtils.get(eventUtils.TRASHCAN_OPEN))( trashcanOpen, this.workspace.id); eventUtils.fire(uiEvent); @@ -517,8 +513,8 @@ export class Trashcan extends DeleteArea implements IAutoHideable, * * @param e A mouse down event. */ - private blockMouseDownWhenOpenable_(e: PointerEvent) { - if (!this.contentsIsOpen() && this.hasContents_()) { + private blockMouseDownWhenOpenable(e: PointerEvent) { + if (!this.contentsIsOpen() && this.hasContents()) { // Don't start a workspace scroll. e.stopPropagation(); } @@ -527,8 +523,8 @@ export class Trashcan extends DeleteArea implements IAutoHideable, /** * Indicate that the trashcan can be clicked (by opening it) if it has blocks. */ - private mouseOver_() { - if (this.hasContents_()) { + private mouseOver() { + if (this.hasContents()) { this.setLidOpen(true); } } @@ -537,7 +533,7 @@ export class Trashcan extends DeleteArea implements IAutoHideable, * Close the lid of the trashcan if it was open (Vis. it was indicating it had * blocks). */ - private mouseOut_() { + private mouseOut() { // No need to do a .hasBlocks check here because if it doesn't the trashcan // won't be open in the first place, and setOpen won't run. this.setLidOpen(false); @@ -549,7 +545,7 @@ export class Trashcan extends DeleteArea implements IAutoHideable, * * @param event Workspace event. */ - private onDelete_(event: Abstract) { + private onDelete(event: Abstract) { if (this.workspace.options.maxTrashcanContents <= 0 || event.type !== eventUtils.BLOCK_DELETE) { return; @@ -560,17 +556,17 @@ export class Trashcan extends DeleteArea implements IAutoHideable, throw new Error('Encountered a delete event without proper oldJson'); } const cleanedJson = - JSON.stringify(this.cleanBlockJson_(deleteEvent.oldJson)); - if (this.contents_.indexOf(cleanedJson) !== -1) { + JSON.stringify(this.cleanBlockJson(deleteEvent.oldJson)); + if (this.contents.indexOf(cleanedJson) !== -1) { return; } - this.contents_.unshift(cleanedJson); - while (this.contents_.length > + this.contents.unshift(cleanedJson); + while (this.contents.length > this.workspace.options.maxTrashcanContents) { - this.contents_.pop(); + this.contents.pop(); } - this.setMinOpenness_(HAS_BLOCKS_LID_ANGLE); + this.setMinOpenness(HAS_BLOCKS_LID_ANGLE); } } @@ -582,7 +578,7 @@ export class Trashcan extends DeleteArea implements IAutoHideable, * @returns A BlockInfo object corresponding to the JSON, cleaned of all * unnecessary attributes. */ - private cleanBlockJson_(json: blocks.State): BlockInfo { + private cleanBlockJson(json: blocks.State): BlockInfo { // Create a deep copy. json = JSON.parse(JSON.stringify(json)) as blocks.State; diff --git a/tests/mocha/comment_deserialization_test.js b/tests/mocha/comment_deserialization_test.js index c8bf0594f..b8df7a365 100644 --- a/tests/mocha/comment_deserialization_test.js +++ b/tests/mocha/comment_deserialization_test.js @@ -71,7 +71,7 @@ suite('Comment Deserialization', function() { this.block.checkAndDelete(); chai.assert.equal(this.workspace.getAllBlocks().length, 0); // Open trashcan. - simulateClick(this.workspace.trashcan.svgGroup_); + simulateClick(this.workspace.trashcan.svgGroup); // Place from trashcan. simulateClick(this.workspace.trashcan.flyout.svgGroup_.querySelector('.blocklyDraggable')); chai.assert.equal(this.workspace.getAllBlocks().length, 1); diff --git a/tests/mocha/trashcan_test.js b/tests/mocha/trashcan_test.js index 028d8fcdc..ad7102872 100644 --- a/tests/mocha/trashcan_test.js +++ b/tests/mocha/trashcan_test.js @@ -56,11 +56,11 @@ suite("Trashcan", function() { suite("Events", function() { test("Delete", function() { fireDeleteEvent(this.workspace, ''); - chai.assert.equal(this.trashcan.contents_.length, 1); + chai.assert.equal(this.trashcan.contents.length, 1); }); test("Non-Delete", function() { fireNonDeleteEvent(this.workspace); - chai.assert.equal(this.trashcan.contents_.length, 0); + chai.assert.equal(this.trashcan.contents.length, 0); }); test("Non-Delete w/ oldXml", function() { let xml = Blockly.utils.xml.textToDom( @@ -70,14 +70,14 @@ suite("Trashcan", function() { ); xml = xml.children[0]; fireNonDeleteEvent(this.workspace, xml); - chai.assert.equal(this.trashcan.contents_.length, 0); + chai.assert.equal(this.trashcan.contents.length, 0); }); test("Shadow Delete", function() { fireDeleteEvent(this.workspace, ''); - chai.assert.equal(this.trashcan.contents_.length, 0); + chai.assert.equal(this.trashcan.contents.length, 0); }); test("Click without contents - fires workspace click", function() { - simulateClick(this.trashcan.svgGroup_); + simulateClick(this.trashcan.svgGroup); assertEventNotFired( this.eventsFireStub, Blockly.Events.TrashcanOpen, {type: eventUtils.CLICK}); @@ -87,11 +87,11 @@ suite("Trashcan", function() { }); test("Click with contents - fires trashcanOpen", function() { fireDeleteEvent(this.workspace, ''); - chai.assert.equal(this.trashcan.contents_.length, 1); + chai.assert.equal(this.trashcan.contents.length, 1); // Stub flyout interaction. const showFlyoutStub = sinon.stub(this.trashcan.flyout, "show"); - simulateClick(this.trashcan.svgGroup_); + simulateClick(this.trashcan.svgGroup); sinon.assert.calledOnce(showFlyoutStub); @@ -122,21 +122,21 @@ suite("Trashcan", function() { test("Simple", function() { fireDeleteEvent(this.workspace, ''); fireDeleteEvent(this.workspace, ''); - chai.assert.equal(this.trashcan.contents_.length, 1); + chai.assert.equal(this.trashcan.contents.length, 1); }); test("Different Coords", function() { fireDeleteEvent( this.workspace, ''); fireDeleteEvent( this.workspace, ''); - chai.assert.equal(this.trashcan.contents_.length, 1); + chai.assert.equal(this.trashcan.contents.length, 1); }); test("Different IDs", function() { fireDeleteEvent( this.workspace, ''); fireDeleteEvent( this.workspace, ''); - chai.assert.equal(this.trashcan.contents_.length, 1); + chai.assert.equal(this.trashcan.contents.length, 1); }); test("No Disabled - Disabled True", function() { fireDeleteEvent( @@ -145,7 +145,7 @@ suite("Trashcan", function() { this.workspace, ''); // Disabled tags get removed because disabled blocks aren't allowed to // be dragged from flyouts. See #2239 and #3243. - chai.assert.equal(this.trashcan.contents_.length, 1); + chai.assert.equal(this.trashcan.contents.length, 1); }); test("Different Field Values", function() { fireDeleteEvent(this.workspace, @@ -158,7 +158,7 @@ suite("Trashcan", function() { ' dummy_value2' + '' ); - chai.assert.equal(this.trashcan.contents_.length, 2); + chai.assert.equal(this.trashcan.contents.length, 2); }); test("No Values - Values", function() { fireDeleteEvent(this.workspace, ''); @@ -169,7 +169,7 @@ suite("Trashcan", function() { ' ' + '' ); - chai.assert.equal(this.trashcan.contents_.length, 2); + chai.assert.equal(this.trashcan.contents.length, 2); }); test("Different Value Blocks", function() { fireDeleteEvent(this.workspace, @@ -186,7 +186,7 @@ suite("Trashcan", function() { ' ' + '' ); - chai.assert.equal(this.trashcan.contents_.length, 2); + chai.assert.equal(this.trashcan.contents.length, 2); }); test("No Statements - Statements", function() { fireDeleteEvent(this.workspace, ''); @@ -197,7 +197,7 @@ suite("Trashcan", function() { ' ' + '' ); - chai.assert.equal(this.trashcan.contents_.length, 2); + chai.assert.equal(this.trashcan.contents.length, 2); }); test("Different Statement Blocks", function() { fireDeleteEvent(this.workspace, @@ -214,7 +214,7 @@ suite("Trashcan", function() { ' ' + '' ); - chai.assert.equal(this.trashcan.contents_.length, 2); + chai.assert.equal(this.trashcan.contents.length, 2); }); test("No Next - Next", function() { fireDeleteEvent(this.workspace, ''); @@ -225,7 +225,7 @@ suite("Trashcan", function() { ' ' + '' ); - chai.assert.equal(this.trashcan.contents_.length, 2); + chai.assert.equal(this.trashcan.contents.length, 2); }); test("Different Next Blocks", function() { fireDeleteEvent(this.workspace, @@ -242,7 +242,7 @@ suite("Trashcan", function() { ' ' + '' ); - chai.assert.equal(this.trashcan.contents_.length, 2); + chai.assert.equal(this.trashcan.contents.length, 2); }); test("No Comment - Comment", function() { fireDeleteEvent(this.workspace, ''); @@ -251,7 +251,7 @@ suite("Trashcan", function() { ' comment_text' + '' ); - chai.assert.equal(this.trashcan.contents_.length, 2); + chai.assert.equal(this.trashcan.contents.length, 2); }); test("Different Comment Text", function() { fireDeleteEvent(this.workspace, @@ -264,7 +264,7 @@ suite("Trashcan", function() { ' comment_text2' + '' ); - chai.assert.equal(this.trashcan.contents_.length, 2); + chai.assert.equal(this.trashcan.contents.length, 2); }); test("Different Comment Size", function() { fireDeleteEvent(this.workspace, @@ -278,7 +278,7 @@ suite("Trashcan", function() { '' ); // h & w tags are removed b/c the blocks appear the same. - chai.assert.equal(this.trashcan.contents_.length, 1); + chai.assert.equal(this.trashcan.contents.length, 1); }); test("Different Comment Pinned", function() { fireDeleteEvent(this.workspace, @@ -292,7 +292,7 @@ suite("Trashcan", function() { '' ); // pinned tags are removed b/c the blocks appear the same. - chai.assert.equal(this.trashcan.contents_.length, 1); + chai.assert.equal(this.trashcan.contents.length, 1); }); test("Different Mutator", function() { fireDeleteEvent(this.workspace, @@ -305,7 +305,7 @@ suite("Trashcan", function() { ' ' + '' ); - chai.assert.equal(this.trashcan.contents_.length, 2); + chai.assert.equal(this.trashcan.contents.length, 2); }); }); suite("Max Contents", function() { @@ -314,7 +314,7 @@ suite("Trashcan", function() { fireDeleteEvent(this.workspace, '' ); - chai.assert.equal(this.trashcan.contents_.length, 0); + chai.assert.equal(this.trashcan.contents.length, 0); this.workspace.options.maxTrashcanContents = Infinity; }); }); From 48bdeb3bdb0a222a6b48589310343248bb29bcb1 Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Fri, 7 Apr 2023 15:40:56 -0700 Subject: [PATCH 008/161] chore: remove underscores from private properties and methods for flyout (#6960) * chore: remove underscores in flyout files * chore: remove underscores in flyout_button --- core/flyout_base.ts | 180 +++++++++++++++++++------------------ core/flyout_button.ts | 96 ++++++++++---------- core/flyout_horizontal.ts | 4 +- core/flyout_vertical.ts | 4 +- tests/mocha/flyout_test.js | 4 +- 5 files changed, 144 insertions(+), 144 deletions(-) diff --git a/core/flyout_base.ts b/core/flyout_base.ts index a517eebe7..1c976a3f3 100644 --- a/core/flyout_base.ts +++ b/core/flyout_base.ts @@ -137,33 +137,36 @@ export abstract class Flyout extends DeleteArea implements IFlyout { * Function that will be registered as a change listener on the workspace * to reflow when blocks in the flyout workspace change. */ - private reflowWrapper_: Function|null = null; + private reflowWrapper: Function|null = null; /** * Function that disables blocks in the flyout based on max block counts * allowed in the target workspace. Registered as a change listener on the * target workspace. */ - private filterWrapper_: Function|null = null; + private filterWrapper: Function|null = null; /** * List of background mats that lurk behind each block to catch clicks * landing in the blocks' lakes and bays. */ - private mats_: SVGElement[] = []; + private mats: SVGElement[] = []; + /** * List of visible buttons. */ protected buttons_: FlyoutButton[] = []; + /** * List of event listeners. */ - private listeners_: browserEvents.Data[] = []; + private listeners: browserEvents.Data[] = []; /** * List of blocks that should always be disabled. */ - private permanentlyDisabled_: Block[] = []; + private permanentlyDisabled: Block[] = []; + protected readonly tabWidth_: number; /** @@ -172,10 +175,12 @@ export abstract class Flyout extends DeleteArea implements IFlyout { * @internal */ targetWorkspace!: WorkspaceSvg; + /** * A list of blocks that can be reused. */ - private recycledBlocks_: BlockSvg[] = []; + private recycledBlocks: BlockSvg[] = []; + /** * Does the flyout automatically close when a block is created? */ @@ -189,7 +194,7 @@ export abstract class Flyout extends DeleteArea implements IFlyout { /** * Whether the workspace containing this flyout is visible. */ - private containerVisible_ = true; + private containerVisible = true; protected rectMap_: WeakMap; /** @@ -361,14 +366,14 @@ export abstract class Flyout extends DeleteArea implements IFlyout { this.boundEvents.push(browserEvents.conditionalBind( (this.svgGroup_ as SVGGElement), 'wheel', this, this.wheel_)); if (!this.autoClose) { - this.filterWrapper_ = this.filterForCapacity_.bind(this); - this.targetWorkspace.addChangeListener(this.filterWrapper_); + this.filterWrapper = this.filterForCapacity.bind(this); + this.targetWorkspace.addChangeListener(this.filterWrapper); } // Dragging the flyout up and down. this.boundEvents.push(browserEvents.conditionalBind( (this.svgBackground_ as SVGPathElement), 'pointerdown', this, - this.onMouseDown_)); + this.onMouseDown)); // A flyout connected to a workspace doesn't have its own current gesture. this.workspace_.getGesture = @@ -402,9 +407,8 @@ export abstract class Flyout extends DeleteArea implements IFlyout { browserEvents.unbind(event); } this.boundEvents.length = 0; - if (this.filterWrapper_) { - this.targetWorkspace.removeChangeListener(this.filterWrapper_); - this.filterWrapper_ = null; + if (this.filterWrapper) { + this.targetWorkspace.removeChangeListener(this.filterWrapper); } if (this.workspace_) { this.workspace_.getThemeManager().unsubscribe(this.svgBackground_!); @@ -412,9 +416,7 @@ export abstract class Flyout extends DeleteArea implements IFlyout { } if (this.svgGroup_) { dom.removeNode(this.svgGroup_); - this.svgGroup_ = null; } - this.svgBackground_ = null; } /** @@ -480,7 +482,7 @@ export abstract class Flyout extends DeleteArea implements IFlyout { // auto-close flyouts need to have their drag target updated. this.workspace_.recordDragTargets(); } - this.updateDisplay_(); + this.updateDisplay(); } } @@ -490,10 +492,10 @@ export abstract class Flyout extends DeleteArea implements IFlyout { * @param visible Whether the container is visible. */ setContainerVisible(visible: boolean) { - const visibilityChanged = visible !== this.containerVisible_; - this.containerVisible_ = visible; + const visibilityChanged = visible !== this.containerVisible; + this.containerVisible = visible; if (visibilityChanged) { - this.updateDisplay_(); + this.updateDisplay(); } } @@ -501,9 +503,9 @@ export abstract class Flyout extends DeleteArea implements IFlyout { * Update the display property of the flyout based whether it thinks it should * be visible and whether its containing workspace is visible. */ - private updateDisplay_() { + private updateDisplay() { let show = true; - if (!this.containerVisible_) { + if (!this.containerVisible) { show = false; } else { show = this.isVisible(); @@ -562,13 +564,13 @@ export abstract class Flyout extends DeleteArea implements IFlyout { } this.setVisible(false); // Delete all the event listeners. - for (const listen of this.listeners_) { + for (const listen of this.listeners) { browserEvents.unbind(listen); } - this.listeners_.length = 0; - if (this.reflowWrapper_) { - this.workspace_.removeChangeListener(this.reflowWrapper_); - this.reflowWrapper_ = null; + this.listeners.length = 0; + if (this.reflowWrapper) { + this.workspace_.removeChangeListener(this.reflowWrapper); + this.reflowWrapper = null; } // Do NOT delete the blocks here. Wait until Flyout.show. // https://neil.fraser.name/news/2014/08/09/ @@ -584,17 +586,17 @@ export abstract class Flyout extends DeleteArea implements IFlyout { show(flyoutDef: toolbox.FlyoutDefinition|string) { this.workspace_.setResizesEnabled(false); this.hide(); - this.clearOldBlocks_(); + this.clearOldBlocks(); // Handle dynamic categories, represented by a name instead of a list. if (typeof flyoutDef === 'string') { - flyoutDef = this.getDynamicCategoryContents_(flyoutDef); + flyoutDef = this.getDynamicCategoryContents(flyoutDef); } this.setVisible(true); // Parse the Array, Node or NodeList into a a list of flyout items. const parsedContent = toolbox.convertFlyoutDefToJsonArray(flyoutDef); - const flyoutInfo = this.createFlyoutInfo_(parsedContent); + const flyoutInfo = this.createFlyoutInfo(parsedContent); this.layout_(flyoutInfo.contents, flyoutInfo.gaps); @@ -606,14 +608,14 @@ export abstract class Flyout extends DeleteArea implements IFlyout { this.workspace_.setResizesEnabled(true); this.reflow(); - this.filterForCapacity_(); + this.filterForCapacity(); // Correctly position the flyout's scrollbar when it opens. this.position(); - this.reflowWrapper_ = this.reflow.bind(this); - this.workspace_.addChangeListener(this.reflowWrapper_); - this.emptyRecycledBlocks_(); + this.reflowWrapper = this.reflow.bind(this); + this.workspace_.addChangeListener(this.reflowWrapper); + this.emptyRecycledBlocks(); } /** @@ -624,21 +626,21 @@ export abstract class Flyout extends DeleteArea implements IFlyout { * of objects to show in the flyout. * @returns The list of contents and gaps needed to lay out the flyout. */ - private createFlyoutInfo_(parsedContent: toolbox.FlyoutItemInfoArray): + private createFlyoutInfo(parsedContent: toolbox.FlyoutItemInfoArray): {contents: FlyoutItem[], gaps: number[]} { const contents: FlyoutItem[] = []; const gaps: number[] = []; - this.permanentlyDisabled_.length = 0; + this.permanentlyDisabled.length = 0; const defaultGap = this.horizontalLayout ? this.GAP_X : this.GAP_Y; for (const info of parsedContent) { if ('custom' in info) { const customInfo = (info as toolbox.DynamicCategoryInfo); const categoryName = customInfo['custom']; - const flyoutDef = this.getDynamicCategoryContents_(categoryName); + const flyoutDef = this.getDynamicCategoryContents(categoryName); const parsedDynamicContent = toolbox.convertFlyoutDefToJsonArray(flyoutDef); const {contents: dynamicContents, gaps: dynamicGaps} = - this.createFlyoutInfo_(parsedDynamicContent); + this.createFlyoutInfo(parsedDynamicContent); contents.push(...dynamicContents); gaps.push(...dynamicGaps); } @@ -646,27 +648,27 @@ export abstract class Flyout extends DeleteArea implements IFlyout { switch (info['kind'].toUpperCase()) { case 'BLOCK': { const blockInfo = (info as toolbox.BlockInfo); - const block = this.createFlyoutBlock_(blockInfo); + const block = this.createFlyoutBlock(blockInfo); contents.push({type: FlyoutItemType.BLOCK, block: block}); - this.addBlockGap_(blockInfo, gaps, defaultGap); + this.addBlockGap(blockInfo, gaps, defaultGap); break; } case 'SEP': { const sepInfo = (info as toolbox.SeparatorInfo); - this.addSeparatorGap_(sepInfo, gaps, defaultGap); + this.addSeparatorGap(sepInfo, gaps, defaultGap); break; } case 'LABEL': { const labelInfo = (info as toolbox.LabelInfo); // A label is a button with different styling. - const label = this.createButton_(labelInfo, /** isLabel */ true); + const label = this.createButton(labelInfo, /** isLabel */ true); contents.push({type: FlyoutItemType.BUTTON, button: label}); gaps.push(defaultGap); break; } case 'BUTTON': { const buttonInfo = (info as toolbox.ButtonInfo); - const button = this.createButton_(buttonInfo, /** isLabel */ false); + const button = this.createButton(buttonInfo, /** isLabel */ false); contents.push({type: FlyoutItemType.BUTTON, button: button}); gaps.push(defaultGap); break; @@ -684,7 +686,7 @@ export abstract class Flyout extends DeleteArea implements IFlyout { * @returns The definition of the * flyout in one of its many forms. */ - private getDynamicCategoryContents_(categoryName: string): + private getDynamicCategoryContents(categoryName: string): toolbox.FlyoutDefinition { // Look up the correct category generation function and call that to get a // valid XML list. @@ -707,7 +709,7 @@ export abstract class Flyout extends DeleteArea implements IFlyout { * @returns The object used to display the button in the * flyout. */ - private createButton_(btnInfo: toolbox.ButtonOrLabelInfo, isLabel: boolean): + private createButton(btnInfo: toolbox.ButtonOrLabelInfo, isLabel: boolean): FlyoutButton { const curButton = new FlyoutButton( this.workspace_, (this.targetWorkspace as WorkspaceSvg), btnInfo, @@ -722,18 +724,18 @@ export abstract class Flyout extends DeleteArea implements IFlyout { * @param blockInfo The info of the block. * @returns The block created from the blockInfo. */ - private createFlyoutBlock_(blockInfo: toolbox.BlockInfo): BlockSvg { + private createFlyoutBlock(blockInfo: toolbox.BlockInfo): BlockSvg { let block; if (blockInfo['blockxml']) { const xml = (typeof blockInfo['blockxml'] === 'string' ? utilsXml.textToDom(blockInfo['blockxml']) : blockInfo['blockxml']) as Element; - block = this.getRecycledBlock_(xml.getAttribute('type')!); + block = this.getRecycledBlock(xml.getAttribute('type')!); if (!block) { block = Xml.domToBlock(xml, this.workspace_); } } else { - block = this.getRecycledBlock_(blockInfo['type']!); + block = this.getRecycledBlock(blockInfo['type']!); if (!block) { if (blockInfo['enabled'] === undefined) { blockInfo['enabled'] = blockInfo['disabled'] !== 'true' && @@ -746,7 +748,7 @@ export abstract class Flyout extends DeleteArea implements IFlyout { if (!block.isEnabled()) { // Record blocks that were initially disabled. // Do not enable these blocks as a result of capacity filtering. - this.permanentlyDisabled_.push(block); + this.permanentlyDisabled.push(block); } return (block as BlockSvg); } @@ -759,15 +761,15 @@ export abstract class Flyout extends DeleteArea implements IFlyout { * @returns The recycled block, or undefined if * one could not be recycled. */ - private getRecycledBlock_(blockType: string): BlockSvg|undefined { + private getRecycledBlock(blockType: string): BlockSvg|undefined { let index = -1; - for (let i = 0; i < this.recycledBlocks_.length; i++) { - if (this.recycledBlocks_[i].type === blockType) { + for (let i = 0; i < this.recycledBlocks.length; i++) { + if (this.recycledBlocks[i].type === blockType) { index = i; break; } } - return index === -1 ? undefined : this.recycledBlocks_.splice(index, 1)[0]; + return index === -1 ? undefined : this.recycledBlocks.splice(index, 1)[0]; } /** @@ -778,7 +780,7 @@ export abstract class Flyout extends DeleteArea implements IFlyout { * @param defaultGap The default gap between one element and the * next. */ - private addBlockGap_( + private addBlockGap( blockInfo: toolbox.BlockInfo, gaps: number[], defaultGap: number) { let gap; if (blockInfo['gap']) { @@ -801,7 +803,7 @@ export abstract class Flyout extends DeleteArea implements IFlyout { * @param defaultGap The default gap between the button and next * element. */ - private addSeparatorGap_( + private addSeparatorGap( sepInfo: toolbox.SeparatorInfo, gaps: number[], defaultGap: number) { // Change the gap between two toolbox elements. // @@ -819,25 +821,25 @@ export abstract class Flyout extends DeleteArea implements IFlyout { /** * Delete blocks, mats and buttons from a previous showing of the flyout. */ - private clearOldBlocks_() { + private clearOldBlocks() { // Delete any blocks from a previous showing. const oldBlocks = this.workspace_.getTopBlocks(false); for (let i = 0, block; block = oldBlocks[i]; i++) { if (this.blockIsRecyclable_(block)) { - this.recycleBlock_(block); + this.recycleBlock(block); } else { block.dispose(false, false); } } // Delete any mats from a previous showing. - for (let j = 0; j < this.mats_.length; j++) { - const rect = this.mats_[j]; + for (let j = 0; j < this.mats.length; j++) { + const rect = this.mats[j]; if (rect) { Tooltip.unbindMouseEvents(rect); dom.removeNode(rect); } } - this.mats_.length = 0; + this.mats.length = 0; // Delete any buttons from a previous showing. for (let i = 0, button; button = this.buttons_[i]; i++) { button.dispose(); @@ -851,11 +853,11 @@ export abstract class Flyout extends DeleteArea implements IFlyout { /** * Empties all of the recycled blocks, properly disposing of them. */ - private emptyRecycledBlocks_() { - for (let i = 0; i < this.recycledBlocks_.length; i++) { - this.recycledBlocks_[i].dispose(); + private emptyRecycledBlocks() { + for (let i = 0; i < this.recycledBlocks.length; i++) { + this.recycledBlocks[i].dispose(); } - this.recycledBlocks_ = []; + this.recycledBlocks = []; } /** @@ -876,10 +878,10 @@ export abstract class Flyout extends DeleteArea implements IFlyout { * * @param block The block to recycle. */ - private recycleBlock_(block: BlockSvg) { + private recycleBlock(block: BlockSvg) { const xy = block.getRelativeToSurfaceXY(); block.moveBy(-xy.x, -xy.y); - this.recycledBlocks_.push(block); + this.recycledBlocks.push(block); } /** @@ -892,17 +894,17 @@ export abstract class Flyout extends DeleteArea implements IFlyout { */ protected addBlockListeners_( root: SVGElement, block: BlockSvg, rect: SVGElement) { - this.listeners_.push(browserEvents.conditionalBind( - root, 'pointerdown', null, this.blockMouseDown_(block))); - this.listeners_.push(browserEvents.conditionalBind( - rect, 'pointerdown', null, this.blockMouseDown_(block))); - this.listeners_.push( + this.listeners.push(browserEvents.conditionalBind( + root, 'pointerdown', null, this.blockMouseDown(block))); + this.listeners.push(browserEvents.conditionalBind( + rect, 'pointerdown', null, this.blockMouseDown(block))); + this.listeners.push( browserEvents.bind(root, 'pointerenter', block, block.addSelect)); - this.listeners_.push( + this.listeners.push( browserEvents.bind(root, 'pointerleave', block, block.removeSelect)); - this.listeners_.push( + this.listeners.push( browserEvents.bind(rect, 'pointerenter', block, block.addSelect)); - this.listeners_.push( + this.listeners.push( browserEvents.bind(rect, 'pointerleave', block, block.removeSelect)); } @@ -912,7 +914,7 @@ export abstract class Flyout extends DeleteArea implements IFlyout { * @param block The flyout block to copy. * @returns Function to call when block is clicked. */ - private blockMouseDown_(block: BlockSvg): Function { + private blockMouseDown(block: BlockSvg): Function { return (e: PointerEvent) => { const gesture = this.targetWorkspace.getGesture(e); if (gesture) { @@ -927,7 +929,7 @@ export abstract class Flyout extends DeleteArea implements IFlyout { * * @param e Pointer down event. */ - private onMouseDown_(e: PointerEvent) { + private onMouseDown(e: PointerEvent) { const gesture = this.targetWorkspace.getGesture(e); if (gesture) { gesture.handleFlyoutStart(e, this); @@ -961,7 +963,7 @@ export abstract class Flyout extends DeleteArea implements IFlyout { const variablesBeforeCreation = this.targetWorkspace.getAllVariables(); this.targetWorkspace.setResizesEnabled(false); try { - newBlock = this.placeNewBlock_(originalBlock); + newBlock = this.placeNewBlock(originalBlock); } finally { eventUtils.enable(); } @@ -988,7 +990,7 @@ export abstract class Flyout extends DeleteArea implements IFlyout { if (this.autoClose) { this.hide(); } else { - this.filterForCapacity_(); + this.filterForCapacity(); } return newBlock; } @@ -1007,8 +1009,8 @@ export abstract class Flyout extends DeleteArea implements IFlyout { button.show(); // Clicking on a flyout button or label is a lot like clicking on the // flyout background. - this.listeners_.push(browserEvents.conditionalBind( - buttonSvg, 'pointerdown', this, this.onMouseDown_)); + this.listeners.push(browserEvents.conditionalBind( + buttonSvg, 'pointerdown', this, this.onMouseDown)); this.buttons_.push(button); } @@ -1044,7 +1046,7 @@ export abstract class Flyout extends DeleteArea implements IFlyout { this.workspace_.getCanvas().insertBefore(rect, block.getSvgRoot()); this.rectMap_.set(block, rect); - this.mats_[index] = rect; + this.mats[index] = rect; return rect; } @@ -1072,10 +1074,10 @@ export abstract class Flyout extends DeleteArea implements IFlyout { * on the workspace, an "a + b" block that has two shadow blocks would be * disabled. */ - private filterForCapacity_() { + private filterForCapacity() { const blocks = this.workspace_.getTopBlocks(false); for (let i = 0, block; block = blocks[i]; i++) { - if (this.permanentlyDisabled_.indexOf(block) === -1) { + if (this.permanentlyDisabled.indexOf(block) === -1) { const enable = this.targetWorkspace.isCapacityAvailable( common.getBlockTypeCounts(block)); while (block) { @@ -1090,12 +1092,12 @@ export abstract class Flyout extends DeleteArea implements IFlyout { * Reflow blocks and their mats. */ reflow() { - if (this.reflowWrapper_) { - this.workspace_.removeChangeListener(this.reflowWrapper_); + if (this.reflowWrapper) { + this.workspace_.removeChangeListener(this.reflowWrapper); } this.reflowInternal_(); - if (this.reflowWrapper_) { - this.workspace_.addChangeListener(this.reflowWrapper_); + if (this.reflowWrapper) { + this.workspace_.addChangeListener(this.reflowWrapper); } } @@ -1115,7 +1117,7 @@ export abstract class Flyout extends DeleteArea implements IFlyout { * @param oldBlock The flyout block to copy. * @returns The new block in the main workspace. */ - private placeNewBlock_(oldBlock: BlockSvg): BlockSvg { + private placeNewBlock(oldBlock: BlockSvg): BlockSvg { const targetWorkspace = this.targetWorkspace; const svgRootOld = oldBlock.getSvgRoot(); if (!svgRootOld) { @@ -1128,7 +1130,7 @@ export abstract class Flyout extends DeleteArea implements IFlyout { targetWorkspace.setResizesEnabled(false); const block = (blocks.append(json, targetWorkspace) as BlockSvg); - this.positionNewBlock_(oldBlock, block); + this.positionNewBlock(oldBlock, block); return block; } @@ -1139,7 +1141,7 @@ export abstract class Flyout extends DeleteArea implements IFlyout { * @param oldBlock The flyout block being copied. * @param block The block to posiiton. */ - private positionNewBlock_(oldBlock: BlockSvg, block: BlockSvg) { + private positionNewBlock(oldBlock: BlockSvg, block: BlockSvg) { const targetWorkspace = this.targetWorkspace; // The offset in pixels between the main workspace's origin and the upper diff --git a/core/flyout_button.ts b/core/flyout_button.ts index 8a91d1c63..ad71dd4e4 100644 --- a/core/flyout_button.ts +++ b/core/flyout_button.ts @@ -36,13 +36,13 @@ export class FlyoutButton { /** The radius of the flyout button's borders. */ static BORDER_RADIUS = 4; - private readonly text_: string; - private readonly position_: Coordinate; - private readonly callbackKey_: string; - private readonly cssClass_: string|null; + private readonly text: string; + private readonly position: Coordinate; + private readonly callbackKey: string; + private readonly cssClass: string|null; /** Mouse up event data. */ - private onMouseUpWrapper_: browserEvents.Data|null = null; + private onMouseUpWrapper: browserEvents.Data|null = null; info: toolbox.ButtonOrLabelInfo; /** The width of the button's rect. */ @@ -52,10 +52,10 @@ export class FlyoutButton { height = 0; /** The root SVG group for the button or label. */ - private svgGroup_: SVGGElement|null = null; + private svgGroup: SVGGElement|null = null; /** The SVG element with the text of the label or button. */ - private svgText_: SVGTextElement|null = null; + private svgText: SVGTextElement|null = null; /** * @param workspace The workspace in which to place this button. @@ -68,19 +68,19 @@ export class FlyoutButton { private readonly workspace: WorkspaceSvg, private readonly targetWorkspace: WorkspaceSvg, json: toolbox.ButtonOrLabelInfo, private readonly isLabel_: boolean) { - this.text_ = json['text']; + this.text = json['text']; - this.position_ = new Coordinate(0, 0); + this.position = new Coordinate(0, 0); /** The key to the function called when this button is clicked. */ - this.callbackKey_ = + this.callbackKey = (json as AnyDuringMigration)['callbackKey'] || /* Check the lower case version too to satisfy IE */ (json as AnyDuringMigration)['callbackkey']; /** If specified, a CSS class to add to this button. */ - this.cssClass_ = (json as AnyDuringMigration)['web-class'] || null; + this.cssClass = (json as AnyDuringMigration)['web-class'] || null; /** The JSON specifying the label / button. */ this.info = json; @@ -93,11 +93,11 @@ export class FlyoutButton { */ createDom(): SVGElement { let cssClass = this.isLabel_ ? 'blocklyFlyoutLabel' : 'blocklyFlyoutButton'; - if (this.cssClass_) { - cssClass += ' ' + this.cssClass_; + if (this.cssClass) { + cssClass += ' ' + this.cssClass; } - this.svgGroup_ = dom.createSvgElement( + this.svgGroup = dom.createSvgElement( Svg.G, {'class': cssClass}, this.workspace.getCanvas()); let shadow; @@ -111,7 +111,7 @@ export class FlyoutButton { 'x': 1, 'y': 1, }, - this.svgGroup_!); + this.svgGroup!); } // Background rectangle. const rect = dom.createSvgElement( @@ -121,7 +121,7 @@ export class FlyoutButton { 'rx': FlyoutButton.BORDER_RADIUS, 'ry': FlyoutButton.BORDER_RADIUS, }, - this.svgGroup_!); + this.svgGroup!); const svgText = dom.createSvgElement( Svg.TEXT, { @@ -130,17 +130,17 @@ export class FlyoutButton { 'y': 0, 'text-anchor': 'middle', }, - this.svgGroup_!); - let text = parsing.replaceMessageReferences(this.text_); + this.svgGroup!); + let text = parsing.replaceMessageReferences(this.text); if (this.workspace.RTL) { // Force text to be RTL by adding an RLM. text += '\u200F'; } svgText.textContent = text; if (this.isLabel_) { - this.svgText_ = svgText; + this.svgText = svgText; this.workspace.getThemeManager().subscribe( - this.svgText_, 'flyoutForegroundColour', 'fill'); + this.svgText, 'flyoutForegroundColour', 'fill'); } const fontSize = style.getComputedStyle(svgText, 'fontSize'); @@ -167,27 +167,26 @@ export class FlyoutButton { String( this.height / 2 - fontMetrics.height / 2 + fontMetrics.baseline)); - this.updateTransform_(); + this.updateTransform(); // AnyDuringMigration because: Argument of type 'SVGGElement | null' is not // assignable to parameter of type 'EventTarget'. - this.onMouseUpWrapper_ = browserEvents.conditionalBind( - this.svgGroup_ as AnyDuringMigration, 'pointerup', this, - this.onMouseUp_); - return this.svgGroup_!; + this.onMouseUpWrapper = browserEvents.conditionalBind( + this.svgGroup as AnyDuringMigration, 'pointerup', this, this.onMouseUp); + return this.svgGroup!; } /** Correctly position the flyout button and make it visible. */ show() { - this.updateTransform_(); - this.svgGroup_!.setAttribute('display', 'block'); + this.updateTransform(); + this.svgGroup!.setAttribute('display', 'block'); } /** Update SVG attributes to match internal state. */ - private updateTransform_() { - this.svgGroup_!.setAttribute( + private updateTransform() { + this.svgGroup!.setAttribute( 'transform', - 'translate(' + this.position_.x + ',' + this.position_.y + ')'); + 'translate(' + this.position.x + ',' + this.position.y + ')'); } /** @@ -197,9 +196,9 @@ export class FlyoutButton { * @param y The new y coordinate. */ moveTo(x: number, y: number) { - this.position_.x = x; - this.position_.y = y; - this.updateTransform_(); + this.position.x = x; + this.position.y = y; + this.updateTransform(); } /** @returns Whether or not the button is a label. */ @@ -214,12 +213,12 @@ export class FlyoutButton { * @internal */ getPosition(): Coordinate { - return this.position_; + return this.position; } /** @returns Text of the button. */ getButtonText(): string { - return this.text_; + return this.text; } /** @@ -233,14 +232,14 @@ export class FlyoutButton { /** Dispose of this button. */ dispose() { - if (this.onMouseUpWrapper_) { - browserEvents.unbind(this.onMouseUpWrapper_); + if (this.onMouseUpWrapper) { + browserEvents.unbind(this.onMouseUpWrapper); } - if (this.svgGroup_) { - dom.removeNode(this.svgGroup_); + if (this.svgGroup) { + dom.removeNode(this.svgGroup); } - if (this.svgText_) { - this.workspace.getThemeManager().unsubscribe(this.svgText_); + if (this.svgText) { + this.workspace.getThemeManager().unsubscribe(this.svgText); } } @@ -249,23 +248,22 @@ export class FlyoutButton { * * @param e Pointer up event. */ - private onMouseUp_(e: PointerEvent) { + private onMouseUp(e: PointerEvent) { const gesture = this.targetWorkspace.getGesture(e); if (gesture) { gesture.cancel(); } - if (this.isLabel_ && this.callbackKey_) { + if (this.isLabel_ && this.callbackKey) { console.warn( - 'Labels should not have callbacks. Label text: ' + this.text_); + 'Labels should not have callbacks. Label text: ' + this.text); } else if ( !this.isLabel_ && - !(this.callbackKey_ && - this.targetWorkspace.getButtonCallback(this.callbackKey_))) { - console.warn('Buttons should have callbacks. Button text: ' + this.text_); + !(this.callbackKey && + this.targetWorkspace.getButtonCallback(this.callbackKey))) { + console.warn('Buttons should have callbacks. Button text: ' + this.text); } else if (!this.isLabel_) { - const callback = - this.targetWorkspace.getButtonCallback(this.callbackKey_); + const callback = this.targetWorkspace.getButtonCallback(this.callbackKey); if (callback) { callback(this); } diff --git a/core/flyout_horizontal.ts b/core/flyout_horizontal.ts index 5a0c96f84..ef11978bb 100644 --- a/core/flyout_horizontal.ts +++ b/core/flyout_horizontal.ts @@ -134,7 +134,7 @@ export class HorizontalFlyout extends Flyout { const edgeWidth = targetWorkspaceViewMetrics.width - 2 * this.CORNER_RADIUS; const edgeHeight = this.height_ - this.CORNER_RADIUS; - this.setBackgroundPath_(edgeWidth, edgeHeight); + this.setBackgroundPath(edgeWidth, edgeHeight); const x = this.getX(); const y = this.getY(); @@ -148,7 +148,7 @@ export class HorizontalFlyout extends Flyout { * @param width The width of the flyout, not including the rounded corners. * @param height The height of the flyout, not including rounded corners. */ - private setBackgroundPath_(width: number, height: number) { + private setBackgroundPath(width: number, height: number) { const atTop = this.toolboxPosition_ === toolbox.Position.TOP; // Start at top left. const path: (string|number)[] = ['M 0,' + (atTop ? 0 : this.CORNER_RADIUS)]; diff --git a/core/flyout_vertical.ts b/core/flyout_vertical.ts index b6c1ae7c2..d9a955ee6 100644 --- a/core/flyout_vertical.ts +++ b/core/flyout_vertical.ts @@ -133,7 +133,7 @@ export class VerticalFlyout extends Flyout { const edgeWidth = this.width_ - this.CORNER_RADIUS; const edgeHeight = targetWorkspaceViewMetrics.height - 2 * this.CORNER_RADIUS; - this.setBackgroundPath_(edgeWidth, edgeHeight); + this.setBackgroundPath(edgeWidth, edgeHeight); const x = this.getX(); const y = this.getY(); @@ -147,7 +147,7 @@ export class VerticalFlyout extends Flyout { * @param width The width of the flyout, not including the rounded corners. * @param height The height of the flyout, not including rounded corners. */ - private setBackgroundPath_(width: number, height: number) { + private setBackgroundPath(width: number, height: number) { const atRight = this.toolboxPosition_ === toolbox.Position.RIGHT; const totalWidth = width + this.CORNER_RADIUS; diff --git a/tests/mocha/flyout_test.js b/tests/mocha/flyout_test.js index cf5e17390..797b72813 100644 --- a/tests/mocha/flyout_test.js +++ b/tests/mocha/flyout_test.js @@ -241,10 +241,10 @@ suite('Flyout', function() { }); }); - suite('createFlyoutInfo_', function() { + suite('createFlyoutInfo', function() { setup(function() { this.flyout = this.workspace.getFlyout(); - this.createFlyoutSpy = sinon.spy(this.flyout, 'createFlyoutInfo_'); + this.createFlyoutSpy = sinon.spy(this.flyout, 'createFlyoutInfo'); }); function checkFlyoutInfo(flyoutSpy) { From 9bcdd5dd18b8440db287d7de290b46dd21c7cec9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Apr 2023 13:54:21 -0700 Subject: [PATCH 009/161] chore(deps): bump google-closure-deps from 20230206.0.0 to 20230228.0.0 (#6965) Bumps [google-closure-deps](https://github.com/google/closure-library) from 20230206.0.0 to 20230228.0.0. - [Release notes](https://github.com/google/closure-library/releases) - [Commits](https://github.com/google/closure-library/compare/v20230206...v20230228) --- updated-dependencies: - dependency-name: google-closure-deps dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package-lock.json | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 333fb4b77..9cd35735e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30,7 +30,7 @@ "eslint-config-google": "^0.14.0", "eslint-plugin-jsdoc": "^40.0.0", "google-closure-compiler": "^20230206.0.0", - "google-closure-deps": "^20230206.0.0", + "google-closure-deps": "^20230228.0.0", "gulp": "^4.0.2", "gulp-clang-format": "^1.0.27", "gulp-concat": "^2.6.1", @@ -5751,9 +5751,9 @@ ] }, "node_modules/google-closure-deps": { - "version": "20230206.0.0", - "resolved": "https://registry.npmjs.org/google-closure-deps/-/google-closure-deps-20230206.0.0.tgz", - "integrity": "sha512-MT0JDygFjCTavsOGfRRE1o3teF/ZZD1a8NbeVlGW0oM3OTY2xkOpoPMvSely4khfFV4i4qqjmlMvtwD8cT7adg==", + "version": "20230228.0.0", + "resolved": "https://registry.npmjs.org/google-closure-deps/-/google-closure-deps-20230228.0.0.tgz", + "integrity": "sha512-U4SEjUU6m5eQPplEcgSVnUVP1HY7vupUYjwbt3d+O/yK8sWQdDM3dmMcsakxzva+X8SVVueQqaCzqiYnPOOwxA==", "dev": true, "dependencies": { "minimatch": "^3.0.4", @@ -17200,9 +17200,9 @@ "optional": true }, "google-closure-deps": { - "version": "20230206.0.0", - "resolved": "https://registry.npmjs.org/google-closure-deps/-/google-closure-deps-20230206.0.0.tgz", - "integrity": "sha512-MT0JDygFjCTavsOGfRRE1o3teF/ZZD1a8NbeVlGW0oM3OTY2xkOpoPMvSely4khfFV4i4qqjmlMvtwD8cT7adg==", + "version": "20230228.0.0", + "resolved": "https://registry.npmjs.org/google-closure-deps/-/google-closure-deps-20230228.0.0.tgz", + "integrity": "sha512-U4SEjUU6m5eQPplEcgSVnUVP1HY7vupUYjwbt3d+O/yK8sWQdDM3dmMcsakxzva+X8SVVueQqaCzqiYnPOOwxA==", "dev": true, "requires": { "minimatch": "^3.0.4", diff --git a/package.json b/package.json index 911efe92c..e15efe5fc 100644 --- a/package.json +++ b/package.json @@ -85,7 +85,7 @@ "eslint-config-google": "^0.14.0", "eslint-plugin-jsdoc": "^40.0.0", "google-closure-compiler": "^20230206.0.0", - "google-closure-deps": "^20230206.0.0", + "google-closure-deps": "^20230228.0.0", "gulp": "^4.0.2", "gulp-clang-format": "^1.0.27", "gulp-concat": "^2.6.1", From 5a671da5aa6a71a92fb9f2549fd6b97379443511 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Apr 2023 13:54:43 -0700 Subject: [PATCH 010/161] chore(deps): bump typescript from 5.0.2 to 5.0.4 (#6966) Bumps [typescript](https://github.com/Microsoft/TypeScript) from 5.0.2 to 5.0.4. - [Release notes](https://github.com/Microsoft/TypeScript/releases) - [Commits](https://github.com/Microsoft/TypeScript/compare/v5.0.2...v5.0.4) --- updated-dependencies: - dependency-name: typescript dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package-lock.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9cd35735e..41c93b40c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11803,9 +11803,9 @@ "dev": true }, "node_modules/typescript": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.2.tgz", - "integrity": "sha512-wVORMBGO/FAs/++blGNeAVdbNKtIh1rbBL2EyQ1+J9lClJ93KiiKe8PmFIVdXhHcyv44SL9oglmfeSsndo0jRw==", + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz", + "integrity": "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==", "dev": true, "bin": { "tsc": "bin/tsc", @@ -22069,9 +22069,9 @@ "dev": true }, "typescript": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.2.tgz", - "integrity": "sha512-wVORMBGO/FAs/++blGNeAVdbNKtIh1rbBL2EyQ1+J9lClJ93KiiKe8PmFIVdXhHcyv44SL9oglmfeSsndo0jRw==", + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz", + "integrity": "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==", "dev": true }, "ua-parser-js": { From b32e76d45f187735674528746dc056b52d34bf66 Mon Sep 17 00:00:00 2001 From: Aaron Dodson Date: Mon, 10 Apr 2023 13:57:04 -0700 Subject: [PATCH 011/161] refactor: Remove some more uses of AnyDuringMigration. (#6970) --- core/blockly.ts | 2 +- core/inject.ts | 36 +++++++++++++++--------------------- core/theme/classic.ts | 3 +-- 3 files changed, 17 insertions(+), 24 deletions(-) diff --git a/core/blockly.ts b/core/blockly.ts index b833924f6..03d4649d0 100644 --- a/core/blockly.ts +++ b/core/blockly.ts @@ -542,7 +542,7 @@ Names.prototype.populateProcedures = function(this: Names, workspace: Workspace) { const procedures = Procedures.allProcedures(workspace); // Flatten the return vs no-return procedure lists. - const flattenedProcedures: AnyDuringMigration[][] = + const flattenedProcedures = procedures[0].concat(procedures[1]); for (let i = 0; i < flattenedProcedures.length; i++) { this.getName(flattenedProcedures[i][0], Names.NameType.PROCEDURE); diff --git a/core/inject.ts b/core/inject.ts index a02ee52b3..69026a897 100644 --- a/core/inject.ts +++ b/core/inject.ts @@ -39,17 +39,15 @@ import {WorkspaceSvg} from './workspace_svg.js'; */ export function inject( container: Element|string, opt_options?: BlocklyOptions): WorkspaceSvg { + let containerElement: Element|null = null; if (typeof container === 'string') { - // AnyDuringMigration because: Type 'Element | null' is not assignable to - // type 'string | Element'. - container = (document.getElementById(container) || - document.querySelector(container)) as AnyDuringMigration; + containerElement = + document.getElementById(container) || document.querySelector(container); + } else { + containerElement = container; } // Verify that the container is in document. - // AnyDuringMigration because: Argument of type 'string | Element' is not - // assignable to parameter of type 'Node'. - if (!container || - !dom.containsNode(document, container as AnyDuringMigration)) { + if (!containerElement || !dom.containsNode(document, containerElement)) { throw Error('Error: container is not in current document.'); } const options = new Options(opt_options || {} as BlocklyOptions); @@ -58,9 +56,7 @@ export function inject( subContainer.tabIndex = 0; aria.setState(subContainer, aria.State.LABEL, Msg['WORKSPACE_ARIA_LABEL']); - // AnyDuringMigration because: Property 'appendChild' does not exist on type - // 'string | Element'. - (container as AnyDuringMigration).appendChild(subContainer); + containerElement.appendChild(subContainer); const svg = createDom(subContainer, options); // Create surfaces for dragging things. These are optimizations @@ -76,16 +72,12 @@ export function inject( // Keep focus on the first workspace so entering keyboard navigation looks // correct. - // AnyDuringMigration because: Argument of type 'WorkspaceSvg' is not - // assignable to parameter of type 'Workspace'. - common.setMainWorkspace(workspace as AnyDuringMigration); + common.setMainWorkspace(workspace); common.svgResize(workspace); subContainer.addEventListener('focusin', function() { - // AnyDuringMigration because: Argument of type 'WorkspaceSvg' is not - // assignable to parameter of type 'Workspace'. - common.setMainWorkspace(workspace as AnyDuringMigration); + common.setMainWorkspace(workspace); }); return workspace; @@ -213,8 +205,7 @@ function init(mainWorkspace: WorkspaceSvg) { // Suppress the browser's context menu. browserEvents.conditionalBind( - svg.parentNode as Element, 'contextmenu', null, - function(e: AnyDuringMigration) { + svg.parentNode as Element, 'contextmenu', null, function(e: Event) { if (!browserEvents.isTargetInput(e)) { e.preventDefault(); } @@ -369,13 +360,16 @@ function loadSounds(pathToMedia: string, workspace: WorkspaceSvg) { 'delete'); // Bind temporary hooks that preload the sounds. - const soundBinds: AnyDuringMigration[] = []; + const soundBinds: browserEvents.Data[] = []; /** * */ function unbindSounds() { while (soundBinds.length) { - browserEvents.unbind(soundBinds.pop()); + const oldSoundBinding = soundBinds.pop(); + if (oldSoundBinding) { + browserEvents.unbind(oldSoundBinding); + } } audioMgr.preload(); } diff --git a/core/theme/classic.ts b/core/theme/classic.ts index 706964f8c..d7bff570d 100644 --- a/core/theme/classic.ts +++ b/core/theme/classic.ts @@ -39,5 +39,4 @@ const categoryStyles = { * Classic theme. * Contains multi-coloured border to create shadow effect. */ -export const Classic = new Theme( - 'classic', defaultBlockStyles as AnyDuringMigration, categoryStyles); +export const Classic = new Theme('classic', defaultBlockStyles, categoryStyles); From 90ffa76086435e1209d4b0edd776b8d667bf6db3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Apr 2023 13:59:01 -0700 Subject: [PATCH 012/161] chore(deps): bump google-closure-compiler (#6948) Bumps [google-closure-compiler](https://github.com/google/closure-compiler-npm) from 20230206.0.0 to 20230228.0.0. - [Release notes](https://github.com/google/closure-compiler-npm/releases) - [Commits](https://github.com/google/closure-compiler-npm/compare/v20230206.0.0...v20230228.0.0) --- updated-dependencies: - dependency-name: google-closure-compiler dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package-lock.json | 78 +++++++++++++++++++++++------------------------ package.json | 2 +- 2 files changed, 40 insertions(+), 40 deletions(-) diff --git a/package-lock.json b/package-lock.json index 41c93b40c..b17af2d8e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -29,7 +29,7 @@ "eslint": "^8.4.1", "eslint-config-google": "^0.14.0", "eslint-plugin-jsdoc": "^40.0.0", - "google-closure-compiler": "^20230206.0.0", + "google-closure-compiler": "^20230228.0.0", "google-closure-deps": "^20230228.0.0", "gulp": "^4.0.2", "gulp-clang-format": "^1.0.27", @@ -5678,13 +5678,13 @@ } }, "node_modules/google-closure-compiler": { - "version": "20230206.0.0", - "resolved": "https://registry.npmjs.org/google-closure-compiler/-/google-closure-compiler-20230206.0.0.tgz", - "integrity": "sha512-gGscQOcO/75AlHyw78v87u0nGKJHWqOrQ224Ks91HH1iISgF+xZ8GYosU/8s5VD66x3VD0tJKXM2rIoGOA1ycA==", + "version": "20230228.0.0", + "resolved": "https://registry.npmjs.org/google-closure-compiler/-/google-closure-compiler-20230228.0.0.tgz", + "integrity": "sha512-jFI4QNZgM4WhNIoaRNwA5kHq6n6NKSWZj3N9HgRsJE9bN4LUrkIURI+svChbEp/WmGh3Bt3o3/5kUlOOWyCo3Q==", "dev": true, "dependencies": { "chalk": "4.x", - "google-closure-compiler-java": "^20230206.0.0", + "google-closure-compiler-java": "^20230228.0.0", "minimist": "1.x", "vinyl": "2.x", "vinyl-sourcemaps-apply": "^0.2.0" @@ -5696,21 +5696,21 @@ "node": ">=10" }, "optionalDependencies": { - "google-closure-compiler-linux": "^20230206.0.0", - "google-closure-compiler-osx": "^20230206.0.0", - "google-closure-compiler-windows": "^20230206.0.0" + "google-closure-compiler-linux": "^20230228.0.0", + "google-closure-compiler-osx": "^20230228.0.0", + "google-closure-compiler-windows": "^20230228.0.0" } }, "node_modules/google-closure-compiler-java": { - "version": "20230206.0.0", - "resolved": "https://registry.npmjs.org/google-closure-compiler-java/-/google-closure-compiler-java-20230206.0.0.tgz", - "integrity": "sha512-OcnDf29yx4JNU13HpptADI2ckl9hEchktSHs2XSLQ/xStUAJQGQOl96to5IYh2VuFgn3Ssaw6M3c6At2pJr7wQ==", + "version": "20230228.0.0", + "resolved": "https://registry.npmjs.org/google-closure-compiler-java/-/google-closure-compiler-java-20230228.0.0.tgz", + "integrity": "sha512-t0sXYJbhfkuNTF6zniwrTv4gLap620D32v6GwBJQzlYUg0lb7yQHN9KswwqBsuuO917cPNwW4okI0O40G7GrMQ==", "dev": true }, "node_modules/google-closure-compiler-linux": { - "version": "20230206.0.0", - "resolved": "https://registry.npmjs.org/google-closure-compiler-linux/-/google-closure-compiler-linux-20230206.0.0.tgz", - "integrity": "sha512-06N6w2elsnZMMA4Gf/vN2A3XzWvu+gUTrBczaw0KQL48GgdLq6OgAXrcopbGdi/K8Gz1WAcG0qf2ccG8dSqYNg==", + "version": "20230228.0.0", + "resolved": "https://registry.npmjs.org/google-closure-compiler-linux/-/google-closure-compiler-linux-20230228.0.0.tgz", + "integrity": "sha512-5YLxfWS8lvHkD/a0+pitTuDV1X9QPBToGQ5mnLFg7HcbBR1w6I5ZKHjl7FAsAOHEXYwIrStwwaLzrNzbolrZLg==", "cpu": [ "x32", "x64" @@ -5722,9 +5722,9 @@ ] }, "node_modules/google-closure-compiler-osx": { - "version": "20230206.0.0", - "resolved": "https://registry.npmjs.org/google-closure-compiler-osx/-/google-closure-compiler-osx-20230206.0.0.tgz", - "integrity": "sha512-lJ/Y4HTk+KdL6PhLmmalP/3DdzGK0mS0+htuFP6y4t9+QXiUKnpHWx/VDQ3Fwm2fWEzqDxfhX3R+wC9lBvFiAg==", + "version": "20230228.0.0", + "resolved": "https://registry.npmjs.org/google-closure-compiler-osx/-/google-closure-compiler-osx-20230228.0.0.tgz", + "integrity": "sha512-ORveHpHuNhJEJIGir35+xP4UuBOldSO8XeOwJV5yunUhZAPzR4aixdTdtm6i0GsqW4/Eu2cjcHrkIR3eFCcwSg==", "cpu": [ "x32", "x64", @@ -5737,9 +5737,9 @@ ] }, "node_modules/google-closure-compiler-windows": { - "version": "20230206.0.0", - "resolved": "https://registry.npmjs.org/google-closure-compiler-windows/-/google-closure-compiler-windows-20230206.0.0.tgz", - "integrity": "sha512-4KPr7XPiOs8g4Ao3T+70egf14avCEne26XF4Mur4Fg5511ym1uEN+NlEyjBOAmfUFfaA7BYDsA8iBzDIetKrnw==", + "version": "20230228.0.0", + "resolved": "https://registry.npmjs.org/google-closure-compiler-windows/-/google-closure-compiler-windows-20230228.0.0.tgz", + "integrity": "sha512-xKMjUq6JwEOFqS97S86TWkn+BMiDHjP85mMgAmR8vRmKxgfHIyxMcr+RlMz0msgY9jedgj119KXyOe32lIQTjA==", "cpu": [ "x32", "x64" @@ -17157,45 +17157,45 @@ } }, "google-closure-compiler": { - "version": "20230206.0.0", - "resolved": "https://registry.npmjs.org/google-closure-compiler/-/google-closure-compiler-20230206.0.0.tgz", - "integrity": "sha512-gGscQOcO/75AlHyw78v87u0nGKJHWqOrQ224Ks91HH1iISgF+xZ8GYosU/8s5VD66x3VD0tJKXM2rIoGOA1ycA==", + "version": "20230228.0.0", + "resolved": "https://registry.npmjs.org/google-closure-compiler/-/google-closure-compiler-20230228.0.0.tgz", + "integrity": "sha512-jFI4QNZgM4WhNIoaRNwA5kHq6n6NKSWZj3N9HgRsJE9bN4LUrkIURI+svChbEp/WmGh3Bt3o3/5kUlOOWyCo3Q==", "dev": true, "requires": { "chalk": "4.x", - "google-closure-compiler-java": "^20230206.0.0", - "google-closure-compiler-linux": "^20230206.0.0", - "google-closure-compiler-osx": "^20230206.0.0", - "google-closure-compiler-windows": "^20230206.0.0", + "google-closure-compiler-java": "^20230228.0.0", + "google-closure-compiler-linux": "^20230228.0.0", + "google-closure-compiler-osx": "^20230228.0.0", + "google-closure-compiler-windows": "^20230228.0.0", "minimist": "1.x", "vinyl": "2.x", "vinyl-sourcemaps-apply": "^0.2.0" } }, "google-closure-compiler-java": { - "version": "20230206.0.0", - "resolved": "https://registry.npmjs.org/google-closure-compiler-java/-/google-closure-compiler-java-20230206.0.0.tgz", - "integrity": "sha512-OcnDf29yx4JNU13HpptADI2ckl9hEchktSHs2XSLQ/xStUAJQGQOl96to5IYh2VuFgn3Ssaw6M3c6At2pJr7wQ==", + "version": "20230228.0.0", + "resolved": "https://registry.npmjs.org/google-closure-compiler-java/-/google-closure-compiler-java-20230228.0.0.tgz", + "integrity": "sha512-t0sXYJbhfkuNTF6zniwrTv4gLap620D32v6GwBJQzlYUg0lb7yQHN9KswwqBsuuO917cPNwW4okI0O40G7GrMQ==", "dev": true }, "google-closure-compiler-linux": { - "version": "20230206.0.0", - "resolved": "https://registry.npmjs.org/google-closure-compiler-linux/-/google-closure-compiler-linux-20230206.0.0.tgz", - "integrity": "sha512-06N6w2elsnZMMA4Gf/vN2A3XzWvu+gUTrBczaw0KQL48GgdLq6OgAXrcopbGdi/K8Gz1WAcG0qf2ccG8dSqYNg==", + "version": "20230228.0.0", + "resolved": "https://registry.npmjs.org/google-closure-compiler-linux/-/google-closure-compiler-linux-20230228.0.0.tgz", + "integrity": "sha512-5YLxfWS8lvHkD/a0+pitTuDV1X9QPBToGQ5mnLFg7HcbBR1w6I5ZKHjl7FAsAOHEXYwIrStwwaLzrNzbolrZLg==", "dev": true, "optional": true }, "google-closure-compiler-osx": { - "version": "20230206.0.0", - "resolved": "https://registry.npmjs.org/google-closure-compiler-osx/-/google-closure-compiler-osx-20230206.0.0.tgz", - "integrity": "sha512-lJ/Y4HTk+KdL6PhLmmalP/3DdzGK0mS0+htuFP6y4t9+QXiUKnpHWx/VDQ3Fwm2fWEzqDxfhX3R+wC9lBvFiAg==", + "version": "20230228.0.0", + "resolved": "https://registry.npmjs.org/google-closure-compiler-osx/-/google-closure-compiler-osx-20230228.0.0.tgz", + "integrity": "sha512-ORveHpHuNhJEJIGir35+xP4UuBOldSO8XeOwJV5yunUhZAPzR4aixdTdtm6i0GsqW4/Eu2cjcHrkIR3eFCcwSg==", "dev": true, "optional": true }, "google-closure-compiler-windows": { - "version": "20230206.0.0", - "resolved": "https://registry.npmjs.org/google-closure-compiler-windows/-/google-closure-compiler-windows-20230206.0.0.tgz", - "integrity": "sha512-4KPr7XPiOs8g4Ao3T+70egf14avCEne26XF4Mur4Fg5511ym1uEN+NlEyjBOAmfUFfaA7BYDsA8iBzDIetKrnw==", + "version": "20230228.0.0", + "resolved": "https://registry.npmjs.org/google-closure-compiler-windows/-/google-closure-compiler-windows-20230228.0.0.tgz", + "integrity": "sha512-xKMjUq6JwEOFqS97S86TWkn+BMiDHjP85mMgAmR8vRmKxgfHIyxMcr+RlMz0msgY9jedgj119KXyOe32lIQTjA==", "dev": true, "optional": true }, diff --git a/package.json b/package.json index e15efe5fc..0f324c286 100644 --- a/package.json +++ b/package.json @@ -84,7 +84,7 @@ "eslint": "^8.4.1", "eslint-config-google": "^0.14.0", "eslint-plugin-jsdoc": "^40.0.0", - "google-closure-compiler": "^20230206.0.0", + "google-closure-compiler": "^20230228.0.0", "google-closure-deps": "^20230228.0.0", "gulp": "^4.0.2", "gulp-clang-format": "^1.0.27", From a344eaf1490844ee4cc4b77f96d63462ed64dc74 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Apr 2023 14:22:11 -0700 Subject: [PATCH 013/161] chore(deps): bump google-github-actions/deploy-appengine (#6951) Bumps [google-github-actions/deploy-appengine](https://github.com/google-github-actions/deploy-appengine) from 1.2.2 to 1.2.6. - [Release notes](https://github.com/google-github-actions/deploy-appengine/releases) - [Changelog](https://github.com/google-github-actions/deploy-appengine/blob/main/CHANGELOG.md) - [Commits](https://github.com/google-github-actions/deploy-appengine/compare/v1.2.2...v1.2.6) --- updated-dependencies: - dependency-name: google-github-actions/deploy-appengine dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/appengine_deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/appengine_deploy.yml b/.github/workflows/appengine_deploy.yml index fc27a2c46..af8af2abf 100644 --- a/.github/workflows/appengine_deploy.yml +++ b/.github/workflows/appengine_deploy.yml @@ -42,7 +42,7 @@ jobs: path: _deploy/ - name: Deploy to App Engine - uses: google-github-actions/deploy-appengine@v1.2.2 + uses: google-github-actions/deploy-appengine@v1.2.6 # For parameters see: # https://github.com/google-github-actions/deploy-appengine#inputs with: From 2bf780e74f6ffb830191beb22ee592f95ed61186 Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Tue, 11 Apr 2023 10:00:39 -0700 Subject: [PATCH 014/161] chore: remove underscores from private properties and methods for names and workspace comments (#6962) * chore: remove private underscores in names.ts * chore: remove private underscores in workspace comments * chore: format * chore: remove unneeded nulls --- core/names.ts | 26 +-- core/workspace_comment.ts | 19 ++- core/workspace_comment_svg.ts | 293 +++++++++++++++++----------------- tests/mocha/names_test.js | 12 +- 4 files changed, 172 insertions(+), 178 deletions(-) diff --git a/core/names.ts b/core/names.ts index 0a7ca3888..3d6d00887 100644 --- a/core/names.ts +++ b/core/names.ts @@ -24,7 +24,7 @@ import type {Workspace} from './workspace.js'; */ export class Names { static DEVELOPER_VARIABLE_TYPE: NameType; - private readonly variablePrefix_: string; + private readonly variablePrefix: string; /** A set of reserved words. */ private readonly reservedWords: Set; @@ -41,7 +41,7 @@ export class Names { /** * The variable map from the workspace, containing Blockly variable models. */ - private variableMap_: VariableMap|null = null; + private variableMap: VariableMap|null = null; /** * @param reservedWordsList A comma-separated string of words that are illegal @@ -51,7 +51,7 @@ export class Names { */ constructor(reservedWordsList: string, opt_variablePrefix?: string) { /** The prefix to attach to variable names in generated code. */ - this.variablePrefix_ = opt_variablePrefix || ''; + this.variablePrefix = opt_variablePrefix || ''; this.reservedWords = new Set(reservedWordsList ? reservedWordsList.split(',') : []); @@ -63,7 +63,7 @@ export class Names { reset() { this.db.clear(); this.dbReverse.clear(); - this.variableMap_ = null; + this.variableMap = null; } /** @@ -72,7 +72,7 @@ export class Names { * @param map The map to track. */ setVariableMap(map: VariableMap) { - this.variableMap_ = map; + this.variableMap = map; } /** @@ -83,8 +83,8 @@ export class Names { * @returns The name of the referenced variable, or null if there was no * variable map or the variable was not found in the map. */ - private getNameForUserVariable_(id: string): string|null { - if (!this.variableMap_) { + private getNameForUserVariable(id: string): string|null { + if (!this.variableMap) { console.warn( 'Deprecated call to Names.prototype.getName without ' + 'defining a variable map. To fix, add the following code in your ' + @@ -93,7 +93,7 @@ export class Names { 'workspace.getVariableMap());'); return null; } - const variable = this.variableMap_.getVariableById(id); + const variable = this.variableMap.getVariableById(id); if (variable) { return variable.name; } @@ -135,7 +135,7 @@ export class Names { getName(nameOrId: string, type: NameType|string): string { let name = nameOrId; if (type === NameType.VARIABLE) { - const varName = this.getNameForUserVariable_(nameOrId); + const varName = this.getNameForUserVariable(nameOrId); if (varName) { // Successful ID lookup. name = varName; @@ -146,7 +146,7 @@ export class Names { const isVar = type === NameType.VARIABLE || type === NameType.DEVELOPER_VARIABLE; - const prefix = isVar ? this.variablePrefix_ : ''; + const prefix = isVar ? this.variablePrefix : ''; if (!this.db.has(type)) { this.db.set(type, new Map()); } @@ -183,7 +183,7 @@ export class Names { * @returns An entity name that is legal in the exported language. */ getDistinctName(name: string, type: NameType|string): string { - let safeName = this.safeName_(name); + let safeName = this.safeName(name); let i: number|null = null; while (this.dbReverse.has(safeName + (i ?? '')) || this.reservedWords.has(safeName + (i ?? ''))) { @@ -194,7 +194,7 @@ export class Names { this.dbReverse.add(safeName); const isVar = type === NameType.VARIABLE || type === NameType.DEVELOPER_VARIABLE; - const prefix = isVar ? this.variablePrefix_ : ''; + const prefix = isVar ? this.variablePrefix : ''; return prefix + safeName; } @@ -206,7 +206,7 @@ export class Names { * @param name Potentially illegal entity name. * @returns Safe entity name. */ - private safeName_(name: string): string { + private safeName(name: string): string { if (!name) { name = Msg['UNNAMED_KEY'] || 'unnamed'; } else { diff --git a/core/workspace_comment.ts b/core/workspace_comment.ts index 88418da82..ca897d61a 100644 --- a/core/workspace_comment.ts +++ b/core/workspace_comment.ts @@ -30,11 +30,11 @@ export class WorkspaceComment { protected width_: number; protected RTL: boolean; - private deletable_ = true; + private deletable = true; - private movable_ = true; + private movable = true; - private editable_ = true; + private editable = true; protected content_: string; /** Whether this comment has been disposed. */ @@ -178,7 +178,7 @@ export class WorkspaceComment { * @internal */ isDeletable(): boolean { - return this.deletable_ && + return this.deletable && !(this.workspace && this.workspace.options.readOnly); } @@ -189,7 +189,7 @@ export class WorkspaceComment { * @internal */ setDeletable(deletable: boolean) { - this.deletable_ = deletable; + this.deletable = deletable; } /** @@ -199,8 +199,7 @@ export class WorkspaceComment { * @internal */ isMovable(): boolean { - return this.movable_ && - !(this.workspace && this.workspace.options.readOnly); + return this.movable && !(this.workspace && this.workspace.options.readOnly); } /** @@ -210,7 +209,7 @@ export class WorkspaceComment { * @internal */ setMovable(movable: boolean) { - this.movable_ = movable; + this.movable = movable; } /** @@ -219,7 +218,7 @@ export class WorkspaceComment { * @returns True if editable. */ isEditable(): boolean { - return this.editable_ && + return this.editable && !(this.workspace && this.workspace.options.readOnly); } @@ -229,7 +228,7 @@ export class WorkspaceComment { * @param editable True if editable. */ setEditable(editable: boolean) { - this.editable_ = editable; + this.editable = editable; } /** diff --git a/core/workspace_comment_svg.ts b/core/workspace_comment_svg.ts index b440b0679..a86994cb3 100644 --- a/core/workspace_comment_svg.ts +++ b/core/workspace_comment_svg.ts @@ -62,36 +62,37 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements override workspace: WorkspaceSvg; /** Mouse up event data. */ - private onMouseUpWrapper_: browserEvents.Data|null = null; + private onMouseUpWrapper: browserEvents.Data|null = null; /** Mouse move event data. */ - private onMouseMoveWrapper_: browserEvents.Data|null = null; + private onMouseMoveWrapper: browserEvents.Data|null = null; /** Whether event handlers have been initialized. */ - private eventsInit_ = false; - private textarea_: HTMLTextAreaElement|null = null; + private eventsInit = false; + private textarea: HTMLTextAreaElement|null = null; - private svgRectTarget_: SVGRectElement|null = null; + private svgRectTarget: SVGRectElement|null = null; - private svgHandleTarget_: SVGRectElement|null = null; + private svgHandleTarget: SVGRectElement|null = null; - private foreignObject_: SVGForeignObjectElement|null = null; + private foreignObject: SVGForeignObjectElement|null = null; - private resizeGroup_: SVGGElement|null = null; + private resizeGroup: SVGGElement|null = null; - private deleteGroup_: SVGGElement|null = null; + private deleteGroup: SVGGElement|null = null; - private deleteIconBorder_: SVGCircleElement|null = null; + private deleteIconBorder: SVGCircleElement|null = null; + + private focused = false; + private autoLayout = false; - private focused_ = false; - private autoLayout_ = false; // Create core elements for the block. - private readonly svgGroup_: SVGElement; + private readonly svgGroup: SVGElement; svgRect_: SVGRectElement; /** Whether the comment is rendered onscreen and is a part of the DOM. */ - private rendered_ = false; - private readonly useDragSurface_: boolean; + private rendered = false; + private readonly useDragSurface: boolean; /** * @param workspace The block's workspace. @@ -105,7 +106,7 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements workspace: WorkspaceSvg, content: string, height: number, width: number, opt_id?: string) { super(workspace, content, height, width, opt_id); - this.svgGroup_ = dom.createSvgElement(Svg.G, {'class': 'blocklyComment'}); + this.svgGroup = dom.createSvgElement(Svg.G, {'class': 'blocklyComment'}); this.workspace = workspace; this.svgRect_ = dom.createSvgElement(Svg.RECT, { @@ -115,13 +116,13 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements 'rx': BORDER_RADIUS, 'ry': BORDER_RADIUS, }); - this.svgGroup_.appendChild(this.svgRect_); + this.svgGroup.appendChild(this.svgRect_); /** * Whether to move the comment to the drag surface when it is dragged. * True if it should move, false if it should be translated directly. */ - this.useDragSurface_ = !!workspace.getBlockDragSurface(); + this.useDragSurface = !!workspace.getBlockDragSurface(); this.render(); } @@ -145,9 +146,9 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements eventUtils.fire(new (eventUtils.get(eventUtils.COMMENT_DELETE))(this)); } - dom.removeNode(this.svgGroup_); + dom.removeNode(this.svgGroup); // Dispose of any rendered components - this.disposeInternal_(); + this.disposeInternal(); eventUtils.disable(); super.dispose(); @@ -165,23 +166,23 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements if (!this.workspace.rendered) { throw TypeError('Workspace is headless.'); } - if (!this.workspace.options.readOnly && !this.eventsInit_) { + if (!this.workspace.options.readOnly && !this.eventsInit) { browserEvents.conditionalBind( - this.svgRectTarget_ as SVGRectElement, 'pointerdown', this, - this.pathMouseDown_); + this.svgRectTarget as SVGRectElement, 'pointerdown', this, + this.pathMouseDown); browserEvents.conditionalBind( - this.svgHandleTarget_ as SVGRectElement, 'pointerdown', this, - this.pathMouseDown_); + this.svgHandleTarget as SVGRectElement, 'pointerdown', this, + this.pathMouseDown); } - this.eventsInit_ = true; + this.eventsInit = true; this.updateMovable(); if (!this.getSvgRoot().parentNode) { this.workspace.getBubbleCanvas().appendChild(this.getSvgRoot()); } - if (!opt_noSelect && this.textarea_) { - this.textarea_.select(); + if (!opt_noSelect && this.textarea) { + this.textarea.select(); } } @@ -190,7 +191,7 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements * * @param e Pointer down event. */ - private pathMouseDown_(e: PointerEvent) { + private pathMouseDown(e: PointerEvent) { const gesture = this.workspace.getGesture(e); if (gesture) { gesture.handleBubbleStart(e, this); @@ -260,7 +261,7 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements * @internal */ addSelect() { - dom.addClass(this.svgGroup_, 'blocklySelected'); + dom.addClass(this.svgGroup, 'blocklySelected'); this.setFocus(); } @@ -270,7 +271,7 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements * @internal */ removeSelect() { - dom.addClass(this.svgGroup_, 'blocklySelected'); + dom.addClass(this.svgGroup, 'blocklySelected'); this.blurFocus(); } @@ -280,7 +281,7 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements * @internal */ addFocus() { - dom.addClass(this.svgGroup_, 'blocklyFocused'); + dom.addClass(this.svgGroup, 'blocklyFocused'); } /** @@ -289,7 +290,7 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements * @internal */ removeFocus() { - dom.removeClass(this.svgGroup_, 'blocklyFocused'); + dom.removeClass(this.svgGroup, 'blocklyFocused'); } /** @@ -306,7 +307,7 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements let x = 0; let y = 0; - const dragSurfaceGroup = this.useDragSurface_ ? + const dragSurfaceGroup = this.useDragSurface ? this.workspace.getBlockDragSurface()!.getGroup() : null; @@ -319,7 +320,7 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements y += xy.y; // If this element is the current element on the drag surface, include // the translation of the drag surface itself. - if (this.useDragSurface_ && + if (this.useDragSurface && this.workspace.getBlockDragSurface()!.getCurrentBlock() === element) { const surfaceTranslation = @@ -377,7 +378,7 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements * @internal */ moveToDragSurface() { - if (!this.useDragSurface_) { + if (!this.useDragSurface) { return; } // The translation for drag surface blocks, @@ -385,7 +386,7 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements // to keep the position in sync as it move on/off the surface. // This is in workspace coordinates. const xy = this.getRelativeToSurfaceXY(); - this.clearTransformAttributes_(); + this.clearTransformAttributes(); this.workspace.getBlockDragSurface()!.translateSurface(xy.x, xy.y); // Execute the move on the top-level SVG component this.workspace.getBlockDragSurface()!.setBlocksAndShow(this.getSvgRoot()); @@ -424,7 +425,7 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements * Clear the comment of transform="..." attributes. * Used when the comment is switching from 3d to 2d transform or vice versa. */ - private clearTransformAttributes_() { + private clearTransformAttributes() { this.getSvgRoot().removeAttribute('transform'); } @@ -464,9 +465,9 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements */ updateMovable() { if (this.isMovable()) { - dom.addClass(this.svgGroup_, 'blocklyDraggable'); + dom.addClass(this.svgGroup, 'blocklyDraggable'); } else { - dom.removeClass(this.svgGroup_, 'blocklyDraggable'); + dom.removeClass(this.svgGroup, 'blocklyDraggable'); } } @@ -488,8 +489,8 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements */ override setEditable(editable: boolean) { super.setEditable(editable); - if (this.textarea_) { - this.textarea_.readOnly = !editable; + if (this.textarea) { + this.textarea.readOnly = !editable; } } @@ -515,7 +516,7 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements * @internal */ getSvgRoot(): SVGElement { - return this.svgGroup_; + return this.svgGroup; } /** @@ -525,7 +526,7 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements * @internal */ override getContent(): string { - return this.textarea_ ? this.textarea_.value : this.content_; + return this.textarea ? this.textarea.value : this.content_; } /** @@ -536,8 +537,8 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements */ override setContent(content: string) { super.setContent(content); - if (this.textarea_) { - this.textarea_.value = content; + if (this.textarea) { + this.textarea.value = content; } } @@ -549,9 +550,9 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements */ setDeleteStyle(enable: boolean) { if (enable) { - dom.addClass(this.svgGroup_, 'blocklyDraggingDelete'); + dom.addClass(this.svgGroup, 'blocklyDraggingDelete'); } else { - dom.removeClass(this.svgGroup_, 'blocklyDraggingDelete'); + dom.removeClass(this.svgGroup, 'blocklyDraggingDelete'); } } @@ -619,57 +620,57 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements * @internal */ render() { - if (this.rendered_) { + if (this.rendered) { return; } const size = this.getHeightWidth(); // Add text area - const foreignObject = this.createEditor_(); - this.svgGroup_.appendChild(foreignObject); + const foreignObject = this.createEditor(); + this.svgGroup.appendChild(foreignObject); - this.svgHandleTarget_ = dom.createSvgElement( + this.svgHandleTarget = dom.createSvgElement( Svg.RECT, {'class': 'blocklyCommentHandleTarget', 'x': 0, 'y': 0}); - this.svgGroup_.appendChild(this.svgHandleTarget_); - this.svgRectTarget_ = dom.createSvgElement(Svg.RECT, { + this.svgGroup.appendChild(this.svgHandleTarget); + this.svgRectTarget = dom.createSvgElement(Svg.RECT, { 'class': 'blocklyCommentTarget', 'x': 0, 'y': 0, 'rx': BORDER_RADIUS, 'ry': BORDER_RADIUS, }); - this.svgGroup_.appendChild(this.svgRectTarget_); + this.svgGroup.appendChild(this.svgRectTarget); // Add the resize icon - this.addResizeDom_(); + this.addResizeDom(); if (this.isDeletable()) { // Add the delete icon - this.addDeleteDom_(); + this.addDeleteDom(); } - this.setSize_(size.width, size.height); + this.setSize(size.width, size.height); // Set the content - this.textarea_!.value = this.content_; + this.textarea!.value = this.content_; - this.rendered_ = true; + this.rendered = true; - if (this.resizeGroup_) { + if (this.resizeGroup) { browserEvents.conditionalBind( - (this.resizeGroup_), 'pointerdown', this, this.resizeMouseDown_); + (this.resizeGroup), 'pointerdown', this, this.resizeMouseDown); } if (this.isDeletable()) { browserEvents.conditionalBind( - this.deleteGroup_ as SVGGElement, 'pointerdown', this, - this.deleteMouseDown_); + this.deleteGroup as SVGGElement, 'pointerdown', this, + this.deleteMouseDown); browserEvents.conditionalBind( - this.deleteGroup_ as SVGGElement, 'pointerout', this, - this.deleteMouseOut_); + this.deleteGroup as SVGGElement, 'pointerout', this, + this.deleteMouseOut); browserEvents.conditionalBind( - this.deleteGroup_ as SVGGElement, 'pointerup', this, - this.deleteMouseUp_); + this.deleteGroup as SVGGElement, 'pointerup', this, + this.deleteMouseUp); } } @@ -678,7 +679,7 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements * * @returns The top-level node of the editor. */ - private createEditor_(): Element { + private createEditor(): Element { /* Create the editor. Here's the markup that will be generated: */ - this.foreignObject_ = dom.createSvgElement(Svg.FOREIGNOBJECT, { + this.foreignObject = dom.createSvgElement(Svg.FOREIGNOBJECT, { 'x': 0, 'y': WorkspaceCommentSvg.TOP_OFFSET, 'class': 'blocklyCommentForeignObject', @@ -702,8 +703,8 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements textarea.setAttribute('dir', this.RTL ? 'RTL' : 'LTR'); textarea.readOnly = !this.isEditable(); body.appendChild(textarea); - this.textarea_ = textarea; - this.foreignObject_.appendChild(body); + this.textarea = textarea; + this.foreignObject.appendChild(body); // Don't zoom with mousewheel. browserEvents.conditionalBind( textarea, 'wheel', this, function(e: WheelEvent) { @@ -714,20 +715,20 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements function(this: WorkspaceCommentSvg, _e: Event) { this.setContent(textarea.value); }); - return this.foreignObject_; + return this.foreignObject; } /** Add the resize icon to the DOM */ - private addResizeDom_() { - this.resizeGroup_ = dom.createSvgElement( + private addResizeDom() { + this.resizeGroup = dom.createSvgElement( Svg.G, {'class': this.RTL ? 'blocklyResizeSW' : 'blocklyResizeSE'}, - this.svgGroup_); + this.svgGroup); dom.createSvgElement( Svg.POLYGON, { 'points': `0,${RESIZE_SIZE} ${RESIZE_SIZE},${RESIZE_SIZE} ${RESIZE_SIZE},0`, }, - this.resizeGroup_); + this.resizeGroup); dom.createSvgElement( Svg.LINE, { 'class': 'blocklyResizeLine', @@ -736,7 +737,7 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements 'x2': RESIZE_SIZE - 1, 'y2': RESIZE_SIZE / 3, }, - this.resizeGroup_); + this.resizeGroup); dom.createSvgElement( Svg.LINE, { 'class': 'blocklyResizeLine', @@ -745,17 +746,17 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements 'x2': RESIZE_SIZE - 1, 'y2': RESIZE_SIZE * 2 / 3, }, - this.resizeGroup_); + this.resizeGroup); } /** Add the delete icon to the DOM */ - private addDeleteDom_() { - this.deleteGroup_ = dom.createSvgElement( - Svg.G, {'class': 'blocklyCommentDeleteIcon'}, this.svgGroup_); - this.deleteIconBorder_ = dom.createSvgElement( + private addDeleteDom() { + this.deleteGroup = dom.createSvgElement( + Svg.G, {'class': 'blocklyCommentDeleteIcon'}, this.svgGroup); + this.deleteIconBorder = dom.createSvgElement( Svg.CIRCLE, {'class': 'blocklyDeleteIconShape', 'r': '7', 'cx': '7.5', 'cy': '7.5'}, - this.deleteGroup_); + this.deleteGroup); // x icon. dom.createSvgElement( Svg.LINE, { @@ -766,7 +767,7 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements 'stroke': '#fff', 'stroke-width': '2', }, - this.deleteGroup_); + this.deleteGroup); dom.createSvgElement( Svg.LINE, { 'x1': '5', @@ -776,7 +777,7 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements 'stroke': '#fff', 'stroke-width': '2', }, - this.deleteGroup_); + this.deleteGroup); } /** @@ -784,8 +785,8 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements * * @param e Pointer down event. */ - private resizeMouseDown_(e: PointerEvent) { - this.unbindDragEvents_(); + private resizeMouseDown(e: PointerEvent) { + this.unbindDragEvents(); if (browserEvents.isRightButton(e)) { // No right-click. e.stopPropagation(); @@ -797,10 +798,10 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements new Coordinate( this.workspace.RTL ? -this.width_ : this.width_, this.height_)); - this.onMouseUpWrapper_ = browserEvents.conditionalBind( - document, 'pointerup', this, this.resizeMouseUp_); - this.onMouseMoveWrapper_ = browserEvents.conditionalBind( - document, 'pointermove', this, this.resizeMouseMove_); + this.onMouseUpWrapper = browserEvents.conditionalBind( + document, 'pointerup', this, this.resizeMouseUp); + this.onMouseMoveWrapper = browserEvents.conditionalBind( + document, 'pointermove', this, this.resizeMouseMove); this.workspace.hideChaff(); // This event has been handled. No need to bubble up to the document. e.stopPropagation(); @@ -811,10 +812,10 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements * * @param e Pointer down event. */ - private deleteMouseDown_(e: PointerEvent) { + private deleteMouseDown(e: PointerEvent) { // Highlight the delete icon. - if (this.deleteIconBorder_) { - dom.addClass(this.deleteIconBorder_, 'blocklyDeleteIconHighlighted'); + if (this.deleteIconBorder) { + dom.addClass(this.deleteIconBorder, 'blocklyDeleteIconHighlighted'); } // This event has been handled. No need to bubble up to the document. e.stopPropagation(); @@ -825,10 +826,10 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements * * @param _e Pointer out event. */ - private deleteMouseOut_(_e: PointerEvent) { + private deleteMouseOut(_e: PointerEvent) { // Restore highlight on the delete icon. - if (this.deleteIconBorder_) { - dom.removeClass(this.deleteIconBorder_, 'blocklyDeleteIconHighlighted'); + if (this.deleteIconBorder) { + dom.removeClass(this.deleteIconBorder, 'blocklyDeleteIconHighlighted'); } } @@ -837,7 +838,7 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements * * @param e Pointer up event. */ - private deleteMouseUp_(e: PointerEvent) { + private deleteMouseUp(e: PointerEvent) { // Delete this comment. this.dispose(); // This event has been handled. No need to bubble up to the document. @@ -845,14 +846,14 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements } /** Stop binding to the global pointerup and pointermove events. */ - private unbindDragEvents_() { - if (this.onMouseUpWrapper_) { - browserEvents.unbind(this.onMouseUpWrapper_); - this.onMouseUpWrapper_ = null; + private unbindDragEvents() { + if (this.onMouseUpWrapper) { + browserEvents.unbind(this.onMouseUpWrapper); + this.onMouseUpWrapper = null; } - if (this.onMouseMoveWrapper_) { - browserEvents.unbind(this.onMouseMoveWrapper_); - this.onMouseMoveWrapper_ = null; + if (this.onMouseMoveWrapper) { + browserEvents.unbind(this.onMouseMoveWrapper); + this.onMouseMoveWrapper = null; } } @@ -862,9 +863,9 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements * * @param _e Pointer up event. */ - private resizeMouseUp_(_e: PointerEvent) { + private resizeMouseUp(_e: PointerEvent) { Touch.clearTouchIdentifier(); - this.unbindDragEvents_(); + this.unbindDragEvents(); } /** @@ -872,31 +873,30 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements * * @param e Pointer move event. */ - private resizeMouseMove_(e: PointerEvent) { - this.autoLayout_ = false; + private resizeMouseMove(e: PointerEvent) { + this.autoLayout = false; const newXY = this.workspace.moveDrag(e); - this.setSize_(this.RTL ? -newXY.x : newXY.x, newXY.y); + this.setSize(this.RTL ? -newXY.x : newXY.x, newXY.y); } /** * Callback function triggered when the comment has resized. * Resize the text area accordingly. */ - private resizeComment_() { + private resizeComment() { const size = this.getHeightWidth(); const topOffset = WorkspaceCommentSvg.TOP_OFFSET; const textOffset = TEXTAREA_OFFSET * 2; - this.foreignObject_?.setAttribute('width', String(size.width)); - this.foreignObject_?.setAttribute( - 'height', String(size.height - topOffset)); + this.foreignObject?.setAttribute('width', String(size.width)); + this.foreignObject?.setAttribute('height', String(size.height - topOffset)); if (this.RTL) { - this.foreignObject_?.setAttribute('x', String(-size.width)); + this.foreignObject?.setAttribute('x', String(-size.width)); } - if (!this.textarea_) return; - this.textarea_.style.width = size.width - textOffset + 'px'; - this.textarea_.style.height = size.height - textOffset - topOffset + 'px'; + if (!this.textarea) return; + this.textarea.style.width = size.width - textOffset + 'px'; + this.textarea.style.height = size.height - textOffset - topOffset + 'px'; } /** @@ -905,7 +905,7 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements * @param width width of the container * @param height height of the container */ - private setSize_(width: number, height: number) { + private setSize(width: number, height: number) { // Minimum size of a comment. width = Math.max(width, 45); height = Math.max(height, 20 + WorkspaceCommentSvg.TOP_OFFSET); @@ -913,48 +913,44 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements this.height_ = height; this.svgRect_.setAttribute('width', `${width}`); this.svgRect_.setAttribute('height', `${height}`); - this.svgRectTarget_?.setAttribute('width', `${width}`); - this.svgRectTarget_?.setAttribute('height', `${height}`); - this.svgHandleTarget_?.setAttribute('width', `${width}`); - this.svgHandleTarget_?.setAttribute( + this.svgRectTarget?.setAttribute('width', `${width}`); + this.svgRectTarget?.setAttribute('height', `${height}`); + this.svgHandleTarget?.setAttribute('width', `${width}`); + this.svgHandleTarget?.setAttribute( 'height', String(WorkspaceCommentSvg.TOP_OFFSET)); if (this.RTL) { this.svgRect_.setAttribute('transform', 'scale(-1 1)'); - this.svgRectTarget_?.setAttribute('transform', 'scale(-1 1)'); + this.svgRectTarget?.setAttribute('transform', 'scale(-1 1)'); } - if (this.resizeGroup_) { + if (this.resizeGroup) { if (this.RTL) { // Mirror the resize group. - this.resizeGroup_.setAttribute( + this.resizeGroup.setAttribute( 'transform', 'translate(' + (-width + RESIZE_SIZE) + ',' + (height - RESIZE_SIZE) + ') scale(-1 1)'); - this.deleteGroup_?.setAttribute( + this.deleteGroup?.setAttribute( 'transform', 'translate(' + (-width + RESIZE_SIZE) + ',' + -RESIZE_SIZE + ') scale(-1 1)'); } else { - this.resizeGroup_.setAttribute( + this.resizeGroup.setAttribute( 'transform', 'translate(' + (width - RESIZE_SIZE) + ',' + (height - RESIZE_SIZE) + ')'); - this.deleteGroup_?.setAttribute( + this.deleteGroup?.setAttribute( 'transform', 'translate(' + (width - RESIZE_SIZE) + ',' + -RESIZE_SIZE + ')'); } } // Allow the contents to resize. - this.resizeComment_(); + this.resizeComment(); } /** Dispose of any rendered comment components. */ - private disposeInternal_() { - this.textarea_ = null; - this.foreignObject_ = null; - this.svgRectTarget_ = null; - this.svgHandleTarget_ = null; + private disposeInternal() { this.disposed_ = true; } @@ -964,20 +960,19 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements * @internal */ setFocus() { - this.focused_ = true; + this.focused = true; // Defer CSS changes. setTimeout(() => { if (this.disposed_) { return; } - this.textarea_!.focus(); + this.textarea!.focus(); this.addFocus(); - if (this.svgRectTarget_) { - dom.addClass(this.svgRectTarget_, 'blocklyCommentTargetFocused'); + if (this.svgRectTarget) { + dom.addClass(this.svgRectTarget, 'blocklyCommentTargetFocused'); } - if (this.svgHandleTarget_) { - dom.addClass( - this.svgHandleTarget_, 'blocklyCommentHandleTargetFocused'); + if (this.svgHandleTarget) { + dom.addClass(this.svgHandleTarget, 'blocklyCommentHandleTargetFocused'); } }, 0); } @@ -988,21 +983,21 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements * @internal */ blurFocus() { - this.focused_ = false; + this.focused = false; // Defer CSS changes. setTimeout(() => { if (this.disposed_) { return; } - this.textarea_!.blur(); + this.textarea!.blur(); this.removeFocus(); - if (this.svgRectTarget_) { - dom.removeClass(this.svgRectTarget_, 'blocklyCommentTargetFocused'); + if (this.svgRectTarget) { + dom.removeClass(this.svgRectTarget, 'blocklyCommentTargetFocused'); } - if (this.svgHandleTarget_) { + if (this.svgHandleTarget) { dom.removeClass( - this.svgHandleTarget_, 'blocklyCommentHandleTargetFocused'); + this.svgHandleTarget, 'blocklyCommentHandleTargetFocused'); } }, 0); } diff --git a/tests/mocha/names_test.js b/tests/mocha/names_test.js index e9a8195be..01e665e31 100644 --- a/tests/mocha/names_test.js +++ b/tests/mocha/names_test.js @@ -19,12 +19,12 @@ suite('Names', function() { test('Safe name', function() { const varDB = new Blockly.Names('window,door'); - chai.assert.equal(varDB.safeName_(''), 'unnamed', 'SafeName empty.'); - chai.assert.equal(varDB.safeName_('foobar'), 'foobar', 'SafeName ok.'); - chai.assert.equal(varDB.safeName_('9lives'), 'my_9lives', 'SafeName number start.'); - chai.assert.equal(varDB.safeName_('lives9'), 'lives9', 'SafeName number end.'); - chai.assert.equal(varDB.safeName_('!@#$'), '____', 'SafeName special chars.'); - chai.assert.equal(varDB.safeName_('door'), 'door', 'SafeName reserved.'); + chai.assert.equal(varDB.safeName(''), 'unnamed', 'SafeName empty.'); + chai.assert.equal(varDB.safeName('foobar'), 'foobar', 'SafeName ok.'); + chai.assert.equal(varDB.safeName('9lives'), 'my_9lives', 'SafeName number start.'); + chai.assert.equal(varDB.safeName('lives9'), 'lives9', 'SafeName number end.'); + chai.assert.equal(varDB.safeName('!@#$'), '____', 'SafeName special chars.'); + chai.assert.equal(varDB.safeName('door'), 'door', 'SafeName reserved.'); }); test('Get name', function() { From 85013f83b25d1c1e837b3cb0771414a6357aecd9 Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Tue, 11 Apr 2023 10:06:17 -0700 Subject: [PATCH 015/161] chore: remove underscores from private properties and methods in connections (#6961) * chore: remove private underscores in connection and connection_db * chore: remove private underscores in rendererd_connection --- core/connection.ts | 62 +++++++++++----------- core/connection_db.ts | 65 ++++++++++++------------ core/rendered_connection.ts | 62 +++++++++++----------- tests/mocha/block_test.js | 8 +-- tests/mocha/blocks/logic_ternary_test.js | 5 +- tests/mocha/connection_db_test.js | 40 +++++++-------- 6 files changed, 121 insertions(+), 121 deletions(-) diff --git a/core/connection.ts b/core/connection.ts index ee7ab8b99..c34c0abbc 100644 --- a/core/connection.ts +++ b/core/connection.ts @@ -51,10 +51,10 @@ export class Connection implements IASTNodeLocationWithBlock { disposed = false; /** List of compatible value types. Null if all types are compatible. */ - private check_: string[]|null = null; + private check: string[]|null = null; /** DOM representation of a shadow block, or null if none. */ - private shadowDom_: Element|null = null; + private shadowDom: Element|null = null; /** * Horizontal location of this connection. @@ -70,7 +70,7 @@ export class Connection implements IASTNodeLocationWithBlock { */ y = 0; - private shadowState_: blocks.State|null = null; + private shadowState: blocks.State|null = null; /** * @param source The block establishing this connection. @@ -99,7 +99,7 @@ export class Connection implements IASTNodeLocationWithBlock { // Make sure the parentConnection is available. let orphan; if (this.isConnected()) { - const shadowState = this.stashShadowState_(); + const shadowState = this.stashShadowState(); const target = this.targetBlock(); if (target!.isShadow()) { target!.dispose(false); @@ -107,7 +107,7 @@ export class Connection implements IASTNodeLocationWithBlock { this.disconnectInternal(); orphan = target; } - this.applyShadowState_(shadowState); + this.applyShadowState(shadowState); } // Connect the new connection to the parent. @@ -147,7 +147,7 @@ export class Connection implements IASTNodeLocationWithBlock { // isConnected returns true for shadows and non-shadows. if (this.isConnected()) { // Destroy the attached shadow block & its children (if it exists). - this.setShadowStateInternal_(); + this.setShadowStateInternal(); const targetBlock = this.targetBlock(); if (targetBlock && !targetBlock.isDeadOrDying()) { @@ -319,7 +319,7 @@ export class Connection implements IASTNodeLocationWithBlock { */ protected respawnShadow_() { // Have to keep respawnShadow_ for backwards compatibility. - this.createShadowBlock_(true); + this.createShadowBlock(true); } /** @@ -360,10 +360,10 @@ export class Connection implements IASTNodeLocationWithBlock { if (!Array.isArray(check)) { check = [check]; } - this.check_ = check; + this.check = check; this.onCheckChanged_(); } else { - this.check_ = null; + this.check = null; } return this; } @@ -375,7 +375,7 @@ export class Connection implements IASTNodeLocationWithBlock { * Null if all types are compatible. */ getCheck(): string[]|null { - return this.check_; + return this.check; } /** @@ -384,7 +384,7 @@ export class Connection implements IASTNodeLocationWithBlock { * @param shadowDom DOM representation of a block or null. */ setShadowDom(shadowDom: Element|null) { - this.setShadowStateInternal_({shadowDom}); + this.setShadowStateInternal({shadowDom}); } /** @@ -399,7 +399,7 @@ export class Connection implements IASTNodeLocationWithBlock { getShadowDom(returnCurrent?: boolean): Element|null { return returnCurrent && this.targetBlock()!.isShadow() ? Xml.blockToDom((this.targetBlock() as Block)) as Element : - this.shadowDom_; + this.shadowDom; } /** @@ -408,7 +408,7 @@ export class Connection implements IASTNodeLocationWithBlock { * @param shadowState An state represetation of the block or null. */ setShadowState(shadowState: blocks.State|null) { - this.setShadowStateInternal_({shadowState}); + this.setShadowStateInternal({shadowState}); } /** @@ -425,7 +425,7 @@ export class Connection implements IASTNodeLocationWithBlock { if (returnCurrent && this.targetBlock() && this.targetBlock()!.isShadow()) { return blocks.save(this.targetBlock() as Block); } - return this.shadowState_; + return this.shadowState; } /** @@ -506,13 +506,13 @@ export class Connection implements IASTNodeLocationWithBlock { * * @returns The state of both the shadowDom_ and shadowState_ properties. */ - private stashShadowState_(): + private stashShadowState(): {shadowDom: Element|null, shadowState: blocks.State|null} { const shadowDom = this.getShadowDom(true); const shadowState = this.getShadowState(true); // Set to null so it doesn't respawn. - this.shadowDom_ = null; - this.shadowState_ = null; + this.shadowDom = null; + this.shadowState = null; return {shadowDom, shadowState}; } @@ -522,12 +522,12 @@ export class Connection implements IASTNodeLocationWithBlock { * @param param0 The state to reapply to the shadowDom_ and shadowState_ * properties. */ - private applyShadowState_({shadowDom, shadowState}: { + private applyShadowState({shadowDom, shadowState}: { shadowDom: Element|null, shadowState: blocks.State|null }) { - this.shadowDom_ = shadowDom; - this.shadowState_ = shadowState; + this.shadowDom = shadowDom; + this.shadowState = shadowState; } /** @@ -535,31 +535,31 @@ export class Connection implements IASTNodeLocationWithBlock { * * @param param0 The state to set the shadow of this connection to. */ - private setShadowStateInternal_({shadowDom = null, shadowState = null}: { + private setShadowStateInternal({shadowDom = null, shadowState = null}: { shadowDom?: Element|null, shadowState?: blocks.State|null } = {}) { // One or both of these should always be null. // If neither is null, the shadowState will get priority. - this.shadowDom_ = shadowDom; - this.shadowState_ = shadowState; + this.shadowDom = shadowDom; + this.shadowState = shadowState; const target = this.targetBlock(); if (!target) { this.respawnShadow_(); if (this.targetBlock() && this.targetBlock()!.isShadow()) { - this.serializeShadow_(this.targetBlock()); + this.serializeShadow(this.targetBlock()); } } else if (target.isShadow()) { target.dispose(false); if (this.getSourceBlock().isDeadOrDying()) return; this.respawnShadow_(); if (this.targetBlock() && this.targetBlock()!.isShadow()) { - this.serializeShadow_(this.targetBlock()); + this.serializeShadow(this.targetBlock()); } } else { - const shadow = this.createShadowBlock_(false); - this.serializeShadow_(shadow); + const shadow = this.createShadowBlock(false); + this.serializeShadow(shadow); if (shadow) { shadow.dispose(false); } @@ -575,7 +575,7 @@ export class Connection implements IASTNodeLocationWithBlock { * @returns The shadow block that was created, or null if both the * shadowState_ and shadowDom_ are null. */ - private createShadowBlock_(attemptToConnect: boolean): Block|null { + private createShadowBlock(attemptToConnect: boolean): Block|null { const parentBlock = this.getSourceBlock(); const shadowState = this.getShadowState(); const shadowDom = this.getShadowDom(); @@ -626,12 +626,12 @@ export class Connection implements IASTNodeLocationWithBlock { * * @param shadow The shadow to serialize, or null. */ - private serializeShadow_(shadow: Block|null) { + private serializeShadow(shadow: Block|null) { if (!shadow) { return; } - this.shadowDom_ = Xml.blockToDom(shadow) as Element; - this.shadowState_ = blocks.save(shadow); + this.shadowDom = Xml.blockToDom(shadow) as Element; + this.shadowState = blocks.save(shadow); } /** diff --git a/core/connection_db.ts b/core/connection_db.ts index 9320d9f28..23dd82983 100644 --- a/core/connection_db.ts +++ b/core/connection_db.ts @@ -27,7 +27,7 @@ import type {Coordinate} from './utils/coordinate.js'; */ export class ConnectionDB { /** Array of connections sorted by y position in workspace units. */ - private readonly connections_: RenderedConnection[] = []; + private readonly connections: RenderedConnection[] = []; /** * @param connectionChecker The workspace's connection type checker, used to @@ -43,8 +43,8 @@ export class ConnectionDB { * @internal */ addConnection(connection: RenderedConnection, yPos: number) { - const index = this.calculateIndexForYPos_(yPos); - this.connections_.splice(index, 0, connection); + const index = this.calculateIndexForYPos(yPos); + this.connections.splice(index, 0, connection); } /** @@ -58,14 +58,14 @@ export class ConnectionDB { * @returns The index of the connection, or -1 if the connection was not * found. */ - private findIndexOfConnection_(conn: RenderedConnection, yPos: number): + private findIndexOfConnection(conn: RenderedConnection, yPos: number): number { - if (!this.connections_.length) { + if (!this.connections.length) { return -1; } - const bestGuess = this.calculateIndexForYPos_(yPos); - if (bestGuess >= this.connections_.length) { + const bestGuess = this.calculateIndexForYPos(yPos); + if (bestGuess >= this.connections.length) { // Not in list return -1; } @@ -73,17 +73,17 @@ export class ConnectionDB { yPos = conn.y; // Walk forward and back on the y axis looking for the connection. let pointer = bestGuess; - while (pointer >= 0 && this.connections_[pointer].y === yPos) { - if (this.connections_[pointer] === conn) { + while (pointer >= 0 && this.connections[pointer].y === yPos) { + if (this.connections[pointer] === conn) { return pointer; } pointer--; } pointer = bestGuess; - while (pointer < this.connections_.length && - this.connections_[pointer].y === yPos) { - if (this.connections_[pointer] === conn) { + while (pointer < this.connections.length && + this.connections[pointer].y === yPos) { + if (this.connections[pointer] === conn) { return pointer; } pointer++; @@ -97,17 +97,17 @@ export class ConnectionDB { * @param yPos The y position used to decide where to insert the connection. * @returns The candidate index. */ - private calculateIndexForYPos_(yPos: number): number { - if (!this.connections_.length) { + private calculateIndexForYPos(yPos: number): number { + if (!this.connections.length) { return 0; } let pointerMin = 0; - let pointerMax = this.connections_.length; + let pointerMax = this.connections.length; while (pointerMin < pointerMax) { const pointerMid = Math.floor((pointerMin + pointerMax) / 2); - if (this.connections_[pointerMid].y < yPos) { + if (this.connections[pointerMid].y < yPos) { pointerMin = pointerMid + 1; - } else if (this.connections_[pointerMid].y > yPos) { + } else if (this.connections[pointerMid].y > yPos) { pointerMax = pointerMid; } else { pointerMin = pointerMid; @@ -125,11 +125,11 @@ export class ConnectionDB { * @throws {Error} If the connection cannot be found in the database. */ removeConnection(connection: RenderedConnection, yPos: number) { - const index = this.findIndexOfConnection_(connection, yPos); + const index = this.findIndexOfConnection(connection, yPos); if (index === -1) { throw Error('Unable to find connection in connectionDB.'); } - this.connections_.splice(index, 1); + this.connections.splice(index, 1); } /** @@ -142,7 +142,7 @@ export class ConnectionDB { */ getNeighbours(connection: RenderedConnection, maxRadius: number): RenderedConnection[] { - const db = this.connections_; + const db = this.connections; const currentX = connection.x; const currentY = connection.y; @@ -169,7 +169,7 @@ export class ConnectionDB { * @returns True if the current connection's vertical distance from the * other connection is less than the allowed radius. */ - function checkConnection_(yIndex: number): boolean { + function checkConnection(yIndex: number): boolean { const dx = currentX - db[yIndex].x; const dy = currentY - db[yIndex].y; const r = Math.sqrt(dx * dx + dy * dy); @@ -183,12 +183,12 @@ export class ConnectionDB { pointerMin = pointerMid; pointerMax = pointerMid; if (db.length) { - while (pointerMin >= 0 && checkConnection_(pointerMin)) { + while (pointerMin >= 0 && checkConnection(pointerMin)) { pointerMin--; } do { pointerMax++; - } while (pointerMax < db.length && checkConnection_(pointerMax)); + } while (pointerMax < db.length && checkConnection(pointerMax)); } return neighbours; @@ -203,9 +203,8 @@ export class ConnectionDB { * @param maxRadius The maximum radius to another connection. * @returns True if connection is in range. */ - private isInYRange_(index: number, baseY: number, maxRadius: number): - boolean { - return Math.abs(this.connections_[index].y - baseY) <= maxRadius; + private isInYRange(index: number, baseY: number, maxRadius: number): boolean { + return Math.abs(this.connections[index].y - baseY) <= maxRadius; } /** @@ -221,7 +220,7 @@ export class ConnectionDB { searchForClosest( conn: RenderedConnection, maxRadius: number, dxy: Coordinate): {connection: RenderedConnection|null, radius: number} { - if (!this.connections_.length) { + if (!this.connections.length) { // Don't bother. return {connection: null, radius: maxRadius}; } @@ -236,7 +235,7 @@ export class ConnectionDB { // calculateIndexForYPos_ finds an index for insertion, which is always // after any block with the same y index. We want to search both forward // and back, so search on both sides of the index. - const closestIndex = this.calculateIndexForYPos_(conn.y); + const closestIndex = this.calculateIndexForYPos(conn.y); let bestConnection = null; let bestRadius = maxRadius; @@ -244,8 +243,8 @@ export class ConnectionDB { // Walk forward and back on the y axis looking for the closest x,y point. let pointerMin = closestIndex - 1; - while (pointerMin >= 0 && this.isInYRange_(pointerMin, conn.y, maxRadius)) { - temp = this.connections_[pointerMin]; + while (pointerMin >= 0 && this.isInYRange(pointerMin, conn.y, maxRadius)) { + temp = this.connections[pointerMin]; if (this.connectionChecker.canConnect(conn, temp, true, bestRadius)) { bestConnection = temp; bestRadius = temp.distanceFrom(conn); @@ -254,9 +253,9 @@ export class ConnectionDB { } let pointerMax = closestIndex; - while (pointerMax < this.connections_.length && - this.isInYRange_(pointerMax, conn.y, maxRadius)) { - temp = this.connections_[pointerMax]; + while (pointerMax < this.connections.length && + this.isInYRange(pointerMax, conn.y, maxRadius)) { + temp = this.connections[pointerMax]; if (this.connectionChecker.canConnect(conn, temp, true, bestRadius)) { bestConnection = temp; bestRadius = temp.distanceFrom(conn); diff --git a/core/rendered_connection.ts b/core/rendered_connection.ts index c472867db..0e46963a9 100644 --- a/core/rendered_connection.ts +++ b/core/rendered_connection.ts @@ -47,10 +47,10 @@ const BUMP_RANDOMNESS = 10; export class RenderedConnection extends Connection { // TODO(b/109816955): remove '!', see go/strict-prop-init-fix. sourceBlock_!: BlockSvg; - private readonly db_: ConnectionDB; - private readonly dbOpposite_: ConnectionDB; - private readonly offsetInBlock_: Coordinate; - private trackedState_: TrackedState; + private readonly db: ConnectionDB; + private readonly dbOpposite: ConnectionDB; + private readonly offsetInBlock: Coordinate; + private trackedState: TrackedState; private highlightPath: SVGPathElement|null = null; /** Connection this connection connects to. Null if not connected. */ @@ -67,21 +67,21 @@ export class RenderedConnection extends Connection { * Connection database for connections of this type on the current * workspace. */ - this.db_ = source.workspace.connectionDBList[type]; + this.db = source.workspace.connectionDBList[type]; /** * Connection database for connections compatible with this type on the * current workspace. */ - this.dbOpposite_ = + this.dbOpposite = source.workspace .connectionDBList[internalConstants.OPPOSITE_TYPE[type]]; /** Workspace units, (0, 0) is top left of block. */ - this.offsetInBlock_ = new Coordinate(0, 0); + this.offsetInBlock = new Coordinate(0, 0); /** Describes the state of this connection's tracked-ness. */ - this.trackedState_ = RenderedConnection.TrackedState.WILL_TRACK; + this.trackedState = RenderedConnection.TrackedState.WILL_TRACK; } /** @@ -92,8 +92,8 @@ export class RenderedConnection extends Connection { */ override dispose() { super.dispose(); - if (this.trackedState_ === RenderedConnection.TrackedState.TRACKED) { - this.db_.removeConnection(this, this.y); + if (this.trackedState === RenderedConnection.TrackedState.TRACKED) { + this.db.removeConnection(this, this.y); } } @@ -192,15 +192,15 @@ export class RenderedConnection extends Connection { const moved = true; let updated = false; - if (this.trackedState_ === RenderedConnection.TrackedState.WILL_TRACK) { - this.db_.addConnection(this, y); - this.trackedState_ = RenderedConnection.TrackedState.TRACKED; + if (this.trackedState === RenderedConnection.TrackedState.WILL_TRACK) { + this.db.addConnection(this, y); + this.trackedState = RenderedConnection.TrackedState.TRACKED; updated = true; } else if ( - this.trackedState_ === RenderedConnection.TrackedState.TRACKED && + this.trackedState === RenderedConnection.TrackedState.TRACKED && moved) { - this.db_.removeConnection(this, this.y); - this.db_.addConnection(this, y); + this.db.removeConnection(this, this.y); + this.db.addConnection(this, y); updated = true; } @@ -233,7 +233,7 @@ export class RenderedConnection extends Connection { */ moveToOffset(blockTL: Coordinate): boolean { return this.moveTo( - blockTL.x + this.offsetInBlock_.x, blockTL.y + this.offsetInBlock_.y); + blockTL.x + this.offsetInBlock.x, blockTL.y + this.offsetInBlock.y); } /** @@ -243,8 +243,8 @@ export class RenderedConnection extends Connection { * @param y The new relative y, in workspace units. */ setOffsetInBlock(x: number, y: number) { - this.offsetInBlock_.x = x; - this.offsetInBlock_.y = y; + this.offsetInBlock.x = x; + this.offsetInBlock.y = y; } /** @@ -254,7 +254,7 @@ export class RenderedConnection extends Connection { * @internal */ getOffsetInBlock(): Coordinate { - return this.offsetInBlock_; + return this.offsetInBlock; } /** @@ -289,7 +289,7 @@ export class RenderedConnection extends Connection { const block = this.targetBlock(); if (!target || !block) return; const offset = - Coordinate.difference(this.offsetInBlock_, target.offsetInBlock_); + Coordinate.difference(this.offsetInBlock, target.offsetInBlock); block.translate(offset.x, offset.y); } @@ -305,7 +305,7 @@ export class RenderedConnection extends Connection { */ closest(maxLimit: number, dxy: Coordinate): {connection: RenderedConnection|null, radius: number} { - return this.dbOpposite_.searchForClosest(this, maxLimit, dxy); + return this.dbOpposite.searchForClosest(this, maxLimit, dxy); } /** Add highlighting around this connection. */ @@ -334,7 +334,7 @@ export class RenderedConnection extends Connection { (shape as unknown as PathLeftShape).pathLeft + svgPaths.lineOnAxis('h', xLen); } - const offset = this.offsetInBlock_; + const offset = this.offsetInBlock; this.highlightPath = dom.createSvgElement( Svg.PATH, { 'class': 'blocklyHighlightedConnectionPath', @@ -361,9 +361,9 @@ export class RenderedConnection extends Connection { */ setTracking(doTracking: boolean) { if (doTracking && - this.trackedState_ === RenderedConnection.TrackedState.TRACKED || + this.trackedState === RenderedConnection.TrackedState.TRACKED || !doTracking && - this.trackedState_ === RenderedConnection.TrackedState.UNTRACKED) { + this.trackedState === RenderedConnection.TrackedState.UNTRACKED) { return; } if (this.sourceBlock_.isInFlyout) { @@ -371,14 +371,14 @@ export class RenderedConnection extends Connection { return; } if (doTracking) { - this.db_.addConnection(this, this.y); - this.trackedState_ = RenderedConnection.TrackedState.TRACKED; + this.db.addConnection(this, this.y); + this.trackedState = RenderedConnection.TrackedState.TRACKED; return; } - if (this.trackedState_ === RenderedConnection.TrackedState.TRACKED) { - this.db_.removeConnection(this, this.y); + if (this.trackedState === RenderedConnection.TrackedState.TRACKED) { + this.db.removeConnection(this, this.y); } - this.trackedState_ = RenderedConnection.TrackedState.UNTRACKED; + this.trackedState = RenderedConnection.TrackedState.UNTRACKED; } /** @@ -532,7 +532,7 @@ export class RenderedConnection extends Connection { * @internal */ override neighbours(maxLimit: number): RenderedConnection[] { - return this.dbOpposite_.getNeighbours(this, maxLimit); + return this.dbOpposite.getNeighbours(this, maxLimit); } /** diff --git a/tests/mocha/block_test.js b/tests/mocha/block_test.js index 093c8ebba..9396f93ce 100644 --- a/tests/mocha/block_test.js +++ b/tests/mocha/block_test.js @@ -477,19 +477,19 @@ suite('Blocks', function() { this.getInputs = function() { return this.workspace - .connectionDBList[ConnectionType.INPUT_VALUE].connections_; + .connectionDBList[ConnectionType.INPUT_VALUE].connections; }; this.getOutputs = function() { return this.workspace - .connectionDBList[ConnectionType.OUTPUT_VALUE].connections_; + .connectionDBList[ConnectionType.OUTPUT_VALUE].connections; }; this.getNext = function() { return this.workspace - .connectionDBList[ConnectionType.NEXT_STATEMENT].connections_; + .connectionDBList[ConnectionType.NEXT_STATEMENT].connections; }; this.getPrevious = function() { return this.workspace - .connectionDBList[ConnectionType.PREVIOUS_STATEMENT].connections_; + .connectionDBList[ConnectionType.PREVIOUS_STATEMENT].connections; }; this.assertConnectionsEmpty = function() { diff --git a/tests/mocha/blocks/logic_ternary_test.js b/tests/mocha/blocks/logic_ternary_test.js index db2de13bb..a160ef801 100644 --- a/tests/mocha/blocks/logic_ternary_test.js +++ b/tests/mocha/blocks/logic_ternary_test.js @@ -34,8 +34,9 @@ suite('Logic ternary', function() { chai.assert.lengthOf(inputs, 3); const ifInput = block.getInput('IF'); chai.assert.exists(ifInput, 'Has "IF" input'); - chai.assert.equal(ifInput.connection.check_.length, 1); - chai.assert.equal(ifInput.connection.check_[0], 'Boolean'); + const checkList = ifInput.connection.getCheck(); + chai.assert.equal(checkList.length, 1); + chai.assert.equal(checkList[0], 'Boolean'); chai.assert.exists(block.onchangeWrapper_, 'Has onchange handler'); if (inputsInline) { chai.assert.isTrue(block.inputsInline); diff --git a/tests/mocha/connection_db_test.js b/tests/mocha/connection_db_test.js index 6d7e2b363..643633f32 100644 --- a/tests/mocha/connection_db_test.js +++ b/tests/mocha/connection_db_test.js @@ -16,10 +16,10 @@ suite('Connection Database', function() { this.database = new Blockly.ConnectionDB(new Blockly.ConnectionChecker()); this.assertOrder = function() { - const length = this.database.connections_.length; + const length = this.database.connections.length; for (let i = 1; i < length; i++) { - chai.assert.isAtMost(this.database.connections_[i - 1].y, - this.database.connections_[i].y); + chai.assert.isAtMost(this.database.connections[i - 1].y, + this.database.connections[i].y); } }; this.createConnection = function(x, y, type, opt_database) { @@ -52,23 +52,23 @@ suite('Connection Database', function() { this.database.addConnection(y2, 2); chai.assert.sameOrderedMembers( - this.database.connections_, [y2]); + this.database.connections, [y2]); this.database.addConnection(y4, 4); chai.assert.sameOrderedMembers( - this.database.connections_, [y2, y4]); + this.database.connections, [y2, y4]); this.database.addConnection(y1, 1); chai.assert.sameOrderedMembers( - this.database.connections_, [y1, y2, y4]); + this.database.connections, [y1, y2, y4]); this.database.addConnection(y3a, 3); chai.assert.sameOrderedMembers( - this.database.connections_, [y1, y2, y3a, y4]); + this.database.connections, [y1, y2, y3a, y4]); this.database.addConnection(y3b, 3); chai.assert.sameOrderedMembers( - this.database.connections_, [y1, y2, y3b, y3a, y4]); + this.database.connections, [y1, y2, y3b, y3a, y4]); }); test('Remove Connection', function() { const y2 = {y: 2}; @@ -86,30 +86,30 @@ suite('Connection Database', function() { this.database.addConnection(y3a, 3); chai.assert.sameOrderedMembers( - this.database.connections_, [y1, y2, y3a, y3b, y3c, y4]); + this.database.connections, [y1, y2, y3a, y3b, y3c, y4]); this.database.removeConnection(y2, 2); chai.assert.sameOrderedMembers( - this.database.connections_, [y1, y3a, y3b, y3c, y4]); + this.database.connections, [y1, y3a, y3b, y3c, y4]); this.database.removeConnection(y4, 4); chai.assert.sameOrderedMembers( - this.database.connections_, [y1, y3a, y3b, y3c]); + this.database.connections, [y1, y3a, y3b, y3c]); this.database.removeConnection(y1, 1); chai.assert.sameOrderedMembers( - this.database.connections_, [y3a, y3b, y3c]); + this.database.connections, [y3a, y3b, y3c]); this.database.removeConnection(y3a, 3); chai.assert.sameOrderedMembers( - this.database.connections_, [y3b, y3c]); + this.database.connections, [y3b, y3c]); this.database.removeConnection(y3c, 3); chai.assert.sameOrderedMembers( - this.database.connections_, [y3b]); + this.database.connections, [y3b]); this.database.removeConnection(y3b, 3); - chai.assert.isEmpty(this.database.connections_); + chai.assert.isEmpty(this.database.connections); }); suite('Get Neighbors', function() { test('Empty Database', function() { @@ -123,7 +123,7 @@ suite('Connection Database', function() { const checkConnection = this.createConnection(0, 0, ConnectionType.NEXT_STATEMENT, new Blockly.ConnectionDB()); const neighbors = this.database.getNeighbours(checkConnection, 4); - chai.assert.sameMembers(neighbors, this.database.connections_.slice(0, 5)); + chai.assert.sameMembers(neighbors, this.database.connections.slice(0, 5)); }); test('Block In Middle', function() { this.createSimpleTestConnections(); @@ -131,7 +131,7 @@ suite('Connection Database', function() { const checkConnection = this.createConnection(0, 4, ConnectionType.NEXT_STATEMENT, new Blockly.ConnectionDB()); const neighbors = this.database.getNeighbours(checkConnection, 2); - chai.assert.sameMembers(neighbors, this.database.connections_.slice(2, 7)); + chai.assert.sameMembers(neighbors, this.database.connections.slice(2, 7)); }); test('Block At End', function() { this.createSimpleTestConnections(); @@ -139,7 +139,7 @@ suite('Connection Database', function() { const checkConnection = this.createConnection(0, 9, ConnectionType.NEXT_STATEMENT, new Blockly.ConnectionDB()); const neighbors = this.database.getNeighbours(checkConnection, 4); - chai.assert.sameMembers(neighbors, this.database.connections_.slice(5, 10)); + chai.assert.sameMembers(neighbors, this.database.connections.slice(5, 10)); }); test('Out of Range X', function() { this.createSimpleTestConnections(); @@ -240,7 +240,7 @@ suite('Connection Database', function() { const checkConnection = this.createCheckConnection(0, 14); - const last = this.database.connections_[9]; + const last = this.database.connections[9]; const closest = this.database.searchForClosest( checkConnection, 5, {x: 0, y: 0}).connection; chai.assert.equal(last, closest); @@ -250,7 +250,7 @@ suite('Connection Database', function() { const checkConnection = this.createCheckConnection(0, 10); - const last = this.database.connections_[9]; + const last = this.database.connections[9]; const closest = this.database.searchForClosest( checkConnection, 5, {x: 0, y: 0}).connection; chai.assert.equal(last, closest); From c0cceb56e6ebeab3b3e2ed8515f7964d3b8f1519 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Tue, 11 Apr 2023 12:07:10 -0700 Subject: [PATCH 016/161] chore: delete update metadata action (#6969) --- .github/workflows/update_metadata.yml | 46 --------------------------- 1 file changed, 46 deletions(-) delete mode 100644 .github/workflows/update_metadata.yml diff --git a/.github/workflows/update_metadata.yml b/.github/workflows/update_metadata.yml deleted file mode 100644 index 33e58a285..000000000 --- a/.github/workflows/update_metadata.yml +++ /dev/null @@ -1,46 +0,0 @@ -# This workflow updates the check_metadata.sh script, which compares the current -# size of build artifacts against their size in the previous version of Blockly. - -name: Update Metadata - -on: [workflow_dispatch] - -permissions: - contents: read - -jobs: - update-metadata: - permissions: - contents: write # for peter-evans/create-pull-request to create branch - pull-requests: write # for peter-evans/create-pull-request to create a PR - runs-on: ubuntu-latest - - steps: - - name: Check Out Blockly - uses: actions/checkout@v3 - with: - ref: 'develop' - - - name: Use Node.js 16.x - uses: actions/setup-node@v3 - with: - node-version: 16.x - - - name: Build Blockly - run: npm run build:compressed - - - name: Build Blockly blocks - run: npm run build:blocks - - - name: Update Metadata - run: source ./tests/scripts/update_metadata.sh - - - name: Create Pull Request - uses: peter-evans/create-pull-request@38e0b6e68b4c852a5500a94740f0e535e0d7ba54 - with: - commit-message: Update build artifact sizes in check_metadata.sh - delete-branch: true - title: Update build artifact sizes in check_metadata.sh - - - name: View Pull Request - run: echo "View Pull Request - ${{ steps.cpr.outputs.pull-request-url }}" \ No newline at end of file From 8ade26148cc4a4263df8367c939236a9caa1d54a Mon Sep 17 00:00:00 2001 From: Neil Fraser Date: Wed, 12 Apr 2023 19:00:41 +0200 Subject: [PATCH 017/161] Fix offset location of connection ripple (#6973) Resolves issue #6972 --- core/insertion_marker_manager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/insertion_marker_manager.ts b/core/insertion_marker_manager.ts index 7f53caa0d..fc25c87fd 100644 --- a/core/insertion_marker_manager.ts +++ b/core/insertion_marker_manager.ts @@ -186,11 +186,11 @@ export class InsertionMarkerManager { eventUtils.enable(); if (this.topBlock.rendered) { const inferiorConnection = local.isSuperior() ? closest : local; - blockAnimations.connectionUiEffect(inferiorConnection.getSourceBlock()); const rootBlock = this.topBlock.getRootBlock(); // bringToFront is incredibly expensive. Delay by at least a frame. requestAnimationFrame(() => { + blockAnimations.connectionUiEffect(inferiorConnection.getSourceBlock()); setTimeout(() => { rootBlock.bringToFront(); }, 0); From 5f8330e74ea758bd450508d971f496790d4b1925 Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Wed, 12 Apr 2023 11:19:41 -0700 Subject: [PATCH 018/161] chore: remove underscores from private properties and methods in keyboard nav and rendering (#6975) * chore: remove underscores in keyboard navigation * chore: remove private underscores from renderers --- core/keyboard_nav/ast_node.ts | 120 ++++++++++++++-------------- core/keyboard_nav/basic_cursor.ts | 12 +-- core/keyboard_nav/marker.ts | 26 +++--- core/renderers/common/constants.ts | 48 +++++------ core/renderers/common/marker_svg.ts | 32 ++++---- core/renderers/geras/highlighter.ts | 32 ++++---- core/renderers/geras/renderer.ts | 10 +-- core/renderers/zelos/constants.ts | 16 ++-- core/renderers/zelos/info.ts | 10 +-- core/renderers/zelos/marker_svg.ts | 32 ++++---- core/renderers/zelos/path_object.ts | 32 ++++---- tests/mocha/astnode_test.js | 32 ++++---- tests/mocha/cursor_test.js | 2 +- 13 files changed, 202 insertions(+), 202 deletions(-) diff --git a/core/keyboard_nav/ast_node.ts b/core/keyboard_nav/ast_node.ts index 624dc6a45..abffd77e4 100644 --- a/core/keyboard_nav/ast_node.ts +++ b/core/keyboard_nav/ast_node.ts @@ -40,14 +40,14 @@ export class ASTNode { * workspace. */ private static readonly DEFAULT_OFFSET_Y: number = -20; - private readonly type_: string; - private readonly isConnection_: boolean; - private readonly location_: IASTNodeLocation; + private readonly type: string; + private readonly isConnectionLocation: boolean; + private readonly location: IASTNodeLocation; /** The coordinate on the workspace. */ // AnyDuringMigration because: Type 'null' is not assignable to type // 'Coordinate'. - private wsCoordinate_: Coordinate = null as AnyDuringMigration; + private wsCoordinate: Coordinate = null as AnyDuringMigration; /** * @param type The type of the location. @@ -64,15 +64,15 @@ export class ASTNode { * The type of the location. * One of ASTNode.types */ - this.type_ = type; + this.type = type; /** Whether the location points to a connection. */ - this.isConnection_ = ASTNode.isConnectionType_(type); + this.isConnectionLocation = ASTNode.isConnectionType(type); /** The location of the AST node. */ - this.location_ = location; + this.location = location; - this.processParams_(opt_params || null); + this.processParams(opt_params || null); } /** @@ -80,12 +80,12 @@ export class ASTNode { * * @param params The user specified parameters. */ - private processParams_(params: Params|null) { + private processParams(params: Params|null) { if (!params) { return; } if (params.wsCoordinate) { - this.wsCoordinate_ = params.wsCoordinate; + this.wsCoordinate = params.wsCoordinate; } } @@ -98,7 +98,7 @@ export class ASTNode { * on. */ getLocation(): IASTNodeLocation { - return this.location_; + return this.location; } /** @@ -108,7 +108,7 @@ export class ASTNode { * @returns The type of the location. */ getType(): string { - return this.type_; + return this.type; } /** @@ -118,7 +118,7 @@ export class ASTNode { * workspace. */ getWsCoordinate(): Coordinate { - return this.wsCoordinate_; + return this.wsCoordinate; } /** @@ -128,7 +128,7 @@ export class ASTNode { * @internal */ isConnection(): boolean { - return this.isConnection_; + return this.isConnectionLocation; } /** @@ -139,8 +139,8 @@ export class ASTNode { * @returns The AST node holding the next field or connection or null if there * is no editable field or input connection after the given input. */ - private findNextForInput_(): ASTNode|null { - const location = this.location_ as Connection; + private findNextForInput(): ASTNode|null { + const location = this.location as Connection; const parentInput = location.getParentInput(); const block = parentInput!.getSourceBlock(); // AnyDuringMigration because: Argument of type 'Input | null' is not @@ -169,8 +169,8 @@ export class ASTNode { * @returns The AST node pointing to the next field or connection or null if * there is no editable field or input connection after the given input. */ - private findNextForField_(): ASTNode|null { - const location = this.location_ as Field; + private findNextForField(): ASTNode|null { + const location = this.location as Field; const input = location.getParentInput(); const block = location.getSourceBlock(); if (!block) { @@ -203,8 +203,8 @@ export class ASTNode { * * @returns The AST node holding the previous field or connection. */ - private findPrevForInput_(): ASTNode|null { - const location = this.location_ as Connection; + private findPrevForInput(): ASTNode|null { + const location = this.location as Connection; const parentInput = location.getParentInput(); const block = parentInput!.getSourceBlock(); // AnyDuringMigration because: Argument of type 'Input | null' is not @@ -232,8 +232,8 @@ export class ASTNode { * * @returns The AST node holding the previous input or field. */ - private findPrevForField_(): ASTNode|null { - const location = this.location_ as Field; + private findPrevForField(): ASTNode|null { + const location = this.location as Field; const parentInput = location.getParentInput(); const block = location.getSourceBlock(); if (!block) { @@ -270,7 +270,7 @@ export class ASTNode { * @returns The first block of the next stack or null if there are no blocks * on the workspace. */ - private navigateBetweenStacks_(forward: boolean): ASTNode|null { + private navigateBetweenStacks(forward: boolean): ASTNode|null { let curLocation = this.getLocation(); // TODO(#6097): Use instanceof checks to exit early for values of // curLocation that don't make sense. @@ -311,7 +311,7 @@ export class ASTNode { * @param block The block that we want to find the top connection on. * @returns The AST node containing the top connection. */ - private findTopASTNodeForBlock_(block: Block): ASTNode|null { + private findTopASTNodeForBlock(block: Block): ASTNode|null { const topConnection = getParentConnection(block); if (topConnection) { return ASTNode.createConnectionNode(topConnection); @@ -328,7 +328,7 @@ export class ASTNode { * @returns The AST node pointing to the input connection or the top block of * the stack this block is in. */ - private getOutAstNodeForBlock_(block: Block): ASTNode|null { + private getOutAstNodeForBlock(block: Block): ASTNode|null { if (!block) { return null; } @@ -359,7 +359,7 @@ export class ASTNode { * Null if there are no editable fields or inputs with connections on the * block. */ - private findFirstFieldOrInput_(block: Block): ASTNode|null { + private findFirstFieldOrInput(block: Block): ASTNode|null { const inputs = block.inputList; for (let i = 0; i < inputs.length; i++) { const input = inputs[i]; @@ -402,32 +402,32 @@ export class ASTNode { * workspace. Or null if there is no node to the right. */ next(): ASTNode|null { - switch (this.type_) { + switch (this.type) { case ASTNode.types.STACK: - return this.navigateBetweenStacks_(true); + return this.navigateBetweenStacks(true); case ASTNode.types.OUTPUT: { - const connection = this.location_ as Connection; + const connection = this.location as Connection; return ASTNode.createBlockNode(connection.getSourceBlock()); } case ASTNode.types.FIELD: - return this.findNextForField_(); + return this.findNextForField(); case ASTNode.types.INPUT: - return this.findNextForInput_(); + return this.findNextForInput(); case ASTNode.types.BLOCK: { - const block = this.location_ as Block; + const block = this.location as Block; const nextConnection = block.nextConnection; if (!nextConnection) return null; return ASTNode.createConnectionNode(nextConnection); } case ASTNode.types.PREVIOUS: { - const connection = this.location_ as Connection; + const connection = this.location as Connection; return ASTNode.createBlockNode(connection.getSourceBlock()); } case ASTNode.types.NEXT: { - const connection = this.location_ as Connection; + const connection = this.location as Connection; const targetConnection = connection.targetConnection; return ASTNode.createConnectionNode(targetConnection!); } @@ -444,9 +444,9 @@ export class ASTNode { * block. Or null if there is nothing below this node. */ in(): ASTNode|null { - switch (this.type_) { + switch (this.type) { case ASTNode.types.WORKSPACE: { - const workspace = this.location_ as Workspace; + const workspace = this.location as Workspace; const topBlocks = workspace.getTopBlocks(true); if (topBlocks.length > 0) { return ASTNode.createStackNode(topBlocks[0]); @@ -454,15 +454,15 @@ export class ASTNode { break; } case ASTNode.types.STACK: { - const block = this.location_ as Block; - return this.findTopASTNodeForBlock_(block); + const block = this.location as Block; + return this.findTopASTNodeForBlock(block); } case ASTNode.types.BLOCK: { - const block = this.location_ as Block; - return this.findFirstFieldOrInput_(block); + const block = this.location as Block; + return this.findFirstFieldOrInput(block); } case ASTNode.types.INPUT: { - const connection = this.location_ as Connection; + const connection = this.location as Connection; const targetConnection = connection.targetConnection; return ASTNode.createConnectionNode(targetConnection!); } @@ -478,27 +478,27 @@ export class ASTNode { * or block. Or null if no node exists to the left. null. */ prev(): ASTNode|null { - switch (this.type_) { + switch (this.type) { case ASTNode.types.STACK: - return this.navigateBetweenStacks_(false); + return this.navigateBetweenStacks(false); case ASTNode.types.OUTPUT: return null; case ASTNode.types.FIELD: - return this.findPrevForField_(); + return this.findPrevForField(); case ASTNode.types.INPUT: - return this.findPrevForInput_(); + return this.findPrevForInput(); case ASTNode.types.BLOCK: { - const block = this.location_ as Block; + const block = this.location as Block; const topConnection = getParentConnection(block); if (!topConnection) return null; return ASTNode.createConnectionNode(topConnection); } case ASTNode.types.PREVIOUS: { - const connection = this.location_ as Connection; + const connection = this.location as Connection; const targetConnection = connection.targetConnection; if (targetConnection && !targetConnection.getParentInput()) { return ASTNode.createConnectionNode(targetConnection); @@ -506,7 +506,7 @@ export class ASTNode { break; } case ASTNode.types.NEXT: { - const connection = this.location_ as Connection; + const connection = this.location as Connection; return ASTNode.createBlockNode(connection.getSourceBlock()); } } @@ -522,9 +522,9 @@ export class ASTNode { * block. Or null if we are at the workspace level. */ out(): ASTNode|null { - switch (this.type_) { + switch (this.type) { case ASTNode.types.STACK: { - const block = this.location_ as Block; + const block = this.location as Block; const blockPos = block.getRelativeToSurfaceXY(); // TODO: Make sure this is in the bounds of the workspace. const wsCoordinate = @@ -532,7 +532,7 @@ export class ASTNode { return ASTNode.createWorkspaceNode(block.workspace, wsCoordinate); } case ASTNode.types.OUTPUT: { - const connection = this.location_ as Connection; + const connection = this.location as Connection; const target = connection.targetConnection; if (target) { return ASTNode.createConnectionNode(target); @@ -540,7 +540,7 @@ export class ASTNode { return ASTNode.createStackNode(connection.getSourceBlock()); } case ASTNode.types.FIELD: { - const field = this.location_ as Field; + const field = this.location as Field; const block = field.getSourceBlock(); if (!block) { throw new Error( @@ -549,20 +549,20 @@ export class ASTNode { return ASTNode.createBlockNode(block); } case ASTNode.types.INPUT: { - const connection = this.location_ as Connection; + const connection = this.location as Connection; return ASTNode.createBlockNode(connection.getSourceBlock()); } case ASTNode.types.BLOCK: { - const block = this.location_ as Block; - return this.getOutAstNodeForBlock_(block); + const block = this.location as Block; + return this.getOutAstNodeForBlock(block); } case ASTNode.types.PREVIOUS: { - const connection = this.location_ as Connection; - return this.getOutAstNodeForBlock_(connection.getSourceBlock()); + const connection = this.location as Connection; + return this.getOutAstNodeForBlock(connection.getSourceBlock()); } case ASTNode.types.NEXT: { - const connection = this.location_ as Connection; - return this.getOutAstNodeForBlock_(connection.getSourceBlock()); + const connection = this.location as Connection; + return this.getOutAstNodeForBlock(connection.getSourceBlock()); } } @@ -575,7 +575,7 @@ export class ASTNode { * @param type The type to check. One of ASTNode.types. * @returns True if a node of the given type points to a connection. */ - private static isConnectionType_(type: string): boolean { + private static isConnectionType(type: string): boolean { switch (type) { case ASTNode.types.PREVIOUS: case ASTNode.types.NEXT: diff --git a/core/keyboard_nav/basic_cursor.ts b/core/keyboard_nav/basic_cursor.ts index 5f0b4dfa4..4a3fb4d17 100644 --- a/core/keyboard_nav/basic_cursor.ts +++ b/core/keyboard_nav/basic_cursor.ts @@ -116,7 +116,7 @@ export class BasicCursor extends Cursor { } else if (newNode) { return this.getNextNode_(newNode, isValid); } - const siblingOrParent = this.findSiblingOrParent_(node.out()); + const siblingOrParent = this.findSiblingOrParent(node.out()); if (isValid(siblingOrParent)) { return siblingOrParent; } else if (siblingOrParent) { @@ -145,7 +145,7 @@ export class BasicCursor extends Cursor { let newNode: ASTNode|null = node.prev(); if (newNode) { - newNode = this.getRightMostChild_(newNode); + newNode = this.getRightMostChild(newNode); } else { newNode = node.out(); } @@ -181,7 +181,7 @@ export class BasicCursor extends Cursor { * @param node The current position in the AST. * @returns The parent AST node or null if there are no valid parents. */ - private findSiblingOrParent_(node: ASTNode|null): ASTNode|null { + private findSiblingOrParent(node: ASTNode|null): ASTNode|null { if (!node) { return null; } @@ -189,7 +189,7 @@ export class BasicCursor extends Cursor { if (nextNode) { return nextNode; } - return this.findSiblingOrParent_(node.out()); + return this.findSiblingOrParent(node.out()); } /** @@ -199,7 +199,7 @@ export class BasicCursor extends Cursor { * @returns The right most child of the given node, or the node if no child * exists. */ - private getRightMostChild_(node: ASTNode|null): ASTNode|null { + private getRightMostChild(node: ASTNode|null): ASTNode|null { if (!node!.in()) { return node; } @@ -207,7 +207,7 @@ export class BasicCursor extends Cursor { while (newNode && newNode.next()) { newNode = newNode.next(); } - return this.getRightMostChild_(newNode); + return this.getRightMostChild(newNode); } } diff --git a/core/keyboard_nav/marker.ts b/core/keyboard_nav/marker.ts index d569f3637..da57e484d 100644 --- a/core/keyboard_nav/marker.ts +++ b/core/keyboard_nav/marker.ts @@ -30,7 +30,7 @@ export class Marker { /** The current location of the marker. */ // AnyDuringMigration because: Type 'null' is not assignable to type // 'ASTNode'. - private curNode_: ASTNode = null as AnyDuringMigration; + private curNode: ASTNode = null as AnyDuringMigration; /** * The object in charge of drawing the visual representation of the current @@ -38,7 +38,7 @@ export class Marker { */ // AnyDuringMigration because: Type 'null' is not assignable to type // 'MarkerSvg'. - private drawer_: MarkerSvg = null as AnyDuringMigration; + private drawer: MarkerSvg = null as AnyDuringMigration; /** The type of the marker. */ type = 'marker'; @@ -52,7 +52,7 @@ export class Marker { * @param drawer The object in charge of drawing the marker. */ setDrawer(drawer: MarkerSvg) { - this.drawer_ = drawer; + this.drawer = drawer; } /** @@ -61,7 +61,7 @@ export class Marker { * @returns The object in charge of drawing the marker. */ getDrawer(): MarkerSvg { - return this.drawer_; + return this.drawer; } /** @@ -70,7 +70,7 @@ export class Marker { * @returns The current field, connection, or block the marker is on. */ getCurNode(): ASTNode { - return this.curNode_; + return this.curNode; } /** @@ -81,10 +81,10 @@ export class Marker { * @param newNode The new location of the marker. */ setCurNode(newNode: ASTNode) { - const oldNode = this.curNode_; - this.curNode_ = newNode; - if (this.drawer_) { - this.drawer_.draw(oldNode, this.curNode_); + const oldNode = this.curNode; + this.curNode = newNode; + if (this.drawer) { + this.drawer.draw(oldNode, this.curNode); } } @@ -94,15 +94,15 @@ export class Marker { * @internal */ draw() { - if (this.drawer_) { - this.drawer_.draw(this.curNode_, this.curNode_); + if (this.drawer) { + this.drawer.draw(this.curNode, this.curNode); } } /** Hide the marker SVG. */ hide() { - if (this.drawer_) { - this.drawer_.hide(); + if (this.drawer) { + this.drawer.hide(); } } diff --git a/core/renderers/common/constants.ts b/core/renderers/common/constants.ts index 1408ccf1b..2c71ccf70 100644 --- a/core/renderers/common/constants.ts +++ b/core/renderers/common/constants.ts @@ -279,7 +279,7 @@ export class ConstantProvider { * The defs tag that contains all filters and patterns for this Blockly * instance. */ - private defs_: SVGElement|null = null; + private defs: SVGElement|null = null; /** * The ID of the emboss filter, or the empty string if no filter is set. @@ -287,7 +287,7 @@ export class ConstantProvider { embossFilterId = ''; /** The element to use for highlighting, or null if not set. */ - private embossFilter_: SVGElement|null = null; + private embossFilter: SVGElement|null = null; /** * The ID of the disabled pattern, or the empty string if no pattern is set. @@ -297,7 +297,7 @@ export class ConstantProvider { /** * The element to use for disabled blocks, or null if not set. */ - private disabledPattern_: SVGElement|null = null; + private disabledPattern: SVGElement|null = null; /** * The ID of the debug filter, or the empty string if no pattern is set. @@ -307,10 +307,10 @@ export class ConstantProvider { /** * The element to use for a debug highlight, or null if not set. */ - private debugFilter_: SVGElement|null = null; + private debugFilter: SVGElement|null = null; /** The
- - + + @@ -138,13 +138,16 @@ 'tests/playgrounds/screenshot.js', 'node_modules/@blockly/dev-tools/dist/index.js', ], - } + };
-