Skip to content

Commit 7589acf

Browse files
committed
Frameloop nextgen update (with lint)
Signed-off-by: FurryR <[email protected]>
1 parent 44c475f commit 7589acf

File tree

11 files changed

+793
-348
lines changed

11 files changed

+793
-348
lines changed

src/blocks/scratch3_json.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class Scratch3JSONBlocks {
6565
valueOfKey (args) {
6666
args.OBJ = Cast.toObject(args.OBJ);
6767
args.KEY = Cast.toString(args.KEY);
68-
return args.OBJ[args.KEY] ?? "";
68+
return args.OBJ[args.KEY] ?? '';
6969
}
7070

7171
setKey (args) {
@@ -106,12 +106,12 @@ class Scratch3JSONBlocks {
106106
valueOfIndex (args) {
107107
args.ARR = Cast.toArray(args.ARR);
108108
args.INDEX = Cast.toNumber(args.INDEX);
109-
return args.ARR[args.INDEX] ?? "";
109+
return args.ARR[args.INDEX] ?? '';
110110
}
111111

112112
indexOfValue (args) {
113113
args.ARR = Cast.toArray(args.ARR);
114-
return args.ARR.indexOf(args.VALUE) !== -1 ? args.ARR.indexOf(args.VALUE) : "";
114+
return args.ARR.indexOf(args.VALUE) !== -1 ? args.ARR.indexOf(args.VALUE) : '';
115115
}
116116

117117
addItem (args) {
@@ -126,9 +126,9 @@ class Scratch3JSONBlocks {
126126
if (args.INDEX >= 0 && args.INDEX < args.ARR.length) {
127127
args.ARR[args.INDEX] = args.ITEM;
128128
return args.ARR;
129-
} else {
130-
return new Array();
131129
}
130+
return new Array();
131+
132132
}
133133

134134
deleteIndex (args) {
@@ -137,15 +137,15 @@ class Scratch3JSONBlocks {
137137
if (args.INDEX >= 0 && args.INDEX < args.ARR.length) {
138138
args.ARR.splice(args.INDEX, 1);
139139
return args.ARR;
140-
} else {
141-
return new Array();
142140
}
141+
return new Array();
142+
143143
}
144144

145145
deleteAllOccurrences (args) {
146146
args.ARR = Cast.toArray(args.ARR);
147147
args.ITEM = Cast.toString(args.ITEM);
148-
return args.ARR.filter((item) => item !== args.ITEM);
148+
return args.ARR.filter(item => item !== args.ITEM);
149149
}
150150

151151
mergeArray (args) {

src/blocks/scratch3_operators.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class Scratch3OperatorsBlocks {
3939
}
4040

4141
checkbox () {
42-
return true;
42+
return true;
4343
}
4444

4545
add (args) {

src/blocks/scratch3_sensing.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ class Scratch3SensingBlocks {
253253
case 'hour': return date.getHours();
254254
case 'minute': return date.getMinutes();
255255
case 'second': return date.getSeconds();
256+
case 'refreshTime': return this.runtime.screenRefreshTime / 1000;
256257
}
257258
return 0;
258259
}

src/compiler/irgen.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,10 @@ class ScriptTreeGenerator {
728728
return {
729729
kind: 'sensing.second'
730730
};
731+
case 'refreshTime':
732+
return {
733+
kind: 'sensing.refreshTime'
734+
};
731735
}
732736
return {
733737
kind: 'constant',
@@ -796,25 +800,25 @@ class ScriptTreeGenerator {
796800
return {
797801
kind: 'comments.reporter',
798802
value: this.descendInputOfBlock(block, 'VALUE'),
799-
comment: this.descendInputOfBlock(block, 'COMMENT'),
803+
comment: this.descendInputOfBlock(block, 'COMMENT')
800804
};
801805
case 'comments_boolean':
802806
return {
803807
kind: 'comments.boolean',
804808
value: this.descendInputOfBlock(block, 'VALUE'),
805-
comment: this.descendInputOfBlock(block, 'COMMENT'),
809+
comment: this.descendInputOfBlock(block, 'COMMENT')
806810
};
807811
case 'comments_object':
808812
return {
809813
kind: 'comments.object',
810814
value: this.descendInputOfBlock(block, 'VALUE'),
811-
comment: this.descendInputOfBlock(block, 'COMMENT'),
815+
comment: this.descendInputOfBlock(block, 'COMMENT')
812816
};
813817
case 'comments_array':
814818
return {
815819
kind: 'comments.array',
816820
value: this.descendInputOfBlock(block, 'VALUE'),
817-
comment: this.descendInputOfBlock(block, 'COMMENT'),
821+
comment: this.descendInputOfBlock(block, 'COMMENT')
818822
};
819823

820824
case 'tw_getLastKeyPressed':
@@ -834,10 +838,10 @@ class ScriptTreeGenerator {
834838
if (blockInfo) {
835839
const type = blockInfo.info.blockType;
836840
if (
837-
type === BlockType.REPORTER
838-
|| type === BlockType.BOOLEAN
839-
|| type === BlockType.OBJECT
840-
|| type === BlockType.ARRAY
841+
type === BlockType.REPORTER ||
842+
type === BlockType.BOOLEAN ||
843+
type === BlockType.OBJECT ||
844+
type === BlockType.ARRAY
841845
) {
842846
return this.descendCompatLayer(block);
843847
}

src/compiler/jsexecute.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @fileoverview Runtime for scripts generated by jsgen
33
*/
44

5-
const { supportsNullishCoalescing: canNullCoalsh } = require('./environment');
5+
const {supportsNullishCoalescing: canNullCoalsh} = require('./environment');
66

77
/* eslint-disable no-unused-vars */
88
/* eslint-disable prefer-template */

src/compiler/jsgen.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,8 @@ class JSGenerator {
778778
return new TypedInput(`(new Date().getMinutes())`, TYPE_NUMBER);
779779
case 'sensing.month':
780780
return new TypedInput(`(new Date().getMonth() + 1)`, TYPE_NUMBER);
781+
case 'sensing.refreshTime':
782+
return new TypedInput(`(runtime.screenRefreshTime / 1000)`, TYPE_NUMBER_NAN);
781783
case 'sensing.of': {
782784
const object = this.descendInput(node.object).asString();
783785
const property = node.property;

src/engine/blocks.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -919,9 +919,9 @@ class Blocks {
919919
if (preserve) {
920920
const parent = this._blocks[block.parent];
921921
const next = this._blocks[block.next];
922-
const input = parent?.inputs
923-
? Object.values(parent.inputs).find(input => input.block === blockId)
924-
: null;
922+
const input = parent?.inputs ?
923+
Object.values(parent.inputs).find(input => input.block === blockId) :
924+
null;
925925
if (parent && !input) {
926926
parent.next = block.next;
927927
}

0 commit comments

Comments
 (0)