pxt-common-packages 12.3.5 → 12.3.25

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 (40) hide show
  1. package/built/common-sim.d.ts +12 -2
  2. package/built/common-sim.js +45 -4
  3. package/libs/azureiot/built/debug/binary.js +461 -461
  4. package/libs/browser-events/browserEvents.cpp +4 -0
  5. package/libs/browser-events/browserEvents.ts +115 -36
  6. package/libs/browser-events/keyboard.ts +147 -41
  7. package/libs/browser-events/shims.d.ts +2 -0
  8. package/libs/browser-events/sim/keyboard.ts +36 -3
  9. package/libs/browser-events/sim/mouseState.ts +15 -1
  10. package/libs/color/built/debug/binary.js +8 -8
  11. package/libs/color-sensor/built/debug/binary.js +8 -8
  12. package/libs/controller/built/debug/binary.js +8560 -8315
  13. package/libs/controller---none/built/debug/binary.js +8539 -8294
  14. package/libs/datalogger/built/debug/binary.js +63 -63
  15. package/libs/edge-connector/built/debug/binary.js +8 -8
  16. package/libs/esp32/built/debug/binary.js +462 -462
  17. package/libs/game/built/debug/binary.js +8452 -8207
  18. package/libs/game/game.ts +5 -2
  19. package/libs/lcd/built/debug/binary.js +8 -8
  20. package/libs/light-spectrum-sensor/built/debug/binary.js +8 -8
  21. package/libs/lora/built/debug/binary.js +8 -8
  22. package/libs/matrix-keypad/built/debug/binary.js +8 -8
  23. package/libs/mixer/playable.ts +6 -2
  24. package/libs/mixer/soundEffect.ts +2 -2
  25. package/libs/mqtt/built/debug/binary.js +176 -176
  26. package/libs/net/built/debug/binary.js +176 -176
  27. package/libs/net-game/built/debug/binary.js +10394 -10149
  28. package/libs/palette/built/debug/binary.js +8451 -8206
  29. package/libs/pixel/built/debug/binary.js +8 -8
  30. package/libs/power/built/debug/binary.js +8 -8
  31. package/libs/proximity/built/debug/binary.js +8 -8
  32. package/libs/radio/built/debug/binary.js +8 -8
  33. package/libs/radio-broadcast/built/debug/binary.js +8 -8
  34. package/libs/rotary-encoder/built/debug/binary.js +8 -8
  35. package/libs/screen/built/debug/binary.js +50 -50
  36. package/libs/screen---st7735/screen.cpp +2 -2
  37. package/libs/servo/built/debug/binary.js +8 -8
  38. package/libs/sprite-scaling/built/debug/binary.js +8451 -8206
  39. package/libs/storyboard/built/debug/binary.js +8451 -8206
  40. package/package.json +2 -2
package/libs/game/game.ts CHANGED
@@ -174,7 +174,10 @@ namespace game {
174
174
  const oldScene = game.currentScene()
175
175
  particles.clearAll();
176
176
  particles.disableAll();
177
- if (!_sceneStack) _sceneStack = [];
177
+ if (!_sceneStack) {
178
+ _sceneStack = [];
179
+ music._initializeSceneStack(game.addScenePushHandler, game.addScenePopHandler);
180
+ }
178
181
  _sceneStack.push(_scene);
179
182
  init(/** forceNewScene **/ true);
180
183
 
@@ -300,7 +303,7 @@ namespace game {
300
303
  /**
301
304
  * Set the message that displays when the game is over
302
305
  * @param win whether the message should show on a win (true) or lose (false)
303
- * @param message
306
+ * @param message
304
307
  */
305
308
  //% blockId=game_setgameovermessage
306
309
  //% block="use message $message for $win"
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
56
56
  const pxsim_numops = pxsim.numops;
57
57
 
58
58
 
59
- function _main___P49445(s) {
59
+ function _main___P49482(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___49688 = (undefined);
70
- globals._pollEventQueue___49701 = (undefined);
69
+ globals._intervals___49725 = (undefined);
70
+ globals._pollEventQueue___49738 = (undefined);
71
71
  r0 = undefined;
72
72
  return leave(s, r0)
73
73
  default: oops()
74
74
  } } }
75
- _main___P49445.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"characterlcd.ts","functionName":"<main>","argumentNames":[]}
76
- _main___P49445.continuations = [ ]
75
+ _main___P49482.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"characterlcd.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P49482.continuations = [ ]
77
77
 
78
- function _main___P49445_mk(s) {
78
+ function _main___P49482_mk(s) {
79
79
  checkStack(s.depth);
80
80
  return {
81
- parent: s, fn: _main___P49445, depth: s.depth + 1,
81
+ parent: s, fn: _main___P49482, 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___P49445_mk(s) {
88
88
 
89
89
  const breakpoints = setupDebugger(1, [])
90
90
 
91
- return _main___P49445
91
+ return _main___P49482
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___P100684(s) {
59
+ function _main___P100795(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___100927 = (undefined);
70
- globals._pollEventQueue___100940 = (undefined);
69
+ globals._intervals___101038 = (undefined);
70
+ globals._pollEventQueue___101051 = (undefined);
71
71
  r0 = undefined;
72
72
  return leave(s, r0)
73
73
  default: oops()
74
74
  } } }
75
- _main___P100684.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"tsl2591.ts","functionName":"<main>","argumentNames":[]}
76
- _main___P100684.continuations = [ ]
75
+ _main___P100795.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"tsl2591.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P100795.continuations = [ ]
77
77
 
78
- function _main___P100684_mk(s) {
78
+ function _main___P100795_mk(s) {
79
79
  checkStack(s.depth);
80
80
  return {
81
- parent: s, fn: _main___P100684, depth: s.depth + 1,
81
+ parent: s, fn: _main___P100795, 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___P100684_mk(s) {
88
88
 
89
89
  const breakpoints = setupDebugger(1, [])
90
90
 
91
- return _main___P100684
91
+ return _main___P100795
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___P60764(s) {
59
+ function _main___P60801(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___61007 = (undefined);
70
- globals._pollEventQueue___61020 = (undefined);
69
+ globals._intervals___61044 = (undefined);
70
+ globals._pollEventQueue___61057 = (undefined);
71
71
  r0 = undefined;
72
72
  return leave(s, r0)
73
73
  default: oops()
74
74
  } } }
75
- _main___P60764.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"lora.ts","functionName":"<main>","argumentNames":[]}
76
- _main___P60764.continuations = [ ]
75
+ _main___P60801.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"lora.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P60801.continuations = [ ]
77
77
 
78
- function _main___P60764_mk(s) {
78
+ function _main___P60801_mk(s) {
79
79
  checkStack(s.depth);
80
80
  return {
81
- parent: s, fn: _main___P60764, depth: s.depth + 1,
81
+ parent: s, fn: _main___P60801, 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___P60764_mk(s) {
88
88
 
89
89
  const breakpoints = setupDebugger(1, [])
90
90
 
91
- return _main___P60764
91
+ return _main___P60801
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___P196962(s) {
59
+ function _main___P197221(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___197205 = (undefined);
70
- globals._pollEventQueue___197218 = (undefined);
69
+ globals._intervals___197464 = (undefined);
70
+ globals._pollEventQueue___197477 = (undefined);
71
71
  r0 = undefined;
72
72
  return leave(s, r0)
73
73
  default: oops()
74
74
  } } }
75
- _main___P196962.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"keypad.ts","functionName":"<main>","argumentNames":[]}
76
- _main___P196962.continuations = [ ]
75
+ _main___P197221.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"keypad.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P197221.continuations = [ ]
77
77
 
78
- function _main___P196962_mk(s) {
78
+ function _main___P197221_mk(s) {
79
79
  checkStack(s.depth);
80
80
  return {
81
- parent: s, fn: _main___P196962, depth: s.depth + 1,
81
+ parent: s, fn: _main___P197221, 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___P196962_mk(s) {
88
88
 
89
89
  const breakpoints = setupDebugger(1, [])
90
90
 
91
- return _main___P196962
91
+ return _main___P197221
92
92
  })
@@ -32,12 +32,16 @@ namespace music {
32
32
  function _init() {
33
33
  if (stateStack) return;
34
34
  stateStack = [new PlayableState()];
35
+ }
36
+
37
+ export function _initializeSceneStack(addScenePushHandler: (handler: () => void) => void, addScenePopHandler: (handler: () => void) => void) {
38
+ _init();
35
39
 
36
- game.addScenePushHandler(() => {
40
+ addScenePushHandler(() => {
37
41
  stateStack.push(new PlayableState());
38
42
  });
39
43
 
40
- game.addScenePopHandler(() => {
44
+ addScenePopHandler(() => {
41
45
  stateStack.pop();
42
46
  if (stateStack.length === 0) stateStack.push(new PlayableState());
43
47
  });
@@ -307,7 +307,7 @@ namespace music {
307
307
  if (res.waveShape === WaveShape.Noise) {
308
308
  // The primary waveforms don't produce sounds that are similar to noise,
309
309
  // but adding an effect sorta does
310
- if (Math.percentChance(20)) {
310
+ if (Math.random() < 0.2) {
311
311
  res.waveShape = randomWave();
312
312
  res.effect = randomEffect();
313
313
  }
@@ -317,7 +317,7 @@ namespace music {
317
317
 
318
318
  // Adding an effect can drastically alter the sound, so keep it
319
319
  // at a low percent chance unless there already is one
320
- if (res.effect !== SoundExpressionEffect.None || Math.percentChance(10)) {
320
+ if (res.effect !== SoundExpressionEffect.None || Math.random() < 0.1) {
321
321
  res.effect = randomEffect();
322
322
  }
323
323
  }