Skip to content

Commit

Permalink
fix!: Update deprecations for the new release. (#6470)
Browse files Browse the repository at this point in the history
* chore: bump early deprecations to v10

* fixup

* fixup

* chore: remove deprecated properties

* chore: add missing @deprecated tags

* chore: format

* chore: format

* chore: fix import
  • Loading branch information
BeksOmega committed Oct 3, 2022
1 parent 12ffd23 commit d3447ea
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 216 deletions.
6 changes: 5 additions & 1 deletion core/block_drag_surface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
29 changes: 9 additions & 20 deletions core/blockly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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
*/
Expand All @@ -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
*/
Expand All @@ -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
*/
Expand All @@ -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
*/
Expand All @@ -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
*/
Expand All @@ -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_
*/
Expand All @@ -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_
*/
Expand Down Expand Up @@ -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_
*/
Expand Down
15 changes: 2 additions & 13 deletions core/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

/**
Expand Down
5 changes: 2 additions & 3 deletions core/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},
}),
Expand Down
10 changes: 4 additions & 6 deletions core/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
},
Expand Down Expand Up @@ -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);
},
},
Expand Down
34 changes: 0 additions & 34 deletions core/renderers/common/block_rendering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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.
*
Expand Down
6 changes: 2 additions & 4 deletions core/renderers/common/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
92 changes: 0 additions & 92 deletions core/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit d3447ea

Please sign in to comment.