pxt-core 7.5.9 → 7.5.12

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
@@ -107946,9 +107946,9 @@ var pxt;
107946
107946
  return cached;
107947
107947
  }
107948
107948
  github.downloadPackageAsync = downloadPackageAsync;
107949
- async function downloadLatestPackageAsync(repo) {
107949
+ async function downloadLatestPackageAsync(repo, useProxy, noCache) {
107950
107950
  const packageConfig = await pxt.packagesConfigAsync();
107951
- const tag = await pxt.github.latestVersionAsync(repo.slug, packageConfig);
107951
+ const tag = await pxt.github.latestVersionAsync(repo.slug, packageConfig, useProxy, noCache);
107952
107952
  // download package into cache
107953
107953
  const repoWithTag = `${repo.fullName}#${tag}`;
107954
107954
  await pxt.github.downloadPackageAsync(repoWithTag, packageConfig);
@@ -154688,7 +154688,7 @@ var pxsim;
154688
154688
  return this.buffer;
154689
154689
  }
154690
154690
  // Synthesize a sample
154691
- let s = this.effect.tone.tonePrint(this.effect.tone.parameter, this.position);
154691
+ let s = this.effect.tone.tonePrint(this.effect.tone.parameter, Math.max(this.position, 0));
154692
154692
  // Apply volume scaling and OR mask (if specified).
154693
154693
  this.buffer[sample] = (((s * gain) + offset)); // | this.orMask;
154694
154694
  // Move on our pointers.
@@ -10889,6 +10889,7 @@ var pxt;
10889
10889
  state.setEventsEnabled(true);
10890
10890
  Blockly.Extensions.apply('inline-svgs', b, false);
10891
10891
  let updatingInputs = false;
10892
+ let firstRender = true;
10892
10893
  appendMutation(b, {
10893
10894
  mutationToDom: (el) => {
10894
10895
  // The reason we store the inputsInitialized variable separately from visibleOptions
@@ -10944,9 +10945,12 @@ var pxt;
10944
10945
  b.render = (opt_bubble) => {
10945
10946
  if (updatingInputs)
10946
10947
  return;
10947
- updatingInputs = true;
10948
- updateShape(0, undefined, true);
10949
- updatingInputs = false;
10948
+ if (firstRender) {
10949
+ firstRender = false;
10950
+ updatingInputs = true;
10951
+ updateShape(0, undefined, true);
10952
+ updatingInputs = false;
10953
+ }
10950
10954
  Blockly.BlockSvg.prototype.render.call(b, opt_bubble);
10951
10955
  };
10952
10956
  // Set skipRender to true if the block is still initializing. Otherwise
@@ -15143,6 +15147,17 @@ var pxtblockly;
15143
15147
  const Y_PADDING = 4;
15144
15148
  const PREVIEW_WIDTH = TOTAL_WIDTH - X_PADDING * 5 - MUSIC_ICON_WIDTH;
15145
15149
  class FieldSoundEffect extends pxtblockly.FieldBase {
15150
+ constructor() {
15151
+ super(...arguments);
15152
+ this.onWorkspaceChange = (ev) => {
15153
+ if (ev.type !== Blockly.Events.CHANGE)
15154
+ return;
15155
+ const block = this.sourceBlock_.workspace.getBlockById(ev.blockId);
15156
+ if (!block || block !== this.sourceBlock_ && block.parentBlock_ !== this.sourceBlock_)
15157
+ return;
15158
+ this.redrawPreview();
15159
+ };
15160
+ }
15146
15161
  onInit() {
15147
15162
  if (!this.options)
15148
15163
  this.options = {};
@@ -15163,8 +15178,10 @@ var pxtblockly;
15163
15178
  if (!this.options.effectFieldName)
15164
15179
  this.options.effectFieldName = "effect";
15165
15180
  this.redrawPreview();
15181
+ this.sourceBlock_.workspace.addChangeListener(this.onWorkspaceChange);
15166
15182
  }
15167
15183
  onDispose() {
15184
+ this.sourceBlock_.workspace.removeChangeListener(this.onWorkspaceChange);
15168
15185
  }
15169
15186
  onValueChanged(newValue) {
15170
15187
  return newValue;
@@ -15172,6 +15189,17 @@ var pxtblockly;
15172
15189
  redrawPreview() {
15173
15190
  if (!this.fieldGroup_)
15174
15191
  return;
15192
+ if (this.drawnSound) {
15193
+ const current = this.readCurrentSound();
15194
+ if (current.startFrequency === this.drawnSound.startFrequency &&
15195
+ current.endFrequency === this.drawnSound.endFrequency &&
15196
+ current.startVolume === this.drawnSound.startVolume &&
15197
+ current.endVolume === this.drawnSound.endVolume &&
15198
+ current.wave === this.drawnSound.wave &&
15199
+ current.interpolation === this.drawnSound.interpolation) {
15200
+ return;
15201
+ }
15202
+ }
15175
15203
  pxsim.U.clear(this.fieldGroup_);
15176
15204
  const bg = new svg.Rect()
15177
15205
  .at(X_PADDING, Y_PADDING)
@@ -15188,10 +15216,11 @@ var pxtblockly;
15188
15216
  .fill("#FFF")
15189
15217
  .at(0, 0);
15190
15218
  clip.appendChild(clipRect);
15219
+ this.drawnSound = this.readCurrentSound();
15191
15220
  const path = new svg.Path()
15192
15221
  .stroke("grey", 2)
15193
15222
  .fill("none")
15194
- .setD(pxt.assets.renderSoundPath(this.readCurrentSound(), TOTAL_WIDTH - X_PADDING * 4 - MUSIC_ICON_WIDTH, TOTAL_HEIGHT - Y_PADDING * 2))
15223
+ .setD(pxt.assets.renderSoundPath(this.drawnSound, TOTAL_WIDTH - X_PADDING * 4 - MUSIC_ICON_WIDTH, TOTAL_HEIGHT - Y_PADDING * 2))
15195
15224
  .clipPath("url('#" + clipPathId + "')");
15196
15225
  const g = new svg.Group()
15197
15226
  .translate(MUSIC_ICON_WIDTH + X_PADDING * 3, Y_PADDING + 3);
@@ -15209,7 +15238,13 @@ var pxtblockly;
15209
15238
  showEditor_() {
15210
15239
  const initialSound = this.readCurrentSound();
15211
15240
  Blockly.Events.disable();
15212
- Blockly.WidgetDiv.show(this, this.sourceBlock_.RTL, () => {
15241
+ let bbox;
15242
+ // This is due to the changes in https://github.com/microsoft/pxt-blockly/pull/289
15243
+ // which caused the widgetdiv to jump around if any fields underneath changed size
15244
+ let widgetOwner = {
15245
+ getScaledBBox: () => bbox
15246
+ };
15247
+ Blockly.WidgetDiv.show(widgetOwner, this.sourceBlock_.RTL, () => {
15213
15248
  fv.hide();
15214
15249
  widgetDiv.classList.remove("sound-effect-editor-widget");
15215
15250
  widgetDiv.style.transform = "";
@@ -15238,7 +15273,7 @@ var pxtblockly;
15238
15273
  const opts = {
15239
15274
  onClose: () => {
15240
15275
  fv.hide();
15241
- Blockly.WidgetDiv.hideIfOwner(this);
15276
+ Blockly.WidgetDiv.hideIfOwner(widgetOwner);
15242
15277
  },
15243
15278
  onSoundChange: (newSound) => {
15244
15279
  this.mostRecentValue = newSound;
@@ -15263,6 +15298,7 @@ var pxtblockly;
15263
15298
  widgetDiv.style.height = "40rem";
15264
15299
  widgetDiv.style.display = "block";
15265
15300
  widgetDiv.style.transition = "transform 0.25s ease 0s, opacity 0.25s ease 0s";
15301
+ widgetDiv.style.borderRadius = "";
15266
15302
  fv.onHide(() => {
15267
15303
  // do nothing
15268
15304
  });
@@ -15272,7 +15308,7 @@ var pxtblockly;
15272
15308
  if (divBounds.height > injectDivBounds.height) {
15273
15309
  widgetDiv.style.height = "";
15274
15310
  widgetDiv.style.top = `calc(1rem - ${animationDistance}px)`;
15275
- widgetDiv.style.bottom = "1rem";
15311
+ widgetDiv.style.bottom = `calc(1rem + ${animationDistance}px)`;
15276
15312
  }
15277
15313
  else {
15278
15314
  if (divBounds.bottom > injectDivBounds.bottom || divBounds.top < injectDivBounds.top) {
@@ -15280,7 +15316,8 @@ var pxtblockly;
15280
15316
  widgetDiv.style.top = (injectDivBounds.top + (injectDivBounds.height / 2) - (divBounds.height / 2)) - animationDistance + "px";
15281
15317
  }
15282
15318
  }
15283
- if (divBounds.width > injectDivBounds.width) {
15319
+ const toolboxWidth = block.workspace.getToolbox().getWidth();
15320
+ if (divBounds.width > injectDivBounds.width - toolboxWidth) {
15284
15321
  widgetDiv.style.width = "";
15285
15322
  widgetDiv.style.left = "1rem";
15286
15323
  widgetDiv.style.right = "1rem";
@@ -15290,7 +15327,6 @@ var pxtblockly;
15290
15327
  if (divBounds.left + divBounds.width >= injectDivBounds.right) {
15291
15328
  // If so, try and place to the left of the block instead of the right
15292
15329
  const blockLeft = pxtblockly.workspaceToScreenCoordinates(block.workspace, new Blockly.utils.Coordinate(bounds.left, bounds.top));
15293
- const toolboxWidth = block.workspace.getToolbox().getWidth();
15294
15330
  const workspaceLeft = injectDivBounds.left + toolboxWidth;
15295
15331
  if (blockLeft.x - divBounds.width - 20 > workspaceLeft) {
15296
15332
  widgetDiv.style.left = (blockLeft.x - divBounds.width - 20) + "px";
@@ -15301,6 +15337,8 @@ var pxtblockly;
15301
15337
  }
15302
15338
  }
15303
15339
  }
15340
+ const finalDimensions = widgetDiv.getBoundingClientRect();
15341
+ bbox = new Blockly.utils.Rect(finalDimensions.top, finalDimensions.bottom, finalDimensions.left, finalDimensions.right);
15304
15342
  requestAnimationFrame(() => {
15305
15343
  widgetDiv.style.opacity = "1";
15306
15344
  widgetDiv.style.transform = `translateY(${animationDistance}px)`;
@@ -1144,6 +1144,7 @@ declare namespace pxtblockly {
1144
1144
  }
1145
1145
  class FieldSoundEffect extends FieldBase<FieldSoundEffectParams> {
1146
1146
  protected mostRecentValue: pxt.assets.Sound;
1147
+ protected drawnSound: pxt.assets.Sound;
1147
1148
  protected onInit(): void;
1148
1149
  protected onDispose(): void;
1149
1150
  protected onValueChanged(newValue: string): string;
@@ -1159,6 +1160,7 @@ declare namespace pxtblockly {
1159
1160
  protected fireFieldDropdownUpdate(name: string, oldValue: string): void;
1160
1161
  protected readCurrentSound(): pxt.assets.Sound;
1161
1162
  protected readBlockDataSound(): pxt.assets.Sound;
1163
+ protected onWorkspaceChange: (ev: Blockly.Events.BlockChange) => void;
1162
1164
  }
1163
1165
  }
1164
1166
  declare namespace pxtblockly {
@@ -7327,6 +7327,7 @@ var pxt;
7327
7327
  state.setEventsEnabled(true);
7328
7328
  Blockly.Extensions.apply('inline-svgs', b, false);
7329
7329
  let updatingInputs = false;
7330
+ let firstRender = true;
7330
7331
  appendMutation(b, {
7331
7332
  mutationToDom: (el) => {
7332
7333
  // The reason we store the inputsInitialized variable separately from visibleOptions
@@ -7382,9 +7383,12 @@ var pxt;
7382
7383
  b.render = (opt_bubble) => {
7383
7384
  if (updatingInputs)
7384
7385
  return;
7385
- updatingInputs = true;
7386
- updateShape(0, undefined, true);
7387
- updatingInputs = false;
7386
+ if (firstRender) {
7387
+ firstRender = false;
7388
+ updatingInputs = true;
7389
+ updateShape(0, undefined, true);
7390
+ updatingInputs = false;
7391
+ }
7388
7392
  Blockly.BlockSvg.prototype.render.call(b, opt_bubble);
7389
7393
  };
7390
7394
  // Set skipRender to true if the block is still initializing. Otherwise
@@ -11581,6 +11585,17 @@ var pxtblockly;
11581
11585
  const Y_PADDING = 4;
11582
11586
  const PREVIEW_WIDTH = TOTAL_WIDTH - X_PADDING * 5 - MUSIC_ICON_WIDTH;
11583
11587
  class FieldSoundEffect extends pxtblockly.FieldBase {
11588
+ constructor() {
11589
+ super(...arguments);
11590
+ this.onWorkspaceChange = (ev) => {
11591
+ if (ev.type !== Blockly.Events.CHANGE)
11592
+ return;
11593
+ const block = this.sourceBlock_.workspace.getBlockById(ev.blockId);
11594
+ if (!block || block !== this.sourceBlock_ && block.parentBlock_ !== this.sourceBlock_)
11595
+ return;
11596
+ this.redrawPreview();
11597
+ };
11598
+ }
11584
11599
  onInit() {
11585
11600
  if (!this.options)
11586
11601
  this.options = {};
@@ -11601,8 +11616,10 @@ var pxtblockly;
11601
11616
  if (!this.options.effectFieldName)
11602
11617
  this.options.effectFieldName = "effect";
11603
11618
  this.redrawPreview();
11619
+ this.sourceBlock_.workspace.addChangeListener(this.onWorkspaceChange);
11604
11620
  }
11605
11621
  onDispose() {
11622
+ this.sourceBlock_.workspace.removeChangeListener(this.onWorkspaceChange);
11606
11623
  }
11607
11624
  onValueChanged(newValue) {
11608
11625
  return newValue;
@@ -11610,6 +11627,17 @@ var pxtblockly;
11610
11627
  redrawPreview() {
11611
11628
  if (!this.fieldGroup_)
11612
11629
  return;
11630
+ if (this.drawnSound) {
11631
+ const current = this.readCurrentSound();
11632
+ if (current.startFrequency === this.drawnSound.startFrequency &&
11633
+ current.endFrequency === this.drawnSound.endFrequency &&
11634
+ current.startVolume === this.drawnSound.startVolume &&
11635
+ current.endVolume === this.drawnSound.endVolume &&
11636
+ current.wave === this.drawnSound.wave &&
11637
+ current.interpolation === this.drawnSound.interpolation) {
11638
+ return;
11639
+ }
11640
+ }
11613
11641
  pxsim.U.clear(this.fieldGroup_);
11614
11642
  const bg = new svg.Rect()
11615
11643
  .at(X_PADDING, Y_PADDING)
@@ -11626,10 +11654,11 @@ var pxtblockly;
11626
11654
  .fill("#FFF")
11627
11655
  .at(0, 0);
11628
11656
  clip.appendChild(clipRect);
11657
+ this.drawnSound = this.readCurrentSound();
11629
11658
  const path = new svg.Path()
11630
11659
  .stroke("grey", 2)
11631
11660
  .fill("none")
11632
- .setD(pxt.assets.renderSoundPath(this.readCurrentSound(), TOTAL_WIDTH - X_PADDING * 4 - MUSIC_ICON_WIDTH, TOTAL_HEIGHT - Y_PADDING * 2))
11661
+ .setD(pxt.assets.renderSoundPath(this.drawnSound, TOTAL_WIDTH - X_PADDING * 4 - MUSIC_ICON_WIDTH, TOTAL_HEIGHT - Y_PADDING * 2))
11633
11662
  .clipPath("url('#" + clipPathId + "')");
11634
11663
  const g = new svg.Group()
11635
11664
  .translate(MUSIC_ICON_WIDTH + X_PADDING * 3, Y_PADDING + 3);
@@ -11647,7 +11676,13 @@ var pxtblockly;
11647
11676
  showEditor_() {
11648
11677
  const initialSound = this.readCurrentSound();
11649
11678
  Blockly.Events.disable();
11650
- Blockly.WidgetDiv.show(this, this.sourceBlock_.RTL, () => {
11679
+ let bbox;
11680
+ // This is due to the changes in https://github.com/microsoft/pxt-blockly/pull/289
11681
+ // which caused the widgetdiv to jump around if any fields underneath changed size
11682
+ let widgetOwner = {
11683
+ getScaledBBox: () => bbox
11684
+ };
11685
+ Blockly.WidgetDiv.show(widgetOwner, this.sourceBlock_.RTL, () => {
11651
11686
  fv.hide();
11652
11687
  widgetDiv.classList.remove("sound-effect-editor-widget");
11653
11688
  widgetDiv.style.transform = "";
@@ -11676,7 +11711,7 @@ var pxtblockly;
11676
11711
  const opts = {
11677
11712
  onClose: () => {
11678
11713
  fv.hide();
11679
- Blockly.WidgetDiv.hideIfOwner(this);
11714
+ Blockly.WidgetDiv.hideIfOwner(widgetOwner);
11680
11715
  },
11681
11716
  onSoundChange: (newSound) => {
11682
11717
  this.mostRecentValue = newSound;
@@ -11701,6 +11736,7 @@ var pxtblockly;
11701
11736
  widgetDiv.style.height = "40rem";
11702
11737
  widgetDiv.style.display = "block";
11703
11738
  widgetDiv.style.transition = "transform 0.25s ease 0s, opacity 0.25s ease 0s";
11739
+ widgetDiv.style.borderRadius = "";
11704
11740
  fv.onHide(() => {
11705
11741
  // do nothing
11706
11742
  });
@@ -11710,7 +11746,7 @@ var pxtblockly;
11710
11746
  if (divBounds.height > injectDivBounds.height) {
11711
11747
  widgetDiv.style.height = "";
11712
11748
  widgetDiv.style.top = `calc(1rem - ${animationDistance}px)`;
11713
- widgetDiv.style.bottom = "1rem";
11749
+ widgetDiv.style.bottom = `calc(1rem + ${animationDistance}px)`;
11714
11750
  }
11715
11751
  else {
11716
11752
  if (divBounds.bottom > injectDivBounds.bottom || divBounds.top < injectDivBounds.top) {
@@ -11718,7 +11754,8 @@ var pxtblockly;
11718
11754
  widgetDiv.style.top = (injectDivBounds.top + (injectDivBounds.height / 2) - (divBounds.height / 2)) - animationDistance + "px";
11719
11755
  }
11720
11756
  }
11721
- if (divBounds.width > injectDivBounds.width) {
11757
+ const toolboxWidth = block.workspace.getToolbox().getWidth();
11758
+ if (divBounds.width > injectDivBounds.width - toolboxWidth) {
11722
11759
  widgetDiv.style.width = "";
11723
11760
  widgetDiv.style.left = "1rem";
11724
11761
  widgetDiv.style.right = "1rem";
@@ -11728,7 +11765,6 @@ var pxtblockly;
11728
11765
  if (divBounds.left + divBounds.width >= injectDivBounds.right) {
11729
11766
  // If so, try and place to the left of the block instead of the right
11730
11767
  const blockLeft = pxtblockly.workspaceToScreenCoordinates(block.workspace, new Blockly.utils.Coordinate(bounds.left, bounds.top));
11731
- const toolboxWidth = block.workspace.getToolbox().getWidth();
11732
11768
  const workspaceLeft = injectDivBounds.left + toolboxWidth;
11733
11769
  if (blockLeft.x - divBounds.width - 20 > workspaceLeft) {
11734
11770
  widgetDiv.style.left = (blockLeft.x - divBounds.width - 20) + "px";
@@ -11739,6 +11775,8 @@ var pxtblockly;
11739
11775
  }
11740
11776
  }
11741
11777
  }
11778
+ const finalDimensions = widgetDiv.getBoundingClientRect();
11779
+ bbox = new Blockly.utils.Rect(finalDimensions.top, finalDimensions.bottom, finalDimensions.left, finalDimensions.right);
11742
11780
  requestAnimationFrame(() => {
11743
11781
  widgetDiv.style.opacity = "1";
11744
11782
  widgetDiv.style.transform = `translateY(${animationDistance}px)`;
package/built/pxtlib.d.ts CHANGED
@@ -1267,7 +1267,7 @@ declare namespace pxt.github {
1267
1267
  function listRefsExtAsync(repopath: string, namespace?: string, useProxy?: boolean, noCache?: boolean): Promise<RefsResult>;
1268
1268
  function pkgConfigAsync(repopath: string, tag: string, config: pxt.PackagesConfig): Promise<PackageConfig>;
1269
1269
  function downloadPackageAsync(repoWithTag: string, config: pxt.PackagesConfig): Promise<CachedPackage>;
1270
- function downloadLatestPackageAsync(repo: ParsedRepo): Promise<{
1270
+ function downloadLatestPackageAsync(repo: ParsedRepo, useProxy?: boolean, noCache?: boolean): Promise<{
1271
1271
  version: string;
1272
1272
  config: pxt.PackageConfig;
1273
1273
  }>;
package/built/pxtlib.js CHANGED
@@ -10260,9 +10260,9 @@ var pxt;
10260
10260
  return cached;
10261
10261
  }
10262
10262
  github.downloadPackageAsync = downloadPackageAsync;
10263
- async function downloadLatestPackageAsync(repo) {
10263
+ async function downloadLatestPackageAsync(repo, useProxy, noCache) {
10264
10264
  const packageConfig = await pxt.packagesConfigAsync();
10265
- const tag = await pxt.github.latestVersionAsync(repo.slug, packageConfig);
10265
+ const tag = await pxt.github.latestVersionAsync(repo.slug, packageConfig, useProxy, noCache);
10266
10266
  // download package into cache
10267
10267
  const repoWithTag = `${repo.fullName}#${tag}`;
10268
10268
  await pxt.github.downloadPackageAsync(repoWithTag, packageConfig);
package/built/pxtsim.js CHANGED
@@ -8039,7 +8039,7 @@ var pxsim;
8039
8039
  return this.buffer;
8040
8040
  }
8041
8041
  // Synthesize a sample
8042
- let s = this.effect.tone.tonePrint(this.effect.tone.parameter, this.position);
8042
+ let s = this.effect.tone.tonePrint(this.effect.tone.parameter, Math.max(this.position, 0));
8043
8043
  // Apply volume scaling and OR mask (if specified).
8044
8044
  this.buffer[sample] = (((s * gain) + offset)); // | this.orMask;
8045
8045
  // Move on our pointers.