scratch-blocks 2.1.17 → 2.1.19
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/dist/main.mjs +1 -1
- package/dist/types/src/checkable_continuous_flyout.d.ts.map +1 -1
- package/dist/types/src/fields/scratch_field_angle.d.ts.map +1 -1
- package/dist/types/src/scratch_blocks_utils.d.ts +10 -6
- package/dist/types/src/scratch_blocks_utils.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/checkable_continuous_flyout.ts +1 -2
- package/src/fields/scratch_field_angle.ts +5 -0
- package/src/scratch_block_paster.ts +1 -1
- package/src/scratch_blocks_utils.ts +27 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkable_continuous_flyout.d.ts","sourceRoot":"","sources":["../../../src/checkable_continuous_flyout.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,gBAAgB,EAAE,KAAK,eAAe,EAAE,MAAM,6BAA6B,CAAA;AACpF,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AAkBvC,qBAAa,yBAA0B,SAAQ,gBAAgB;IAC7D,UAAkB,SAAS,EAAE,MAAM,CAAA;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IAErB;;;OAGG;gBACS,gBAAgB,EAAE,OAAO,CAAC,OAAO;IAQ7C;;;;OAIG;IACH,SAAS,CAAC,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,QAAQ;
|
|
1
|
+
{"version":3,"file":"checkable_continuous_flyout.d.ts","sourceRoot":"","sources":["../../../src/checkable_continuous_flyout.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,gBAAgB,EAAE,KAAK,eAAe,EAAE,MAAM,6BAA6B,CAAA;AACpF,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AAkBvC,qBAAa,yBAA0B,SAAQ,gBAAgB;IAC7D,UAAkB,SAAS,EAAE,MAAM,CAAA;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IAErB;;;OAGG;gBACS,gBAAgB,EAAE,OAAO,CAAC,OAAO;IAQ7C;;;;OAIG;IACH,SAAS,CAAC,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,QAAQ;IAUhD;;;;OAIG;IACH,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO;IAahD,cAAc;IAId,QAAQ;IAIR,SAAS,CAAC,eAAe;IAwBzB;;;;OAIG;IACH,SAAS,CAAC,kBAAkB,CAAC,IAAI,EAAE,OAAO,CAAC,UAAU,GAAG,IAAI,IAAI,eAAe;IAO/E;;OAEG;IACH,oBAAoB;IASpB,QAAQ,CAAC,QAAQ,EAAE,MAAM;CAG1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scratch_field_angle.d.ts","sourceRoot":"","sources":["../../../../src/fields/scratch_field_angle.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"scratch_field_angle.d.ts","sourceRoot":"","sources":["../../../../src/fields/scratch_field_angle.ts"],"names":[],"mappings":"AAucA,MAAM,WAAW,2BAA2B;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED;;GAEG;AACH,wBAAgB,yBAAyB,SAExC"}
|
|
@@ -22,14 +22,18 @@
|
|
|
22
22
|
*/
|
|
23
23
|
import type * as Blockly from 'blockly/core';
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
25
|
+
* Return a new serialized block state object with `id` properties removed
|
|
26
|
+
* from this block and recursively from nested `inputs`/`next` block and
|
|
27
|
+
* shadow states so they get fresh IDs when deserialized onto the workspace.
|
|
28
|
+
* The input state is NOT modified. Blockly's serialization shares shadow
|
|
29
|
+
* state objects by reference with the live workspace, so mutating the
|
|
30
|
+
* serialized tree in place would corrupt the original block's internal
|
|
31
|
+
* shadow state.
|
|
30
32
|
* @param state A serialized block state object.
|
|
33
|
+
* @returns A new state object with `id` properties removed from serialized
|
|
34
|
+
* block/shadow subtrees.
|
|
31
35
|
*/
|
|
32
|
-
export declare function stripIds(state: Blockly.serialization.blocks.State):
|
|
36
|
+
export declare function stripIds(state: Blockly.serialization.blocks.State): Blockly.serialization.blocks.State;
|
|
33
37
|
/**
|
|
34
38
|
* Compare strings with natural number sorting.
|
|
35
39
|
* @param str1 First input.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scratch_blocks_utils.d.ts","sourceRoot":"","sources":["../../../src/scratch_blocks_utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH;;;GAGG;AACH,OAAO,KAAK,KAAK,OAAO,MAAM,cAAc,CAAA;AAE5C
|
|
1
|
+
{"version":3,"file":"scratch_blocks_utils.d.ts","sourceRoot":"","sources":["../../../src/scratch_blocks_utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH;;;GAGG;AACH,OAAO,KAAK,KAAK,OAAO,MAAM,cAAc,CAAA;AAE5C;;;;;;;;;;;GAWG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,CAqBtG;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAKjE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scratch-blocks",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.19",
|
|
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,8 +38,8 @@
|
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@commitlint/cli": "20.5.0",
|
|
40
40
|
"@commitlint/config-conventional": "20.5.0",
|
|
41
|
-
"@vitest/browser": "4.1.
|
|
42
|
-
"@vitest/browser-playwright": "4.1.
|
|
41
|
+
"@vitest/browser": "4.1.5",
|
|
42
|
+
"@vitest/browser-playwright": "4.1.5",
|
|
43
43
|
"eslint": "9.39.4",
|
|
44
44
|
"eslint-config-scratch": "14.1.12",
|
|
45
45
|
"husky": "9.1.7",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"source-map-loader": "5.0.0",
|
|
51
51
|
"ts-loader": "9.5.7",
|
|
52
52
|
"typescript": "5.9.3",
|
|
53
|
-
"vitest": "4.1.
|
|
53
|
+
"vitest": "4.1.5",
|
|
54
54
|
"webpack": "5.106.2",
|
|
55
55
|
"webpack-cli": "6.0.1",
|
|
56
56
|
"webpack-dev-server": "5.2.3"
|
|
@@ -50,8 +50,7 @@ export class CheckableContinuousFlyout extends ContinuousFlyout {
|
|
|
50
50
|
// from a previous copy can reuse the flyout's IDs, causing two workspace
|
|
51
51
|
// blocks to share the same shadow in the VM. Deleting one then destroys
|
|
52
52
|
// the other's shadow (bug 878291).
|
|
53
|
-
stripIds(json)
|
|
54
|
-
return json
|
|
53
|
+
return stripIds(json)
|
|
55
54
|
}
|
|
56
55
|
|
|
57
56
|
/**
|
|
@@ -140,12 +140,15 @@ class ScratchFieldAngle extends Blockly.FieldNumber {
|
|
|
140
140
|
this.gauge = undefined
|
|
141
141
|
if (this.mouseDownWrapper_) {
|
|
142
142
|
Blockly.browserEvents.unbind(this.mouseDownWrapper_)
|
|
143
|
+
this.mouseDownWrapper_ = undefined
|
|
143
144
|
}
|
|
144
145
|
if (this.mouseUpWrapper) {
|
|
145
146
|
Blockly.browserEvents.unbind(this.mouseUpWrapper)
|
|
147
|
+
this.mouseUpWrapper = undefined
|
|
146
148
|
}
|
|
147
149
|
if (this.mouseMoveWrapper) {
|
|
148
150
|
Blockly.browserEvents.unbind(this.mouseMoveWrapper)
|
|
151
|
+
this.mouseMoveWrapper = undefined
|
|
149
152
|
}
|
|
150
153
|
}
|
|
151
154
|
|
|
@@ -298,9 +301,11 @@ class ScratchFieldAngle extends Blockly.FieldNumber {
|
|
|
298
301
|
onMouseUp() {
|
|
299
302
|
if (this.mouseMoveWrapper) {
|
|
300
303
|
Blockly.browserEvents.unbind(this.mouseMoveWrapper)
|
|
304
|
+
this.mouseMoveWrapper = undefined
|
|
301
305
|
}
|
|
302
306
|
if (this.mouseUpWrapper) {
|
|
303
307
|
Blockly.browserEvents.unbind(this.mouseUpWrapper)
|
|
308
|
+
this.mouseUpWrapper = undefined
|
|
304
309
|
}
|
|
305
310
|
}
|
|
306
311
|
|
|
@@ -28,7 +28,7 @@ class ScratchBlockPaster extends Blockly.clipboard.BlockPaster {
|
|
|
28
28
|
// original block can reuse the same ID, causing the VM to think both
|
|
29
29
|
// blocks share the same shadow. Deleting one then destroys the other's
|
|
30
30
|
// shadow (forum topic 878291).
|
|
31
|
-
stripIds(copyData.blockState)
|
|
31
|
+
copyData = { ...copyData, blockState: stripIds(copyData.blockState) }
|
|
32
32
|
const block = super.paste(copyData, workspace, coordinate)
|
|
33
33
|
if (block?.type === 'argument_reporter_boolean' || block?.type === 'argument_reporter_string_number') {
|
|
34
34
|
block.setDragStrategy(new Blockly.dragging.BlockDragStrategy(block))
|
|
@@ -23,26 +23,38 @@
|
|
|
23
23
|
import type * as Blockly from 'blockly/core'
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
26
|
+
* Return a new serialized block state object with `id` properties removed
|
|
27
|
+
* from this block and recursively from nested `inputs`/`next` block and
|
|
28
|
+
* shadow states so they get fresh IDs when deserialized onto the workspace.
|
|
29
|
+
* The input state is NOT modified. Blockly's serialization shares shadow
|
|
30
|
+
* state objects by reference with the live workspace, so mutating the
|
|
31
|
+
* serialized tree in place would corrupt the original block's internal
|
|
32
|
+
* shadow state.
|
|
31
33
|
* @param state A serialized block state object.
|
|
34
|
+
* @returns A new state object with `id` properties removed from serialized
|
|
35
|
+
* block/shadow subtrees.
|
|
32
36
|
*/
|
|
33
|
-
export function stripIds(state: Blockly.serialization.blocks.State):
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
export function stripIds(state: Blockly.serialization.blocks.State): Blockly.serialization.blocks.State {
|
|
38
|
+
const copy: Blockly.serialization.blocks.State = { ...state }
|
|
39
|
+
delete copy.id
|
|
40
|
+
if (copy.inputs) {
|
|
41
|
+
const inputs: typeof copy.inputs = {}
|
|
42
|
+
for (const inputName in copy.inputs) {
|
|
43
|
+
const conn = copy.inputs[inputName]
|
|
44
|
+
inputs[inputName] = {
|
|
45
|
+
...(conn.shadow && { shadow: stripIds(conn.shadow) }),
|
|
46
|
+
...(conn.block && { block: stripIds(conn.block) }),
|
|
47
|
+
}
|
|
40
48
|
}
|
|
49
|
+
copy.inputs = inputs
|
|
41
50
|
}
|
|
42
|
-
if (
|
|
43
|
-
|
|
44
|
-
|
|
51
|
+
if (copy.next) {
|
|
52
|
+
copy.next = {
|
|
53
|
+
...(copy.next.shadow && { shadow: stripIds(copy.next.shadow) }),
|
|
54
|
+
...(copy.next.block && { block: stripIds(copy.next.block) }),
|
|
55
|
+
}
|
|
45
56
|
}
|
|
57
|
+
return copy
|
|
46
58
|
}
|
|
47
59
|
|
|
48
60
|
/**
|