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
@@ -8,11 +8,12 @@ namespace pxsim.multiplayer {
8
8
  return;
9
9
  const asBuf = pxsim.image.toBuffer(im);
10
10
  const sb = board() as ScreenBoard;
11
- throttledImgPost(<MultiplayerImageMessage>{
11
+ const screenState = sb && sb.screenState;
12
+ throttledImgPost({
12
13
  content: "Image",
13
14
  image: asBuf,
14
- palette: sb?.screenState?.paletteToUint8Array(),
15
- });
15
+ palette: screenState && screenState.paletteToUint8Array(),
16
+ } as pxsim.MultiplayerImageMessage);
16
17
  }
17
18
 
18
19
 
@@ -61,6 +62,12 @@ namespace pxsim {
61
62
  state: "Pressed" | "Released" | "Held";
62
63
  }
63
64
 
65
+ export interface MultiplayerAudioEvent extends SimulatorMultiplayerMessage {
66
+ content: "Audio";
67
+ instruction: "playinstructions" | "muteallchannels";
68
+ soundbuf?: Uint8Array;
69
+ }
70
+
64
71
  export class MultiplayerState {
65
72
  lastMessageId: number;
66
73
  origin: string;
@@ -71,28 +78,39 @@ namespace pxsim {
71
78
  }
72
79
 
73
80
  send(msg: SimulatorMultiplayerMessage) {
74
- Runtime.postMessage(<SimulatorMultiplayerMessage>{
81
+ Runtime.postMessage({
75
82
  ...msg,
76
83
  broadcast: true,
77
84
  toParentIFrameOnly: true,
78
85
  type: "multiplayer",
79
86
  origin: this.origin,
80
87
  id: this.lastMessageId++
81
- });
88
+ } as SimulatorMultiplayerMessage);
82
89
  }
83
90
 
84
91
  init(origin: string) {
85
92
  this.origin = origin;
86
93
  runtime.board.addMessageListener(msg => this.messageHandler(msg));
94
+ if (this.origin === "server") {
95
+ pxsim.AudioContextManager.soundEventCallback = (ev: "playinstructions" | "muteallchannels", data?: Uint8Array) => {
96
+ this.send({
97
+ content: "Audio",
98
+ instruction: ev,
99
+ soundbuf: data,
100
+ } as pxsim.MultiplayerAudioEvent)
101
+ }
102
+ } else {
103
+ pxsim.AudioContextManager.soundEventCallback = undefined;
104
+ }
87
105
  }
88
106
 
89
107
  setButton(key: number, isPressed: boolean) {
90
108
  if (this.origin === "client") {
91
- this.send(<pxsim.MultiplayerButtonEvent>{
109
+ this.send({
92
110
  content: "Button",
93
111
  button: key,
94
112
  state: isPressed ? "Pressed" : "Released"
95
- })
113
+ } as pxsim.MultiplayerButtonEvent)
96
114
  }
97
115
  }
98
116
 
@@ -108,7 +126,7 @@ namespace pxsim {
108
126
  msg.image.data = new Uint8Array(msg.image.data);
109
127
  }
110
128
  this.backgroundImage = pxsim.image.ofBuffer(msg.image);
111
- if (msg.palette?.length === 48) {
129
+ if (msg.palette && msg.palette.length === 48) {
112
130
  const palBuffer = new pxsim.RefBuffer(msg.palette)
113
131
  pxsim.pxtcore.setPalette(palBuffer);
114
132
  }
@@ -120,6 +138,14 @@ namespace pxsim {
120
138
  msg.state === "Pressed" || msg.state === "Held"
121
139
  );
122
140
  }
141
+ } else if (isAudioMessage(msg)) {
142
+ if (this.origin === "client") {
143
+ if (msg.instruction === "playinstructions") {
144
+ pxsim.AudioContextManager.playInstructionsAsync(msg.soundbuf)
145
+ } else if (msg.instruction === "muteallchannels") {
146
+ pxsim.AudioContextManager.muteAllChannels();
147
+ }
148
+ }
123
149
  }
124
150
  }
125
151
  }
@@ -135,4 +161,8 @@ namespace pxsim {
135
161
  function isButtonMessage(msg: SimulatorMultiplayerMessage): msg is MultiplayerButtonEvent {
136
162
  return msg && msg.content === "Button";
137
163
  }
164
+
165
+ function isAudioMessage(msg: SimulatorMultiplayerMessage): msg is MultiplayerAudioEvent {
166
+ return msg && msg.content === "Audio";
167
+ }
138
168
  }
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
56
56
  const pxsim_numops = pxsim.numops;
57
57
 
58
58
 
59
- function _main___P48498(s) {
59
+ function _main___P48539(s) {
60
60
  let r0 = s.r0, step = s.pc;
61
61
  s.pc = -1;
62
62
 
@@ -66,19 +66,19 @@ if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) re
66
66
  switch (step) {
67
67
  case 0:
68
68
 
69
- globals._intervals___48741 = (undefined);
70
- globals._pollEventQueue___48754 = (undefined);
69
+ globals._intervals___48782 = (undefined);
70
+ globals._pollEventQueue___48795 = (undefined);
71
71
  r0 = undefined;
72
72
  return leave(s, r0)
73
73
  default: oops()
74
74
  } } }
75
- _main___P48498.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"characterlcd.ts","functionName":"<main>","argumentNames":[]}
76
- _main___P48498.continuations = [ ]
75
+ _main___P48539.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"characterlcd.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P48539.continuations = [ ]
77
77
 
78
- function _main___P48498_mk(s) {
78
+ function _main___P48539_mk(s) {
79
79
  checkStack(s.depth);
80
80
  return {
81
- parent: s, fn: _main___P48498, depth: s.depth + 1,
81
+ parent: s, fn: _main___P48539, depth: s.depth + 1,
82
82
  pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
83
83
  } }
84
84
 
@@ -88,5 +88,5 @@ function _main___P48498_mk(s) {
88
88
 
89
89
  const breakpoints = setupDebugger(1, [])
90
90
 
91
- return _main___P48498
91
+ return _main___P48539
92
92
  })
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
56
56
  const pxsim_numops = pxsim.numops;
57
57
 
58
58
 
59
- function _main___P97826(s) {
59
+ function _main___P97949(s) {
60
60
  let r0 = s.r0, step = s.pc;
61
61
  s.pc = -1;
62
62
 
@@ -66,19 +66,19 @@ if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) re
66
66
  switch (step) {
67
67
  case 0:
68
68
 
69
- globals._intervals___98069 = (undefined);
70
- globals._pollEventQueue___98082 = (undefined);
69
+ globals._intervals___98192 = (undefined);
70
+ globals._pollEventQueue___98205 = (undefined);
71
71
  r0 = undefined;
72
72
  return leave(s, r0)
73
73
  default: oops()
74
74
  } } }
75
- _main___P97826.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"tsl2591.ts","functionName":"<main>","argumentNames":[]}
76
- _main___P97826.continuations = [ ]
75
+ _main___P97949.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"tsl2591.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P97949.continuations = [ ]
77
77
 
78
- function _main___P97826_mk(s) {
78
+ function _main___P97949_mk(s) {
79
79
  checkStack(s.depth);
80
80
  return {
81
- parent: s, fn: _main___P97826, depth: s.depth + 1,
81
+ parent: s, fn: _main___P97949, depth: s.depth + 1,
82
82
  pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
83
83
  } }
84
84
 
@@ -88,5 +88,5 @@ function _main___P97826_mk(s) {
88
88
 
89
89
  const breakpoints = setupDebugger(1, [])
90
90
 
91
- return _main___P97826
91
+ return _main___P97949
92
92
  })
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
56
56
  const pxsim_numops = pxsim.numops;
57
57
 
58
58
 
59
- function _main___P59800(s) {
59
+ function _main___P59841(s) {
60
60
  let r0 = s.r0, step = s.pc;
61
61
  s.pc = -1;
62
62
 
@@ -66,19 +66,19 @@ if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) re
66
66
  switch (step) {
67
67
  case 0:
68
68
 
69
- globals._intervals___60043 = (undefined);
70
- globals._pollEventQueue___60056 = (undefined);
69
+ globals._intervals___60084 = (undefined);
70
+ globals._pollEventQueue___60097 = (undefined);
71
71
  r0 = undefined;
72
72
  return leave(s, r0)
73
73
  default: oops()
74
74
  } } }
75
- _main___P59800.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"lora.ts","functionName":"<main>","argumentNames":[]}
76
- _main___P59800.continuations = [ ]
75
+ _main___P59841.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"lora.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P59841.continuations = [ ]
77
77
 
78
- function _main___P59800_mk(s) {
78
+ function _main___P59841_mk(s) {
79
79
  checkStack(s.depth);
80
80
  return {
81
- parent: s, fn: _main___P59800, depth: s.depth + 1,
81
+ parent: s, fn: _main___P59841, depth: s.depth + 1,
82
82
  pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
83
83
  } }
84
84
 
@@ -88,5 +88,5 @@ function _main___P59800_mk(s) {
88
88
 
89
89
  const breakpoints = setupDebugger(1, [])
90
90
 
91
- return _main___P59800
91
+ return _main___P59841
92
92
  })
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
56
56
  const pxsim_numops = pxsim.numops;
57
57
 
58
58
 
59
- function _main___P190006(s) {
59
+ function _main___P190293(s) {
60
60
  let r0 = s.r0, step = s.pc;
61
61
  s.pc = -1;
62
62
 
@@ -66,19 +66,19 @@ if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) re
66
66
  switch (step) {
67
67
  case 0:
68
68
 
69
- globals._intervals___190249 = (undefined);
70
- globals._pollEventQueue___190262 = (undefined);
69
+ globals._intervals___190536 = (undefined);
70
+ globals._pollEventQueue___190549 = (undefined);
71
71
  r0 = undefined;
72
72
  return leave(s, r0)
73
73
  default: oops()
74
74
  } } }
75
- _main___P190006.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"keypad.ts","functionName":"<main>","argumentNames":[]}
76
- _main___P190006.continuations = [ ]
75
+ _main___P190293.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"keypad.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P190293.continuations = [ ]
77
77
 
78
- function _main___P190006_mk(s) {
78
+ function _main___P190293_mk(s) {
79
79
  checkStack(s.depth);
80
80
  return {
81
- parent: s, fn: _main___P190006, depth: s.depth + 1,
81
+ parent: s, fn: _main___P190293, depth: s.depth + 1,
82
82
  pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
83
83
  } }
84
84
 
@@ -88,5 +88,5 @@ function _main___P190006_mk(s) {
88
88
 
89
89
  const breakpoints = setupDebugger(1, [])
90
90
 
91
- return _main___P190006
91
+ return _main___P190293
92
92
  })