pxt-arcade 1.12.6 → 1.12.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.
package/built/sim.js CHANGED
@@ -153,6 +153,7 @@ var pxsim;
153
153
  var pxsim;
154
154
  (function (pxsim) {
155
155
  let forcedUpdateLoop;
156
+ let isFirstRunSafari = true;
156
157
  window.addEventListener("DOMContentLoaded", () => {
157
158
  const searchParams = new URL(window.location.toString()).searchParams;
158
159
  setSimThemeColor("background-color", searchParams.get("background-color"));
@@ -304,7 +305,7 @@ var pxsim;
304
305
  }
305
306
  };
306
307
  window.addEventListener("message", (ev) => {
307
- if (ev.data.button !== undefined) {
308
+ if (ev.data.button !== undefined && ev.data.type !== "multiplayer") {
308
309
  let key;
309
310
  switch (ev.data.button) {
310
311
  case 0:
@@ -492,7 +493,11 @@ var pxsim;
492
493
  // ignore
493
494
  }
494
495
  resize() { }
495
- initAsync(msg) {
496
+ async initAsync(msg) {
497
+ var _a;
498
+ if (msg.options.mpRole) {
499
+ this.multiplayerState.origin = msg.options.mpRole;
500
+ }
496
501
  this.runOptions = msg;
497
502
  this.stats = document.getElementById("debug-stats");
498
503
  this.stats.className = "stats no-select";
@@ -510,7 +515,27 @@ var pxsim;
510
515
  }
511
516
  }
512
517
  this.updateStats();
513
- return Promise.resolve();
518
+ let safariEnablePromise;
519
+ if (isFirstRunSafari && !safariEnablePromise) {
520
+ const safariWarning = document.getElementById("safari-enable-game");
521
+ if (isSafari() && ((_a = msg.options) === null || _a === void 0 ? void 0 : _a.mpRole) === "server") {
522
+ safariEnablePromise = new Promise(resolve => {
523
+ safariWarning.style.display = "flex";
524
+ safariWarning.addEventListener("click", () => {
525
+ safariWarning.remove();
526
+ isFirstRunSafari = false;
527
+ resolve();
528
+ });
529
+ });
530
+ }
531
+ else {
532
+ safariWarning.remove();
533
+ isFirstRunSafari = false;
534
+ }
535
+ }
536
+ if (isFirstRunSafari) {
537
+ await safariEnablePromise;
538
+ }
514
539
  }
515
540
  updateStats() {
516
541
  this.stats.textContent = this.screenState.stats || "";
@@ -573,6 +598,12 @@ function isChrome() {
573
598
  (/Chrome/i.test(navigator.userAgent) ||
574
599
  /Chromium/i.test(navigator.userAgent)));
575
600
  }
601
+ //Chrome and Microsoft Edge lie about being Safari
602
+ function isSafari() {
603
+ //Could also check isMac but I don't want to risk excluding iOS
604
+ //Checking for iPhone, iPod or iPad as well as Safari in order to detect home screen browsers on iOS
605
+ return !isChrome() && !isEdge() && !!navigator && /(Macintosh|Safari|iPod|iPhone|iPad)/i.test(navigator.userAgent);
606
+ }
576
607
  (function (pxsim) {
577
608
  var pxtcore;
578
609
  (function (pxtcore) {