pxt-core 12.2.2 → 12.2.3

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.
@@ -143,13 +143,13 @@ var pxtc = ts.pxtc;
143
143
  function htmlEscape(_input) {
144
144
  if (!_input)
145
145
  return _input; // null, undefined, empty string test
146
- return _input.replace(/([^\w .!?\-$])/g, c => "&#" + c.charCodeAt(0) + ";");
146
+ return _input.replace(/([^\w .!?\-$])/ug, c => "&#" + c.codePointAt(0) + ";");
147
147
  }
148
148
  Util.htmlEscape = htmlEscape;
149
149
  function htmlUnescape(_input) {
150
150
  if (!_input)
151
151
  return _input; // null, undefined, empty string test
152
- return _input.replace(/(&#\d+;)/g, c => String.fromCharCode(Number(c.substr(2, c.length - 3))));
152
+ return _input.replace(/(&#\d+;)/g, c => String.fromCodePoint(Number(c.substr(2, c.length - 3))));
153
153
  }
154
154
  Util.htmlUnescape = htmlUnescape;
155
155
  function jsStringQuote(s) {
package/built/pxt.js CHANGED
@@ -98753,13 +98753,13 @@ var pxtc = ts.pxtc;
98753
98753
  function htmlEscape(_input) {
98754
98754
  if (!_input)
98755
98755
  return _input; // null, undefined, empty string test
98756
- return _input.replace(/([^\w .!?\-$])/g, c => "&#" + c.charCodeAt(0) + ";");
98756
+ return _input.replace(/([^\w .!?\-$])/ug, c => "&#" + c.codePointAt(0) + ";");
98757
98757
  }
98758
98758
  Util.htmlEscape = htmlEscape;
98759
98759
  function htmlUnescape(_input) {
98760
98760
  if (!_input)
98761
98761
  return _input; // null, undefined, empty string test
98762
- return _input.replace(/(&#\d+;)/g, c => String.fromCharCode(Number(c.substr(2, c.length - 3))));
98762
+ return _input.replace(/(&#\d+;)/g, c => String.fromCodePoint(Number(c.substr(2, c.length - 3))));
98763
98763
  }
98764
98764
  Util.htmlUnescape = htmlUnescape;
98765
98765
  function jsStringQuote(s) {
@@ -102104,8 +102104,19 @@ var pxt;
102104
102104
  }
102105
102105
  blocks.hasHandler = hasHandler;
102106
102106
  function getHelpUrl(fn) {
102107
- if (fn.attributes.help) {
102108
- const helpUrl = fn.attributes.help.replace(/^\//, '');
102107
+ var _a, _b, _c;
102108
+ let helpAttr = fn.attributes.help;
102109
+ if ((_a = fn.attributes.blockId) === null || _a === void 0 ? void 0 : _a.endsWith(`_blockCombine_get`)) {
102110
+ helpAttr = fn.attributes.blockCombineGetHelp || helpAttr;
102111
+ }
102112
+ else if ((_b = fn.attributes.blockId) === null || _b === void 0 ? void 0 : _b.endsWith(`_blockCombine_set`)) {
102113
+ helpAttr = fn.attributes.blockCombineSetHelp || helpAttr;
102114
+ }
102115
+ else if ((_c = fn.attributes.blockId) === null || _c === void 0 ? void 0 : _c.endsWith(`_blockCombine_change`)) {
102116
+ helpAttr = fn.attributes.blockCombineChangeHelp || helpAttr;
102117
+ }
102118
+ if (helpAttr) {
102119
+ const helpUrl = helpAttr.replace(/^\//, '');
102109
102120
  if (/^github:/.test(helpUrl)) {
102110
102121
  return helpUrl;
102111
102122
  }
@@ -115593,6 +115604,22 @@ var ts;
115593
115604
  }
115594
115605
  blocks.push(ex);
115595
115606
  }
115607
+ function copyOverHelp(param) {
115608
+ if (s.attributes[param]) {
115609
+ if (ex.attributes[param]) {
115610
+ if (ex.attributes[param] !== s.attributes[param]) {
115611
+ console.warn(`Ignoring duplicate ${param} for get/set/change block: ${s.attributes[param]}`);
115612
+ }
115613
+ }
115614
+ else {
115615
+ ex.attributes[param] = s.attributes[param];
115616
+ }
115617
+ }
115618
+ }
115619
+ copyOverHelp("blockCombineChangeHelp");
115620
+ copyOverHelp("blockCombineGetHelp");
115621
+ copyOverHelp("blockCombineSetHelp");
115622
+ copyOverHelp("help");
115596
115623
  ex.combinedProperties.push(s.qName);
115597
115624
  }
115598
115625
  for (let s of pxtc.Util.values(info.byQName)) {
@@ -118066,7 +118093,7 @@ var pxt;
118066
118093
  this.nextID = 0;
118067
118094
  this.nextInternalID = 0;
118068
118095
  this.committedState = {
118069
- revision: 0,
118096
+ revision: TilemapProject.nextRevision++,
118070
118097
  assets: {
118071
118098
  ["image" /* AssetType.Image */]: new AssetCollection("image" /* AssetType.Image */),
118072
118099
  ["tile" /* AssetType.Tile */]: new AssetCollection("tile" /* AssetType.Tile */),
@@ -118077,7 +118104,7 @@ var pxt;
118077
118104
  }
118078
118105
  };
118079
118106
  this.state = {
118080
- revision: this.nextID++,
118107
+ revision: TilemapProject.nextRevision++,
118081
118108
  assets: {
118082
118109
  ["image" /* AssetType.Image */]: new AssetCollection("image" /* AssetType.Image */),
118083
118110
  ["tile" /* AssetType.Tile */]: new AssetCollection("tile" /* AssetType.Tile */),
@@ -118575,7 +118602,7 @@ var pxt;
118575
118602
  return this.getAssetCollection(type).getSnapshot();
118576
118603
  }
118577
118604
  getGalleryAssets(type) {
118578
- return this.getAssetCollection(type).getSnapshot();
118605
+ return this.getAssetCollection(type, true).getSnapshot();
118579
118606
  }
118580
118607
  lookupBlockAsset(type, blockID) {
118581
118608
  let filter = (a) => { var _a, _b; return ((_b = (_a = a.meta) === null || _a === void 0 ? void 0 : _a.blockIDs) === null || _b === void 0 ? void 0 : _b.indexOf(blockID)) !== -1; };
@@ -118928,7 +118955,7 @@ var pxt;
118928
118955
  }
118929
118956
  onChange() {
118930
118957
  this.needsRebuild = true;
118931
- this.state.revision = this.nextID++;
118958
+ this.state.revision = TilemapProject.nextRevision++;
118932
118959
  }
118933
118960
  readImages(allJRes, isProjectFile = false) {
118934
118961
  const assets = [];
@@ -118980,6 +119007,7 @@ var pxt;
118980
119007
  }
118981
119008
  }
118982
119009
  }
119010
+ TilemapProject.nextRevision = 0;
118983
119011
  pxt.TilemapProject = TilemapProject;
118984
119012
  function getTilemaps(allJRes) {
118985
119013
  const res = [];
@@ -126598,15 +126626,15 @@ var ts;
126598
126626
  "leaveAccessor"
126599
126627
  ];
126600
126628
  function jsEmit(bin, cres) {
126601
- let jssource = "(function (ectx) {\n'use strict';\n";
126629
+ let jsheader = "(function (ectx) {\n'use strict';\n";
126602
126630
  for (let n of evalIfaceFields) {
126603
- jssource += `const ${n} = ectx.${n};\n`;
126631
+ jsheader += `const ${n} = ectx.${n};\n`;
126604
126632
  }
126605
- jssource += `const __this = runtime;\n`;
126606
- jssource += `const pxtrt = pxsim.pxtrt;\n`;
126607
- jssource += `let yieldSteps = 1;\n`;
126608
- jssource += `ectx.setupYield(function() { yieldSteps = 100; })\n`;
126609
- jssource += "pxsim.setTitle(" + JSON.stringify(bin.getTitle()) + ");\n";
126633
+ jsheader += `const __this = runtime;\n`;
126634
+ jsheader += `const pxtrt = pxsim.pxtrt;\n`;
126635
+ jsheader += `let yieldSteps = 1;\n`;
126636
+ jsheader += `ectx.setupYield(function() { yieldSteps = 100; })\n`;
126637
+ let jssource = "pxsim.setTitle(" + JSON.stringify(bin.getTitle()) + ");\n";
126610
126638
  let cfg = {};
126611
126639
  let cfgKey = {};
126612
126640
  for (let ce of cres.configData || []) {
@@ -126628,6 +126656,9 @@ var ts;
126628
126656
  if (p.cachedJS) {
126629
126657
  curr = p.cachedJS;
126630
126658
  cachedLen += curr.length;
126659
+ for (const hexlit of Object.keys(p.cachedJSHexLiterals)) {
126660
+ bin.hexlits[hexlit] = p.cachedJSHexLiterals[hexlit];
126661
+ }
126631
126662
  }
126632
126663
  else {
126633
126664
  curr = irToJS(bin, p);
@@ -126642,6 +126673,10 @@ var ts;
126642
126673
  if (cres.breakpoints)
126643
126674
  jssource += `\nconst breakpoints = setupDebugger(${cres.breakpoints.length}, [${bin.globals.filter(c => c.isUserVariable).map(c => `"${c.uniqueName()}"`).join(",")}])\n`;
126644
126675
  jssource += `\nreturn ${bin.procs[0] ? bin.procs[0].label() : "null"}\n})\n`;
126676
+ for (const hexlit of Object.keys(bin.hexlits)) {
126677
+ jsheader += bin.hexlits[hexlit];
126678
+ }
126679
+ jssource = jsheader + jssource;
126645
126680
  const total = jssource.length;
126646
126681
  const perc = (n) => ((100 * n) / total).toFixed(2) + "%";
126647
126682
  const sizes = `// total=${jssource.length} new=${perc(newLen)} cached=${perc(cachedLen)} other=${perc(total - newLen - cachedLen)}\n`;
@@ -126658,7 +126693,6 @@ var ts;
126658
126693
  let exprStack = [];
126659
126694
  let maxStack = 0;
126660
126695
  let localsCache = {};
126661
- let hexlits = "";
126662
126696
  writeRaw(`
126663
126697
  function ${proc.label()}(s) {
126664
126698
  let r0 = s.r0, step = s.pc;
@@ -126748,7 +126782,6 @@ switch (step) {
126748
126782
  if (proc.isRoot)
126749
126783
  writeRaw(`${proc.label()}.continuations = [ ${asyncContinuations.join(",")} ]`);
126750
126784
  writeRaw(fnctor(proc.label() + "_mk", proc.label(), maxStack, Object.keys(localsCache)));
126751
- writeRaw(hexlits);
126752
126785
  proc.cachedJS = resText;
126753
126786
  return resText;
126754
126787
  // pre-create stack frame for this procedure with all the fields we need, so the
@@ -126869,7 +126902,9 @@ function ${id}(s) {
126869
126902
  return e.ptrlabel().lblId + "";
126870
126903
  }
126871
126904
  else if (e.hexlit() != null) {
126872
- hexlits += `const ${e.data} = pxsim.BufferMethods.createBufferFromHex("${e.hexlit()}")\n`;
126905
+ const lit = `const ${e.data} = pxsim.BufferMethods.createBufferFromHex("${e.hexlit()}")\n`;
126906
+ proc.cachedJSHexLiterals[e.data] = lit;
126907
+ bin.hexlits[e.data] = lit;
126873
126908
  return e.data;
126874
126909
  }
126875
126910
  else if (typeof e.jsInfo == "string") {
@@ -132765,6 +132800,7 @@ var ts;
132765
132800
  this.lblNo = 0;
132766
132801
  this.action = null;
132767
132802
  this.cachedJS = null;
132803
+ this.cachedJSHexLiterals = {};
132768
132804
  this.usingCtx = null;
132769
132805
  }
132770
132806
  reset() {
@@ -13,9 +13,11 @@ export declare type TilesetDropdownOption = [ImageJSON, string, pxt.Tile];
13
13
  export declare class FieldTileset extends FieldImages implements FieldCustom {
14
14
  protected selectedOption_: TilesetDropdownOption;
15
15
  protected static referencedTiles: TilesetDropdownOption[];
16
+ protected static cachedPalette: string;
16
17
  protected static cachedRevision: number;
17
- protected static cachedWorkspaceId: string;
18
+ protected static bitmapCache: Map<string, string>;
18
19
  protected static getReferencedTiles(workspace: Blockly.Workspace): TilesetDropdownOption[];
20
+ static getTileImage(t: pxt.Tile): string;
19
21
  isFieldCustom_: boolean;
20
22
  protected selected: pxt.Tile;
21
23
  protected blocksInfo: pxtc.BlocksInfo;
@@ -510,6 +510,7 @@ declare namespace ts.pxtc.ir {
510
510
  action: ts.FunctionLikeDeclaration;
511
511
  inlineBody: ir.Expr;
512
512
  cachedJS: string;
513
+ cachedJSHexLiterals: pxt.Map<string>;
513
514
  usingCtx: PxtNode;
514
515
  reset(): void;
515
516
  isGetter(): boolean;
@@ -2310,15 +2310,15 @@ var ts;
2310
2310
  "leaveAccessor"
2311
2311
  ];
2312
2312
  function jsEmit(bin, cres) {
2313
- let jssource = "(function (ectx) {\n'use strict';\n";
2313
+ let jsheader = "(function (ectx) {\n'use strict';\n";
2314
2314
  for (let n of evalIfaceFields) {
2315
- jssource += `const ${n} = ectx.${n};\n`;
2315
+ jsheader += `const ${n} = ectx.${n};\n`;
2316
2316
  }
2317
- jssource += `const __this = runtime;\n`;
2318
- jssource += `const pxtrt = pxsim.pxtrt;\n`;
2319
- jssource += `let yieldSteps = 1;\n`;
2320
- jssource += `ectx.setupYield(function() { yieldSteps = 100; })\n`;
2321
- jssource += "pxsim.setTitle(" + JSON.stringify(bin.getTitle()) + ");\n";
2317
+ jsheader += `const __this = runtime;\n`;
2318
+ jsheader += `const pxtrt = pxsim.pxtrt;\n`;
2319
+ jsheader += `let yieldSteps = 1;\n`;
2320
+ jsheader += `ectx.setupYield(function() { yieldSteps = 100; })\n`;
2321
+ let jssource = "pxsim.setTitle(" + JSON.stringify(bin.getTitle()) + ");\n";
2322
2322
  let cfg = {};
2323
2323
  let cfgKey = {};
2324
2324
  for (let ce of cres.configData || []) {
@@ -2340,6 +2340,9 @@ var ts;
2340
2340
  if (p.cachedJS) {
2341
2341
  curr = p.cachedJS;
2342
2342
  cachedLen += curr.length;
2343
+ for (const hexlit of Object.keys(p.cachedJSHexLiterals)) {
2344
+ bin.hexlits[hexlit] = p.cachedJSHexLiterals[hexlit];
2345
+ }
2343
2346
  }
2344
2347
  else {
2345
2348
  curr = irToJS(bin, p);
@@ -2354,6 +2357,10 @@ var ts;
2354
2357
  if (cres.breakpoints)
2355
2358
  jssource += `\nconst breakpoints = setupDebugger(${cres.breakpoints.length}, [${bin.globals.filter(c => c.isUserVariable).map(c => `"${c.uniqueName()}"`).join(",")}])\n`;
2356
2359
  jssource += `\nreturn ${bin.procs[0] ? bin.procs[0].label() : "null"}\n})\n`;
2360
+ for (const hexlit of Object.keys(bin.hexlits)) {
2361
+ jsheader += bin.hexlits[hexlit];
2362
+ }
2363
+ jssource = jsheader + jssource;
2357
2364
  const total = jssource.length;
2358
2365
  const perc = (n) => ((100 * n) / total).toFixed(2) + "%";
2359
2366
  const sizes = `// total=${jssource.length} new=${perc(newLen)} cached=${perc(cachedLen)} other=${perc(total - newLen - cachedLen)}\n`;
@@ -2370,7 +2377,6 @@ var ts;
2370
2377
  let exprStack = [];
2371
2378
  let maxStack = 0;
2372
2379
  let localsCache = {};
2373
- let hexlits = "";
2374
2380
  writeRaw(`
2375
2381
  function ${proc.label()}(s) {
2376
2382
  let r0 = s.r0, step = s.pc;
@@ -2460,7 +2466,6 @@ switch (step) {
2460
2466
  if (proc.isRoot)
2461
2467
  writeRaw(`${proc.label()}.continuations = [ ${asyncContinuations.join(",")} ]`);
2462
2468
  writeRaw(fnctor(proc.label() + "_mk", proc.label(), maxStack, Object.keys(localsCache)));
2463
- writeRaw(hexlits);
2464
2469
  proc.cachedJS = resText;
2465
2470
  return resText;
2466
2471
  // pre-create stack frame for this procedure with all the fields we need, so the
@@ -2581,7 +2586,9 @@ function ${id}(s) {
2581
2586
  return e.ptrlabel().lblId + "";
2582
2587
  }
2583
2588
  else if (e.hexlit() != null) {
2584
- hexlits += `const ${e.data} = pxsim.BufferMethods.createBufferFromHex("${e.hexlit()}")\n`;
2589
+ const lit = `const ${e.data} = pxsim.BufferMethods.createBufferFromHex("${e.hexlit()}")\n`;
2590
+ proc.cachedJSHexLiterals[e.data] = lit;
2591
+ bin.hexlits[e.data] = lit;
2585
2592
  return e.data;
2586
2593
  }
2587
2594
  else if (typeof e.jsInfo == "string") {
@@ -8477,6 +8484,7 @@ var ts;
8477
8484
  this.lblNo = 0;
8478
8485
  this.action = null;
8479
8486
  this.cachedJS = null;
8487
+ this.cachedJSHexLiterals = {};
8480
8488
  this.usingCtx = null;
8481
8489
  }
8482
8490
  reset() {
package/built/pxtlib.d.ts CHANGED
@@ -3028,6 +3028,7 @@ declare namespace pxt {
3028
3028
  }
3029
3029
  export class TilemapProject {
3030
3030
  needsRebuild: boolean;
3031
+ protected static nextRevision: number;
3031
3032
  protected extensionTileSets: TileSetCollection[];
3032
3033
  protected state: AssetSnapshot;
3033
3034
  protected committedState: AssetSnapshot;
package/built/pxtlib.js CHANGED
@@ -1032,13 +1032,13 @@ var pxtc = ts.pxtc;
1032
1032
  function htmlEscape(_input) {
1033
1033
  if (!_input)
1034
1034
  return _input; // null, undefined, empty string test
1035
- return _input.replace(/([^\w .!?\-$])/g, c => "&#" + c.charCodeAt(0) + ";");
1035
+ return _input.replace(/([^\w .!?\-$])/ug, c => "&#" + c.codePointAt(0) + ";");
1036
1036
  }
1037
1037
  Util.htmlEscape = htmlEscape;
1038
1038
  function htmlUnescape(_input) {
1039
1039
  if (!_input)
1040
1040
  return _input; // null, undefined, empty string test
1041
- return _input.replace(/(&#\d+;)/g, c => String.fromCharCode(Number(c.substr(2, c.length - 3))));
1041
+ return _input.replace(/(&#\d+;)/g, c => String.fromCodePoint(Number(c.substr(2, c.length - 3))));
1042
1042
  }
1043
1043
  Util.htmlUnescape = htmlUnescape;
1044
1044
  function jsStringQuote(s) {
@@ -4383,8 +4383,19 @@ var pxt;
4383
4383
  }
4384
4384
  blocks.hasHandler = hasHandler;
4385
4385
  function getHelpUrl(fn) {
4386
- if (fn.attributes.help) {
4387
- const helpUrl = fn.attributes.help.replace(/^\//, '');
4386
+ var _a, _b, _c;
4387
+ let helpAttr = fn.attributes.help;
4388
+ if ((_a = fn.attributes.blockId) === null || _a === void 0 ? void 0 : _a.endsWith(`_blockCombine_get`)) {
4389
+ helpAttr = fn.attributes.blockCombineGetHelp || helpAttr;
4390
+ }
4391
+ else if ((_b = fn.attributes.blockId) === null || _b === void 0 ? void 0 : _b.endsWith(`_blockCombine_set`)) {
4392
+ helpAttr = fn.attributes.blockCombineSetHelp || helpAttr;
4393
+ }
4394
+ else if ((_c = fn.attributes.blockId) === null || _c === void 0 ? void 0 : _c.endsWith(`_blockCombine_change`)) {
4395
+ helpAttr = fn.attributes.blockCombineChangeHelp || helpAttr;
4396
+ }
4397
+ if (helpAttr) {
4398
+ const helpUrl = helpAttr.replace(/^\//, '');
4388
4399
  if (/^github:/.test(helpUrl)) {
4389
4400
  return helpUrl;
4390
4401
  }
@@ -17872,6 +17883,22 @@ var ts;
17872
17883
  }
17873
17884
  blocks.push(ex);
17874
17885
  }
17886
+ function copyOverHelp(param) {
17887
+ if (s.attributes[param]) {
17888
+ if (ex.attributes[param]) {
17889
+ if (ex.attributes[param] !== s.attributes[param]) {
17890
+ console.warn(`Ignoring duplicate ${param} for get/set/change block: ${s.attributes[param]}`);
17891
+ }
17892
+ }
17893
+ else {
17894
+ ex.attributes[param] = s.attributes[param];
17895
+ }
17896
+ }
17897
+ }
17898
+ copyOverHelp("blockCombineChangeHelp");
17899
+ copyOverHelp("blockCombineGetHelp");
17900
+ copyOverHelp("blockCombineSetHelp");
17901
+ copyOverHelp("help");
17875
17902
  ex.combinedProperties.push(s.qName);
17876
17903
  }
17877
17904
  for (let s of pxtc.Util.values(info.byQName)) {
@@ -20345,7 +20372,7 @@ var pxt;
20345
20372
  this.nextID = 0;
20346
20373
  this.nextInternalID = 0;
20347
20374
  this.committedState = {
20348
- revision: 0,
20375
+ revision: TilemapProject.nextRevision++,
20349
20376
  assets: {
20350
20377
  ["image" /* AssetType.Image */]: new AssetCollection("image" /* AssetType.Image */),
20351
20378
  ["tile" /* AssetType.Tile */]: new AssetCollection("tile" /* AssetType.Tile */),
@@ -20356,7 +20383,7 @@ var pxt;
20356
20383
  }
20357
20384
  };
20358
20385
  this.state = {
20359
- revision: this.nextID++,
20386
+ revision: TilemapProject.nextRevision++,
20360
20387
  assets: {
20361
20388
  ["image" /* AssetType.Image */]: new AssetCollection("image" /* AssetType.Image */),
20362
20389
  ["tile" /* AssetType.Tile */]: new AssetCollection("tile" /* AssetType.Tile */),
@@ -20854,7 +20881,7 @@ var pxt;
20854
20881
  return this.getAssetCollection(type).getSnapshot();
20855
20882
  }
20856
20883
  getGalleryAssets(type) {
20857
- return this.getAssetCollection(type).getSnapshot();
20884
+ return this.getAssetCollection(type, true).getSnapshot();
20858
20885
  }
20859
20886
  lookupBlockAsset(type, blockID) {
20860
20887
  let filter = (a) => { var _a, _b; return ((_b = (_a = a.meta) === null || _a === void 0 ? void 0 : _a.blockIDs) === null || _b === void 0 ? void 0 : _b.indexOf(blockID)) !== -1; };
@@ -21207,7 +21234,7 @@ var pxt;
21207
21234
  }
21208
21235
  onChange() {
21209
21236
  this.needsRebuild = true;
21210
- this.state.revision = this.nextID++;
21237
+ this.state.revision = TilemapProject.nextRevision++;
21211
21238
  }
21212
21239
  readImages(allJRes, isProjectFile = false) {
21213
21240
  const assets = [];
@@ -21259,6 +21286,7 @@ var pxt;
21259
21286
  }
21260
21287
  }
21261
21288
  }
21289
+ TilemapProject.nextRevision = 0;
21262
21290
  pxt.TilemapProject = TilemapProject;
21263
21291
  function getTilemaps(allJRes) {
21264
21292
  const res = [];