From d3447ea5653a21cf0b33cd4cef44ea3168f0ed20 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Mon, 3 Oct 2022 11:21:52 -0700 Subject: [PATCH] fix!: Update deprecations for the new release. (#6470) * chore: bump early deprecations to v10 * fixup * fixup * chore: remove deprecated properties * chore: add missing @deprecated tags * chore: format * chore: format * chore: fix import --- core/block_drag_surface.ts | 6 +- core/blockly.ts | 29 +++----- core/css.ts | 15 +--- core/generator.ts | 5 +- core/main.js | 10 ++- core/renderers/common/block_rendering.ts | 34 --------- core/renderers/common/debug.ts | 6 +- core/utils.ts | 92 ------------------------ core/utils/object.ts | 8 ++- core/utils/string.ts | 2 +- core/utils/style.ts | 4 +- core/utils/svg_math.ts | 26 +------ core/workspace_svg.ts | 13 ---- 13 files changed, 34 insertions(+), 216 deletions(-) diff --git a/core/block_drag_surface.ts b/core/block_drag_surface.ts index 092bbb820..cfcce75cd 100644 --- a/core/block_drag_surface.ts +++ b/core/block_drag_surface.ts @@ -75,7 +75,11 @@ export class BlockDragSurfaceSvg { this.dragGroup_ = dom.createSvgElement(Svg.G, {}, this.svg_ as SVGElement); } - /** Create the drag surface and inject it into the container. */ + /** + * Create the drag surface and inject it into the container. + * + * @deprecated The DOM is automatically created by the constructor. + */ createDom() { // No alternative provided, because now the dom is just automatically // created in the constructor now. diff --git a/core/blockly.ts b/core/blockly.ts index b1d2cc20d..0682f729d 100644 --- a/core/blockly.ts +++ b/core/blockly.ts @@ -345,23 +345,12 @@ export const defineBlocksWithJsonArray = common.defineBlocksWithJsonArray; */ export const setParentContainer = common.setParentContainer; -/** - * Returns the dimensions of the specified SVG image. - * - * @param svg SVG image. - * @returns Contains width and height properties. - * @deprecated Use workspace.setCachedParentSvgSize. (2021 March 5) - * @see Blockly.WorkspaceSvg.setCachedParentSvgSize - * @alias Blockly.svgSize - */ -export const svgSize = svgMath.svgSize; - /** * Size the workspace when the contents change. This also updates * scrollbars accordingly. * * @param workspace The workspace to resize. - * @deprecated Use workspace.resizeContents. (2021 December) + * @deprecated Use **workspace.resizeContents** instead. * @see Blockly.WorkspaceSvg.resizeContents * @alias Blockly.resizeSvgContents */ @@ -377,7 +366,7 @@ export const resizeSvgContents = resizeSvgContentsLocal; * Copy a block or workspace comment onto the local clipboard. * * @param toCopy Block or Workspace Comment to be copied. - * @deprecated Use Blockly.clipboard.copy(). (2021 December) + * @deprecated Use **Blockly.clipboard.copy** instead. * @see Blockly.clipboard.copy * @alias Blockly.copy */ @@ -392,7 +381,7 @@ export function copy(toCopy: ICopyable) { * Paste a block or workspace comment on to the main workspace. * * @returns True if the paste was successful, false otherwise. - * @deprecated Use Blockly.clipboard.paste(). (2021 December) + * @deprecated Use **Blockly.clipboard.paste** instead. * @see Blockly.clipboard.paste * @alias Blockly.paste */ @@ -407,7 +396,7 @@ export function paste(): boolean { * Duplicate this block and its children, or a workspace comment. * * @param toDuplicate Block or Workspace Comment to be copied. - * @deprecated Use Blockly.clipboard.duplicate(). (2021 December) + * @deprecated Use **Blockly.clipboard.duplicate** instead. * @see Blockly.clipboard.duplicate * @alias Blockly.duplicate */ @@ -423,7 +412,7 @@ export function duplicate(toDuplicate: ICopyable) { * * @param str Input string. * @returns True if number, false otherwise. - * @deprecated Use Blockly.utils.string.isNumber(str). (2021 December) + * @deprecated Use **Blockly.utils.string.isNumber** instead. * @see Blockly.utils.string.isNumber * @alias Blockly.isNumber */ @@ -439,7 +428,7 @@ export function isNumber(str: string): boolean { * * @param hue Hue on a colour wheel (0-360). * @returns RGB code, e.g. '#5ba65b'. - * @deprecated Use Blockly.utils.colour.hueToHex(). (2021 December) + * @deprecated Use **Blockly.utils.colour.hueToHex** instead. * @see Blockly.utils.colour.hueToHex * @alias Blockly.hueToHex */ @@ -461,7 +450,7 @@ export function hueToHex(hue: number): string { * @param thisObject The value of 'this' in the function. * @param func Function to call when event is triggered. * @returns Opaque data that can be passed to unbindEvent_. - * @deprecated Use Blockly.browserEvents.bind(). (December 2021) + * @deprecated Use **Blockly.browserEvents.bind** instead. * @see Blockly.browserEvents.bind * @alias Blockly.bindEvent_ */ @@ -480,7 +469,7 @@ export function bindEvent_( * @param bindData Opaque data from bindEvent_. * This list is emptied during the course of calling this function. * @returns The function call. - * @deprecated Use Blockly.browserEvents.unbind(). (December 2021) + * @deprecated Use **Blockly.browserEvents.unbind** instead. * @see browserEvents.unbind * @alias Blockly.unbindEvent_ */ @@ -508,7 +497,7 @@ export function unbindEvent_(bindData: browserEvents.Data): Function { * the default handler. False by default. If opt_noPreventDefault is * provided, opt_noCaptureIdentifier must also be provided. * @returns Opaque data that can be passed to unbindEvent_. - * @deprecated Use Blockly.browserEvents.conditionalBind(). (December 2021) + * @deprecated Use **Blockly.browserEvents.conditionalBind** instead. * @see browserEvents.conditionalBind * @alias Blockly.bindEventWithChecks_ */ diff --git a/core/css.ts b/core/css.ts index 02c4e2a9d..4d7917d2d 100644 --- a/core/css.ts +++ b/core/css.ts @@ -12,8 +12,6 @@ import * as goog from '../closure/goog/goog.js'; goog.declareModuleId('Blockly.Css'); -import * as deprecation from './utils/deprecation.js'; - /** Has CSS already been injected? */ let injected = false; @@ -25,20 +23,11 @@ let injected = false; * @param cssContent Multiline CSS string or an array of single lines of CSS. * @alias Blockly.Css.register */ -export function register(cssContent: string|string[]) { +export function register(cssContent: string) { if (injected) { throw Error('CSS already injected'); } - - if (Array.isArray(cssContent)) { - deprecation.warn( - 'Registering CSS by passing an array of strings', 'September 2021', - 'September 2022', 'css.register passing a multiline string'); - content += '\n' + cssContent.join('\n'); - } else { - // Add new cssContent in the global content. - content += '\n' + cssContent; - } + content += '\n' + cssContent; } /** diff --git a/core/generator.ts b/core/generator.ts index 443af0ff8..1d47d43c2 100644 --- a/core/generator.ts +++ b/core/generator.ts @@ -526,13 +526,12 @@ Object.defineProperties(Generator.prototype, { /** @returns Name database. */ get(this: Generator): Names | undefined { - deprecation.warn( - 'variableDB_', 'May 2021', 'September 2022', 'nameDB_'); + deprecation.warn('variableDB_', 'version 9', 'version 10', 'nameDB_'); return this.nameDB_; }, /** @param nameDb New name database. */ set(this: Generator, nameDb: Names|undefined) { - deprecation.warn('variableDB_', 'May 2021', 'September2022', 'nameDB_'); + deprecation.warn('variableDB_', 'version 9', 'version 10', 'nameDB_'); this.nameDB_ = nameDb; }, }), diff --git a/core/main.js b/core/main.js index 280920375..af34084a8 100644 --- a/core/main.js +++ b/core/main.js @@ -86,13 +86,13 @@ Object.defineProperties(Blockly, { mainWorkspace: { set: function(x) { deprecation.warn( - 'Blockly.mainWorkspace', 'August 2022', 'September 2022', + 'Blockly.mainWorkspace', 'version 9', 'version 10', 'Blockly.getMainWorkspace'); common.setMainWorkspace(x); }, get: function() { deprecation.warn( - 'Blockly.mainWorkspace', 'August 2022', 'September 2022', + 'Blockly.mainWorkspace', 'version 9', 'version 10', 'Blockly.getMainWorkspace'); return common.getMainWorkspace(); }, @@ -130,14 +130,12 @@ Object.defineProperties(Blockly, { selected: { get: function() { deprecation.warn( - 'Blockly.selected', 'August 2022', 'September 2022', - 'Blockly.getSelected'); + 'Blockly.selected', 'version 9', 'version 10', 'Blockly.getSelected'); return common.getSelected(); }, set: function(newSelection) { deprecation.warn( - 'Blockly.selected', 'August 2022', 'September 2022', - 'Blockly.getSelected'); + 'Blockly.selected', 'version 9', 'version 10', 'Blockly.getSelected'); common.setSelected(newSelection); }, }, diff --git a/core/renderers/common/block_rendering.ts b/core/renderers/common/block_rendering.ts index 2af3a97da..3700bfa91 100644 --- a/core/renderers/common/block_rendering.ts +++ b/core/renderers/common/block_rendering.ts @@ -48,24 +48,6 @@ import {MarkerSvg} from './marker_svg.js'; import {PathObject} from './path_object.js'; import {Renderer} from './renderer.js'; - -/** - * Returns whether the debugger is turned on. - * - * @returns Whether the debugger is turned on. - * @alias Blockly.blockRendering.isDebuggerEnabled - * @deprecated Use the debug renderer in **\@blockly/dev-tools** (See {@link - * https://www.npmjs.com/package/@blockly/dev-tools}.) - * @internal - */ -export function isDebuggerEnabled(): boolean { - deprecation.warn( - 'Blockly.blockRendering.isDebuggerEnabled()', 'September 2021', - 'September 2022', - 'the debug renderer in @blockly/dev-tools (See https://www.npmjs.com/package/@blockly/dev-tools.)'); - return debug.isDebuggerEnabled(); -} - /** * Registers a new renderer. * @@ -87,22 +69,6 @@ export function unregister(name: string) { registry.unregister(registry.Type.RENDERER, name); } -/** - * Turn on the blocks debugger. - * - * @alias Blockly.blockRendering.startDebugger - * @deprecated Use the debug renderer in **\@blockly/dev-tools** (See {@link - * https://www.npmjs.com/package/@blockly/dev-tools}.) - * @internal - */ -export function startDebugger() { - deprecation.warn( - 'Blockly.blockRendering.startDebugger()', 'September 2021', - 'September 2022', - 'the debug renderer in @blockly/dev-tools (See https://www.npmjs.com/package/@blockly/dev-tools.)'); - debug.startDebugger(); -} - /** * Turn off the blocks debugger. * diff --git a/core/renderers/common/debug.ts b/core/renderers/common/debug.ts index a0c2f98ab..d54a2866e 100644 --- a/core/renderers/common/debug.ts +++ b/core/renderers/common/debug.ts @@ -38,8 +38,7 @@ export function isDebuggerEnabled(): boolean { */ export function startDebugger() { deprecation.warn( - 'Blockly.blockRendering.debug.startDebugger()', 'February 2022', - 'September 2022', + 'Blockly.blockRendering.debug.startDebugger()', 'version 8', 'version 10', 'the debug renderer in @blockly/dev-tools (See https://www.npmjs.com/package/@blockly/dev-tools.)'); useDebugger = true; } @@ -54,8 +53,7 @@ export function startDebugger() { */ export function stopDebugger() { deprecation.warn( - 'Blockly.blockRendering.debug.stopDebugger()', 'February 2022', - 'September 2022', + 'Blockly.blockRendering.debug.stopDebugger()', 'version 8', 'version 10', 'the debug renderer in @blockly/dev-tools (See https://www.npmjs.com/package/@blockly/dev-tools.)'); useDebugger = false; } diff --git a/core/utils.ts b/core/utils.ts index 44a3720b9..3891d0b21 100644 --- a/core/utils.ts +++ b/core/utils.ts @@ -68,35 +68,6 @@ export { xml, }; -/** - * Halts the propagation of the event without doing anything else. - * - * @param e An event. - * @deprecated No longer provided by Blockly. - * @alias Blockly.utils.noEvent - */ -export function noEvent(e: Event) { - deprecation.warn('Blockly.utils.noEvent', 'September 2021', 'September 2022'); - // This event has been handled. No need to bubble up to the document. - e.preventDefault(); - e.stopPropagation(); -} - -/** - * Returns true if this event is targeting a text input widget? - * - * @param e An event. - * @returns True if text input. - * @deprecated Use **Blockly.browserEvents.isTargetInput** instead. - * @alias Blockly.utils.isTargetInput - */ -export function isTargetInput(e: Event): boolean { - deprecation.warn( - 'Blockly.utils.isTargetInput', 'September 2021', 'September 2022', - 'Blockly.browserEvents.isTargetInput'); - return browserEvents.isTargetInput(e); -} - /** * Return the coordinates of the top-left corner of this element relative to * its parent. Only for SVG elements and children (e.g. rect, g, path). @@ -131,55 +102,6 @@ function getInjectionDivXY(element: Element): Coordinate { } export const getInjectionDivXY_ = getInjectionDivXY; -/** - * Returns true this event is a right-click. - * - * @param e Mouse event. - * @returns True if right-click. - * @deprecated Use **Blockly.browserEvents.isRightButton** instead. - * @alias Blockly.utils.isRightButton - */ -export function isRightButton(e: Event): boolean { - deprecation.warn( - 'Blockly.utils.isRightButton', 'September 2021', 'September 2022', - 'Blockly.browserEvents.isRightButton'); - return browserEvents.isRightButton(e as MouseEvent); -} - -/** - * Returns the converted coordinates of the given mouse event. - * The origin (0,0) is the top-left corner of the Blockly SVG. - * - * @param e Mouse event. - * @param svg SVG element. - * @param matrix Inverted screen CTM to use. - * @returns Object with .x and .y properties. - * @deprecated Use **Blockly.browserEvents.mouseToSvg** instead; - * @alias Blockly.utils.mouseToSvg - */ -export function mouseToSvg( - e: Event, svg: SVGSVGElement, matrix: SVGMatrix|null): SVGPoint { - deprecation.warn( - 'Blockly.utils.mouseToSvg', 'September 2021', 'September 2022', - 'Blockly.browserEvents.mouseToSvg'); - return browserEvents.mouseToSvg(e as MouseEvent, svg, matrix); -} - -/** - * Returns the scroll delta of a mouse event in pixel units. - * - * @param e Mouse event. - * @returns Scroll delta object with .x and .y properties. - * @deprecated Use **Blockly.browserEvents.getScrollDeltaPixels** instead. - * @alias Blockly.utils.getScrollDeltaPixels - */ -export function getScrollDeltaPixels(e: WheelEvent): {x: number, y: number} { - deprecation.warn( - 'Blockly.utils.getScrollDeltaPixels', 'September 2021', 'September 2022', - 'Blockly.browserEvents.getScrollDeltaPixels'); - return browserEvents.getScrollDeltaPixels(e); -} - /** * Parse a string with any number of interpolation tokens (%1, %2, ...). * It will also replace string table references (e.g., %{bky_my_msg} and @@ -235,20 +157,6 @@ export function checkMessageReferences(message: string): boolean { return parsing.checkMessageReferences(message); } -/** - * Generate a unique ID. - * - * @returns A globally unique ID string. - * @deprecated Use **Blockly.utils.idGenerator.genUid** instead. - * @alias Blockly.utils.genUid - */ -export function genUid(): string { - deprecation.warn( - 'Blockly.utils.genUid', 'September 2021', 'September 2022', - 'Blockly.utils.idGenerator.genUid'); - return idGenerator.genUid(); -} - /** * Check if 3D transforms are supported by adding an element * and attempting to set the property. diff --git a/core/utils/object.ts b/core/utils/object.ts index e094ec612..708c69905 100644 --- a/core/utils/object.ts +++ b/core/utils/object.ts @@ -21,11 +21,11 @@ import * as deprecation from './deprecation.js'; * @param childCtor Child class. * @param parentCtor Parent class. * @suppress {strictMissingProperties} superClass_ is not defined on Function. + * @deprecated No longer provided by Blockly. * @alias Blockly.utils.object.inherits */ export function inherits(childCtor: Function, parentCtor: Function) { - deprecation.warn( - 'Blockly.utils.object.inherits', 'version 9.0.0', 'version 10.0.0'); + deprecation.warn('Blockly.utils.object.inherits', 'version 9', 'version 10'); // Set a .superClass_ property so that methods can call parent methods // without hard-coding the parent class name. // Could be replaced by ES6's super(). @@ -49,6 +49,7 @@ export function inherits(childCtor: Function, parentCtor: Function) { * * @param target Target. * @param source Source. + * @deprecated Use the built-in **Object.assign** instead. * @alias Blockly.utils.object.mixin */ export function mixin(target: AnyDuringMigration, source: AnyDuringMigration) { @@ -85,11 +86,12 @@ export function deepMerge( * * @param obj Object containing values. * @returns Array of values. + * @deprecated Use the built-in **Object.values** instead. * @alias Blockly.utils.object.values */ export function values(obj: AnyDuringMigration): AnyDuringMigration[] { deprecation.warn( - 'Blockly.utils.object.values', 'version 9.0.0', 'version 10.0.0', + 'Blockly.utils.object.values', 'version 9', 'version 10', 'Object.values'); return Object.values(obj); } diff --git a/core/utils/string.ts b/core/utils/string.ts index c95def9ae..35856f354 100644 --- a/core/utils/string.ts +++ b/core/utils/string.ts @@ -25,7 +25,7 @@ import * as deprecation from './deprecation.js'; * @param prefix A string to look for at the start of `str`. * @returns True if `str` begins with `prefix`. * @alias Blockly.utils.string.startsWith - * @deprecated April 2022. Use built-in string.startsWith. + * @deprecated Use built-in **string.startsWith** instead. */ export function startsWith(str: string, prefix: string): boolean { deprecation.warn( diff --git a/core/utils/style.ts b/core/utils/style.ts index 6ec94bd58..dbe6f9020 100644 --- a/core/utils/style.ts +++ b/core/utils/style.ts @@ -103,12 +103,12 @@ export function getComputedStyle(element: Element, property: string): string { * @param element Element to get style of. * @param style Property to get (camel-case). * @returns Style value. + * @deprecated No longer provided by Blockly. * @alias Blockly.utils.style.getCascadedStyle */ export function getCascadedStyle(element: Element, style: string): string { deprecation.warn( - 'Blockly.utils.style.getCascadedStyle', 'version 9.0.0', - 'version 10.0.0'); + 'Blockly.utils.style.getCascadedStyle', 'version 9', 'version 10'); // AnyDuringMigration because: Property 'currentStyle' does not exist on type // 'Element'. AnyDuringMigration because: Property 'currentStyle' does not // exist on type 'Element'. diff --git a/core/utils/svg_math.ts b/core/utils/svg_math.ts index 4f16332d7..60820c915 100644 --- a/core/utils/svg_math.ts +++ b/core/utils/svg_math.ts @@ -17,7 +17,6 @@ import type {WorkspaceSvg} from '../workspace_svg.js'; import {Coordinate} from './coordinate.js'; import * as deprecation from './deprecation.js'; import {Rect} from './rect.js'; -import {Size} from './size.js'; import * as style from './style.js'; @@ -114,12 +113,13 @@ export function getInjectionDivXY(element: Element): Coordinate { * and attempting to set the property. * * @returns True if 3D transforms are supported. + * @deprecated No longer provided by Blockly. * @alias Blockly.utils.svgMath.is3dSupported */ export function is3dSupported(): boolean { // All browsers support translate3d in 2022. deprecation.warn( - 'Blockly.utils.svgMath.is3dSupported', 'version 9.0.0', 'version 10.0.0'); + 'Blockly.utils.svgMath.is3dSupported', 'version 9', 'version 10'); return true; } @@ -191,28 +191,6 @@ export function screenToWsCoordinates( return finalOffsetMainWs; } -/** - * Returns the dimensions of the specified SVG image. - * - * @param svg SVG image. - * @returns Contains width and height properties. - * @deprecated Use workspace.getCachedParentSvgSize. (2021 March 5) - * @alias Blockly.utils.svgMath.svgSize - */ -export function svgSize(svg: SVGElement): Size { - // When removing this function, remove svg.cachedWidth_ and svg.cachedHeight_ - // from setCachedParentSvgSize. - // The deprecated name is `Blockly.svgSize` because this function used to be - // declared in Blockly.js. - deprecation.warn( - 'Blockly.svgSize', 'March 2021', 'March 2022', - 'workspace.getCachedParentSvgSize'); - svg = svg as AnyDuringMigration; - return new Size( - Number(svg.getAttribute('data-cached-width')), - Number(svg.getAttribute('data-cached-height'))); -} - export const TEST_ONLY = { XY_REGEX, XY_STYLE_REGEX, diff --git a/core/workspace_svg.ts b/core/workspace_svg.ts index 59c0feacb..f7a18d914 100644 --- a/core/workspace_svg.ts +++ b/core/workspace_svg.ts @@ -58,7 +58,6 @@ import {ThemeManager} from './theme_manager.js'; import * as Tooltip from './tooltip.js'; import {TouchGesture} from './touch_gesture.js'; import type {Trashcan} from './trashcan.js'; -import * as utils from './utils.js'; import * as arrayUtils from './utils/array.js'; import {Coordinate} from './utils/coordinate.js'; import * as dom from './utils/dom.js'; @@ -1563,18 +1562,6 @@ export class WorkspaceSvg extends Workspace implements IASTNodeLocationSvg { return newVar; } - /** - * Make a list of all the delete areas for this workspace. - * - * @deprecated Use workspace.recordDragTargets. (2021 June) - */ - recordDeleteAreas() { - utils.deprecation.warn( - 'WorkspaceSvg.prototype.recordDeleteAreas', 'June 2021', 'June 2022', - 'WorkspaceSvg.prototype.recordDragTargets'); - this.recordDragTargets(); - } - /** Make a list of all the delete areas for this workspace. */ recordDragTargets() { const dragTargets = this.componentManager_.getComponents(