mirror of
https://github.com/google/blockly.git
synced 2026-03-11 15:50:10 +01:00
refactor!: remove unused constants from internalConstants (#5889)
This commit is contained in:
@@ -655,8 +655,6 @@ 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;
|
||||
@@ -664,10 +662,7 @@ 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;
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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.
|
||||
@@ -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,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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
|
||||
@@ -84,13 +68,6 @@ 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
|
||||
@@ -98,21 +75,6 @@ exports.BUMP_RANDOMNESS = BUMP_RANDOMNESS;
|
||||
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).
|
||||
|
||||
@@ -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.
|
||||
@@ -181,10 +187,10 @@ 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.
|
||||
@@ -192,7 +198,7 @@ RenderedConnection.prototype.bumpAwayFrom = function(staticConnection) {
|
||||
}
|
||||
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);
|
||||
|
||||
@@ -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
|
||||
@@ -107,7 +112,7 @@ const longStart = function(e, gesture) {
|
||||
if (gesture) {
|
||||
gesture.handleRightClick(e);
|
||||
}
|
||||
}, internalConstants.LONGPRESS);
|
||||
}, LONGPRESS);
|
||||
};
|
||||
exports.longStart = longStart;
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -55,6 +61,7 @@ class WorkspaceAudio {
|
||||
*/
|
||||
this.lastSound_ = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispose of this audio manager.
|
||||
* @package
|
||||
@@ -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;
|
||||
|
||||
@@ -222,7 +222,7 @@ goog.addDependency('../../core/toolbox/separator.js', ['Blockly.ToolboxSeparator
|
||||
goog.addDependency('../../core/toolbox/toolbox.js', ['Blockly.Toolbox'], ['Blockly.BlockSvg', 'Blockly.CollapsibleToolboxCategory', 'Blockly.ComponentManager', 'Blockly.Css', 'Blockly.DeleteArea', 'Blockly.Events.ToolboxItemSelect', 'Blockly.Events.utils', 'Blockly.IAutoHideable', 'Blockly.IKeyboardAccessible', 'Blockly.IStyleable', 'Blockly.IToolbox', 'Blockly.Options', 'Blockly.Touch', 'Blockly.browserEvents', 'Blockly.common', 'Blockly.registry', 'Blockly.utils.KeyCodes', 'Blockly.utils.Rect', 'Blockly.utils.aria', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.toolbox'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/toolbox/toolbox_item.js', ['Blockly.ToolboxItem'], ['Blockly.IToolboxItem', 'Blockly.utils.idGenerator'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/tooltip.js', ['Blockly.Tooltip'], ['Blockly.browserEvents', 'Blockly.common', 'Blockly.utils.deprecation', 'Blockly.utils.string'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/touch.js', ['Blockly.Touch'], ['Blockly.internalConstants', 'Blockly.utils.global', 'Blockly.utils.string'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/touch.js', ['Blockly.Touch'], ['Blockly.utils.global', 'Blockly.utils.string'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/touch_gesture.js', ['Blockly.TouchGesture'], ['Blockly.Gesture', 'Blockly.Touch', 'Blockly.browserEvents', 'Blockly.utils.Coordinate', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/trashcan.js', ['Blockly.Trashcan'], ['Blockly.ComponentManager', 'Blockly.DeleteArea', 'Blockly.Events.TrashcanOpen', 'Blockly.Events.utils', 'Blockly.IAutoHideable', 'Blockly.IPositionable', 'Blockly.Options', 'Blockly.browserEvents', 'Blockly.internalConstants', 'Blockly.registry', 'Blockly.uiPosition', 'Blockly.utils.Rect', 'Blockly.utils.Size', 'Blockly.utils.Svg', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.toolbox'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/utils.js', ['Blockly.utils'], ['Blockly.Extensions', 'Blockly.browserEvents', 'Blockly.common', 'Blockly.utils.Coordinate', 'Blockly.utils.KeyCodes', 'Blockly.utils.Metrics', 'Blockly.utils.Rect', 'Blockly.utils.Size', 'Blockly.utils.Svg', 'Blockly.utils.aria', 'Blockly.utils.array', 'Blockly.utils.colour', 'Blockly.utils.deprecation', 'Blockly.utils.dom', 'Blockly.utils.global', 'Blockly.utils.idGenerator', 'Blockly.utils.math', 'Blockly.utils.object', 'Blockly.utils.parsing', 'Blockly.utils.string', 'Blockly.utils.style', 'Blockly.utils.svgMath', 'Blockly.utils.svgPaths', 'Blockly.utils.toolbox', 'Blockly.utils.userAgent', 'Blockly.utils.xml'], {'lang': 'es6', 'module': 'goog'});
|
||||
@@ -256,7 +256,7 @@ goog.addDependency('../../core/variables_dynamic.js', ['Blockly.VariablesDynamic
|
||||
goog.addDependency('../../core/warning.js', ['Blockly.Warning'], ['Blockly.Bubble', 'Blockly.Events.BubbleOpen', 'Blockly.Events.utils', 'Blockly.Icon', 'Blockly.utils.Svg', 'Blockly.utils.dom', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/widgetdiv.js', ['Blockly.WidgetDiv'], ['Blockly.common', 'Blockly.utils.deprecation', 'Blockly.utils.dom'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/workspace.js', ['Blockly.Workspace'], ['Blockly.ConnectionChecker', 'Blockly.Events.utils', 'Blockly.IASTNodeLocation', 'Blockly.Options', 'Blockly.VariableMap', 'Blockly.registry', 'Blockly.utils.array', 'Blockly.utils.idGenerator', 'Blockly.utils.math'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/workspace_audio.js', ['Blockly.WorkspaceAudio'], ['Blockly.internalConstants', 'Blockly.utils.global', 'Blockly.utils.userAgent'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/workspace_audio.js', ['Blockly.WorkspaceAudio'], ['Blockly.utils.global', 'Blockly.utils.userAgent'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/workspace_comment.js', ['Blockly.WorkspaceComment'], ['Blockly.Events.CommentChange', 'Blockly.Events.CommentCreate', 'Blockly.Events.CommentDelete', 'Blockly.Events.CommentMove', 'Blockly.Events.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.idGenerator', 'Blockly.utils.xml'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/workspace_comment_svg.js', ['Blockly.WorkspaceCommentSvg'], ['Blockly.ContextMenu', 'Blockly.Css', 'Blockly.Events.CommentCreate', 'Blockly.Events.CommentDelete', 'Blockly.Events.CommentMove', 'Blockly.Events.Selected', 'Blockly.Events.utils', 'Blockly.IBoundedElement', 'Blockly.IBubble', 'Blockly.ICopyable', 'Blockly.Touch', 'Blockly.WorkspaceComment', 'Blockly.browserEvents', 'Blockly.common', 'Blockly.utils.Coordinate', 'Blockly.utils.Rect', 'Blockly.utils.Svg', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.svgMath'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/workspace_drag_surface_svg.js', ['Blockly.WorkspaceDragSurfaceSvg'], ['Blockly.utils.Svg', 'Blockly.utils.dom', 'Blockly.utils.svgMath'], {'lang': 'es6', 'module': 'goog'});
|
||||
|
||||
Reference in New Issue
Block a user