pxt-common-packages 10.2.4 → 10.2.6
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/common-sim.d.ts +9 -2
- package/built/common-sim.js +61 -18
- package/libs/azureiot/built/debug/binary.js +461 -461
- package/libs/color/built/debug/binary.js +8 -8
- package/libs/color-sensor/built/debug/binary.js +8 -8
- package/libs/controller/built/debug/binary.js +7386 -7294
- package/libs/controller---none/built/debug/binary.js +7365 -7273
- package/libs/datalogger/built/debug/binary.js +63 -63
- package/libs/edge-connector/built/debug/binary.js +8 -8
- package/libs/esp32/built/debug/binary.js +462 -462
- package/libs/game/_locales/game-jsdoc-strings.json +1 -0
- package/libs/game/built/debug/binary.js +7278 -7186
- package/libs/game/controller.ts +27 -3
- package/libs/game/info.ts +175 -91
- package/libs/game/multiplayer.cpp +1 -4
- package/libs/game/multiplayer.ts +13 -0
- package/libs/game/scene.ts +2 -0
- package/libs/game/sim/multiplayer.ts +52 -21
- package/libs/lcd/built/debug/binary.js +8 -8
- package/libs/light-spectrum-sensor/built/debug/binary.js +8 -8
- package/libs/lora/built/debug/binary.js +8 -8
- package/libs/matrix-keypad/built/debug/binary.js +8 -8
- package/libs/mqtt/built/debug/binary.js +176 -176
- package/libs/net/built/debug/binary.js +176 -176
- package/libs/net-game/built/debug/binary.js +9066 -8974
- package/libs/palette/built/debug/binary.js +7277 -7185
- package/libs/pixel/built/debug/binary.js +8 -8
- package/libs/power/built/debug/binary.js +8 -8
- package/libs/proximity/built/debug/binary.js +8 -8
- package/libs/radio/built/debug/binary.js +8 -8
- package/libs/radio-broadcast/built/debug/binary.js +8 -8
- package/libs/rotary-encoder/built/debug/binary.js +8 -8
- package/libs/screen/built/debug/binary.js +50 -50
- package/libs/screen/sim/state.ts +27 -5
- package/libs/servo/built/debug/binary.js +8 -8
- package/libs/sprite-scaling/built/debug/binary.js +7277 -7185
- package/libs/storyboard/built/debug/binary.js +7277 -7185
- package/package.json +2 -2
|
@@ -1,19 +1,29 @@
|
|
|
1
1
|
namespace pxsim.multiplayer {
|
|
2
|
-
|
|
2
|
+
const throttledImgPost = pxsim.U.throttle((msg: MultiplayerImageMessage) =>{
|
|
3
|
+
getMultiplayerState().send(msg);
|
|
4
|
+
}, 50, true);
|
|
5
|
+
|
|
6
|
+
export function postImage(im: pxsim.RefImage) {
|
|
7
|
+
if (getMultiplayerState().origin !== "server")
|
|
8
|
+
return;
|
|
3
9
|
const asBuf = pxsim.image.toBuffer(im);
|
|
4
|
-
|
|
10
|
+
const sb = board() as ScreenBoard;
|
|
11
|
+
const screenState = sb && sb.screenState;
|
|
12
|
+
throttledImgPost({
|
|
5
13
|
content: "Image",
|
|
6
14
|
image: asBuf,
|
|
7
|
-
|
|
8
|
-
});
|
|
15
|
+
palette: screenState && screenState.paletteToUint8Array(),
|
|
16
|
+
} as pxsim.MultiplayerImageMessage);
|
|
9
17
|
}
|
|
10
18
|
|
|
19
|
+
|
|
11
20
|
export function getCurrentImage(): pxsim.RefImage {
|
|
12
21
|
return getMultiplayerState().backgroundImage;
|
|
13
22
|
}
|
|
14
23
|
|
|
15
24
|
export function setOrigin(origin: "client" | "server" | undefined) {
|
|
16
25
|
getMultiplayerState().origin = origin;
|
|
26
|
+
|
|
17
27
|
}
|
|
18
28
|
|
|
19
29
|
export function getOrigin(): string {
|
|
@@ -41,8 +51,9 @@ namespace pxsim {
|
|
|
41
51
|
|
|
42
52
|
export interface MultiplayerImageMessage extends SimulatorMultiplayerMessage {
|
|
43
53
|
content: "Image";
|
|
44
|
-
goal: string; // goal of message; e.g. "broadcast-screen"
|
|
45
54
|
image: RefBuffer;
|
|
55
|
+
// 48bytes, [r0,g0,b0,r1,g1,b1,...]
|
|
56
|
+
palette: Uint8Array;
|
|
46
57
|
}
|
|
47
58
|
|
|
48
59
|
export interface MultiplayerButtonEvent extends SimulatorMultiplayerMessage {
|
|
@@ -51,51 +62,55 @@ namespace pxsim {
|
|
|
51
62
|
state: "Pressed" | "Released" | "Held";
|
|
52
63
|
}
|
|
53
64
|
|
|
54
|
-
|
|
65
|
+
export interface MultiplayerAudioEvent extends SimulatorMultiplayerMessage {
|
|
66
|
+
content: "Audio";
|
|
67
|
+
instruction: "playinstructions" | "muteallchannels";
|
|
68
|
+
soundbuf?: Uint8Array;
|
|
69
|
+
}
|
|
70
|
+
|
|
55
71
|
export class MultiplayerState {
|
|
56
72
|
lastMessageId: number;
|
|
57
73
|
origin: string;
|
|
58
74
|
backgroundImage: RefImage;
|
|
59
75
|
|
|
60
|
-
|
|
61
76
|
constructor() {
|
|
62
77
|
this.lastMessageId = 0;
|
|
63
78
|
}
|
|
64
79
|
|
|
65
80
|
send(msg: SimulatorMultiplayerMessage) {
|
|
66
|
-
Runtime.postMessage(
|
|
81
|
+
Runtime.postMessage({
|
|
67
82
|
...msg,
|
|
68
83
|
broadcast: true,
|
|
69
84
|
toParentIFrameOnly: true,
|
|
70
85
|
type: "multiplayer",
|
|
71
86
|
origin: this.origin,
|
|
72
87
|
id: this.lastMessageId++
|
|
73
|
-
});
|
|
88
|
+
} as SimulatorMultiplayerMessage);
|
|
74
89
|
}
|
|
75
90
|
|
|
76
91
|
init(origin: string) {
|
|
77
92
|
this.origin = origin;
|
|
78
93
|
runtime.board.addMessageListener(msg => this.messageHandler(msg));
|
|
79
|
-
if (
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const lastImage = screenState && screenState.lastImage;
|
|
87
|
-
lastImage && pxsim.multiplayer.postImage(lastImage, "broadcast-screen");
|
|
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)
|
|
88
101
|
}
|
|
89
|
-
}
|
|
102
|
+
} else {
|
|
103
|
+
pxsim.AudioContextManager.soundEventCallback = undefined;
|
|
104
|
+
}
|
|
90
105
|
}
|
|
91
106
|
|
|
92
107
|
setButton(key: number, isPressed: boolean) {
|
|
93
108
|
if (this.origin === "client") {
|
|
94
|
-
this.send(
|
|
109
|
+
this.send({
|
|
95
110
|
content: "Button",
|
|
96
111
|
button: key,
|
|
97
112
|
state: isPressed ? "Pressed" : "Released"
|
|
98
|
-
})
|
|
113
|
+
} as pxsim.MultiplayerButtonEvent)
|
|
99
114
|
}
|
|
100
115
|
}
|
|
101
116
|
|
|
@@ -111,6 +126,10 @@ namespace pxsim {
|
|
|
111
126
|
msg.image.data = new Uint8Array(msg.image.data);
|
|
112
127
|
}
|
|
113
128
|
this.backgroundImage = pxsim.image.ofBuffer(msg.image);
|
|
129
|
+
if (msg.palette && msg.palette.length === 48) {
|
|
130
|
+
const palBuffer = new pxsim.RefBuffer(msg.palette)
|
|
131
|
+
pxsim.pxtcore.setPalette(palBuffer);
|
|
132
|
+
}
|
|
114
133
|
}
|
|
115
134
|
} else if (isButtonMessage(msg)) {
|
|
116
135
|
if (this.origin === "server") {
|
|
@@ -119,6 +138,14 @@ namespace pxsim {
|
|
|
119
138
|
msg.state === "Pressed" || msg.state === "Held"
|
|
120
139
|
);
|
|
121
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
|
+
}
|
|
122
149
|
}
|
|
123
150
|
}
|
|
124
151
|
}
|
|
@@ -134,4 +161,8 @@ namespace pxsim {
|
|
|
134
161
|
function isButtonMessage(msg: SimulatorMultiplayerMessage): msg is MultiplayerButtonEvent {
|
|
135
162
|
return msg && msg.content === "Button";
|
|
136
163
|
}
|
|
164
|
+
|
|
165
|
+
function isAudioMessage(msg: SimulatorMultiplayerMessage): msg is MultiplayerAudioEvent {
|
|
166
|
+
return msg && msg.content === "Audio";
|
|
167
|
+
}
|
|
137
168
|
}
|
|
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
|
|
|
56
56
|
const pxsim_numops = pxsim.numops;
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
function
|
|
59
|
+
function _main___P48517(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.
|
|
70
|
-
globals.
|
|
69
|
+
globals._intervals___48760 = (undefined);
|
|
70
|
+
globals._pollEventQueue___48773 = (undefined);
|
|
71
71
|
r0 = undefined;
|
|
72
72
|
return leave(s, r0)
|
|
73
73
|
default: oops()
|
|
74
74
|
} } }
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
_main___P48517.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"characterlcd.ts","functionName":"<main>","argumentNames":[]}
|
|
76
|
+
_main___P48517.continuations = [ ]
|
|
77
77
|
|
|
78
|
-
function
|
|
78
|
+
function _main___P48517_mk(s) {
|
|
79
79
|
checkStack(s.depth);
|
|
80
80
|
return {
|
|
81
|
-
parent: s, fn:
|
|
81
|
+
parent: s, fn: _main___P48517, 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___P48480_mk(s) {
|
|
|
88
88
|
|
|
89
89
|
const breakpoints = setupDebugger(1, [])
|
|
90
90
|
|
|
91
|
-
return
|
|
91
|
+
return _main___P48517
|
|
92
92
|
})
|
|
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
|
|
|
56
56
|
const pxsim_numops = pxsim.numops;
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
function
|
|
59
|
+
function _main___P97883(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.
|
|
70
|
-
globals.
|
|
69
|
+
globals._intervals___98126 = (undefined);
|
|
70
|
+
globals._pollEventQueue___98139 = (undefined);
|
|
71
71
|
r0 = undefined;
|
|
72
72
|
return leave(s, r0)
|
|
73
73
|
default: oops()
|
|
74
74
|
} } }
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
_main___P97883.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"tsl2591.ts","functionName":"<main>","argumentNames":[]}
|
|
76
|
+
_main___P97883.continuations = [ ]
|
|
77
77
|
|
|
78
|
-
function
|
|
78
|
+
function _main___P97883_mk(s) {
|
|
79
79
|
checkStack(s.depth);
|
|
80
80
|
return {
|
|
81
|
-
parent: s, fn:
|
|
81
|
+
parent: s, fn: _main___P97883, 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___P97772_mk(s) {
|
|
|
88
88
|
|
|
89
89
|
const breakpoints = setupDebugger(1, [])
|
|
90
90
|
|
|
91
|
-
return
|
|
91
|
+
return _main___P97883
|
|
92
92
|
})
|
|
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
|
|
|
56
56
|
const pxsim_numops = pxsim.numops;
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
function
|
|
59
|
+
function _main___P59819(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.
|
|
70
|
-
globals.
|
|
69
|
+
globals._intervals___60062 = (undefined);
|
|
70
|
+
globals._pollEventQueue___60075 = (undefined);
|
|
71
71
|
r0 = undefined;
|
|
72
72
|
return leave(s, r0)
|
|
73
73
|
default: oops()
|
|
74
74
|
} } }
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
_main___P59819.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"lora.ts","functionName":"<main>","argumentNames":[]}
|
|
76
|
+
_main___P59819.continuations = [ ]
|
|
77
77
|
|
|
78
|
-
function
|
|
78
|
+
function _main___P59819_mk(s) {
|
|
79
79
|
checkStack(s.depth);
|
|
80
80
|
return {
|
|
81
|
-
parent: s, fn:
|
|
81
|
+
parent: s, fn: _main___P59819, 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___P59782_mk(s) {
|
|
|
88
88
|
|
|
89
89
|
const breakpoints = setupDebugger(1, [])
|
|
90
90
|
|
|
91
|
-
return
|
|
91
|
+
return _main___P59819
|
|
92
92
|
})
|
|
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
|
|
|
56
56
|
const pxsim_numops = pxsim.numops;
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
function
|
|
59
|
+
function _main___P190139(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.
|
|
70
|
-
globals.
|
|
69
|
+
globals._intervals___190382 = (undefined);
|
|
70
|
+
globals._pollEventQueue___190395 = (undefined);
|
|
71
71
|
r0 = undefined;
|
|
72
72
|
return leave(s, r0)
|
|
73
73
|
default: oops()
|
|
74
74
|
} } }
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
_main___P190139.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"keypad.ts","functionName":"<main>","argumentNames":[]}
|
|
76
|
+
_main___P190139.continuations = [ ]
|
|
77
77
|
|
|
78
|
-
function
|
|
78
|
+
function _main___P190139_mk(s) {
|
|
79
79
|
checkStack(s.depth);
|
|
80
80
|
return {
|
|
81
|
-
parent: s, fn:
|
|
81
|
+
parent: s, fn: _main___P190139, 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___P189880_mk(s) {
|
|
|
88
88
|
|
|
89
89
|
const breakpoints = setupDebugger(1, [])
|
|
90
90
|
|
|
91
|
-
return
|
|
91
|
+
return _main___P190139
|
|
92
92
|
})
|