scratch-blocks 2.1.14 → 2.1.15
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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scratch-blocks",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.15",
|
|
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",
|
|
@@ -41,17 +41,17 @@
|
|
|
41
41
|
"@vitest/browser": "4.1.4",
|
|
42
42
|
"@vitest/browser-playwright": "4.1.4",
|
|
43
43
|
"eslint": "9.39.4",
|
|
44
|
-
"eslint-config-scratch": "14.1.
|
|
44
|
+
"eslint-config-scratch": "14.1.11",
|
|
45
45
|
"husky": "9.1.7",
|
|
46
46
|
"playwright": "1.59.1",
|
|
47
|
-
"prettier": "3.8.
|
|
47
|
+
"prettier": "3.8.3",
|
|
48
48
|
"scratch-semantic-release-config": "4.0.1",
|
|
49
49
|
"semantic-release": "25.0.3",
|
|
50
50
|
"source-map-loader": "5.0.0",
|
|
51
51
|
"ts-loader": "9.5.7",
|
|
52
52
|
"typescript": "5.9.3",
|
|
53
53
|
"vitest": "4.1.4",
|
|
54
|
-
"webpack": "5.106.
|
|
54
|
+
"webpack": "5.106.2",
|
|
55
55
|
"webpack-cli": "6.0.1",
|
|
56
56
|
"webpack-dev-server": "5.2.3"
|
|
57
57
|
},
|
|
@@ -81,9 +81,10 @@ Reflect.set(
|
|
|
81
81
|
// Restore a real block from a statement input to nextConnection so that
|
|
82
82
|
// unplug(true) can heal the stack correctly. Conditions:
|
|
83
83
|
// - marker is mid-stack (has a predecessor)
|
|
84
|
-
// - marker.nextConnection is empty
|
|
84
|
+
// - marker.nextConnection is either empty or absent (cap blocks do not
|
|
85
|
+
// have a bottom connector, so the displaced block is NOT already there)
|
|
85
86
|
// - a non-marker block is sitting in a statement input
|
|
86
|
-
if (markerPreviousConnection?.isConnected() &&
|
|
87
|
+
if (markerPreviousConnection?.isConnected() && !markerNextConnection?.isConnected()) {
|
|
87
88
|
for (const input of marker.inputList) {
|
|
88
89
|
const conn = input.connection
|
|
89
90
|
const connType = conn?.type as Blockly.ConnectionType | undefined
|
|
@@ -97,7 +98,19 @@ Reflect.set(
|
|
|
97
98
|
continue
|
|
98
99
|
}
|
|
99
100
|
prev.disconnect()
|
|
100
|
-
markerNextConnection
|
|
101
|
+
if (markerNextConnection) {
|
|
102
|
+
markerNextConnection.connect(prev)
|
|
103
|
+
} else {
|
|
104
|
+
// Blocks without a bottom connector (e.g. forever) have no nextConnection. Reconnect
|
|
105
|
+
// the displaced block directly to the connection the marker's
|
|
106
|
+
// previousConnection is plugged into, then detach the marker
|
|
107
|
+
// so unplug() has nothing left to heal.
|
|
108
|
+
const aboveConn = markerPreviousConnection.targetConnection
|
|
109
|
+
if (aboveConn) {
|
|
110
|
+
markerPreviousConnection.disconnect()
|
|
111
|
+
aboveConn.connect(prev)
|
|
112
|
+
}
|
|
113
|
+
}
|
|
101
114
|
break
|
|
102
115
|
}
|
|
103
116
|
}
|
|
@@ -44,6 +44,32 @@ class ScratchConnectionChecker extends Blockly.ConnectionChecker {
|
|
|
44
44
|
return false
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
// Blockly's base doDragChecks rejects inserting a block with no
|
|
48
|
+
// nextConnection into the middle of a stack (NEXT_STATEMENT case) because
|
|
49
|
+
// it assumes the displaced blocks have nowhere to go. Our
|
|
50
|
+
// getConnectionForOrphanedConnection patch routes displaced blocks into
|
|
51
|
+
// statement inputs, so we allow the connection when a suitable statement
|
|
52
|
+
// input exists on the dragging block.
|
|
53
|
+
if (
|
|
54
|
+
(b.type as Blockly.ConnectionType) === Blockly.ConnectionType.NEXT_STATEMENT &&
|
|
55
|
+
b.isConnected() &&
|
|
56
|
+
!(a.getSourceBlock() as Blockly.Block).nextConnection
|
|
57
|
+
) {
|
|
58
|
+
const orphan = b.targetBlock()
|
|
59
|
+
const orphanPrev = (orphan as Blockly.Block | null)?.previousConnection
|
|
60
|
+
if (orphan && !orphan.isShadow() && orphanPrev) {
|
|
61
|
+
const canWrap = !!Blockly.Connection.getConnectionForOrphanedConnection(a.getSourceBlock(), orphanPrev)
|
|
62
|
+
if (canWrap) {
|
|
63
|
+
// Skip the base class NEXT_STATEMENT check (which would reject
|
|
64
|
+
// this) but still apply the other generic guards it uses.
|
|
65
|
+
if ('distanceFrom' in a && a.distanceFrom(b) > distance) return false
|
|
66
|
+
if (b.getSourceBlock().isInsertionMarker()) return false
|
|
67
|
+
if (Blockly.common.draggingConnections.includes(b)) return false
|
|
68
|
+
return true
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
47
73
|
return super.doDragChecks(a, b, distance)
|
|
48
74
|
}
|
|
49
75
|
}
|