scratch-blocks 2.1.7 → 2.1.8

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.
@@ -10,7 +10,7 @@ export declare class RenderInfo extends Blockly.zelos.RenderInfo {
10
10
  populateTopRow_(): void;
11
11
  populateBottomRow_(): void;
12
12
  computeBounds_(): void;
13
- getInRowSpacing_(prev: Blockly.blockRendering.Measurable, next: Blockly.blockRendering.Measurable): number;
13
+ getInRowSpacing_(prev: Blockly.blockRendering.Measurable | null, next: Blockly.blockRendering.Measurable | null): number;
14
14
  getSpacerRowHeight_(prev: Blockly.blockRendering.Row, next: Blockly.blockRendering.Row): number;
15
15
  getElemCenterline_(row: Blockly.blockRendering.Row, elem: Blockly.blockRendering.Measurable): number;
16
16
  isBowlerHatBlock(): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"render_info.d.ts","sourceRoot":"","sources":["../../../../src/renderer/render_info.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAE9C,qBAAa,UAAW,SAAQ,OAAO,CAAC,KAAK,CAAC,UAAU;IAC9C,UAAU,EAAE,gBAAgB,CAAA;IAE3B,eAAe;IAaf,kBAAkB;IAOlB,cAAc;IA0Bd,gBAAgB,CACvB,IAAI,EAAE,OAAO,CAAC,cAAc,CAAC,UAAU,EACvC,IAAI,EAAE,OAAO,CAAC,cAAc,CAAC,UAAU,GACtC,MAAM;IAYA,mBAAmB,CAAC,IAAI,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,GAAG,MAAM;IAQ/F,kBAAkB,CAAC,GAAG,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,cAAc,CAAC,UAAU,GAAG,MAAM;IAgB7G,gBAAgB;IAIhB,aAAa;CAGd"}
1
+ {"version":3,"file":"render_info.d.ts","sourceRoot":"","sources":["../../../../src/renderer/render_info.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAS9C,qBAAa,UAAW,SAAQ,OAAO,CAAC,KAAK,CAAC,UAAU;IAC9C,UAAU,EAAE,gBAAgB,CAAA;IAE3B,eAAe;IAaf,kBAAkB;IAOlB,cAAc;IA0Bd,gBAAgB,CACvB,IAAI,EAAE,OAAO,CAAC,cAAc,CAAC,UAAU,GAAG,IAAI,EAC9C,IAAI,EAAE,OAAO,CAAC,cAAc,CAAC,UAAU,GAAG,IAAI,GAC7C,MAAM;IAYA,mBAAmB,CAAC,IAAI,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,GAAG,MAAM;IAQ/F,kBAAkB,CAAC,GAAG,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,cAAc,CAAC,UAAU,GAAG,MAAM;IAmB7G,gBAAgB;IAIhB,aAAa;CAGd"}
package/eslint.config.mjs CHANGED
@@ -16,22 +16,6 @@ export default eslintConfigScratch.defineConfig(
16
16
  files: ['**/*.{ts,tsx,mts,cts}'],
17
17
  plugins: { '@typescript-eslint': tseslint.plugin },
18
18
  },
19
- {
20
- // TODO: upstream to eslint-config-scratch
21
- files: ['**/*.{ts,tsx,mts,cts}'],
22
- rules: {
23
- '@typescript-eslint/no-empty-function': 'off',
24
- '@typescript-eslint/no-unused-vars': [
25
- 'error',
26
- {
27
- argsIgnorePattern: '^_',
28
- caughtErrorsIgnorePattern: '^_',
29
- destructuredArrayIgnorePattern: '^_',
30
- ignoreRestSiblings: true,
31
- },
32
- ],
33
- },
34
- },
35
19
  {
36
20
  // Tests frequently introspect internals and invoke prototype methods directly.
37
21
  files: ['tests/**/*.{ts,tsx,mts,cts}'],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scratch-blocks",
3
- "version": "2.1.7",
3
+ "version": "2.1.8",
4
4
  "description": "Scratch Blocks is a library for building creative computing interfaces.",
5
5
  "author": "Massachusetts Institute of Technology",
6
6
  "license": "Apache-2.0",
@@ -38,10 +38,10 @@
38
38
  "devDependencies": {
39
39
  "@commitlint/cli": "20.5.0",
40
40
  "@commitlint/config-conventional": "20.5.0",
41
- "@vitest/browser": "4.1.0",
42
- "@vitest/browser-playwright": "4.1.0",
41
+ "@vitest/browser": "4.1.2",
42
+ "@vitest/browser-playwright": "4.1.2",
43
43
  "eslint": "9.39.4",
44
- "eslint-config-scratch": "14.0.12",
44
+ "eslint-config-scratch": "14.1.1",
45
45
  "husky": "9.1.7",
46
46
  "playwright": "1.58.2",
47
47
  "prettier": "3.8.1",
@@ -50,7 +50,7 @@
50
50
  "source-map-loader": "5.0.0",
51
51
  "ts-loader": "9.5.4",
52
52
  "typescript": "5.9.3",
53
- "vitest": "4.1.0",
53
+ "vitest": "4.1.2",
54
54
  "webpack": "5.105.4",
55
55
  "webpack-cli": "6.0.1",
56
56
  "webpack-dev-server": "5.2.3"
@@ -6,6 +6,13 @@ import * as Blockly from 'blockly/core'
6
6
  import { BowlerHat } from './bowler_hat'
7
7
  import { ConstantProvider } from './constants'
8
8
 
9
+ // Blockly's BlockSvg types previousConnection as non-null, but blocks without a
10
+ // previous connector (hat blocks) have it as null at runtime. This type corrects
11
+ // that so null checks are recognized by the type system instead of suppressed.
12
+ type BlockSvgWithNullableConnections = Omit<Blockly.BlockSvg, 'previousConnection'> & {
13
+ previousConnection: Blockly.RenderedConnection | null
14
+ }
15
+
9
16
  export class RenderInfo extends Blockly.zelos.RenderInfo {
10
17
  declare constants_: ConstantProvider
11
18
 
@@ -56,12 +63,12 @@ export class RenderInfo extends Blockly.zelos.RenderInfo {
56
63
  }
57
64
 
58
65
  override getInRowSpacing_(
59
- prev: Blockly.blockRendering.Measurable,
60
- next: Blockly.blockRendering.Measurable,
66
+ prev: Blockly.blockRendering.Measurable | null,
67
+ next: Blockly.blockRendering.Measurable | null,
61
68
  ): number {
62
69
  if (
63
70
  this.isBowlerHatBlock() &&
64
- (Blockly.blockRendering.Types.isHat(prev) || Blockly.blockRendering.Types.isHat(next))
71
+ ((prev && Blockly.blockRendering.Types.isHat(prev)) || (next && Blockly.blockRendering.Types.isHat(next)))
65
72
  ) {
66
73
  // Bowler hat rows have no spacing/gaps, just the hat.
67
74
  return 0
@@ -86,7 +93,10 @@ export class RenderInfo extends Blockly.zelos.RenderInfo {
86
93
  this.block_.isScratchExtension &&
87
94
  Blockly.blockRendering.Types.isField(elem) &&
88
95
  elem.field instanceof Blockly.FieldImage &&
89
- elem.field === this.block_.inputList[0].fieldRow[0]
96
+ elem.field === this.block_.inputList[0].fieldRow[0] &&
97
+ // Hat-style extension blocks have no previousConnection and use their
98
+ // own centering; only offset stack-style extensions.
99
+ (this.block_ as BlockSvgWithNullableConnections).previousConnection
90
100
  ) {
91
101
  // Vertically center the icon on extension blocks.
92
102
  return super.getElemCenterline_(row, elem) + this.constants_.GRID_UNIT