pxt-common-packages 10.2.5 → 10.2.7

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.
Files changed (34) hide show
  1. package/built/common-sim.d.ts +5 -0
  2. package/built/common-sim.js +28 -4
  3. package/libs/azureiot/built/debug/binary.js +461 -461
  4. package/libs/color/built/debug/binary.js +8 -8
  5. package/libs/color-sensor/built/debug/binary.js +8 -8
  6. package/libs/controller/built/debug/binary.js +6968 -6968
  7. package/libs/controller---none/built/debug/binary.js +6950 -6950
  8. package/libs/datalogger/built/debug/binary.js +63 -63
  9. package/libs/edge-connector/built/debug/binary.js +8 -8
  10. package/libs/esp32/built/debug/binary.js +462 -462
  11. package/libs/game/_locales/game-jsdoc-strings.json +1 -0
  12. package/libs/game/built/debug/binary.js +6889 -6889
  13. package/libs/game/controller.ts +27 -3
  14. package/libs/game/info.ts +263 -91
  15. package/libs/game/sim/multiplayer.ts +38 -8
  16. package/libs/lcd/built/debug/binary.js +8 -8
  17. package/libs/light-spectrum-sensor/built/debug/binary.js +8 -8
  18. package/libs/lora/built/debug/binary.js +8 -8
  19. package/libs/matrix-keypad/built/debug/binary.js +8 -8
  20. package/libs/mqtt/built/debug/binary.js +176 -176
  21. package/libs/net/built/debug/binary.js +176 -176
  22. package/libs/net-game/built/debug/binary.js +8478 -8478
  23. package/libs/palette/built/debug/binary.js +6888 -6888
  24. package/libs/pixel/built/debug/binary.js +8 -8
  25. package/libs/power/built/debug/binary.js +8 -8
  26. package/libs/proximity/built/debug/binary.js +8 -8
  27. package/libs/radio/built/debug/binary.js +8 -8
  28. package/libs/radio-broadcast/built/debug/binary.js +8 -8
  29. package/libs/rotary-encoder/built/debug/binary.js +8 -8
  30. package/libs/screen/built/debug/binary.js +50 -50
  31. package/libs/servo/built/debug/binary.js +8 -8
  32. package/libs/sprite-scaling/built/debug/binary.js +6888 -6888
  33. package/libs/storyboard/built/debug/binary.js +6888 -6888
  34. package/package.json +2 -2
@@ -801,6 +801,11 @@ declare namespace pxsim {
801
801
  button: number;
802
802
  state: "Pressed" | "Released" | "Held";
803
803
  }
804
+ interface MultiplayerAudioEvent extends SimulatorMultiplayerMessage {
805
+ content: "Audio";
806
+ instruction: "playinstructions" | "muteallchannels";
807
+ soundbuf?: Uint8Array;
808
+ }
804
809
  class MultiplayerState {
805
810
  lastMessageId: number;
806
811
  origin: string;
@@ -2541,15 +2541,15 @@ var pxsim;
2541
2541
  pxsim.getMultiplayerState().send(msg);
2542
2542
  }, 50, true);
2543
2543
  function postImage(im) {
2544
- var _a;
2545
2544
  if (pxsim.getMultiplayerState().origin !== "server")
2546
2545
  return;
2547
2546
  const asBuf = pxsim.image.toBuffer(im);
2548
2547
  const sb = pxsim.board();
2548
+ const screenState = sb && sb.screenState;
2549
2549
  throttledImgPost({
2550
2550
  content: "Image",
2551
2551
  image: asBuf,
2552
- palette: (_a = sb === null || sb === void 0 ? void 0 : sb.screenState) === null || _a === void 0 ? void 0 : _a.paletteToUint8Array(),
2552
+ palette: screenState && screenState.paletteToUint8Array(),
2553
2553
  });
2554
2554
  }
2555
2555
  multiplayer.postImage = postImage;
@@ -2582,6 +2582,18 @@ var pxsim;
2582
2582
  init(origin) {
2583
2583
  this.origin = origin;
2584
2584
  pxsim.runtime.board.addMessageListener(msg => this.messageHandler(msg));
2585
+ if (this.origin === "server") {
2586
+ pxsim.AudioContextManager.soundEventCallback = (ev, data) => {
2587
+ this.send({
2588
+ content: "Audio",
2589
+ instruction: ev,
2590
+ soundbuf: data,
2591
+ });
2592
+ };
2593
+ }
2594
+ else {
2595
+ pxsim.AudioContextManager.soundEventCallback = undefined;
2596
+ }
2585
2597
  }
2586
2598
  setButton(key, isPressed) {
2587
2599
  if (this.origin === "client") {
@@ -2593,7 +2605,6 @@ var pxsim;
2593
2605
  }
2594
2606
  }
2595
2607
  messageHandler(msg) {
2596
- var _a;
2597
2608
  if (!isMultiplayerMessage(msg)) {
2598
2609
  return;
2599
2610
  }
@@ -2604,7 +2615,7 @@ var pxsim;
2604
2615
  msg.image.data = new Uint8Array(msg.image.data);
2605
2616
  }
2606
2617
  this.backgroundImage = pxsim.image.ofBuffer(msg.image);
2607
- if (((_a = msg.palette) === null || _a === void 0 ? void 0 : _a.length) === 48) {
2618
+ if (msg.palette && msg.palette.length === 48) {
2608
2619
  const palBuffer = new pxsim.RefBuffer(msg.palette);
2609
2620
  pxsim.pxtcore.setPalette(palBuffer);
2610
2621
  }
@@ -2616,6 +2627,16 @@ var pxsim;
2616
2627
  msg.state === "Pressed" || msg.state === "Held");
2617
2628
  }
2618
2629
  }
2630
+ else if (isAudioMessage(msg)) {
2631
+ if (this.origin === "client") {
2632
+ if (msg.instruction === "playinstructions") {
2633
+ pxsim.AudioContextManager.playInstructionsAsync(msg.soundbuf);
2634
+ }
2635
+ else if (msg.instruction === "muteallchannels") {
2636
+ pxsim.AudioContextManager.muteAllChannels();
2637
+ }
2638
+ }
2639
+ }
2619
2640
  }
2620
2641
  }
2621
2642
  pxsim.MultiplayerState = MultiplayerState;
@@ -2628,6 +2649,9 @@ var pxsim;
2628
2649
  function isButtonMessage(msg) {
2629
2650
  return msg && msg.content === "Button";
2630
2651
  }
2652
+ function isAudioMessage(msg) {
2653
+ return msg && msg.content === "Audio";
2654
+ }
2631
2655
  })(pxsim || (pxsim = {}));
2632
2656
  var pxsim;
2633
2657
  (function (pxsim) {