Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/blocks/scratch3_json.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
valueOfKey (args) {
args.OBJ = Cast.toObject(args.OBJ);
args.KEY = Cast.toString(args.KEY);
return args.OBJ[args.KEY] ?? "";
return args.OBJ[args.KEY] ?? '';
}

setKey (args) {
Expand All @@ -91,7 +91,7 @@
hasKey (args) {
args.OBJ = Cast.toObject(args.OBJ);
args.KEY = Cast.toString(args.KEY);
return args.OBJ.hasOwnProperty(args.KEY);

Check failure on line 94 in src/blocks/scratch3_json.js

View workflow job for this annotation

GitHub Actions / build

Do not access Object.prototype method 'hasOwnProperty' from target object

Check failure on line 94 in src/blocks/scratch3_json.js

View workflow job for this annotation

GitHub Actions / build

Do not access Object.prototype method 'hasOwnProperty' from target object
}

newArray () {
Expand All @@ -106,12 +106,12 @@
valueOfIndex (args) {
args.ARR = Cast.toArray(args.ARR);
args.INDEX = Cast.toNumber(args.INDEX);
return args.ARR[args.INDEX] ?? "";
return args.ARR[args.INDEX] ?? '';
}

indexOfValue (args) {
args.ARR = Cast.toArray(args.ARR);
return args.ARR.indexOf(args.VALUE) !== -1 ? args.ARR.indexOf(args.VALUE) : "";
return args.ARR.indexOf(args.VALUE) !== -1 ? args.ARR.indexOf(args.VALUE) : '';

Check failure on line 114 in src/blocks/scratch3_json.js

View workflow job for this annotation

GitHub Actions / build

Unexpected negated condition

Check failure on line 114 in src/blocks/scratch3_json.js

View workflow job for this annotation

GitHub Actions / build

Unexpected negated condition
}

addItem (args) {
Expand All @@ -126,9 +126,9 @@
if (args.INDEX >= 0 && args.INDEX < args.ARR.length) {
args.ARR[args.INDEX] = args.ITEM;
return args.ARR;
} else {
return new Array();
}
return new Array();

}

deleteIndex (args) {
Expand All @@ -137,15 +137,15 @@
if (args.INDEX >= 0 && args.INDEX < args.ARR.length) {
args.ARR.splice(args.INDEX, 1);
return args.ARR;
} else {
return new Array();
}
return new Array();

}

deleteAllOccurrences (args) {
args.ARR = Cast.toArray(args.ARR);
args.ITEM = Cast.toString(args.ITEM);
return args.ARR.filter((item) => item !== args.ITEM);
return args.ARR.filter(item => item !== args.ITEM);
}

mergeArray (args) {
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/scratch3_operators.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Scratch3OperatorsBlocks {
}

checkbox () {
return true;
return true;
}

add (args) {
Expand Down
1 change: 1 addition & 0 deletions src/blocks/scratch3_sensing.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ class Scratch3SensingBlocks {
case 'hour': return date.getHours();
case 'minute': return date.getMinutes();
case 'second': return date.getSeconds();
case 'refreshtime': return this.runtime.screenRefreshTime / 1000;
}
return 0;
}
Expand Down
20 changes: 12 additions & 8 deletions src/compiler/irgen.js
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,10 @@ class ScriptTreeGenerator {
return {
kind: 'sensing.second'
};
case 'refreshtime':
return {
kind: 'sensing.refreshTime'
};
}
return {
kind: 'constant',
Expand Down Expand Up @@ -796,25 +800,25 @@ class ScriptTreeGenerator {
return {
kind: 'comments.reporter',
value: this.descendInputOfBlock(block, 'VALUE'),
comment: this.descendInputOfBlock(block, 'COMMENT'),
comment: this.descendInputOfBlock(block, 'COMMENT')
};
case 'comments_boolean':
return {
kind: 'comments.boolean',
value: this.descendInputOfBlock(block, 'VALUE'),
comment: this.descendInputOfBlock(block, 'COMMENT'),
comment: this.descendInputOfBlock(block, 'COMMENT')
};
case 'comments_object':
return {
kind: 'comments.object',
value: this.descendInputOfBlock(block, 'VALUE'),
comment: this.descendInputOfBlock(block, 'COMMENT'),
comment: this.descendInputOfBlock(block, 'COMMENT')
};
case 'comments_array':
return {
kind: 'comments.array',
value: this.descendInputOfBlock(block, 'VALUE'),
comment: this.descendInputOfBlock(block, 'COMMENT'),
comment: this.descendInputOfBlock(block, 'COMMENT')
};

case 'tw_getLastKeyPressed':
Expand All @@ -834,10 +838,10 @@ class ScriptTreeGenerator {
if (blockInfo) {
const type = blockInfo.info.blockType;
if (
type === BlockType.REPORTER
|| type === BlockType.BOOLEAN
|| type === BlockType.OBJECT
|| type === BlockType.ARRAY
type === BlockType.REPORTER ||
type === BlockType.BOOLEAN ||
type === BlockType.OBJECT ||
type === BlockType.ARRAY
) {
return this.descendCompatLayer(block);
}
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/jsexecute.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @fileoverview Runtime for scripts generated by jsgen
*/

const { supportsNullishCoalescing: canNullCoalsh } = require('./environment');
const {supportsNullishCoalescing: canNullCoalsh} = require('./environment');

/* eslint-disable no-unused-vars */
/* eslint-disable prefer-template */
Expand Down
2 changes: 2 additions & 0 deletions src/compiler/jsgen.js
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,8 @@ class JSGenerator {
return new TypedInput(`(new Date().getMinutes())`, TYPE_NUMBER);
case 'sensing.month':
return new TypedInput(`(new Date().getMonth() + 1)`, TYPE_NUMBER);
case 'sensing.refreshTime':
return new TypedInput(`(runtime.screenRefreshTime / 1000)`, TYPE_NUMBER_NAN);
case 'sensing.of': {
const object = this.descendInput(node.object).asString();
const property = node.property;
Expand Down
6 changes: 3 additions & 3 deletions src/engine/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -919,9 +919,9 @@
if (preserve) {
const parent = this._blocks[block.parent];
const next = this._blocks[block.next];
const input = parent?.inputs
? Object.values(parent.inputs).find(input => input.block === blockId)
: null;
const input = parent?.inputs ?
Object.values(parent.inputs).find(input => input.block === blockId) :

Check failure on line 923 in src/engine/blocks.js

View workflow job for this annotation

GitHub Actions / build

'input' is already declared in the upper scope on line 922 column 19

Check failure on line 923 in src/engine/blocks.js

View workflow job for this annotation

GitHub Actions / build

'input' is already declared in the upper scope on line 922 column 19
null;
if (parent && !input) {
parent.next = block.next;
}
Expand Down
Loading
Loading