pxt-core 7.5.27 → 7.5.28

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/built/pxt.js CHANGED
@@ -138736,7 +138736,6 @@ var ts;
138736
138736
  // don't export, fuse is internal only
138737
138737
  let lastFuse;
138738
138738
  let lastProjectFuse;
138739
- let lastExtensionFuse;
138740
138739
  function fileDiags(fn) {
138741
138740
  if (!/\.ts$/.test(fn))
138742
138741
  return [];
@@ -139157,26 +139156,6 @@ var ts;
139157
139156
  const fns = lastFuse.search(search.term);
139158
139157
  return fns.slice(0, SEARCH_RESULT_COUNT);
139159
139158
  },
139160
- extensionSearch: v => {
139161
- const extensions = v.extensions.srcs;
139162
- const searchFor = v.search.term;
139163
- const fuseOptions = {
139164
- shouldSort: true,
139165
- threshold: 0.6,
139166
- location: 0,
139167
- distance: 100,
139168
- maxPatternLength: 16,
139169
- minMatchCharLength: 2,
139170
- findAllMatches: false,
139171
- caseSensitive: false,
139172
- keys: [
139173
- { name: 'name', weight: 1 }
139174
- ]
139175
- };
139176
- lastExtensionFuse = new Fuse(extensions, fuseOptions);
139177
- const found = lastExtensionFuse.search(searchFor);
139178
- return found;
139179
- },
139180
139159
  projectSearch: v => {
139181
139160
  const search = v.projectSearch;
139182
139161
  const searchSet = search.headers;
@@ -141486,9 +141465,27 @@ var pxt;
141486
141465
  unifyTypeOf(n.target, tpNumber);
141487
141466
  let start = r.args.length == 1 ? B.mkText("0") : expr(r.args[0]);
141488
141467
  let stop = expr(r.args[r.args.length == 1 ? 0 : 1]);
141489
- return B.mkStmt(B.mkText("for ("), B.mkInfix(def, "=", start), B.mkText("; "), B.mkInfix(ref, "<", stop), B.mkText("; "), r.args.length >= 3 ?
141490
- B.mkInfix(ref, "+=", expr(r.args[2])) :
141491
- B.mkPostfix([ref], "++"), B.mkText(")"), stmts(n.body));
141468
+ if (r.args.length <= 2) {
141469
+ return B.mkStmt(B.mkText("for ("), B.mkInfix(def, "=", start), B.mkText("; "), B.mkInfix(ref, "<", stop), B.mkText("; "), B.mkPostfix([ref], "++"), B.mkText(")"), stmts(n.body));
141470
+ }
141471
+ // If there are three range arguments, the comparator we need to use
141472
+ // will either be > or < depending on the sign of the third argument.
141473
+ let numValue = r.args[2].kind === "Num" ? r.args[2].n : undefined;
141474
+ if (numValue == undefined && r.args[2].kind === "UnaryOp") {
141475
+ const uOp = r.args[2];
141476
+ if (uOp.operand.kind === "Num") {
141477
+ if (uOp.op === "UAdd")
141478
+ numValue = uOp.operand.n;
141479
+ else if (uOp.op === "USub")
141480
+ numValue = -uOp.operand.n;
141481
+ }
141482
+ }
141483
+ // If the third argument is not a number, we can't know the sign so we
141484
+ // have to emit a for-of loop instead
141485
+ if (numValue !== undefined) {
141486
+ const comparator = numValue > 0 ? "<" : ">";
141487
+ return B.mkStmt(B.mkText("for ("), B.mkInfix(def, "=", start), B.mkText("; "), B.mkInfix(ref, comparator, stop), B.mkText("; "), B.mkInfix(ref, "+=", expr(r.args[2])), B.mkText(")"), stmts(n.body));
141488
+ }
141492
141489
  }
141493
141490
  if (currIteration > 1) {
141494
141491
  const typeOfTarget = typeOf(n.target);
@@ -985,7 +985,6 @@ declare namespace ts.pxtc.service {
985
985
  snippet: (v: OpArg) => string;
986
986
  blocksInfo: (v: OpArg) => BlocksInfo;
987
987
  apiSearch: (v: OpArg) => SearchInfo[];
988
- extensionSearch: (v: OpArg) => ExtensionMeta[];
989
988
  projectSearch: (v: OpArg) => ProjectSearchInfo[];
990
989
  projectSearchClear: () => void;
991
990
  }
@@ -17682,7 +17682,6 @@ var ts;
17682
17682
  // don't export, fuse is internal only
17683
17683
  let lastFuse;
17684
17684
  let lastProjectFuse;
17685
- let lastExtensionFuse;
17686
17685
  function fileDiags(fn) {
17687
17686
  if (!/\.ts$/.test(fn))
17688
17687
  return [];
@@ -18103,26 +18102,6 @@ var ts;
18103
18102
  const fns = lastFuse.search(search.term);
18104
18103
  return fns.slice(0, SEARCH_RESULT_COUNT);
18105
18104
  },
18106
- extensionSearch: v => {
18107
- const extensions = v.extensions.srcs;
18108
- const searchFor = v.search.term;
18109
- const fuseOptions = {
18110
- shouldSort: true,
18111
- threshold: 0.6,
18112
- location: 0,
18113
- distance: 100,
18114
- maxPatternLength: 16,
18115
- minMatchCharLength: 2,
18116
- findAllMatches: false,
18117
- caseSensitive: false,
18118
- keys: [
18119
- { name: 'name', weight: 1 }
18120
- ]
18121
- };
18122
- lastExtensionFuse = new Fuse(extensions, fuseOptions);
18123
- const found = lastExtensionFuse.search(searchFor);
18124
- return found;
18125
- },
18126
18105
  projectSearch: v => {
18127
18106
  const search = v.projectSearch;
18128
18107
  const searchSet = search.headers;
package/built/pxtpy.js CHANGED
@@ -1231,9 +1231,27 @@ var pxt;
1231
1231
  unifyTypeOf(n.target, tpNumber);
1232
1232
  let start = r.args.length == 1 ? B.mkText("0") : expr(r.args[0]);
1233
1233
  let stop = expr(r.args[r.args.length == 1 ? 0 : 1]);
1234
- return B.mkStmt(B.mkText("for ("), B.mkInfix(def, "=", start), B.mkText("; "), B.mkInfix(ref, "<", stop), B.mkText("; "), r.args.length >= 3 ?
1235
- B.mkInfix(ref, "+=", expr(r.args[2])) :
1236
- B.mkPostfix([ref], "++"), B.mkText(")"), stmts(n.body));
1234
+ if (r.args.length <= 2) {
1235
+ return B.mkStmt(B.mkText("for ("), B.mkInfix(def, "=", start), B.mkText("; "), B.mkInfix(ref, "<", stop), B.mkText("; "), B.mkPostfix([ref], "++"), B.mkText(")"), stmts(n.body));
1236
+ }
1237
+ // If there are three range arguments, the comparator we need to use
1238
+ // will either be > or < depending on the sign of the third argument.
1239
+ let numValue = r.args[2].kind === "Num" ? r.args[2].n : undefined;
1240
+ if (numValue == undefined && r.args[2].kind === "UnaryOp") {
1241
+ const uOp = r.args[2];
1242
+ if (uOp.operand.kind === "Num") {
1243
+ if (uOp.op === "UAdd")
1244
+ numValue = uOp.operand.n;
1245
+ else if (uOp.op === "USub")
1246
+ numValue = -uOp.operand.n;
1247
+ }
1248
+ }
1249
+ // If the third argument is not a number, we can't know the sign so we
1250
+ // have to emit a for-of loop instead
1251
+ if (numValue !== undefined) {
1252
+ const comparator = numValue > 0 ? "<" : ">";
1253
+ return B.mkStmt(B.mkText("for ("), B.mkInfix(def, "=", start), B.mkText("; "), B.mkInfix(ref, comparator, stop), B.mkText("; "), B.mkInfix(ref, "+=", expr(r.args[2])), B.mkText(")"), stmts(n.body));
1254
+ }
1237
1255
  }
1238
1256
  if (currIteration > 1) {
1239
1257
  const typeOfTarget = typeOf(n.target);