pxt-core 11.3.58 → 11.3.61

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
@@ -111061,23 +111061,14 @@ var pxt;
111061
111061
  this.layers = layers;
111062
111062
  this.nextId = 0;
111063
111063
  }
111064
- cloneData(includeEditorData = false) {
111065
- var _a, _c, _d, _e;
111064
+ cloneData() {
111066
111065
  const tm = this.tilemap.copy();
111067
111066
  const tileset = {
111068
111067
  tileWidth: this.tileset.tileWidth,
111069
111068
  tiles: this.tileset.tiles.map(t => (Object.assign(Object.assign({}, t), { bitmap: Bitmap.fromData(t.bitmap).copy().data() })))
111070
111069
  };
111071
111070
  const layers = Bitmap.fromData(this.layers).copy().data();
111072
- const result = new TilemapData(tm, tileset, layers);
111073
- if (includeEditorData) {
111074
- result.nextId = this.nextId;
111075
- result.projectReferences = (_a = this.projectReferences) === null || _a === void 0 ? void 0 : _a.slice();
111076
- result.tileOrder = (_c = this.tileOrder) === null || _c === void 0 ? void 0 : _c.slice();
111077
- result.editedTiles = (_d = this.editedTiles) === null || _d === void 0 ? void 0 : _d.slice();
111078
- result.deletedTiles = (_e = this.deletedTiles) === null || _e === void 0 ? void 0 : _e.slice();
111079
- }
111080
- return result;
111071
+ return new TilemapData(tm, tileset, layers);
111081
111072
  }
111082
111073
  equals(other) {
111083
111074
  return this.tilemap.equals(other.tilemap) &&
@@ -117607,20 +117598,15 @@ var pxt;
117607
117598
  }
117608
117599
  getSnapshot(filter) {
117609
117600
  if (filter) {
117610
- return this.assets.filter(a => filter(a)).map(a => cloneAsset(a));
117601
+ return this.assets.filter(a => filter(a)).map(cloneAsset);
117611
117602
  }
117612
- return this.assets.map(a => cloneAsset(a));
117603
+ return this.assets.map(cloneAsset);
117613
117604
  }
117614
117605
  update(id, newValue) {
117615
117606
  let asset;
117616
117607
  if (this.takenNames[id]) {
117617
117608
  const existing = this.lookupByID(id);
117618
117609
  if (!assetEquals(existing, newValue)) {
117619
- if (!validateAsset(newValue) && validateAsset(existing)) {
117620
- pxt.warn("Refusing to overwrite asset with invalid version");
117621
- pxt.tickEvent("assets.invalidAssetOverwrite", { assetType: newValue.type });
117622
- return existing;
117623
- }
117624
117610
  this.removeByID(id);
117625
117611
  asset = this.add(newValue);
117626
117612
  this.notifyListener(newValue.internalID);
@@ -118882,11 +118868,8 @@ var pxt;
118882
118868
  const layers = new pxt.sprite.Bitmap(tmWidth, tmHeight, 0, 0, new Uint8ClampedArray(bitmapData)).data();
118883
118869
  return new pxt.sprite.TilemapData(tilemap, tileset, layers);
118884
118870
  }
118885
- function cloneAsset(asset, includeEditorData = false) {
118871
+ function cloneAsset(asset) {
118886
118872
  asset.meta = Object.assign({}, asset.meta);
118887
- if (asset.meta.temporaryInfo) {
118888
- asset.meta.temporaryInfo = Object.assign({}, asset.meta.temporaryInfo);
118889
- }
118890
118873
  switch (asset.type) {
118891
118874
  case "tile" /* AssetType.Tile */:
118892
118875
  case "image" /* AssetType.Image */:
@@ -118894,7 +118877,7 @@ var pxt;
118894
118877
  case "animation" /* AssetType.Animation */:
118895
118878
  return Object.assign(Object.assign({}, asset), { frames: asset.frames.map(frame => cloneBitmap(frame)) });
118896
118879
  case "tilemap" /* AssetType.Tilemap */:
118897
- return Object.assign(Object.assign({}, asset), { data: asset.data.cloneData(includeEditorData) });
118880
+ return Object.assign(Object.assign({}, asset), { data: asset.data.cloneData() });
118898
118881
  case "song" /* AssetType.Song */:
118899
118882
  return Object.assign(Object.assign({}, asset), { song: pxt.assets.music.cloneSong(asset.song) });
118900
118883
  }
@@ -119087,62 +119070,6 @@ var pxt;
119087
119070
  return getShortIDCore(asset.type, asset.id);
119088
119071
  }
119089
119072
  pxt.getShortIDForAsset = getShortIDForAsset;
119090
- function validateAsset(asset) {
119091
- if (!asset)
119092
- return false;
119093
- switch (asset.type) {
119094
- case "image" /* AssetType.Image */:
119095
- case "tile" /* AssetType.Tile */:
119096
- return validateImageAsset(asset);
119097
- case "tilemap" /* AssetType.Tilemap */:
119098
- return validateTilemap(asset);
119099
- case "animation" /* AssetType.Animation */:
119100
- return validateAnimation(asset);
119101
- case "song" /* AssetType.Song */:
119102
- return validateSong(asset);
119103
- }
119104
- }
119105
- pxt.validateAsset = validateAsset;
119106
- function validateImageAsset(asset) {
119107
- if (!asset.bitmap)
119108
- return false;
119109
- return validateBitmap(pxt.sprite.Bitmap.fromData(asset.bitmap));
119110
- }
119111
- function validateTilemap(tilemap) {
119112
- var _a;
119113
- if (!tilemap.data ||
119114
- !tilemap.data.tilemap ||
119115
- !tilemap.data.tileset ||
119116
- !tilemap.data.tileset.tileWidth ||
119117
- !((_a = tilemap.data.tileset.tiles) === null || _a === void 0 ? void 0 : _a.length) ||
119118
- !tilemap.data.layers) {
119119
- return false;
119120
- }
119121
- return validateBitmap(pxt.sprite.Bitmap.fromData(tilemap.data.layers)) &&
119122
- validateBitmap(tilemap.data.tilemap);
119123
- }
119124
- function validateAnimation(animation) {
119125
- var _a;
119126
- if (!((_a = animation.frames) === null || _a === void 0 ? void 0 : _a.length) || animation.interval <= 0) {
119127
- return false;
119128
- }
119129
- return !animation.frames.some(frame => !validateBitmap(pxt.sprite.Bitmap.fromData(frame)));
119130
- }
119131
- function validateBitmap(bitmap) {
119132
- return bitmap.width > 0 &&
119133
- bitmap.height > 0 &&
119134
- !Number.isNaN(bitmap.x0) &&
119135
- !Number.isNaN(bitmap.y0) &&
119136
- bitmap.data().data.length === bitmap.dataLength();
119137
- }
119138
- function validateSong(song) {
119139
- return song.song &&
119140
- song.song.ticksPerBeat > 0 &&
119141
- song.song.beatsPerMeasure > 0 &&
119142
- song.song.measures > 0 &&
119143
- song.song.beatsPerMinute > 0 &&
119144
- !!song.song.tracks;
119145
- }
119146
119073
  function getShortIDCore(assetType, id, allowNoPrefix = false) {
119147
119074
  let prefix;
119148
119075
  switch (assetType) {
@@ -119243,6 +119170,10 @@ var pxt;
119243
119170
  }
119244
119171
  };
119245
119172
  }
119173
+ function set16Bit(buf, offset, value) {
119174
+ buf[offset] = value & 0xff;
119175
+ buf[offset + 1] = (value >> 8) & 0xff;
119176
+ }
119246
119177
  function read16Bit(buf, offset) {
119247
119178
  return buf[offset] | (buf[offset + 1] << 8);
119248
119179
  }
@@ -119255,21 +119186,6 @@ var pxt;
119255
119186
  case "song" /* AssetType.Song */: return snapshot.songs;
119256
119187
  }
119257
119188
  }
119258
- function patchTemporaryAsset(oldValue, newValue, project) {
119259
- if (!oldValue || assetEquals(oldValue, newValue))
119260
- return newValue;
119261
- newValue = cloneAsset(newValue, true);
119262
- const wasTemporary = !oldValue.meta.displayName;
119263
- const isTemporary = !newValue.meta.displayName;
119264
- // if we went from being temporary to no longer being temporary,
119265
- // make sure we replace the junk id with a new value
119266
- if (wasTemporary && !isTemporary) {
119267
- newValue.id = project.generateNewID(newValue.type);
119268
- newValue.internalID = project.getNewInternalId();
119269
- }
119270
- return newValue;
119271
- }
119272
- pxt.patchTemporaryAsset = patchTemporaryAsset;
119273
119189
  })(pxt || (pxt = {}));
119274
119190
  var pxt;
119275
119191
  (function (pxt) {
@@ -52,7 +52,6 @@ export declare abstract class FieldAssetEditor<U extends FieldAssetEditorOptions
52
52
  protected updateAssetListener(): void;
53
53
  protected assetChangeListener: () => void;
54
54
  protected isFullscreen(): boolean;
55
- protected temporaryAssetId(): string;
56
55
  }
57
56
  export declare class BlocklyTilemapChange extends Blockly.Events.BlockChange {
58
57
  protected oldRevision: number;
package/built/pxtlib.d.ts CHANGED
@@ -1834,7 +1834,7 @@ declare namespace pxt.sprite {
1834
1834
  protected coordToIndex(col: number, row: number): number;
1835
1835
  protected getCore(index: number): number;
1836
1836
  protected setCore(index: number, value: number): void;
1837
- dataLength(): number;
1837
+ protected dataLength(): number;
1838
1838
  }
1839
1839
  class Tilemap extends Bitmap {
1840
1840
  static fromData(data: BitmapData): Tilemap;
@@ -1842,7 +1842,7 @@ declare namespace pxt.sprite {
1842
1842
  resize(width: number, height: number): Tilemap;
1843
1843
  protected getCore(index: number): number;
1844
1844
  protected setCore(index: number, value: number): void;
1845
- dataLength(): number;
1845
+ protected dataLength(): number;
1846
1846
  }
1847
1847
  class TilemapData {
1848
1848
  tilemap: Tilemap;
@@ -1854,7 +1854,7 @@ declare namespace pxt.sprite {
1854
1854
  editedTiles: string[];
1855
1855
  deletedTiles: string[];
1856
1856
  constructor(tilemap: Tilemap, tileset: TileSet, layers: BitmapData);
1857
- cloneData(includeEditorData?: boolean): TilemapData;
1857
+ cloneData(): TilemapData;
1858
1858
  equals(other: TilemapData): boolean;
1859
1859
  }
1860
1860
  class Bitmask {
@@ -3132,7 +3132,7 @@ declare namespace pxt {
3132
3132
  export function emitGalleryDeclarations(jres: pxt.Map<JRes>, namespaceName: string): [pxt.Map<JRes>, string];
3133
3133
  export function emitTilemapsFromJRes(jres: pxt.Map<JRes>): string;
3134
3134
  export function emitProjectImages(jres: pxt.Map<JRes | string>): string;
3135
- export function cloneAsset<U extends Asset>(asset: U, includeEditorData?: boolean): U;
3135
+ export function cloneAsset<U extends Asset>(asset: U): U;
3136
3136
  export function assetEquals(a: Asset, b: Asset, valueOnly?: boolean): boolean;
3137
3137
  export function validateAssetName(name: string): boolean;
3138
3138
  export function getTSReferenceForAsset(asset: pxt.Asset, isPython?: boolean): string;
@@ -3143,8 +3143,6 @@ declare namespace pxt {
3143
3143
  export function lookupProjectAssetByTSReference(ts: string, project: TilemapProject): Tile | ProjectImage | Animation | ProjectTilemap | Song;
3144
3144
  export function getDefaultAssetDisplayName(type: pxt.AssetType): string;
3145
3145
  export function getShortIDForAsset(asset: pxt.Asset): string;
3146
- export function validateAsset(asset: pxt.Asset): boolean;
3147
- export function patchTemporaryAsset(oldValue: pxt.Asset, newValue: pxt.Asset, project: TilemapProject): Asset;
3148
3146
  export {};
3149
3147
  }
3150
3148
  declare namespace pxt.toolbox {
package/built/pxtlib.js CHANGED
@@ -13375,23 +13375,14 @@ var pxt;
13375
13375
  this.layers = layers;
13376
13376
  this.nextId = 0;
13377
13377
  }
13378
- cloneData(includeEditorData = false) {
13379
- var _a, _c, _d, _e;
13378
+ cloneData() {
13380
13379
  const tm = this.tilemap.copy();
13381
13380
  const tileset = {
13382
13381
  tileWidth: this.tileset.tileWidth,
13383
13382
  tiles: this.tileset.tiles.map(t => (Object.assign(Object.assign({}, t), { bitmap: Bitmap.fromData(t.bitmap).copy().data() })))
13384
13383
  };
13385
13384
  const layers = Bitmap.fromData(this.layers).copy().data();
13386
- const result = new TilemapData(tm, tileset, layers);
13387
- if (includeEditorData) {
13388
- result.nextId = this.nextId;
13389
- result.projectReferences = (_a = this.projectReferences) === null || _a === void 0 ? void 0 : _a.slice();
13390
- result.tileOrder = (_c = this.tileOrder) === null || _c === void 0 ? void 0 : _c.slice();
13391
- result.editedTiles = (_d = this.editedTiles) === null || _d === void 0 ? void 0 : _d.slice();
13392
- result.deletedTiles = (_e = this.deletedTiles) === null || _e === void 0 ? void 0 : _e.slice();
13393
- }
13394
- return result;
13385
+ return new TilemapData(tm, tileset, layers);
13395
13386
  }
13396
13387
  equals(other) {
13397
13388
  return this.tilemap.equals(other.tilemap) &&
@@ -19921,20 +19912,15 @@ var pxt;
19921
19912
  }
19922
19913
  getSnapshot(filter) {
19923
19914
  if (filter) {
19924
- return this.assets.filter(a => filter(a)).map(a => cloneAsset(a));
19915
+ return this.assets.filter(a => filter(a)).map(cloneAsset);
19925
19916
  }
19926
- return this.assets.map(a => cloneAsset(a));
19917
+ return this.assets.map(cloneAsset);
19927
19918
  }
19928
19919
  update(id, newValue) {
19929
19920
  let asset;
19930
19921
  if (this.takenNames[id]) {
19931
19922
  const existing = this.lookupByID(id);
19932
19923
  if (!assetEquals(existing, newValue)) {
19933
- if (!validateAsset(newValue) && validateAsset(existing)) {
19934
- pxt.warn("Refusing to overwrite asset with invalid version");
19935
- pxt.tickEvent("assets.invalidAssetOverwrite", { assetType: newValue.type });
19936
- return existing;
19937
- }
19938
19924
  this.removeByID(id);
19939
19925
  asset = this.add(newValue);
19940
19926
  this.notifyListener(newValue.internalID);
@@ -21196,11 +21182,8 @@ var pxt;
21196
21182
  const layers = new pxt.sprite.Bitmap(tmWidth, tmHeight, 0, 0, new Uint8ClampedArray(bitmapData)).data();
21197
21183
  return new pxt.sprite.TilemapData(tilemap, tileset, layers);
21198
21184
  }
21199
- function cloneAsset(asset, includeEditorData = false) {
21185
+ function cloneAsset(asset) {
21200
21186
  asset.meta = Object.assign({}, asset.meta);
21201
- if (asset.meta.temporaryInfo) {
21202
- asset.meta.temporaryInfo = Object.assign({}, asset.meta.temporaryInfo);
21203
- }
21204
21187
  switch (asset.type) {
21205
21188
  case "tile" /* AssetType.Tile */:
21206
21189
  case "image" /* AssetType.Image */:
@@ -21208,7 +21191,7 @@ var pxt;
21208
21191
  case "animation" /* AssetType.Animation */:
21209
21192
  return Object.assign(Object.assign({}, asset), { frames: asset.frames.map(frame => cloneBitmap(frame)) });
21210
21193
  case "tilemap" /* AssetType.Tilemap */:
21211
- return Object.assign(Object.assign({}, asset), { data: asset.data.cloneData(includeEditorData) });
21194
+ return Object.assign(Object.assign({}, asset), { data: asset.data.cloneData() });
21212
21195
  case "song" /* AssetType.Song */:
21213
21196
  return Object.assign(Object.assign({}, asset), { song: pxt.assets.music.cloneSong(asset.song) });
21214
21197
  }
@@ -21401,62 +21384,6 @@ var pxt;
21401
21384
  return getShortIDCore(asset.type, asset.id);
21402
21385
  }
21403
21386
  pxt.getShortIDForAsset = getShortIDForAsset;
21404
- function validateAsset(asset) {
21405
- if (!asset)
21406
- return false;
21407
- switch (asset.type) {
21408
- case "image" /* AssetType.Image */:
21409
- case "tile" /* AssetType.Tile */:
21410
- return validateImageAsset(asset);
21411
- case "tilemap" /* AssetType.Tilemap */:
21412
- return validateTilemap(asset);
21413
- case "animation" /* AssetType.Animation */:
21414
- return validateAnimation(asset);
21415
- case "song" /* AssetType.Song */:
21416
- return validateSong(asset);
21417
- }
21418
- }
21419
- pxt.validateAsset = validateAsset;
21420
- function validateImageAsset(asset) {
21421
- if (!asset.bitmap)
21422
- return false;
21423
- return validateBitmap(pxt.sprite.Bitmap.fromData(asset.bitmap));
21424
- }
21425
- function validateTilemap(tilemap) {
21426
- var _a;
21427
- if (!tilemap.data ||
21428
- !tilemap.data.tilemap ||
21429
- !tilemap.data.tileset ||
21430
- !tilemap.data.tileset.tileWidth ||
21431
- !((_a = tilemap.data.tileset.tiles) === null || _a === void 0 ? void 0 : _a.length) ||
21432
- !tilemap.data.layers) {
21433
- return false;
21434
- }
21435
- return validateBitmap(pxt.sprite.Bitmap.fromData(tilemap.data.layers)) &&
21436
- validateBitmap(tilemap.data.tilemap);
21437
- }
21438
- function validateAnimation(animation) {
21439
- var _a;
21440
- if (!((_a = animation.frames) === null || _a === void 0 ? void 0 : _a.length) || animation.interval <= 0) {
21441
- return false;
21442
- }
21443
- return !animation.frames.some(frame => !validateBitmap(pxt.sprite.Bitmap.fromData(frame)));
21444
- }
21445
- function validateBitmap(bitmap) {
21446
- return bitmap.width > 0 &&
21447
- bitmap.height > 0 &&
21448
- !Number.isNaN(bitmap.x0) &&
21449
- !Number.isNaN(bitmap.y0) &&
21450
- bitmap.data().data.length === bitmap.dataLength();
21451
- }
21452
- function validateSong(song) {
21453
- return song.song &&
21454
- song.song.ticksPerBeat > 0 &&
21455
- song.song.beatsPerMeasure > 0 &&
21456
- song.song.measures > 0 &&
21457
- song.song.beatsPerMinute > 0 &&
21458
- !!song.song.tracks;
21459
- }
21460
21387
  function getShortIDCore(assetType, id, allowNoPrefix = false) {
21461
21388
  let prefix;
21462
21389
  switch (assetType) {
@@ -21557,6 +21484,10 @@ var pxt;
21557
21484
  }
21558
21485
  };
21559
21486
  }
21487
+ function set16Bit(buf, offset, value) {
21488
+ buf[offset] = value & 0xff;
21489
+ buf[offset + 1] = (value >> 8) & 0xff;
21490
+ }
21560
21491
  function read16Bit(buf, offset) {
21561
21492
  return buf[offset] | (buf[offset + 1] << 8);
21562
21493
  }
@@ -21569,21 +21500,6 @@ var pxt;
21569
21500
  case "song" /* AssetType.Song */: return snapshot.songs;
21570
21501
  }
21571
21502
  }
21572
- function patchTemporaryAsset(oldValue, newValue, project) {
21573
- if (!oldValue || assetEquals(oldValue, newValue))
21574
- return newValue;
21575
- newValue = cloneAsset(newValue, true);
21576
- const wasTemporary = !oldValue.meta.displayName;
21577
- const isTemporary = !newValue.meta.displayName;
21578
- // if we went from being temporary to no longer being temporary,
21579
- // make sure we replace the junk id with a new value
21580
- if (wasTemporary && !isTemporary) {
21581
- newValue.id = project.generateNewID(newValue.type);
21582
- newValue.internalID = project.getNewInternalId();
21583
- }
21584
- return newValue;
21585
- }
21586
- pxt.patchTemporaryAsset = patchTemporaryAsset;
21587
21503
  })(pxt || (pxt = {}));
21588
21504
  var pxt;
21589
21505
  (function (pxt) {