Skip to content
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 unused constants #5889

Merged
merged 2 commits into from
Jan 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions core/blockly.js
Original file line number Diff line number Diff line change
Expand Up @@ -655,19 +655,14 @@ const bindEventWithChecks_ = function(
exports.bindEventWithChecks_ = bindEventWithChecks_;

// Aliases to allow external code to access these values for legacy reasons.
exports.LINE_MODE_MULTIPLIER = internalConstants.LINE_MODE_MULTIPLIER;
exports.PAGE_MODE_MULTIPLIER = internalConstants.PAGE_MODE_MULTIPLIER;
exports.DRAG_RADIUS = internalConstants.DRAG_RADIUS;
exports.FLYOUT_DRAG_RADIUS = internalConstants.FLYOUT_DRAG_RADIUS;
exports.SNAP_RADIUS = internalConstants.SNAP_RADIUS;
exports.CONNECTING_SNAP_RADIUS = internalConstants.CONNECTING_SNAP_RADIUS;
exports.CURRENT_CONNECTION_PREFERENCE =
internalConstants.CURRENT_CONNECTION_PREFERENCE;
exports.BUMP_DELAY = internalConstants.BUMP_DELAY;
exports.BUMP_RANDOMNESS = internalConstants.BUMP_RANDOMNESS;
exports.COLLAPSE_CHARS = internalConstants.COLLAPSE_CHARS;
exports.LONGPRESS = internalConstants.LONGPRESS;
exports.SOUND_LIMIT = internalConstants.SOUND_LIMIT;
exports.DRAG_STACK = internalConstants.DRAG_STACK;
exports.SPRITE = internalConstants.SPRITE;
exports.DRAG_NONE = internalConstants.DRAG_NONE;
Expand Down
27 changes: 22 additions & 5 deletions core/browser_events.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
goog.module('Blockly.browserEvents');

const Touch = goog.require('Blockly.Touch');
const internalConstants = goog.require('Blockly.internalConstants');
const userAgent = goog.require('Blockly.utils.userAgent');
const {globalThis} = goog.require('Blockly.utils.global');

Expand All @@ -30,6 +29,24 @@ const {globalThis} = goog.require('Blockly.utils.global');
let Data;
exports.Data = Data;

/**
* The multiplier for scroll wheel deltas using the line delta mode.
* See https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
* for more information on deltaMode.
* @type {number}
* @const
*/
const LINE_MODE_MULTIPLIER = 40;

/**
* The multiplier for scroll wheel deltas using the page delta mode.
* See https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
* for more information on deltaMode.
* @type {number}
* @const
*/
const PAGE_MODE_MULTIPLIER = 125;

/**
* Bind an event handler that can be ignored if it is not part of the active
* touch stream.
Expand Down Expand Up @@ -254,13 +271,13 @@ const getScrollDeltaPixels = function(e) {
return {x: e.deltaX, y: e.deltaY};
case 0x01: // Line mode.
return {
x: e.deltaX * internalConstants.LINE_MODE_MULTIPLIER,
y: e.deltaY * internalConstants.LINE_MODE_MULTIPLIER,
x: e.deltaX * LINE_MODE_MULTIPLIER,
y: e.deltaY * LINE_MODE_MULTIPLIER,
};
case 0x02: // Page mode.
return {
x: e.deltaX * internalConstants.PAGE_MODE_MULTIPLIER,
y: e.deltaY * internalConstants.PAGE_MODE_MULTIPLIER,
x: e.deltaX * PAGE_MODE_MULTIPLIER,
y: e.deltaY * PAGE_MODE_MULTIPLIER,
};
}
};
Expand Down
38 changes: 0 additions & 38 deletions core/internal_constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,6 @@ goog.module('Blockly.internalConstants');
const {ConnectionType} = goog.require('Blockly.ConnectionType');


/**
* The multiplier for scroll wheel deltas using the line delta mode.
* @type {number}
* @alias Blockly.internalConstants.LINE_MODE_MULTIPLIER
*/
const LINE_MODE_MULTIPLIER = 40;
exports.LINE_MODE_MULTIPLIER = LINE_MODE_MULTIPLIER;

/**
* The multiplier for scroll wheel deltas using the page delta mode.
* @type {number}
* @alias Blockly.internalConstants.PAGE_MODE_MULTIPLIER
*/
const PAGE_MODE_MULTIPLIER = 125;
exports.PAGE_MODE_MULTIPLIER = PAGE_MODE_MULTIPLIER;

/**
* Number of pixels the mouse must move before a drag starts.
* @alias Blockly.internalConstants.DRAG_RADIUS
Expand Down Expand Up @@ -84,35 +68,13 @@ exports.CURRENT_CONNECTION_PREFERENCE = CURRENT_CONNECTION_PREFERENCE;
const BUMP_DELAY = 250;
exports.BUMP_DELAY = BUMP_DELAY;

/**
* Maximum randomness in workspace units for bumping a block.
* @alias Blockly.internalConstants.BUMP_RANDOMNESS
*/
const BUMP_RANDOMNESS = 10;
exports.BUMP_RANDOMNESS = BUMP_RANDOMNESS;

/**
* Number of characters to truncate a collapsed block to.
* @alias Blockly.internalConstants.COLLAPSE_CHARS
*/
const COLLAPSE_CHARS = 30;
exports.COLLAPSE_CHARS = COLLAPSE_CHARS;

/**
* Length in ms for a touch to become a long press.
* @alias Blockly.internalConstants.LONGPRESS
*/
const LONGPRESS = 750;
exports.LONGPRESS = LONGPRESS;

/**
* Prevent a sound from playing if another sound preceded it within this many
* milliseconds.
* @alias Blockly.internalConstants.SOUND_LIMIT
*/
const SOUND_LIMIT = 100;
exports.SOUND_LIMIT = SOUND_LIMIT;

/**
* When dragging a block out of a stack, split the stack in two (true), or drag
* out the block healing the stack (false).
Expand Down
12 changes: 9 additions & 3 deletions core/rendered_connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ RenderedConnection.TrackedState = {
TRACKED: 1,
};

/**
* Maximum randomness in workspace units for bumping a block.
* @const
*/
const BUMP_RANDOMNESS = 10;

/**
* Dispose of this connection. Remove it from the database (if it is
* tracked) and call the super-function to deal with connected blocks.
Expand Down Expand Up @@ -181,18 +187,18 @@ RenderedConnection.prototype.bumpAwayFrom = function(staticConnection) {
const selected = common.getSelected() == rootBlock;
selected || rootBlock.addSelect();
let dx = (staticConnection.x + internalConstants.SNAP_RADIUS +
Math.floor(Math.random() * internalConstants.BUMP_RANDOMNESS)) -
Math.floor(Math.random() * BUMP_RANDOMNESS)) -
this.x;
let dy = (staticConnection.y + internalConstants.SNAP_RADIUS +
Math.floor(Math.random() * internalConstants.BUMP_RANDOMNESS)) -
Math.floor(Math.random() * BUMP_RANDOMNESS)) -
this.y;
if (reverse) {
// When reversing a bump due to an uneditable block, bump up.
dy = -dy;
}
if (rootBlock.RTL) {
dx = (staticConnection.x - internalConstants.SNAP_RADIUS -
Math.floor(Math.random() * internalConstants.BUMP_RANDOMNESS)) -
Math.floor(Math.random() * BUMP_RANDOMNESS)) -
this.x;
}
rootBlock.moveBy(dx, dy);
Expand Down
9 changes: 7 additions & 2 deletions core/touch.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,18 @@
*/
goog.module('Blockly.Touch');

const internalConstants = goog.require('Blockly.internalConstants');
const utilsString = goog.require('Blockly.utils.string');
/* eslint-disable-next-line no-unused-vars */
const {Gesture} = goog.requireType('Blockly.Gesture');
const {globalThis} = goog.require('Blockly.utils.global');


/**
* Length in ms for a touch to become a long press.
* @const
*/
const LONGPRESS = 750;

/**
* Whether touch is enabled in the browser.
* Copied from Closure's goog.events.BrowserFeature.TOUCH_ENABLED
Expand Down Expand Up @@ -107,7 +112,7 @@ const longStart = function(e, gesture) {
if (gesture) {
gesture.handleRightClick(e);
}
}, internalConstants.LONGPRESS);
}, LONGPRESS);
};
exports.longStart = longStart;

Expand Down
12 changes: 9 additions & 3 deletions core/workspace_audio.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,19 @@
*/
goog.module('Blockly.WorkspaceAudio');

const internalConstants = goog.require('Blockly.internalConstants');
const userAgent = goog.require('Blockly.utils.userAgent');
/* eslint-disable-next-line no-unused-vars */
const {WorkspaceSvg} = goog.requireType('Blockly.WorkspaceSvg');
const {globalThis} = goog.require('Blockly.utils.global');


/**
* Prevent a sound from playing if another sound preceded it within this many
* milliseconds.
* @const
*/
const SOUND_LIMIT = 100;

/**
* Class for loading, storing, and playing audio for a workspace.
* @alias Blockly.WorkspaceAudio
Expand Down Expand Up @@ -55,6 +61,7 @@ class WorkspaceAudio {
*/
this.lastSound_ = null;
}

/**
* Dispose of this audio manager.
* @package
Expand Down Expand Up @@ -137,8 +144,7 @@ class WorkspaceAudio {
if (sound) {
// Don't play one sound on top of another.
const now = new Date;
if (this.lastSound_ !== null &&
now - this.lastSound_ < internalConstants.SOUND_LIMIT) {
if (this.lastSound_ !== null && now - this.lastSound_ < SOUND_LIMIT) {
return;
}
this.lastSound_ = now;
Expand Down
4 changes: 2 additions & 2 deletions tests/deps.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.