pxt-microbit 5.1.25 → 5.1.26

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/editor.js CHANGED
@@ -3967,7 +3967,7 @@ exports.mkDAPLinkPacketIOWrapper = mkDAPLinkPacketIOWrapper;
3967
3967
  <field name="LED34">FALSE</field>
3968
3968
  <field name="LED44">FALSE</field>
3969
3969
  </block>
3970
-
3970
+
3971
3971
  to
3972
3972
  <block type="device_show_leds">
3973
3973
  <field name="LEDS">`
@@ -3983,6 +3983,37 @@ exports.mkDAPLinkPacketIOWrapper = mkDAPLinkPacketIOWrapper;
3983
3983
  Object.defineProperty(exports, "__esModule", { value: true });
3984
3984
  exports.patchBlocks = void 0;
3985
3985
  function patchBlocks(pkgTargetVersion, dom) {
3986
+ if (pxt.semver.majorCmp(pkgTargetVersion || "0.0.0", "5.0.12") <= 0) {
3987
+ // Eighth note misspelling
3988
+ /*
3989
+ <block type="basic_show_icon">
3990
+ <field name="i">IconNames.EigthNote</field>
3991
+ </block>
3992
+
3993
+ converts to
3994
+
3995
+ <block type="basic_show_icon">
3996
+ <field name="i">IconNames.EighthNote</field>
3997
+ </block>
3998
+ */
3999
+ pxt.U.toArray(dom.querySelectorAll("block[type=basic_show_icon]>field[name=i]"))
4000
+ .filter(node => node.textContent === "IconNames.EigthNote")
4001
+ .forEach(node => node.textContent = "IconNames.EighthNote");
4002
+ // Italian translation error
4003
+ /*
4004
+ <shadow type="device_note">
4005
+ <field name="note">466</field>
4006
+ </shadow>
4007
+
4008
+ converts to
4009
+
4010
+ <shadow type="device_note">
4011
+ <field name="name">466</field>
4012
+ </shadow>
4013
+ */
4014
+ pxt.U.toArray(dom.querySelectorAll("shadow[type=device_note]>field[name=note]"))
4015
+ .forEach(node => node.setAttribute("name", "name"));
4016
+ }
3986
4017
  // is this a old script?
3987
4018
  if (pxt.semver.majorCmp(pkgTargetVersion || "0.0.0", "1.0.0") >= 0)
3988
4019
  return;
@@ -4030,9 +4061,9 @@ function patchBlocks(pkgTargetVersion, dom) {
4030
4061
  <mutation callbackproperties="receivedString" renamemap="{}"></mutation>
4031
4062
  <field name="receivedString">receivedString</field>
4032
4063
  </block>
4033
-
4064
+
4034
4065
  converts to
4035
-
4066
+
4036
4067
  <block type="radio_on_number" x="196" y="208">
4037
4068
  <field name="HANDLER_receivedNumber" id="DCy(W;1)*jLWQUpoy4Mm" variabletype="">receivedNumber</field>
4038
4069
  </block>
package/built/sim.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  /// <reference path="../libs/core/dal.d.ts" />
2
2
  /// <reference path="../libs/core/enums.d.ts" />
3
+ /// <reference types="dom-mediacapture-record" />
3
4
  declare namespace pxsim {
4
5
  interface CommonBoard extends CoreBoard, EventBusBoard {
5
6
  bus: EventBus;
@@ -564,6 +565,12 @@ declare namespace pxsim.music.MusicalProgressions {
564
565
  declare namespace pxsim {
565
566
  class RecordingState {
566
567
  currentlyRecording: boolean;
568
+ stream: MediaStream;
569
+ recorder: MediaRecorder;
570
+ chunks: Blob[];
571
+ audioURL: string;
572
+ recording: HTMLAudioElement;
573
+ audioPlaying: boolean;
567
574
  }
568
575
  }
569
576
  declare namespace pxsim.record {
package/built/sim.js CHANGED
@@ -2278,6 +2278,7 @@ var pxsim;
2278
2278
  class RecordingState {
2279
2279
  constructor() {
2280
2280
  this.currentlyRecording = false;
2281
+ this.audioPlaying = false;
2281
2282
  }
2282
2283
  }
2283
2284
  pxsim.RecordingState = RecordingState;
@@ -2285,34 +2286,29 @@ var pxsim;
2285
2286
  (function (pxsim) {
2286
2287
  var record;
2287
2288
  (function (record_1) {
2288
- let stream;
2289
- let recorder;
2290
- let chunks;
2291
- let audioURL;
2292
- let recording;
2293
- let audioPlaying = false;
2294
2289
  async function record() {
2295
2290
  //request permission is asynchronous
2296
2291
  let b = pxsim.board();
2292
+ let recordingState = b.recordingState;
2297
2293
  if (!b.recordingState.currentlyRecording) {
2298
2294
  b.recordingState.currentlyRecording = true;
2299
2295
  pxsim.runtime.queueDisplayUpdate();
2300
2296
  if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
2301
2297
  try {
2302
- stream = await navigator.mediaDevices.getUserMedia({ video: false, audio: true });
2303
- recorder = new MediaRecorder(stream);
2304
- recorder.start();
2298
+ recordingState.stream = await navigator.mediaDevices.getUserMedia({ video: false, audio: true });
2299
+ recordingState.recorder = new MediaRecorder(recordingState.stream);
2300
+ recordingState.recorder.start();
2305
2301
  setTimeout(() => {
2306
- recorder.stop();
2302
+ recordingState.recorder.stop();
2307
2303
  pxsim.runtime.queueDisplayUpdate();
2308
2304
  }, 4000);
2309
- recorder.ondataavailable = (e) => {
2310
- chunks.push(e.data);
2305
+ recordingState.recorder.ondataavailable = (e) => {
2306
+ recordingState.chunks.push(e.data);
2311
2307
  };
2312
- recorder.onstop = () => {
2313
- const blob = new Blob(chunks, { type: "audio/ogg; codecs=opus" });
2314
- audioURL = window.URL.createObjectURL(blob);
2315
- recording = new Audio(audioURL);
2308
+ recordingState.recorder.onstop = () => {
2309
+ const blob = new Blob(recordingState.chunks, { type: "audio/ogg; codecs=opus" });
2310
+ recordingState.audioURL = window.URL.createObjectURL(blob);
2311
+ recordingState.recording = new Audio(recordingState.audioURL);
2316
2312
  b.recordingState.currentlyRecording = false;
2317
2313
  erase();
2318
2314
  };
@@ -2328,8 +2324,11 @@ var pxsim;
2328
2324
  }
2329
2325
  record_1.record = record;
2330
2326
  function play() {
2331
- if (recording) {
2332
- recording.play();
2327
+ const b = pxsim.board();
2328
+ if (!b)
2329
+ return;
2330
+ if (b.recordingState.recording) {
2331
+ b.recordingState.recording.play();
2333
2332
  }
2334
2333
  }
2335
2334
  record_1.play = play;
@@ -2337,7 +2336,10 @@ var pxsim;
2337
2336
  }
2338
2337
  record_1.stop = stop;
2339
2338
  function erase() {
2340
- chunks = [];
2339
+ const b = pxsim.board();
2340
+ if (!b)
2341
+ return;
2342
+ b.recordingState.chunks = [];
2341
2343
  }
2342
2344
  record_1.erase = erase;
2343
2345
  function setMicrophoneGain(gain) {
@@ -2348,23 +2350,32 @@ var pxsim;
2348
2350
  }
2349
2351
  record_1.audioDuration = audioDuration;
2350
2352
  function audioIsPlaying() {
2351
- if (recording) {
2352
- recording.addEventListener("playing", () => {
2353
- audioPlaying = true;
2353
+ const b = pxsim.board();
2354
+ if (!b)
2355
+ return false;
2356
+ if (b.recordingState.recording) {
2357
+ b.recordingState.recording.addEventListener("playing", () => {
2358
+ b.recordingState.audioPlaying = true;
2354
2359
  }, { once: true });
2355
- recording.addEventListener("ended", () => {
2356
- audioPlaying = false;
2360
+ b.recordingState.recording.addEventListener("ended", () => {
2361
+ b.recordingState.audioPlaying = false;
2357
2362
  }, { once: true });
2358
2363
  }
2359
- return audioPlaying;
2364
+ return b.recordingState.audioPlaying;
2360
2365
  }
2361
2366
  record_1.audioIsPlaying = audioIsPlaying;
2362
2367
  function audioIsRecording() {
2363
- return recorder ? recorder.state == "recording" : false;
2368
+ const b = pxsim.board();
2369
+ if (!b)
2370
+ return false;
2371
+ return b.recordingState.recorder ? b.recordingState.recorder.state == "recording" : false;
2364
2372
  }
2365
2373
  record_1.audioIsRecording = audioIsRecording;
2366
2374
  function audioIsStopped() {
2367
- return recorder ? !audioPlaying && recorder.state == "inactive" : true;
2375
+ const b = pxsim.board();
2376
+ if (!b)
2377
+ return true;
2378
+ return b.recordingState.recorder ? !b.recordingState.audioPlaying && b.recordingState.recorder.state == "inactive" : true;
2368
2379
  }
2369
2380
  record_1.audioIsStopped = audioIsStopped;
2370
2381
  function setInputSampleRate(sampleRate) {