pxt-common-packages 10.3.11 → 10.4.1

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 (32) hide show
  1. package/built/common-sim.d.ts +6 -0
  2. package/built/common-sim.js +15 -0
  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 +8627 -8381
  7. package/libs/controller---none/built/debug/binary.js +8629 -8383
  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/built/debug/binary.js +9031 -8785
  12. package/libs/game/multiplayer.ts +39 -0
  13. package/libs/game/sim/multiplayer.ts +23 -0
  14. package/libs/lcd/built/debug/binary.js +8 -8
  15. package/libs/light-spectrum-sensor/built/debug/binary.js +8 -8
  16. package/libs/lora/built/debug/binary.js +8 -8
  17. package/libs/matrix-keypad/built/debug/binary.js +8 -8
  18. package/libs/mqtt/built/debug/binary.js +176 -176
  19. package/libs/net/built/debug/binary.js +176 -176
  20. package/libs/net-game/built/debug/binary.js +10613 -10367
  21. package/libs/palette/built/debug/binary.js +9030 -8784
  22. package/libs/pixel/built/debug/binary.js +8 -8
  23. package/libs/power/built/debug/binary.js +8 -8
  24. package/libs/proximity/built/debug/binary.js +8 -8
  25. package/libs/radio/built/debug/binary.js +8 -8
  26. package/libs/radio-broadcast/built/debug/binary.js +8 -8
  27. package/libs/rotary-encoder/built/debug/binary.js +8 -8
  28. package/libs/screen/built/debug/binary.js +50 -50
  29. package/libs/servo/built/debug/binary.js +8 -8
  30. package/libs/sprite-scaling/built/debug/binary.js +9030 -8784
  31. package/libs/storyboard/built/debug/binary.js +9030 -8784
  32. package/package.json +1 -1
@@ -818,6 +818,11 @@ declare namespace pxsim {
818
818
  instruction: "playinstructions" | "muteallchannels";
819
819
  soundbuf?: Uint8Array;
820
820
  }
821
+ interface MultiplayerConnectionEvent extends SimulatorMultiplayerMessage {
822
+ content: "Connection";
823
+ slot: number;
824
+ connected: boolean;
825
+ }
821
826
  class MultiplayerState {
822
827
  lastMessageId: number;
823
828
  origin: string;
@@ -826,6 +831,7 @@ declare namespace pxsim {
826
831
  send(msg: SimulatorMultiplayerMessage): void;
827
832
  init(origin: string): void;
828
833
  setButton(key: number, isPressed: boolean): void;
834
+ registerConnectionState(player: number, connected: boolean): void;
829
835
  protected messageHandler(msg: SimulatorMessage): void;
830
836
  }
831
837
  }
@@ -2594,6 +2594,8 @@ var pxsim;
2594
2594
  IconType[IconType["Player"] = 0] = "Player";
2595
2595
  IconType[IconType["Reaction"] = 1] = "Reaction";
2596
2596
  })(IconType = pxsim.IconType || (pxsim.IconType = {}));
2597
+ const MULTIPLAYER_PLAYER_JOINED_ID = 3241;
2598
+ const MULTIPLAYER_PLAYER_LEFT_ID = 3242;
2597
2599
  class MultiplayerState {
2598
2600
  constructor() {
2599
2601
  this.lastMessageId = 0;
@@ -2626,6 +2628,11 @@ var pxsim;
2626
2628
  });
2627
2629
  }
2628
2630
  }
2631
+ registerConnectionState(player, connected) {
2632
+ const evId = connected ? MULTIPLAYER_PLAYER_JOINED_ID : MULTIPLAYER_PLAYER_LEFT_ID;
2633
+ const b = pxsim.board();
2634
+ b.bus.queue(evId, player);
2635
+ }
2629
2636
  messageHandler(msg) {
2630
2637
  if (!isMultiplayerMessage(msg)) {
2631
2638
  return;
@@ -2659,6 +2666,11 @@ var pxsim;
2659
2666
  }
2660
2667
  }
2661
2668
  }
2669
+ else if (isConnectionMessage(msg)) {
2670
+ if (this.origin === "server") {
2671
+ this.registerConnectionState(msg.slot, msg.connected);
2672
+ }
2673
+ }
2662
2674
  }
2663
2675
  }
2664
2676
  pxsim.MultiplayerState = MultiplayerState;
@@ -2674,6 +2686,9 @@ var pxsim;
2674
2686
  function isAudioMessage(msg) {
2675
2687
  return msg && msg.content === "Audio";
2676
2688
  }
2689
+ function isConnectionMessage(msg) {
2690
+ return msg && msg.content === "Connection";
2691
+ }
2677
2692
  })(pxsim || (pxsim = {}));
2678
2693
  var pxsim;
2679
2694
  (function (pxsim) {