pxt-core 13.0.4 → 13.0.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.
@@ -1052,7 +1052,7 @@ ${opts.repo.name.replace(/^pxt-/, '')}=github:${opts.repo.fullName}#${opts.repo.
1052
1052
  \`\`\`
1053
1053
  `;
1054
1054
  //Uses the CmdLink definitions to replace links to YouTube and Vimeo (limited at the moment)
1055
- markdown = markdown.replace(/^\s*https?:\/\/(\S+)\s*$/mg, (f, lnk) => {
1055
+ markdown = markdown.replace(/^[ \t]*https?:\/\/(\S+)[ \t]*\r?$/mg, (f, lnk) => {
1056
1056
  for (let ent of links) {
1057
1057
  let m = ent.rx.exec(lnk);
1058
1058
  if (m) {
package/built/pxt.js CHANGED
@@ -106143,6 +106143,9 @@ var pxt;
106143
106143
  diff_1.compute = compute;
106144
106144
  function computeFormattedDiff(fileA, fileB, options = {}) {
106145
106145
  const diff = compute(fileA, fileB, options);
106146
+ if (!diff) {
106147
+ return null;
106148
+ }
106146
106149
  if (options.context == Infinity || options.full) {
106147
106150
  return diff.map(formatEdit);
106148
106151
  }
@@ -107363,7 +107366,7 @@ ${opts.repo.name.replace(/^pxt-/, '')}=github:${opts.repo.fullName}#${opts.repo.
107363
107366
  \`\`\`
107364
107367
  `;
107365
107368
  //Uses the CmdLink definitions to replace links to YouTube and Vimeo (limited at the moment)
107366
- markdown = markdown.replace(/^\s*https?:\/\/(\S+)\s*$/mg, (f, lnk) => {
107369
+ markdown = markdown.replace(/^[ \t]*https?:\/\/(\S+)[ \t]*\r?$/mg, (f, lnk) => {
107367
107370
  for (let ent of links) {
107368
107371
  let m = ent.rx.exec(lnk);
107369
107372
  if (m) {
@@ -150553,7 +150556,11 @@ var pxt;
150553
150556
  else {
150554
150557
  let [exp, sup] = emitExp(s.body);
150555
150558
  stmts = stmts.concat(sup);
150556
- stmts.concat(exp);
150559
+ stmts = stmts.concat(exp);
150560
+ const retType = tc.getTypeAtLocation(s.body);
150561
+ if (retType && !hasTypeFlag(retType, ts.TypeFlags.Void)) {
150562
+ stmts = expWrap("return ", stmts);
150563
+ }
150557
150564
  }
150558
150565
  if (stmts.length) {
150559
150566
  // global or nonlocal declerations
@@ -157934,8 +157941,6 @@ var pxsim;
157934
157941
  this._runOptions = {};
157935
157942
  this.state = SimulatorState.Unloaded;
157936
157943
  this._allowedOrigins = [];
157937
- // BEGIN TEMPORARY: jacdac simulator
157938
- this.newJacdacSimulator = false;
157939
157944
  this.frameCleanupTimeout = undefined;
157940
157945
  this.debuggerSeq = 1;
157941
157946
  this.debuggerResolvers = {};
@@ -158145,7 +158150,6 @@ var pxsim;
158145
158150
  setSingleSimulator() {
158146
158151
  this.singleSimulator = true;
158147
158152
  }
158148
- // END TEMPORARY: jacdac simulator
158149
158153
  postMessage(msg, source, frameID) {
158150
158154
  var _a;
158151
158155
  if (this.hwdbg) {
@@ -158159,8 +158163,14 @@ var pxsim;
158159
158163
  let isDeferrableBroadcastMessage = false;
158160
158164
  const broadcastmsg = msg;
158161
158165
  if (source && (broadcastmsg === null || broadcastmsg === void 0 ? void 0 : broadcastmsg.broadcast)) {
158166
+ const mkcdFrames = frames.filter(frame => !frame.dataset[FRAME_DATA_MESSAGE_CHANNEL]);
158167
+ const messageChannel = msg.type === "messagepacket" && msg.channel;
158162
158168
  // include index of the source iframe
158163
158169
  broadcastmsg.srcFrameIndex = this.simFrames().findIndex((item) => item.contentWindow === source);
158170
+ const sourceFrame = broadcastmsg.srcFrameIndex >= 0 ? this.simFrames()[broadcastmsg.srcFrameIndex] : undefined;
158171
+ // jacdac messages from a board sim other than first should be dropped
158172
+ if (broadcastmsg.srcFrameIndex > 0 && mkcdFrames.find(f => f === sourceFrame) && messageChannel === "jacdac")
158173
+ return;
158164
158174
  // if the editor is hosted in a multi-editor setting
158165
158175
  // don't start extra frames
158166
158176
  const single = !!((_a = this._currentRuntime) === null || _a === void 0 ? void 0 : _a.single);
@@ -158184,7 +158194,6 @@ var pxsim;
158184
158194
  // start second simulator
158185
158195
  }
158186
158196
  else if (!single) {
158187
- const messageChannel = msg.type === "messagepacket" && msg.channel;
158188
158197
  const messageSimulator = messageChannel &&
158189
158198
  this.options.messageSimulators &&
158190
158199
  this.options.messageSimulators[messageChannel];
@@ -158210,10 +158219,6 @@ var pxsim;
158210
158219
  if (simulatorExtension) {
158211
158220
  // find a frame already running that simulator
158212
158221
  let messageFrame = frames.find(frame => frame.dataset[FRAME_DATA_MESSAGE_CHANNEL] === messageChannel);
158213
- // BEGIN TEMPORARY: jacdac simulator
158214
- if (messageChannel === "jacdac/pxt-jacdac")
158215
- this.newJacdacSimulator = true;
158216
- // END TEMPORARY: jacdac simulator
158217
158222
  // not found, spin a new one
158218
158223
  if (!messageFrame) {
158219
158224
  const url = new URL(simulatorExtension.url);
@@ -158234,13 +158239,11 @@ var pxsim;
158234
158239
  let messageFrame = frames.find(frame => frame.dataset[FRAME_DATA_MESSAGE_CHANNEL] === messageChannel);
158235
158240
  // not found, spin a new one
158236
158241
  if (!messageFrame) {
158237
- if (messageChannel !== "jacdac" || !this.newJacdacSimulator) { // TEMPORARY: jacdac simulator
158238
- const useLocalHost = pxsim.U.isLocalHost() && /localhostmessagesims=1/i.test(window.location.href);
158239
- const url = ((useLocalHost && messageSimulator.localHostUrl) || messageSimulator.url)
158240
- .replace("$PARENT_ORIGIN$", encodeURIComponent(this.options.parentOrigin || ""))
158241
- .replace("$LANGUAGE$", encodeURIComponent(this.options.userLanguage));
158242
- startSimulatorExtension(url, messageSimulator.permanent, messageSimulator.aspectRatio);
158243
- }
158242
+ const useLocalHost = pxsim.U.isLocalHost() && /localhostmessagesims=1/i.test(window.location.href);
158243
+ const url = ((useLocalHost && messageSimulator.localHostUrl) || messageSimulator.url)
158244
+ .replace("$PARENT_ORIGIN$", encodeURIComponent(this.options.parentOrigin || ""))
158245
+ .replace("$LANGUAGE$", encodeURIComponent(this.options.userLanguage));
158246
+ startSimulatorExtension(url, messageSimulator.permanent, messageSimulator.aspectRatio);
158244
158247
  }
158245
158248
  // not running the curren run, restart
158246
158249
  else if (messageFrame.dataset['runid'] != this.runId) {
@@ -158250,7 +158253,6 @@ var pxsim;
158250
158253
  else {
158251
158254
  isDeferrableBroadcastMessage = true;
158252
158255
  // start secondary frame if needed
158253
- const mkcdFrames = frames.filter(frame => !frame.dataset[FRAME_DATA_MESSAGE_CHANNEL]);
158254
158256
  if (!messageChannel &&
158255
158257
  (mkcdFrames.length == 0 || mkcdFrames.length == 1 && !this.singleSimulator)) {
158256
158258
  // messageChannel is set to false whenever msg.type !== "messagepacket"
@@ -158275,6 +158277,10 @@ var pxsim;
158275
158277
  // same frame as source
158276
158278
  if (source && frame.contentWindow == source)
158277
158279
  continue;
158280
+ // if jacdac message, don't send to other (board) simulator frames
158281
+ if (i > 0 && !frame.dataset[FRAME_DATA_MESSAGE_CHANNEL] &&
158282
+ msg.type === "messagepacket" && msg.channel === "jacdac")
158283
+ continue;
158278
158284
  // frame not in DOM
158279
158285
  if (!frame.contentWindow)
158280
158286
  continue;
package/built/pxtlib.js CHANGED
@@ -8422,6 +8422,9 @@ var pxt;
8422
8422
  diff_1.compute = compute;
8423
8423
  function computeFormattedDiff(fileA, fileB, options = {}) {
8424
8424
  const diff = compute(fileA, fileB, options);
8425
+ if (!diff) {
8426
+ return null;
8427
+ }
8425
8428
  if (options.context == Infinity || options.full) {
8426
8429
  return diff.map(formatEdit);
8427
8430
  }
@@ -9642,7 +9645,7 @@ ${opts.repo.name.replace(/^pxt-/, '')}=github:${opts.repo.fullName}#${opts.repo.
9642
9645
  \`\`\`
9643
9646
  `;
9644
9647
  //Uses the CmdLink definitions to replace links to YouTube and Vimeo (limited at the moment)
9645
- markdown = markdown.replace(/^\s*https?:\/\/(\S+)\s*$/mg, (f, lnk) => {
9648
+ markdown = markdown.replace(/^[ \t]*https?:\/\/(\S+)[ \t]*\r?$/mg, (f, lnk) => {
9646
9649
  for (let ent of links) {
9647
9650
  let m = ent.rx.exec(lnk);
9648
9651
  if (m) {
package/built/pxtpy.js CHANGED
@@ -5747,7 +5747,11 @@ var pxt;
5747
5747
  else {
5748
5748
  let [exp, sup] = emitExp(s.body);
5749
5749
  stmts = stmts.concat(sup);
5750
- stmts.concat(exp);
5750
+ stmts = stmts.concat(exp);
5751
+ const retType = tc.getTypeAtLocation(s.body);
5752
+ if (retType && !hasTypeFlag(retType, ts.TypeFlags.Void)) {
5753
+ stmts = expWrap("return ", stmts);
5754
+ }
5751
5755
  }
5752
5756
  if (stmts.length) {
5753
5757
  // global or nonlocal declerations
package/built/pxtsim.d.ts CHANGED
@@ -1474,7 +1474,6 @@ declare namespace pxsim {
1474
1474
  private simFrames;
1475
1475
  private getSimUrl;
1476
1476
  setSingleSimulator(): void;
1477
- newJacdacSimulator: boolean;
1478
1477
  postMessage(msg: pxsim.SimulatorMessage, source?: Window, frameID?: string): void;
1479
1478
  protected deferredMessages: [HTMLIFrameElement, SimulatorMessage][];
1480
1479
  protected postDeferrableMessage(frame: HTMLIFrameElement, msg: SimulatorMessage): void;
package/built/pxtsim.js CHANGED
@@ -6440,8 +6440,6 @@ var pxsim;
6440
6440
  this._runOptions = {};
6441
6441
  this.state = SimulatorState.Unloaded;
6442
6442
  this._allowedOrigins = [];
6443
- // BEGIN TEMPORARY: jacdac simulator
6444
- this.newJacdacSimulator = false;
6445
6443
  this.frameCleanupTimeout = undefined;
6446
6444
  this.debuggerSeq = 1;
6447
6445
  this.debuggerResolvers = {};
@@ -6651,7 +6649,6 @@ var pxsim;
6651
6649
  setSingleSimulator() {
6652
6650
  this.singleSimulator = true;
6653
6651
  }
6654
- // END TEMPORARY: jacdac simulator
6655
6652
  postMessage(msg, source, frameID) {
6656
6653
  var _a;
6657
6654
  if (this.hwdbg) {
@@ -6665,8 +6662,14 @@ var pxsim;
6665
6662
  let isDeferrableBroadcastMessage = false;
6666
6663
  const broadcastmsg = msg;
6667
6664
  if (source && (broadcastmsg === null || broadcastmsg === void 0 ? void 0 : broadcastmsg.broadcast)) {
6665
+ const mkcdFrames = frames.filter(frame => !frame.dataset[FRAME_DATA_MESSAGE_CHANNEL]);
6666
+ const messageChannel = msg.type === "messagepacket" && msg.channel;
6668
6667
  // include index of the source iframe
6669
6668
  broadcastmsg.srcFrameIndex = this.simFrames().findIndex((item) => item.contentWindow === source);
6669
+ const sourceFrame = broadcastmsg.srcFrameIndex >= 0 ? this.simFrames()[broadcastmsg.srcFrameIndex] : undefined;
6670
+ // jacdac messages from a board sim other than first should be dropped
6671
+ if (broadcastmsg.srcFrameIndex > 0 && mkcdFrames.find(f => f === sourceFrame) && messageChannel === "jacdac")
6672
+ return;
6670
6673
  // if the editor is hosted in a multi-editor setting
6671
6674
  // don't start extra frames
6672
6675
  const single = !!((_a = this._currentRuntime) === null || _a === void 0 ? void 0 : _a.single);
@@ -6690,7 +6693,6 @@ var pxsim;
6690
6693
  // start second simulator
6691
6694
  }
6692
6695
  else if (!single) {
6693
- const messageChannel = msg.type === "messagepacket" && msg.channel;
6694
6696
  const messageSimulator = messageChannel &&
6695
6697
  this.options.messageSimulators &&
6696
6698
  this.options.messageSimulators[messageChannel];
@@ -6716,10 +6718,6 @@ var pxsim;
6716
6718
  if (simulatorExtension) {
6717
6719
  // find a frame already running that simulator
6718
6720
  let messageFrame = frames.find(frame => frame.dataset[FRAME_DATA_MESSAGE_CHANNEL] === messageChannel);
6719
- // BEGIN TEMPORARY: jacdac simulator
6720
- if (messageChannel === "jacdac/pxt-jacdac")
6721
- this.newJacdacSimulator = true;
6722
- // END TEMPORARY: jacdac simulator
6723
6721
  // not found, spin a new one
6724
6722
  if (!messageFrame) {
6725
6723
  const url = new URL(simulatorExtension.url);
@@ -6740,13 +6738,11 @@ var pxsim;
6740
6738
  let messageFrame = frames.find(frame => frame.dataset[FRAME_DATA_MESSAGE_CHANNEL] === messageChannel);
6741
6739
  // not found, spin a new one
6742
6740
  if (!messageFrame) {
6743
- if (messageChannel !== "jacdac" || !this.newJacdacSimulator) { // TEMPORARY: jacdac simulator
6744
- const useLocalHost = pxsim.U.isLocalHost() && /localhostmessagesims=1/i.test(window.location.href);
6745
- const url = ((useLocalHost && messageSimulator.localHostUrl) || messageSimulator.url)
6746
- .replace("$PARENT_ORIGIN$", encodeURIComponent(this.options.parentOrigin || ""))
6747
- .replace("$LANGUAGE$", encodeURIComponent(this.options.userLanguage));
6748
- startSimulatorExtension(url, messageSimulator.permanent, messageSimulator.aspectRatio);
6749
- }
6741
+ const useLocalHost = pxsim.U.isLocalHost() && /localhostmessagesims=1/i.test(window.location.href);
6742
+ const url = ((useLocalHost && messageSimulator.localHostUrl) || messageSimulator.url)
6743
+ .replace("$PARENT_ORIGIN$", encodeURIComponent(this.options.parentOrigin || ""))
6744
+ .replace("$LANGUAGE$", encodeURIComponent(this.options.userLanguage));
6745
+ startSimulatorExtension(url, messageSimulator.permanent, messageSimulator.aspectRatio);
6750
6746
  }
6751
6747
  // not running the curren run, restart
6752
6748
  else if (messageFrame.dataset['runid'] != this.runId) {
@@ -6756,7 +6752,6 @@ var pxsim;
6756
6752
  else {
6757
6753
  isDeferrableBroadcastMessage = true;
6758
6754
  // start secondary frame if needed
6759
- const mkcdFrames = frames.filter(frame => !frame.dataset[FRAME_DATA_MESSAGE_CHANNEL]);
6760
6755
  if (!messageChannel &&
6761
6756
  (mkcdFrames.length == 0 || mkcdFrames.length == 1 && !this.singleSimulator)) {
6762
6757
  // messageChannel is set to false whenever msg.type !== "messagepacket"
@@ -6781,6 +6776,10 @@ var pxsim;
6781
6776
  // same frame as source
6782
6777
  if (source && frame.contentWindow == source)
6783
6778
  continue;
6779
+ // if jacdac message, don't send to other (board) simulator frames
6780
+ if (i > 0 && !frame.dataset[FRAME_DATA_MESSAGE_CHANNEL] &&
6781
+ msg.type === "messagepacket" && msg.channel === "jacdac")
6782
+ continue;
6784
6783
  // frame not in DOM
6785
6784
  if (!frame.contentWindow)
6786
6785
  continue;