pxt-core 8.5.2 → 8.5.4

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
@@ -113654,7 +113654,7 @@ var pxt;
113654
113654
  v = { data: v };
113655
113655
  }
113656
113656
  let ns = v.namespace || base.namespace || "";
113657
- if (ns)
113657
+ if (ns && !ns.endsWith("."))
113658
113658
  ns += ".";
113659
113659
  let id = v.id || ns + k;
113660
113660
  let icon = v.icon;
@@ -115386,8 +115386,9 @@ var ts;
115386
115386
  (function (service) {
115387
115387
  let ExtensionType;
115388
115388
  (function (ExtensionType) {
115389
- ExtensionType[ExtensionType["Bundled"] = 0] = "Bundled";
115390
- ExtensionType[ExtensionType["Github"] = 1] = "Github";
115389
+ ExtensionType[ExtensionType["Bundled"] = 1] = "Bundled";
115390
+ ExtensionType[ExtensionType["Github"] = 2] = "Github";
115391
+ ExtensionType[ExtensionType["ShareScript"] = 3] = "ShareScript";
115391
115392
  })(ExtensionType = service.ExtensionType || (service.ExtensionType = {}));
115392
115393
  })(service = pxtc.service || (pxtc.service = {}));
115393
115394
  })(pxtc = ts.pxtc || (ts.pxtc = {}));
@@ -117244,28 +117245,36 @@ var pxt;
117244
117245
  this.undoStack = [];
117245
117246
  this.redoStack = [];
117246
117247
  }
117247
- loadTilemapJRes(jres, skipDuplicates = false) {
117248
+ loadTilemapJRes(jres, skipDuplicates = false, gallery = false) {
117248
117249
  jres = pxt.inflateJRes(jres);
117249
- const tiles = this.readImages(jres, true).filter(im => im.type === "tile" /* pxt.AssetType.Tile */);
117250
+ const tiles = this.readImages(jres, !gallery).filter(im => im.type === "tile" /* pxt.AssetType.Tile */);
117250
117251
  // If we are loading JRES into an existing project (i.e. in multipart tutorials)
117251
117252
  // we need to correct the tile ids because the user may have created new tiles
117252
117253
  // and taken some of the ids that were used by the tutorial author
117253
117254
  let tileMapping = {};
117254
- for (const tile of tiles) {
117255
- if (skipDuplicates) {
117256
- const existing = this.resolveTileByBitmap(tile.bitmap);
117257
- if (existing) {
117258
- tileMapping[tile.id] = existing.id;
117259
- continue;
117260
- }
117255
+ if (gallery) {
117256
+ for (const tile of tiles) {
117257
+ this.gallery.tiles.add(tile);
117261
117258
  }
117262
- const newTile = this.createNewTile(tile.bitmap, tile.id, tile.meta.displayName);
117263
- if (newTile.id !== tile.id) {
117264
- tileMapping[tile.id] = newTile.id;
117259
+ }
117260
+ else {
117261
+ for (const tile of tiles) {
117262
+ if (skipDuplicates) {
117263
+ const existing = this.resolveTileByBitmap(tile.bitmap);
117264
+ if (existing) {
117265
+ tileMapping[tile.id] = existing.id;
117266
+ continue;
117267
+ }
117268
+ }
117269
+ const newTile = this.createNewTile(tile.bitmap, tile.id, tile.meta.displayName);
117270
+ if (newTile.id !== tile.id) {
117271
+ tileMapping[tile.id] = newTile.id;
117272
+ }
117265
117273
  }
117266
117274
  }
117275
+ const state = gallery ? this.gallery : this.state;
117267
117276
  for (const tm of getTilemaps(jres)) {
117268
- this.state.tilemaps.add({
117277
+ state.tilemaps.add({
117269
117278
  internalID: this.getNewInternalId(),
117270
117279
  type: "tilemap" /* AssetType.Tilemap */,
117271
117280
  id: tm.id,
@@ -117282,16 +117291,17 @@ var pxt;
117282
117291
  });
117283
117292
  }
117284
117293
  }
117285
- loadAssetsJRes(jres) {
117294
+ loadAssetsJRes(jres, gallery = false) {
117286
117295
  jres = pxt.inflateJRes(jres);
117287
117296
  const toInflate = [];
117297
+ const state = gallery ? this.gallery : this.state;
117288
117298
  for (const key of Object.keys(jres)) {
117289
117299
  const entry = jres[key];
117290
117300
  if (entry.tilemapTile) {
117291
- this.state.tiles.add(this.generateImage(entry, "tile" /* AssetType.Tile */));
117301
+ state.tiles.add(this.generateImage(entry, "tile" /* AssetType.Tile */));
117292
117302
  }
117293
117303
  else if (entry.mimeType === pxt.IMAGE_MIME_TYPE) {
117294
- this.state.images.add(this.generateImage(entry, "image" /* AssetType.Image */));
117304
+ state.images.add(this.generateImage(entry, "image" /* AssetType.Image */));
117295
117305
  }
117296
117306
  else if (entry.mimeType === pxt.ANIMATION_MIME_TYPE) {
117297
117307
  const [animation, needsInflation] = this.generateAnimation(entry);
@@ -117299,15 +117309,15 @@ var pxt;
117299
117309
  toInflate.push(animation);
117300
117310
  }
117301
117311
  else {
117302
- this.state.animations.add(animation);
117312
+ state.animations.add(animation);
117303
117313
  }
117304
117314
  }
117305
117315
  else if (entry.mimeType === pxt.SONG_MIME_TYPE) {
117306
- this.state.songs.add(this.generateSong(entry));
117316
+ state.songs.add(this.generateSong(entry));
117307
117317
  }
117308
117318
  }
117309
117319
  for (const animation of toInflate) {
117310
- this.state.animations.add(this.inflateAnimation(animation, this.state.images.getSnapshot()));
117320
+ state.animations.add(this.inflateAnimation(animation, state.images.getSnapshot()));
117311
117321
  }
117312
117322
  }
117313
117323
  removeInactiveBlockAssets(activeBlockIDs) {
@@ -117487,8 +117497,12 @@ var pxt;
117487
117497
  const entry = jres[key];
117488
117498
  if (entry.tilemapTile) {
117489
117499
  // FIXME: we should get the "image.ofBuffer" and blockIdentity from pxtarget probably
117500
+ let varName = key;
117501
+ if (varName.indexOf(".") !== -1) {
117502
+ varName = varName.split(".").slice(-1)[0];
117503
+ }
117490
117504
  out += `${indent}//% fixedInstance jres blockIdentity=images._tile\n`;
117491
- out += `${indent}export const ${key} = image.ofBuffer(hex\`\`);\n`;
117505
+ out += `${indent}export const ${varName} = image.ofBuffer(hex\`\`);\n`;
117492
117506
  tileEntries.push({ keys: [entry.displayName, getShortIDCore("tile" /* AssetType.Tile */, key, true)], expression: key });
117493
117507
  }
117494
117508
  if (entry.mimeType === pxt.TILEMAP_MIME_TYPE) {
package/built/pxtlib.d.ts CHANGED
@@ -2296,8 +2296,9 @@ declare namespace ts.pxtc.service {
2296
2296
  pos: number;
2297
2297
  }
2298
2298
  enum ExtensionType {
2299
- Bundled = 0,
2300
- Github = 1
2299
+ Bundled = 1,
2300
+ Github = 2,
2301
+ ShareScript = 3
2301
2302
  }
2302
2303
  interface ExtensionMeta {
2303
2304
  name: string;
@@ -2305,9 +2306,10 @@ declare namespace ts.pxtc.service {
2305
2306
  description?: string;
2306
2307
  imageUrl?: string;
2307
2308
  type?: ExtensionType;
2309
+ learnMoreUrl?: string;
2308
2310
  pkgConfig?: pxt.PackageConfig;
2309
2311
  repo?: pxt.github.GitRepo;
2310
- learnMoreUrl?: string;
2312
+ scriptInfo?: pxt.Cloud.JsonScript;
2311
2313
  }
2312
2314
  interface SearchInfo {
2313
2315
  id: string;
@@ -2908,8 +2910,8 @@ declare namespace pxt {
2908
2910
  addChangeListener(asset: Asset, listener: () => void): void;
2909
2911
  removeChangeListener(type: AssetType, listener: () => void): void;
2910
2912
  loadPackage(pack: MainPackage): void;
2911
- loadTilemapJRes(jres: Map<JRes>, skipDuplicates?: boolean): void;
2912
- loadAssetsJRes(jres: Map<JRes>): void;
2913
+ loadTilemapJRes(jres: Map<JRes>, skipDuplicates?: boolean, gallery?: boolean): void;
2914
+ loadAssetsJRes(jres: Map<JRes>, gallery?: boolean): void;
2913
2915
  removeInactiveBlockAssets(activeBlockIDs: string[]): void;
2914
2916
  protected generateImage(entry: JRes, type: AssetType.Image): ProjectImage;
2915
2917
  protected generateImage(entry: JRes, type: AssetType.Tile): Tile;
package/built/pxtlib.js CHANGED
@@ -15968,7 +15968,7 @@ var pxt;
15968
15968
  v = { data: v };
15969
15969
  }
15970
15970
  let ns = v.namespace || base.namespace || "";
15971
- if (ns)
15971
+ if (ns && !ns.endsWith("."))
15972
15972
  ns += ".";
15973
15973
  let id = v.id || ns + k;
15974
15974
  let icon = v.icon;
@@ -17700,8 +17700,9 @@ var ts;
17700
17700
  (function (service) {
17701
17701
  let ExtensionType;
17702
17702
  (function (ExtensionType) {
17703
- ExtensionType[ExtensionType["Bundled"] = 0] = "Bundled";
17704
- ExtensionType[ExtensionType["Github"] = 1] = "Github";
17703
+ ExtensionType[ExtensionType["Bundled"] = 1] = "Bundled";
17704
+ ExtensionType[ExtensionType["Github"] = 2] = "Github";
17705
+ ExtensionType[ExtensionType["ShareScript"] = 3] = "ShareScript";
17705
17706
  })(ExtensionType = service.ExtensionType || (service.ExtensionType = {}));
17706
17707
  })(service = pxtc.service || (pxtc.service = {}));
17707
17708
  })(pxtc = ts.pxtc || (ts.pxtc = {}));
@@ -19558,28 +19559,36 @@ var pxt;
19558
19559
  this.undoStack = [];
19559
19560
  this.redoStack = [];
19560
19561
  }
19561
- loadTilemapJRes(jres, skipDuplicates = false) {
19562
+ loadTilemapJRes(jres, skipDuplicates = false, gallery = false) {
19562
19563
  jres = pxt.inflateJRes(jres);
19563
- const tiles = this.readImages(jres, true).filter(im => im.type === "tile" /* pxt.AssetType.Tile */);
19564
+ const tiles = this.readImages(jres, !gallery).filter(im => im.type === "tile" /* pxt.AssetType.Tile */);
19564
19565
  // If we are loading JRES into an existing project (i.e. in multipart tutorials)
19565
19566
  // we need to correct the tile ids because the user may have created new tiles
19566
19567
  // and taken some of the ids that were used by the tutorial author
19567
19568
  let tileMapping = {};
19568
- for (const tile of tiles) {
19569
- if (skipDuplicates) {
19570
- const existing = this.resolveTileByBitmap(tile.bitmap);
19571
- if (existing) {
19572
- tileMapping[tile.id] = existing.id;
19573
- continue;
19574
- }
19569
+ if (gallery) {
19570
+ for (const tile of tiles) {
19571
+ this.gallery.tiles.add(tile);
19575
19572
  }
19576
- const newTile = this.createNewTile(tile.bitmap, tile.id, tile.meta.displayName);
19577
- if (newTile.id !== tile.id) {
19578
- tileMapping[tile.id] = newTile.id;
19573
+ }
19574
+ else {
19575
+ for (const tile of tiles) {
19576
+ if (skipDuplicates) {
19577
+ const existing = this.resolveTileByBitmap(tile.bitmap);
19578
+ if (existing) {
19579
+ tileMapping[tile.id] = existing.id;
19580
+ continue;
19581
+ }
19582
+ }
19583
+ const newTile = this.createNewTile(tile.bitmap, tile.id, tile.meta.displayName);
19584
+ if (newTile.id !== tile.id) {
19585
+ tileMapping[tile.id] = newTile.id;
19586
+ }
19579
19587
  }
19580
19588
  }
19589
+ const state = gallery ? this.gallery : this.state;
19581
19590
  for (const tm of getTilemaps(jres)) {
19582
- this.state.tilemaps.add({
19591
+ state.tilemaps.add({
19583
19592
  internalID: this.getNewInternalId(),
19584
19593
  type: "tilemap" /* AssetType.Tilemap */,
19585
19594
  id: tm.id,
@@ -19596,16 +19605,17 @@ var pxt;
19596
19605
  });
19597
19606
  }
19598
19607
  }
19599
- loadAssetsJRes(jres) {
19608
+ loadAssetsJRes(jres, gallery = false) {
19600
19609
  jres = pxt.inflateJRes(jres);
19601
19610
  const toInflate = [];
19611
+ const state = gallery ? this.gallery : this.state;
19602
19612
  for (const key of Object.keys(jres)) {
19603
19613
  const entry = jres[key];
19604
19614
  if (entry.tilemapTile) {
19605
- this.state.tiles.add(this.generateImage(entry, "tile" /* AssetType.Tile */));
19615
+ state.tiles.add(this.generateImage(entry, "tile" /* AssetType.Tile */));
19606
19616
  }
19607
19617
  else if (entry.mimeType === pxt.IMAGE_MIME_TYPE) {
19608
- this.state.images.add(this.generateImage(entry, "image" /* AssetType.Image */));
19618
+ state.images.add(this.generateImage(entry, "image" /* AssetType.Image */));
19609
19619
  }
19610
19620
  else if (entry.mimeType === pxt.ANIMATION_MIME_TYPE) {
19611
19621
  const [animation, needsInflation] = this.generateAnimation(entry);
@@ -19613,15 +19623,15 @@ var pxt;
19613
19623
  toInflate.push(animation);
19614
19624
  }
19615
19625
  else {
19616
- this.state.animations.add(animation);
19626
+ state.animations.add(animation);
19617
19627
  }
19618
19628
  }
19619
19629
  else if (entry.mimeType === pxt.SONG_MIME_TYPE) {
19620
- this.state.songs.add(this.generateSong(entry));
19630
+ state.songs.add(this.generateSong(entry));
19621
19631
  }
19622
19632
  }
19623
19633
  for (const animation of toInflate) {
19624
- this.state.animations.add(this.inflateAnimation(animation, this.state.images.getSnapshot()));
19634
+ state.animations.add(this.inflateAnimation(animation, state.images.getSnapshot()));
19625
19635
  }
19626
19636
  }
19627
19637
  removeInactiveBlockAssets(activeBlockIDs) {
@@ -19801,8 +19811,12 @@ var pxt;
19801
19811
  const entry = jres[key];
19802
19812
  if (entry.tilemapTile) {
19803
19813
  // FIXME: we should get the "image.ofBuffer" and blockIdentity from pxtarget probably
19814
+ let varName = key;
19815
+ if (varName.indexOf(".") !== -1) {
19816
+ varName = varName.split(".").slice(-1)[0];
19817
+ }
19804
19818
  out += `${indent}//% fixedInstance jres blockIdentity=images._tile\n`;
19805
- out += `${indent}export const ${key} = image.ofBuffer(hex\`\`);\n`;
19819
+ out += `${indent}export const ${varName} = image.ofBuffer(hex\`\`);\n`;
19806
19820
  tileEntries.push({ keys: [entry.displayName, getShortIDCore("tile" /* AssetType.Tile */, key, true)], expression: key });
19807
19821
  }
19808
19822
  if (entry.mimeType === pxt.TILEMAP_MIME_TYPE) {