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: properly export interfaces that were typedefs #6250

Merged
merged 5 commits into from
Jun 30, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
13 changes: 9 additions & 4 deletions core/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2102,8 +2102,13 @@ export class Block implements IASTNodeLocation, IDeletable {
return msg;
}
}
export interface CommentModel {
text: string|null;
pinned: boolean;
size: Size;

export namespace Block {
export interface CommentModel {
text: string|null;
pinned: boolean;
size: Size;
}
}

export type CommentModel = Block.CommentModel;
16 changes: 11 additions & 5 deletions core/component_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,14 @@ export class ComponentManager {
return components;
}
}
export interface ComponentDatum {
component: IComponent;
capabilities: Array<string|Capability<IComponent>>;
weight: number;
}

export namespace ComponentManager {
/** An object storing component information. */
export interface ComponentDatum {
component: IComponent;
capabilities: Array<string|Capability<IComponent>>;
weight: number;
}
}

export type ComponentDatum = ComponentManager.ComponentDatum;
13 changes: 9 additions & 4 deletions core/interfaces/i_copyable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,13 @@ export interface ICopyable extends ISelectable {
*/
toCopyData: AnyDuringMigration;
}
export interface CopyData {
saveInfo: AnyDuringMigration|Element;
source: WorkspaceSvg;
typeCounts: AnyDuringMigration|null;

export namespace ICopyable {
export interface CopyData {
BeksOmega marked this conversation as resolved.
Show resolved Hide resolved
saveInfo: AnyDuringMigration|Element;
source: WorkspaceSvg;
typeCounts: AnyDuringMigration|null;
}
}

export type CopyData = ICopyable.CopyData;
36 changes: 22 additions & 14 deletions core/keyboard_nav/ast_node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,6 @@ import {Workspace} from '../workspace.js';
* @alias Blockly.ASTNode
*/
export class ASTNode {
/** Object holding different types for an AST node. */
static types = {
FIELD: 'field',
BLOCK: 'block',
INPUT: 'input',
OUTPUT: 'output',
NEXT: 'next',
PREVIOUS: 'previous',
STACK: 'stack',
WORKSPACE: 'workspace',
};

/**
* True to navigate to all fields. False to only navigate to clickable fields.
*/
Expand Down Expand Up @@ -694,10 +682,30 @@ export class ASTNode {
return astNode;
}
}
export interface Params {
wsCoordinate: Coordinate;

export namespace ASTNode {
export interface Params {
wsCoordinate: Coordinate;
}
cpcallen marked this conversation as resolved.
Show resolved Hide resolved

export enum types {
FIELD = 'field',
BLOCK = 'block',
INPUT = 'input',
OUTPUT = 'output',
NEXT = 'next',
PREVIOUS = 'previous',
STACK = 'stack',
WORKSPACE = 'workspace',
}
}

export type Params = ASTNode.Params;
// No need to export ASTNode.types from the module at this time because (1) it
// wasn't automatically converted by the automatic migration script, (2) the
// name doesn't follow the styleguide.


/**
* Gets the parent connection on a block.
* This is either an output connection, previous connection or undefined.
Expand Down
74 changes: 49 additions & 25 deletions core/metrics_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,32 +401,56 @@ export class MetricsManager implements IMetricsManager {
};
}
}
export interface ToolboxMetrics {
width: number;
height: number;
position: toolboxUtils.Position;
}
export interface AbsoluteMetrics {
left: number;
top: number;
}
export interface ContainerRegion {
height: number;
width: number;
top: number;
left: number;
}
export interface FixedEdges {
top?: number;
bottom?: number;
left?: number;
right?: number;
}
export interface UiMetrics {
viewMetrics: ContainerRegion;
absoluteMetrics: AbsoluteMetrics;
toolboxMetrics: ToolboxMetrics;

export namespace MetricsManager {
/**
* Describes the width, height and location of the toolbox on the main
* workspace.
*/
export interface ToolboxMetrics {
width: number;
height: number;
position: toolboxUtils.Position;
}

/** Describes where the viewport starts in relation to the workspace SVG. */
export interface AbsoluteMetrics {
left: number;
top: number;
}

/**
* All the measurements needed to describe the size and location of a
* container.
*/
export interface ContainerRegion {
height: number;
width: number;
top: number;
left: number;
}

/** Describes fixed edges of the workspace. */
export interface FixedEdges {
top?: number;
bottom?: number;
left?: number;
right?: number;
}

/** Common metrics used for UI elements. */
export interface UiMetrics {
viewMetrics: ContainerRegion;
absoluteMetrics: AbsoluteMetrics;
toolboxMetrics: ToolboxMetrics;
}
}

export type ToolboxMetrics = MetricsManager.ToolboxMetrics;
export type AbsoluteMetrics = MetricsManager.AbsoluteMetrics;
export type ContainerRegion = MetricsManager.ContainerRegion;
export type FixedEdges = MetricsManager.FixedEdges;
export type UiMetrics = MetricsManager.UiMetrics;

registry.register(
registry.Type.METRICS_MANAGER, registry.DEFAULT, MetricsManager);
57 changes: 34 additions & 23 deletions core/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,27 +427,38 @@ export class Options {
theme.name || 'builtin' + idGenerator.getNextUniqueId(), theme);
}
}
export interface GridOptions {
colour: string;
length: number;
snap: boolean;
spacing: number;
}
export interface MoveOptions {
drag: boolean;
scrollbars: boolean|ScrollbarOptions;
wheel: boolean;
}
export interface ScrollbarOptions {
horizontal: boolean;
vertical: boolean;
}
export interface ZoomOptions {
controls: boolean;
maxScale: number;
minScale: number;
pinch: boolean;
scaleSpeed: number;
startScale: number;
wheel: boolean;

export namespace Options {
export interface GridOptions {
colour: string;
length: number;
snap: boolean;
spacing: number;
}

export interface MoveOptions {
drag: boolean;
scrollbars: boolean|ScrollbarOptions;
wheel: boolean;
}

export interface ScrollbarOptions {
horizontal: boolean;
vertical: boolean;
}

export interface ZoomOptions {
controls: boolean;
maxScale: number;
minScale: number;
pinch: boolean;
scaleSpeed: number;
startScale: number;
wheel: boolean;
}
}

export type GridOptions = Options.GridOptions;
export type MoveOptions = Options.MoveOptions;
export type ScrollbarOptions = Options.ScrollbarOptions;
export type ZoomOptions = Options.ZoomOptions;
3 changes: 1 addition & 2 deletions core/renderers/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,7 @@ export class ConstantProvider {
*/
INSERTION_MARKER_OPACITY = 0.2;

/** Enum for connection shapes. */
SHAPES = {PUZZLE: 1, NOTCH: 2};
SHAPES: {[key: string]: number} = {PUZZLE: 1, NOTCH: 2};
// TODO(b/109816955): remove '!', see go/strict-prop-init-fix.
JAGGED_TEETH!: JaggedTeeth;
// TODO(b/109816955): remove '!', see go/strict-prop-init-fix.
Expand Down
36 changes: 22 additions & 14 deletions core/shortcut_registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,6 @@ import {Workspace} from './workspace.js';
* @alias Blockly.ShortcutRegistry
*/
export class ShortcutRegistry {
/** Enum of valid modifiers. */
static modifierKeys = {
'Shift': KeyCodes.SHIFT,
'Control': KeyCodes.CTRL,
'Alt': KeyCodes.ALT,
'Meta': KeyCodes.META,
};
static registry: AnyDuringMigration;
// TODO(b/109816955): remove '!', see go/strict-prop-init-fix.
private registry_!: {[key: string]: KeyboardShortcut};
Expand Down Expand Up @@ -326,15 +319,30 @@ export class ShortcutRegistry {
}
}

export interface KeyboardShortcut {
callback?: ((p1: Workspace, p2: Event, p3: KeyboardShortcut) => boolean);
name: string;
preconditionFn?: ((p1: Workspace) => boolean);
metadata?: object;
keyCodes?: (number|string)[];
allowCollision?: boolean;
export namespace ShortcutRegistry {
cpcallen marked this conversation as resolved.
Show resolved Hide resolved
export interface KeyboardShortcut {
BeksOmega marked this conversation as resolved.
Show resolved Hide resolved
callback?: ((p1: Workspace, p2: Event, p3: KeyboardShortcut) => boolean);
name: string;
preconditionFn?: ((p1: Workspace) => boolean);
metadata?: object;
keyCodes?: (number|string)[];
allowCollision?: boolean;
}

/** Supported modifiers. */
export enum modifierKeys {
Shift = KeyCodes.SHIFT,
Control = KeyCodes.CTRL,
Alt = KeyCodes.ALT,
Meta = KeyCodes.META,
}
}

export type KeyboardShortcut = ShortcutRegistry.KeyboardShortcut;
// No need to export ShorcutRegistry.modifierKeys from the module at this time
// because (1) it wasn't automatically converted by the automatic migration
// script, (2) the name doesn't follow the styleguide.

// Creates and assigns the singleton instance.
const registry = new ShortcutRegistry();
ShortcutRegistry.registry = registry;
73 changes: 42 additions & 31 deletions core/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,35 +165,46 @@ export class Theme {
return theme;
}
}
export interface BlockStyle {
colourPrimary: string;
colourSecondary: string;
colourTertiary: string;
hat?: string;
}
export interface CategoryStyle {
colour: string;
}
export interface ComponentStyle {
workspaceBackgroundColour: string|null;
toolboxBackgroundColour: string|null;
toolboxForegroundColour: string|null;
flyoutBackgroundColour: string|null;
flyoutForegroundColour: string|null;
flyoutOpacity: number|null;
scrollbarColour: string|null;
scrollbarOpacity: number|null;
insertionMarkerColour: string|null;
insertionMarkerOpacity: number|null;
markerColour: string|null;
cursorColour: string|null;
selectedGlowColour: string|null;
selectedGlowOpacity: number|null;
replacementGlowColour: string|null;
replacementGlowOpacity: number|null;
}
export interface FontStyle {
family: string|null;
weight: string|null;
size: number|null;

export namespace Theme {
export interface BlockStyle {
cpcallen marked this conversation as resolved.
Show resolved Hide resolved
colourPrimary: string;
colourSecondary: string;
colourTertiary: string;
hat?: string;
}

export interface CategoryStyle {
colour: string;
}

export interface ComponentStyle {
workspaceBackgroundColour: string|null;
toolboxBackgroundColour: string|null;
toolboxForegroundColour: string|null;
flyoutBackgroundColour: string|null;
flyoutForegroundColour: string|null;
flyoutOpacity: number|null;
scrollbarColour: string|null;
scrollbarOpacity: number|null;
insertionMarkerColour: string|null;
insertionMarkerOpacity: number|null;
markerColour: string|null;
cursorColour: string|null;
selectedGlowColour: string|null;
selectedGlowOpacity: number|null;
replacementGlowColour: string|null;
replacementGlowOpacity: number|null;
}

export interface FontStyle {
family: string|null;
weight: string|null;
size: number|null;
}
}

export type BlockStyle = Theme.BlockStyle;
export type CategoryStyle = Theme.CategoryStyle;
export type ComponentStyle = Theme.ComponentStyle;
export type FontStyle = Theme.FontStyle;
Loading