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

fix!: Update deprecations for the new release. #6470

Merged
merged 8 commits into from
Oct 3, 2022
Merged
Show file tree
Hide file tree
Changes from 6 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
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
18 changes: 9 additions & 9 deletions core/blockly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ export const svgSize = svgMath.svgSize;
* 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 +377,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 +392,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 +407,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 +423,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 +439,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 +461,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 +480,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 +508,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
8 changes: 5 additions & 3 deletions core/utils/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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().
Expand All @@ -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) {
Expand Down Expand Up @@ -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);
}
Loading