-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor!: remove constants for internal constants #5897
Merged
alschmiedt
merged 19 commits into
google:develop
from
alschmiedt:more_internal_constants
Feb 9, 2022
Merged
Changes from 13 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
35e0cd2
refactor!: remove unused drag contents
alschmiedt 367a8a1
refactor!: move writable constants to constants.js
alschmiedt c545d0e
chore: ran clang format
alschmiedt 149f43b
refactor: move the values from constants to config
alschmiedt 7f4d752
Merge branch 'develop' of https://github.com/google/blockly into more…
alschmiedt 1a85445
chore: updates after merge
alschmiedt 623317b
chore: re organize imports because alphabetizing is apparently difficult
alschmiedt 31874fa
chore: run format
alschmiedt 2b65dd8
chore: add config.js
alschmiedt 3234d11
chore: clean up after merge
alschmiedt f35ba5f
chore: clean up types
alschmiedt 6e44de5
chore: fix types
alschmiedt 9bbb53c
chore: run format
alschmiedt 2a1be5d
Merge branch 'develop' of https://github.com/google/blockly into more…
alschmiedt 4627481
chore: fix up after merge
alschmiedt 2720a83
chore: more cleanup
alschmiedt fe7e698
refactor: move SPRITE into its own file
alschmiedt d8bcbb2
chore: cleanup
alschmiedt 1691f18
fix: add file
alschmiedt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/** | ||
* @license | ||
* Copyright 2022 Google LLC | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/** | ||
* @fileoverview All the values that we expect developers to be able to change | ||
* before injecting Blockly. Changing these values during run time is not | ||
* generally recommended. | ||
*/ | ||
'use strict'; | ||
|
||
/** | ||
* All the values that we expect developers to be able to change | ||
* before injecting Blockly. Changing these values during run time is not | ||
* generally recommended. | ||
* @namespace Blockly.config | ||
*/ | ||
goog.module('Blockly.config'); | ||
|
||
|
||
/** | ||
* All the values that we expect developers to be able to change | ||
* before injecting Blockly. | ||
* @typedef {{ | ||
* dragRadius: number, | ||
* flyoutDragRadius: number, | ||
* snapRadius: number, | ||
* currentConnectionPreference: number, | ||
* bumpDelay: number, | ||
* connectingSnapRadius: number | ||
* }} | ||
*/ | ||
let Config; // eslint-disable-line no-unused-vars | ||
|
||
/** | ||
* Default snap radius. | ||
* @type {number} | ||
*/ | ||
const DEFAULT_SNAP_RADIUS = 28; | ||
|
||
/** | ||
* Object holding all the values on Blockly that we expect developers to be | ||
* able to change. | ||
* @type {Config} | ||
*/ | ||
const config = { | ||
/** | ||
* Number of pixels the mouse must move before a drag starts. | ||
* @alias Blockly.config.dragRadius | ||
*/ | ||
dragRadius: 5, | ||
/** | ||
* Number of pixels the mouse must move before a drag/scroll starts from the | ||
* flyout. Because the drag-intention is determined when this is reached, it | ||
* is larger than dragRadius so that the drag-direction is clearer. | ||
* @alias Blockly.config.flyoutDragRadius | ||
*/ | ||
flyoutDragRadius: 10, | ||
/** | ||
* Maximum misalignment between connections for them to snap together. | ||
* @alias Blockly.config.snapRadius | ||
*/ | ||
snapRadius: DEFAULT_SNAP_RADIUS, | ||
/** | ||
* Maximum misalignment between connections for them to snap together. | ||
* This should be the same as the snap radius. | ||
* @alias Blockly.config.connectingSnapRadius | ||
*/ | ||
connectingSnapRadius: DEFAULT_SNAP_RADIUS, | ||
/** | ||
* How much to prefer staying connected to the current connection over moving | ||
* to a new connection. The current previewed connection is considered to be | ||
* this much closer to the matching connection on the block than it actually | ||
* is. | ||
* @alias Blockly.config.currentConnectionPreference | ||
*/ | ||
currentConnectionPreference: 8, | ||
/** | ||
* Delay in ms between trigger and bumping unconnected block out of alignment. | ||
* @alias Blockly.config.bumpDelay | ||
*/ | ||
bumpDelay: 250, | ||
}; | ||
|
||
exports.config = config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this export be marked as deprecated, or deleted outright?
The entry in
renamings.js
suggests that we expect developers to useBlockly.constants.SPRITE
rather thanBlockly.SPRITE
. I would not suggest creating aset
accessor just to print a deprecation warning, but perhaps putting a comment about it so we remember to delete it in due course, if you don't want to do so now?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I think it is actually fine to delete now. I looked back through GitHub and didn't see anyone using it externally.
This makes me think though- do we actually want to keep
internal_constants.js
around for values like this? I think the original issue says we should remove all values from internal_constants, but I think it serves a different purpose thanconstants
which are public and we expect developers to use.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems like a good idea to me: don't make public anything which doesn't need to be. An alternative might be to introduce a
core/sprite.js
(Blockly.sprite
perhaps?) that is imported by the two modules which need these constants. (I had a look to see if there were any other shared dependencies which might be a suitable home; the only one that looked at all promising wascore/positionable_helpers.js
(Blockly.uiPosition
), but that doesn't seem quite right.Maybe @rachel-fenichel has an opinion about this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with deleting it from exports now and eventually moving it to its own file (core/sprite.js is reasonable). We certainly don't need to keep internal constants around long-term--everything in it should eventually end up in a more logical place.