pxt-core 8.5.3 → 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 +34 -21
- package/built/pxtlib.d.ts +2 -2
- package/built/pxtlib.js +34 -21
- package/built/target.js +1 -1
- package/built/web/main.js +1 -1
- package/built/web/pxtapp.js +1 -1
- package/built/web/pxtasseteditor.js +1 -1
- package/built/web/pxtembed.js +1 -1
- package/built/web/pxtlib.js +1 -1
- package/built/web/pxtworker.js +1 -1
- package/package.json +1 -1
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;
|
|
@@ -117245,28 +117245,36 @@ var pxt;
|
|
|
117245
117245
|
this.undoStack = [];
|
|
117246
117246
|
this.redoStack = [];
|
|
117247
117247
|
}
|
|
117248
|
-
loadTilemapJRes(jres, skipDuplicates = false) {
|
|
117248
|
+
loadTilemapJRes(jres, skipDuplicates = false, gallery = false) {
|
|
117249
117249
|
jres = pxt.inflateJRes(jres);
|
|
117250
|
-
const tiles = this.readImages(jres,
|
|
117250
|
+
const tiles = this.readImages(jres, !gallery).filter(im => im.type === "tile" /* pxt.AssetType.Tile */);
|
|
117251
117251
|
// If we are loading JRES into an existing project (i.e. in multipart tutorials)
|
|
117252
117252
|
// we need to correct the tile ids because the user may have created new tiles
|
|
117253
117253
|
// and taken some of the ids that were used by the tutorial author
|
|
117254
117254
|
let tileMapping = {};
|
|
117255
|
-
|
|
117256
|
-
|
|
117257
|
-
|
|
117258
|
-
if (existing) {
|
|
117259
|
-
tileMapping[tile.id] = existing.id;
|
|
117260
|
-
continue;
|
|
117261
|
-
}
|
|
117255
|
+
if (gallery) {
|
|
117256
|
+
for (const tile of tiles) {
|
|
117257
|
+
this.gallery.tiles.add(tile);
|
|
117262
117258
|
}
|
|
117263
|
-
|
|
117264
|
-
|
|
117265
|
-
|
|
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
|
+
}
|
|
117266
117273
|
}
|
|
117267
117274
|
}
|
|
117275
|
+
const state = gallery ? this.gallery : this.state;
|
|
117268
117276
|
for (const tm of getTilemaps(jres)) {
|
|
117269
|
-
|
|
117277
|
+
state.tilemaps.add({
|
|
117270
117278
|
internalID: this.getNewInternalId(),
|
|
117271
117279
|
type: "tilemap" /* AssetType.Tilemap */,
|
|
117272
117280
|
id: tm.id,
|
|
@@ -117283,16 +117291,17 @@ var pxt;
|
|
|
117283
117291
|
});
|
|
117284
117292
|
}
|
|
117285
117293
|
}
|
|
117286
|
-
loadAssetsJRes(jres) {
|
|
117294
|
+
loadAssetsJRes(jres, gallery = false) {
|
|
117287
117295
|
jres = pxt.inflateJRes(jres);
|
|
117288
117296
|
const toInflate = [];
|
|
117297
|
+
const state = gallery ? this.gallery : this.state;
|
|
117289
117298
|
for (const key of Object.keys(jres)) {
|
|
117290
117299
|
const entry = jres[key];
|
|
117291
117300
|
if (entry.tilemapTile) {
|
|
117292
|
-
|
|
117301
|
+
state.tiles.add(this.generateImage(entry, "tile" /* AssetType.Tile */));
|
|
117293
117302
|
}
|
|
117294
117303
|
else if (entry.mimeType === pxt.IMAGE_MIME_TYPE) {
|
|
117295
|
-
|
|
117304
|
+
state.images.add(this.generateImage(entry, "image" /* AssetType.Image */));
|
|
117296
117305
|
}
|
|
117297
117306
|
else if (entry.mimeType === pxt.ANIMATION_MIME_TYPE) {
|
|
117298
117307
|
const [animation, needsInflation] = this.generateAnimation(entry);
|
|
@@ -117300,15 +117309,15 @@ var pxt;
|
|
|
117300
117309
|
toInflate.push(animation);
|
|
117301
117310
|
}
|
|
117302
117311
|
else {
|
|
117303
|
-
|
|
117312
|
+
state.animations.add(animation);
|
|
117304
117313
|
}
|
|
117305
117314
|
}
|
|
117306
117315
|
else if (entry.mimeType === pxt.SONG_MIME_TYPE) {
|
|
117307
|
-
|
|
117316
|
+
state.songs.add(this.generateSong(entry));
|
|
117308
117317
|
}
|
|
117309
117318
|
}
|
|
117310
117319
|
for (const animation of toInflate) {
|
|
117311
|
-
|
|
117320
|
+
state.animations.add(this.inflateAnimation(animation, state.images.getSnapshot()));
|
|
117312
117321
|
}
|
|
117313
117322
|
}
|
|
117314
117323
|
removeInactiveBlockAssets(activeBlockIDs) {
|
|
@@ -117488,8 +117497,12 @@ var pxt;
|
|
|
117488
117497
|
const entry = jres[key];
|
|
117489
117498
|
if (entry.tilemapTile) {
|
|
117490
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
|
+
}
|
|
117491
117504
|
out += `${indent}//% fixedInstance jres blockIdentity=images._tile\n`;
|
|
117492
|
-
out += `${indent}export const ${
|
|
117505
|
+
out += `${indent}export const ${varName} = image.ofBuffer(hex\`\`);\n`;
|
|
117493
117506
|
tileEntries.push({ keys: [entry.displayName, getShortIDCore("tile" /* AssetType.Tile */, key, true)], expression: key });
|
|
117494
117507
|
}
|
|
117495
117508
|
if (entry.mimeType === pxt.TILEMAP_MIME_TYPE) {
|
package/built/pxtlib.d.ts
CHANGED
|
@@ -2910,8 +2910,8 @@ declare namespace pxt {
|
|
|
2910
2910
|
addChangeListener(asset: Asset, listener: () => void): void;
|
|
2911
2911
|
removeChangeListener(type: AssetType, listener: () => void): void;
|
|
2912
2912
|
loadPackage(pack: MainPackage): void;
|
|
2913
|
-
loadTilemapJRes(jres: Map<JRes>, skipDuplicates?: boolean): void;
|
|
2914
|
-
loadAssetsJRes(jres: Map<JRes
|
|
2913
|
+
loadTilemapJRes(jres: Map<JRes>, skipDuplicates?: boolean, gallery?: boolean): void;
|
|
2914
|
+
loadAssetsJRes(jres: Map<JRes>, gallery?: boolean): void;
|
|
2915
2915
|
removeInactiveBlockAssets(activeBlockIDs: string[]): void;
|
|
2916
2916
|
protected generateImage(entry: JRes, type: AssetType.Image): ProjectImage;
|
|
2917
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;
|
|
@@ -19559,28 +19559,36 @@ var pxt;
|
|
|
19559
19559
|
this.undoStack = [];
|
|
19560
19560
|
this.redoStack = [];
|
|
19561
19561
|
}
|
|
19562
|
-
loadTilemapJRes(jres, skipDuplicates = false) {
|
|
19562
|
+
loadTilemapJRes(jres, skipDuplicates = false, gallery = false) {
|
|
19563
19563
|
jres = pxt.inflateJRes(jres);
|
|
19564
|
-
const tiles = this.readImages(jres,
|
|
19564
|
+
const tiles = this.readImages(jres, !gallery).filter(im => im.type === "tile" /* pxt.AssetType.Tile */);
|
|
19565
19565
|
// If we are loading JRES into an existing project (i.e. in multipart tutorials)
|
|
19566
19566
|
// we need to correct the tile ids because the user may have created new tiles
|
|
19567
19567
|
// and taken some of the ids that were used by the tutorial author
|
|
19568
19568
|
let tileMapping = {};
|
|
19569
|
-
|
|
19570
|
-
|
|
19571
|
-
|
|
19572
|
-
if (existing) {
|
|
19573
|
-
tileMapping[tile.id] = existing.id;
|
|
19574
|
-
continue;
|
|
19575
|
-
}
|
|
19569
|
+
if (gallery) {
|
|
19570
|
+
for (const tile of tiles) {
|
|
19571
|
+
this.gallery.tiles.add(tile);
|
|
19576
19572
|
}
|
|
19577
|
-
|
|
19578
|
-
|
|
19579
|
-
|
|
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
|
+
}
|
|
19580
19587
|
}
|
|
19581
19588
|
}
|
|
19589
|
+
const state = gallery ? this.gallery : this.state;
|
|
19582
19590
|
for (const tm of getTilemaps(jres)) {
|
|
19583
|
-
|
|
19591
|
+
state.tilemaps.add({
|
|
19584
19592
|
internalID: this.getNewInternalId(),
|
|
19585
19593
|
type: "tilemap" /* AssetType.Tilemap */,
|
|
19586
19594
|
id: tm.id,
|
|
@@ -19597,16 +19605,17 @@ var pxt;
|
|
|
19597
19605
|
});
|
|
19598
19606
|
}
|
|
19599
19607
|
}
|
|
19600
|
-
loadAssetsJRes(jres) {
|
|
19608
|
+
loadAssetsJRes(jres, gallery = false) {
|
|
19601
19609
|
jres = pxt.inflateJRes(jres);
|
|
19602
19610
|
const toInflate = [];
|
|
19611
|
+
const state = gallery ? this.gallery : this.state;
|
|
19603
19612
|
for (const key of Object.keys(jres)) {
|
|
19604
19613
|
const entry = jres[key];
|
|
19605
19614
|
if (entry.tilemapTile) {
|
|
19606
|
-
|
|
19615
|
+
state.tiles.add(this.generateImage(entry, "tile" /* AssetType.Tile */));
|
|
19607
19616
|
}
|
|
19608
19617
|
else if (entry.mimeType === pxt.IMAGE_MIME_TYPE) {
|
|
19609
|
-
|
|
19618
|
+
state.images.add(this.generateImage(entry, "image" /* AssetType.Image */));
|
|
19610
19619
|
}
|
|
19611
19620
|
else if (entry.mimeType === pxt.ANIMATION_MIME_TYPE) {
|
|
19612
19621
|
const [animation, needsInflation] = this.generateAnimation(entry);
|
|
@@ -19614,15 +19623,15 @@ var pxt;
|
|
|
19614
19623
|
toInflate.push(animation);
|
|
19615
19624
|
}
|
|
19616
19625
|
else {
|
|
19617
|
-
|
|
19626
|
+
state.animations.add(animation);
|
|
19618
19627
|
}
|
|
19619
19628
|
}
|
|
19620
19629
|
else if (entry.mimeType === pxt.SONG_MIME_TYPE) {
|
|
19621
|
-
|
|
19630
|
+
state.songs.add(this.generateSong(entry));
|
|
19622
19631
|
}
|
|
19623
19632
|
}
|
|
19624
19633
|
for (const animation of toInflate) {
|
|
19625
|
-
|
|
19634
|
+
state.animations.add(this.inflateAnimation(animation, state.images.getSnapshot()));
|
|
19626
19635
|
}
|
|
19627
19636
|
}
|
|
19628
19637
|
removeInactiveBlockAssets(activeBlockIDs) {
|
|
@@ -19802,8 +19811,12 @@ var pxt;
|
|
|
19802
19811
|
const entry = jres[key];
|
|
19803
19812
|
if (entry.tilemapTile) {
|
|
19804
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
|
+
}
|
|
19805
19818
|
out += `${indent}//% fixedInstance jres blockIdentity=images._tile\n`;
|
|
19806
|
-
out += `${indent}export const ${
|
|
19819
|
+
out += `${indent}export const ${varName} = image.ofBuffer(hex\`\`);\n`;
|
|
19807
19820
|
tileEntries.push({ keys: [entry.displayName, getShortIDCore("tile" /* AssetType.Tile */, key, true)], expression: key });
|
|
19808
19821
|
}
|
|
19809
19822
|
if (entry.mimeType === pxt.TILEMAP_MIME_TYPE) {
|