/** * @license * Copyright 2019 Google LLC * SPDX-License-Identifier: Apache-2.0 */ import type { RenderedConnection } from '../../rendered_connection.js'; import type { BlockStyle, Theme } from '../../theme.js'; /** An object containing sizing and path information about outside corners. */ export interface OutsideCorners { topLeft: string; topRight: string; bottomRight: string; bottomLeft: string; rightHeight: number; } /** An object containing sizing and path information about inside corners. */ export interface InsideCorners { width: number; height: number; pathTop: string; pathBottom: string; } /** An object containing sizing and path information about a start hat. */ export interface StartHat { height: number; width: number; path: string; } /** An object containing sizing and path information about a notch. */ export interface Notch { type: number; width: number; height: number; pathLeft: string; pathRight: string; } /** An object containing sizing and path information about a puzzle tab. */ export interface PuzzleTab { type: number; width: number; height: number; pathDown: string; pathUp: string; } /** * An object containing sizing and path information about collapsed block * indicators. */ export interface JaggedTeeth { height: number; width: number; path: string; } export type BaseShape = { type: number; width: number; height: number; }; /** An object containing sizing and type information about a dynamic shape. */ export type DynamicShape = { type: number; width: (p1: number) => number; height: (p1: number) => number; isDynamic: true; connectionOffsetY: (p1: number) => number; connectionOffsetX: (p1: number) => number; pathDown: (p1: number) => string; pathUp: (p1: number) => string; pathRightDown: (p1: number) => string; pathRightUp: (p1: number) => string; }; /** An object containing sizing and type information about a shape. */ export type Shape = BaseShape | DynamicShape; /** * Returns whether the shape is dynamic or not. * * @param shape The shape to check for dynamic-ness. * @returns Whether the shape is a dynamic shape or not. */ export declare function isDynamicShape(shape: Shape): shape is DynamicShape; /** Returns whether the shape is a puzzle tab or not. */ export declare function isPuzzleTab(shape: Shape): shape is PuzzleTab; /** Returns whether the shape is a notch or not. */ export declare function isNotch(shape: Shape): shape is Notch; /** * An object that provides constants for rendering blocks. */ export declare class ConstantProvider { /** The size of an empty spacer. */ NO_PADDING: number; /** The size of small padding. */ SMALL_PADDING: number; /** The size of medium padding. */ MEDIUM_PADDING: number; /** The size of medium-large padding. */ MEDIUM_LARGE_PADDING: number; /** The size of large padding. */ LARGE_PADDING: number; TALL_INPUT_FIELD_OFFSET_Y: number; /** The height of the puzzle tab used for input and output connections. */ TAB_HEIGHT: number; /** * The offset from the top of the block at which a puzzle tab is positioned. */ TAB_OFFSET_FROM_TOP: number; /** * Vertical overlap of the puzzle tab, used to make it look more like a * puzzle piece. */ TAB_VERTICAL_OVERLAP: number; /** The width of the puzzle tab used for input and output connections. */ TAB_WIDTH: number; /** The width of the notch used for previous and next connections. */ NOTCH_WIDTH: number; /** The height of the notch used for previous and next connections. */ NOTCH_HEIGHT: number; /** The minimum width of the block. */ MIN_BLOCK_WIDTH: number; EMPTY_BLOCK_SPACER_HEIGHT: number; DUMMY_INPUT_MIN_HEIGHT: number; DUMMY_INPUT_SHADOW_MIN_HEIGHT: number; /** Rounded corner radius. */ CORNER_RADIUS: number; /** * Offset from the left side of a block or the inside of a statement input * to the left side of the notch. */ NOTCH_OFFSET_LEFT: number; STATEMENT_INPUT_NOTCH_OFFSET: number; STATEMENT_BOTTOM_SPACER: number; STATEMENT_INPUT_PADDING_LEFT: number; /** Vertical padding between consecutive statement inputs. */ BETWEEN_STATEMENT_PADDING_Y: number; TOP_ROW_MIN_HEIGHT: number; TOP_ROW_PRECEDES_STATEMENT_MIN_HEIGHT: number; BOTTOM_ROW_MIN_HEIGHT: number; BOTTOM_ROW_AFTER_STATEMENT_MIN_HEIGHT: number; /** * Whether to add a 'hat' on top of all blocks with no previous or output * connections. Can be overridden by 'hat' property on Theme.BlockStyle. */ ADD_START_HATS: boolean; /** Height of the top hat. */ START_HAT_HEIGHT: number; /** Width of the top hat. */ START_HAT_WIDTH: number; SPACER_DEFAULT_HEIGHT: number; MIN_BLOCK_HEIGHT: number; EMPTY_INLINE_INPUT_PADDING: number; EMPTY_INLINE_INPUT_HEIGHT: number; EXTERNAL_VALUE_INPUT_PADDING: number; EMPTY_STATEMENT_INPUT_HEIGHT: number; START_POINT: string; /** Height of SVG path for jagged teeth at the end of collapsed blocks. */ JAGGED_TEETH_HEIGHT: number; /** Width of SVG path for jagged teeth at the end of collapsed blocks. */ JAGGED_TEETH_WIDTH: number; /** Point size of text. */ FIELD_TEXT_FONTSIZE: number; /** Text font weight. */ FIELD_TEXT_FONTWEIGHT: string; /** Text font family. */ FIELD_TEXT_FONTFAMILY: string; /** * Height of text. This constant is dynamically set in * `setFontConstants_` to be the height of the text based on the font * used. */ FIELD_TEXT_HEIGHT: number; /** * Text baseline. This constant is dynamically set in `setFontConstants_` * to be the baseline of the text based on the font used. */ FIELD_TEXT_BASELINE: number; /** A field's border rect corner radius. */ FIELD_BORDER_RECT_RADIUS: number; /** A field's border rect default height. */ FIELD_BORDER_RECT_HEIGHT: number; /** A field's border rect X padding. */ FIELD_BORDER_RECT_X_PADDING: number; /** A field's border rect Y padding. */ FIELD_BORDER_RECT_Y_PADDING: number; /** * The backing colour of a field's border rect. */ FIELD_BORDER_RECT_COLOUR: string; FIELD_TEXT_BASELINE_CENTER: boolean; FIELD_DROPDOWN_BORDER_RECT_HEIGHT: number; /** * Whether or not a dropdown field should add a border rect when in a shadow * block. */ FIELD_DROPDOWN_NO_BORDER_RECT_SHADOW: boolean; /** * Whether or not a dropdown field's div should be coloured to match the * block colours. */ FIELD_DROPDOWN_COLOURED_DIV: boolean; /** Whether or not a dropdown field uses a text or SVG arrow. */ FIELD_DROPDOWN_SVG_ARROW: boolean; FIELD_DROPDOWN_SVG_ARROW_PADDING: number; /** A dropdown field's SVG arrow size. */ FIELD_DROPDOWN_SVG_ARROW_SIZE: number; FIELD_DROPDOWN_SVG_ARROW_DATAURI: string; /** * Whether or not to show a box shadow around the widget div. This is only a * feature of full block fields. */ FIELD_TEXTINPUT_BOX_SHADOW: boolean; /** * Whether or not the colour field should display its colour value on the * entire block. */ FIELD_COLOUR_FULL_BLOCK: boolean; /** A colour field's default width. */ FIELD_COLOUR_DEFAULT_WIDTH: number; FIELD_COLOUR_DEFAULT_HEIGHT: number; FIELD_CHECKBOX_X_OFFSET: number; randomIdentifier: string; /** * The defs tag that contains all filters and patterns for this Blockly * instance. */ private defs; /** * The ID of the emboss filter, or the empty string if no filter is set. */ embossFilterId: string; /** The element to use for highlighting, or null if not set. */ private embossFilter; /** * The ID of the disabled pattern, or the empty string if no pattern is set. */ disabledPatternId: string; /** * The element to use for disabled blocks, or null if not set. */ private disabledPattern; /** * The ID of the debug filter, or the empty string if no pattern is set. */ debugFilterId: string; /** * The element to use for a debug highlight, or null if not set. */ private debugFilter; /** The