Skip to content

Commit

Permalink
fix: input exports (google#7165)
Browse files Browse the repository at this point in the history
* fix: input exports

* chore: fix build

* chore: attempt to fix build

* chore: attempt to fix build

* chore: create new align enum to replace old one

* chore: format

* fix: Tweak renamings entries

It appears that the goal is to map:

Blockly.Input.Align -> Blockly.inputs.Align
Blockly.Align -> Blockly.inputs.Align
Blockly.ALIGN_* -> Blockly.inputs.Align.*

I believe this commit achieves that in a more minimal (and correct)
way—but if I have misunderstood the intention then this will not
be a useful correction.

---------

Co-authored-by: Christopher Allen <[email protected]>
  • Loading branch information
BeksOmega and cpcallen authored Jun 16, 2023
1 parent 2d3aec4 commit d7ccf8a
Show file tree
Hide file tree
Showing 14 changed files with 89 additions and 21 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ function buildTSOverride({files, tsconfig}) {
'remarks',
'define',
'nocollapse',
'suppress',
],
},
],
Expand Down
2 changes: 1 addition & 1 deletion blocks/lists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ goog.declareModuleId('Blockly.libraryBlocks.lists');

import * as fieldRegistry from '../core/field_registry.js';
import * as xmlUtils from '../core/utils/xml.js';
import {Align} from '../core/inputs/input.js';
import {Align} from '../core/inputs/align.js';
import type {Block} from '../core/block.js';
import type {Connection} from '../core/connection.js';
import type {BlockSvg} from '../core/block_svg.js';
Expand Down
2 changes: 1 addition & 1 deletion blocks/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ goog.declareModuleId('Blockly.libraryBlocks.texts');
import * as Extensions from '../core/extensions.js';
import * as fieldRegistry from '../core/field_registry.js';
import * as xmlUtils from '../core/utils/xml.js';
import {Align} from '../core/inputs/input.js';
import {Align} from '../core/inputs/align.js';
import type {Block} from '../core/block.js';
import type {BlockSvg} from '../core/block_svg.js';
import {Connection} from '../core/connection.js';
Expand Down
3 changes: 2 additions & 1 deletion core/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ import * as eventUtils from './events/utils.js';
import * as Extensions from './extensions.js';
import type {Field} from './field.js';
import * as fieldRegistry from './field_registry.js';
import {Align, Input} from './inputs/input.js';
import {Input} from './inputs/input.js';
import {Align} from './inputs/align.js';
import type {IASTNodeLocation} from './interfaces/i_ast_node_location.js';
import type {IDeletable} from './interfaces/i_deletable.js';
import type {IIcon} from './interfaces/i_icon.js';
Expand Down
20 changes: 9 additions & 11 deletions core/blockly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,10 @@ import {Gesture} from './gesture.js';
import {Grid} from './grid.js';
import * as icons from './icons.js';
import {inject} from './inject.js';
import {Align, Input} from './inputs/input.js';
import {Align} from './inputs/align.js';
import {Input} from './inputs/input.js';
import {inputTypes} from './inputs/input_types.js';
import {DummyInput} from './inputs/dummy_input.js';
import {StatementInput} from './inputs/statement_input.js';
import {ValueInput} from './inputs/value_input.js';
import * as inputs from './inputs.js';
import {InsertionMarkerManager} from './insertion_marker_manager.js';
import {IASTNodeLocation} from './interfaces/i_ast_node_location.js';
import {IASTNodeLocationSvg} from './interfaces/i_ast_node_location_svg.js';
Expand Down Expand Up @@ -244,16 +243,19 @@ export const VERSION = 'uncompiled';

/**
* @see Blockly.Input.Align.LEFT
* @deprecated Use `Blockly.inputs.Align.LEFT`. To be removed in v11.
*/
export const ALIGN_LEFT = Align.LEFT;

/**
* @see Blockly.Input.Align.CENTRE
* @deprecated Use `Blockly.inputs.Align.CENTER`. To be removed in v11.
*/
export const ALIGN_CENTRE = Align.CENTRE;

/**
* @see Blockly.Input.Align.RIGHT
* @deprecated Use `Blockly.inputs.Align.RIGHT`. To be removed in v11.
*/
export const ALIGN_RIGHT = Align.RIGHT;
/*
Expand Down Expand Up @@ -282,6 +284,7 @@ export const PREVIOUS_STATEMENT = ConnectionType.PREVIOUS_STATEMENT;

/**
* @see inputTypes.DUMMY_INPUT
* @deprecated Use `Blockly.inputs.inputTypes.DUMMY`. To be removed in v11.
*/
export const DUMMY_INPUT = inputTypes.DUMMY;

Expand Down Expand Up @@ -592,13 +595,7 @@ export {IKeyboardAccessible};
export {IMetricsManager};
export {IMovable};
export {Input};
export const inputs = {
Input,
inputTypes,
DummyInput,
StatementInput,
ValueInput,
};
export {inputs};
export {InsertionMarkerManager};
export {IObservable, isObservable};
export {IPositionable};
Expand Down Expand Up @@ -644,5 +641,6 @@ export {config};
/** @deprecated Use Blockly.ConnectionType instead. */
export const connectionTypes = ConnectionType;
export {inject};
/** @deprecated Use Blockly.inputs.inputTypes instead. To be removed in v11. */
export {inputTypes};
export {serialization};
14 changes: 14 additions & 0 deletions core/inputs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* @license
* Copyright 2023 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/

import {Align} from './inputs/align.js';
import {Input} from './inputs/input.js';
import {DummyInput} from './inputs/dummy_input.js';
import {StatementInput} from './inputs/statement_input.js';
import {ValueInput} from './inputs/value_input.js';
import {inputTypes} from './inputs/input_types.js';

export {Align, Input, DummyInput, StatementInput, ValueInput, inputTypes};
14 changes: 14 additions & 0 deletions core/inputs/align.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* @license
* Copyright 2012 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/

/**
* Enum for alignment of inputs.
*/
export enum Align {
LEFT = -1,
CENTRE = 0,
RIGHT = 1,
}
7 changes: 7 additions & 0 deletions core/inputs/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,12 @@ export class Input {
}

export namespace Input {
// TODO(v11): When this is removed in v11, also re-enable errors on access
// of deprecated things (in build_tasks.js).
/**
* Enum for alignment of inputs.
*
* @deprecated Use Blockly.inputs.Align. To be removed in v11.
*/
export enum Align {
LEFT = -1,
Expand All @@ -318,5 +321,9 @@ export namespace Input {
}
}

/** @deprecated Use Blockly.inputs.Align. To be removed in v11. */
/** @suppress {deprecated} */
export type Align = Input.Align;
/** @deprecated Use Blockly.inputs.Align. To be removed in v11. */
/** @suppress {deprecated} */
export const Align = Input.Align;
3 changes: 2 additions & 1 deletion core/renderers/common/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import * as goog from '../../../closure/goog/goog.js';
goog.declareModuleId('Blockly.blockRendering.RenderInfo');

import type {BlockSvg} from '../../block_svg.js';
import {Align, Input} from '../../inputs/input.js';
import {Input} from '../../inputs/input.js';
import {Align} from '../../inputs/align.js';
import type {RenderedConnection} from '../../rendered_connection.js';
import type {Measurable} from '../measurables/base.js';
import {BottomRow} from '../measurables/bottom_row.js';
Expand Down
3 changes: 2 additions & 1 deletion core/renderers/zelos/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import {DummyInput} from '../../inputs/dummy_input.js';
import {FieldImage} from '../../field_image.js';
import {FieldLabel} from '../../field_label.js';
import {FieldTextInput} from '../../field_textinput.js';
import {Align, Input} from '../../inputs/input.js';
import {Input} from '../../inputs/input.js';
import {Align} from '../../inputs/align.js';
import {RenderInfo as BaseRenderInfo} from '../common/info.js';
import type {Measurable} from '../measurables/base.js';
import {Field} from '../measurables/field.js';
Expand Down
4 changes: 2 additions & 2 deletions scripts/gulpfiles/build_tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,6 @@ const JSCOMP_ERROR = [
'conformanceViolations',
'const',
'constantProperty',
'deprecated',
'deprecatedAnnotations',
'duplicateMessage',
'es5Strict',
'externsValidation',
Expand Down Expand Up @@ -234,6 +232,8 @@ const JSCOMP_ERROR = [
* it's generally sufficient to remove them from JSCOMP_ERROR.
*/
const JSCOMP_WARNING = [
'deprecated',
'deprecatedAnnotations',
];

/**
Expand Down
28 changes: 28 additions & 0 deletions scripts/migration/renamings.json5
Original file line number Diff line number Diff line change
Expand Up @@ -1482,5 +1482,33 @@
oldName: 'Blockly.Icon',
newName: 'Blockly.icons.Icon',
},
{
oldName: 'Blockly.Input',
exports: {
'Align': {
newPath: 'Blockly.inputs.Align',
},
},
},
{
oldName: 'Blockly',
exports: {
'Align': {
newPath: 'Blockly.inputs.Align',
},
'ALIGN_LEFT': {
newPath: 'Blockly.inputs.Align.LEFT',
},
'ALIGN_CENTER': {
newPath: 'Blockly.inputs.Align.CENTER',
},
'ALIGN_RIGHT': {
newPath: 'Blockly.inputs.Align.RIGHT',
},
'inputTypes': {
newModule: 'Blockly.inputs',
},
},
},
],
}
2 changes: 1 addition & 1 deletion tests/mocha/block_json_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

goog.declareModuleId('Blockly.test.blockJson');

import {Align} from '../../build/src/core/inputs/input.js';
import {Align} from '../../build/src/core/inputs/align.js';
import {
sharedTestSetup,
sharedTestTeardown,
Expand Down
7 changes: 5 additions & 2 deletions tsdoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
{
"tagName": "@nocollapse",
"syntaxKind": "modifier"
},
{
"tagName": "@suppress",
"syntaxKind": "modifier"
}
],

Expand All @@ -26,7 +30,6 @@
"@define": true,
"@license": true,
"@nocollapse": true,
"@suppress": true,
"@unrestricted": true
"@suppress": true
}
}

0 comments on commit d7ccf8a

Please sign in to comment.