blockly 10.2.1 → 10.3.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,8 +13,10 @@ import type { Block } from './block.js';
13
13
  import { Names } from './names.js';
14
14
  import type { Workspace } from './workspace.js';
15
15
  /**
16
- * Type declaration for per-block-type generator functions.
16
+ * Deprecated, no-longer used type declaration for per-block-type generator
17
+ * functions.
17
18
  *
19
+ * @deprecated
18
20
  * @see {@link https://developers.google.com/blockly/guides/create-custom-blocks/generating-code}
19
21
  * @param block The Block instance to generate code for.
20
22
  * @param genearator The CodeGenerator calling the function.
@@ -28,10 +30,22 @@ export type BlockGenerator = (block: Block, generator: CodeGenerator) => [string
28
30
  */
29
31
  export declare class CodeGenerator {
30
32
  name_: string;
31
- /** A dictionary of block generator functions keyed by block type. */
32
- forBlock: {
33
- [type: string]: BlockGenerator;
34
- };
33
+ /**
34
+ * A dictionary of block generator functions, keyed by block type.
35
+ * Each block generator function takes two parameters:
36
+ *
37
+ * - the Block to generate code for, and
38
+ * - the calling CodeGenerator (or subclass) instance, so the
39
+ * function can call methods defined below (e.g. blockToCode) or
40
+ * on the relevant subclass (e.g. JavascripGenerator),
41
+ *
42
+ * and returns:
43
+ *
44
+ * - a [code, precedence] tuple (for value/expression blocks), or
45
+ * - a string containing the generated code (for statement blocks), or
46
+ * - null if no code should be emitted for block.
47
+ */
48
+ forBlock: Record<string, (block: Block, generator: this) => [string, number] | string | null>;
35
49
  /**
36
50
  * This is used as a placeholder in functions defined using
37
51
  * CodeGenerator.provideFunction_. It must not be legal code that could
@@ -93,11 +93,11 @@ export declare class RenderInfo {
93
93
  /**
94
94
  * Decide whether to start a new row between the two Blockly.Inputs.
95
95
  *
96
- * @param input The first input to consider
97
- * @param lastInput The input that follows.
98
- * @returns True if the next input should be rendered on a new row.
96
+ * @param currInput The current input.
97
+ * @param prevInput The previous input.
98
+ * @returns True if the current input should be rendered on a new row.
99
99
  */
100
- protected shouldStartNewRow_(input: Input, lastInput?: Input): boolean;
100
+ protected shouldStartNewRow_(currInput: Input, prevInput?: Input): boolean;
101
101
  /** Add horizontal spacing between and around elements within each row. */
102
102
  protected addElemSpacing_(): void;
103
103
  /**
@@ -42,7 +42,7 @@ export declare class RenderInfo extends BaseRenderInfo {
42
42
  */
43
43
  getRenderer(): Renderer;
44
44
  measure(): void;
45
- shouldStartNewRow_(input: Input, lastInput: Input): boolean;
45
+ shouldStartNewRow_(currInput: Input, prevInput: Input): boolean;
46
46
  getDesiredRowWidth_(row: Row): number;
47
47
  getInRowSpacing_(prev: Measurable | null, next: Measurable | null): number;
48
48
  getSpacerRowHeight_(prev: Row, next: Row): number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blockly",
3
- "version": "10.2.1",
3
+ "version": "10.3.0-beta.0",
4
4
  "description": "Blockly is a library for building visual programming editors.",
5
5
  "keywords": [
6
6
  "blockly"