pxt-core 11.2.6 → 11.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.
package/built/pxt.js CHANGED
@@ -153947,6 +153947,14 @@ var pxsim;
153947
153947
  return v;
153948
153948
  }
153949
153949
  U.unique = unique;
153950
+ function sanitizeCssName(name) {
153951
+ let sanitized = name.replace(/[^a-zA-Z0-9-_]/g, '_');
153952
+ if (!/^[a-zA-Z_]/.test(sanitized)) {
153953
+ sanitized = 'cls_' + sanitized;
153954
+ }
153955
+ return sanitized;
153956
+ }
153957
+ U.sanitizeCssName = sanitizeCssName;
153950
153958
  })(U = pxsim.U || (pxsim.U = {}));
153951
153959
  class BreakLoopException {
153952
153960
  }
@@ -155567,13 +155575,16 @@ var pxsim;
155567
155575
  const simulatorExtension = messageChannel &&
155568
155576
  this.options.simulatorExtensions &&
155569
155577
  this.options.simulatorExtensions[messageChannel];
155570
- const startSimulatorExtension = (url, permanent) => {
155578
+ const startSimulatorExtension = (url, permanent, aspectRatio) => {
155579
+ var _a;
155580
+ aspectRatio = aspectRatio || ((_a = this._runOptions) === null || _a === void 0 ? void 0 : _a.aspectRatio) || 1.22;
155571
155581
  let wrapper = this.createFrame(url);
155572
155582
  this.container.appendChild(wrapper);
155573
155583
  const messageFrame = wrapper.firstElementChild;
155574
155584
  messageFrame.dataset[FRAME_DATA_MESSAGE_CHANNEL] = messageChannel;
155585
+ messageFrame.dataset[FRAME_ASPECT_RATIO] = aspectRatio + "";
155575
155586
  pxsim.U.addClass(wrapper, "simmsg");
155576
- pxsim.U.addClass(wrapper, "simmsg" + messageChannel);
155587
+ pxsim.U.addClass(wrapper, "simmsg" + pxsim.U.sanitizeCssName(messageChannel));
155577
155588
  if (permanent)
155578
155589
  messageFrame.dataset[PERMANENT] = "true";
155579
155590
  this.startFrame(messageFrame);
@@ -155590,7 +155601,7 @@ var pxsim;
155590
155601
  url.searchParams.set("parentOrigin", encodeURIComponent(this.options.parentOrigin));
155591
155602
  if (this.options.userLanguage)
155592
155603
  url.searchParams.set("language", encodeURIComponent(this.options.userLanguage));
155593
- startSimulatorExtension(url.toString(), simulatorExtension.permanent);
155604
+ startSimulatorExtension(url.toString(), simulatorExtension.permanent, simulatorExtension.aspectRatio);
155594
155605
  }
155595
155606
  // not running the current run, restart
155596
155607
  else if (messageFrame.dataset['runid'] != this.runId) {
@@ -155607,7 +155618,7 @@ var pxsim;
155607
155618
  const url = ((useLocalHost && messageSimulator.localHostUrl) || messageSimulator.url)
155608
155619
  .replace("$PARENT_ORIGIN$", encodeURIComponent(this.options.parentOrigin || ""))
155609
155620
  .replace("$LANGUAGE$", encodeURIComponent(this.options.userLanguage));
155610
- startSimulatorExtension(url, messageSimulator.permanent);
155621
+ startSimulatorExtension(url, messageSimulator.permanent, messageSimulator.aspectRatio);
155611
155622
  }
155612
155623
  // not running the curren run, restart
155613
155624
  else if (messageFrame.dataset['runid'] != this.runId) {
package/built/pxtsim.d.ts CHANGED
@@ -1063,6 +1063,7 @@ declare namespace pxsim {
1063
1063
  function isLocalHost(): boolean;
1064
1064
  function isLocalHostDev(): boolean;
1065
1065
  function unique<T>(arr: T[], f: (t: T) => string): T[];
1066
+ function sanitizeCssName(name: string): string;
1066
1067
  }
1067
1068
  export interface Map<T> {
1068
1069
  [index: string]: T;
package/built/pxtsim.js CHANGED
@@ -4742,6 +4742,14 @@ var pxsim;
4742
4742
  return v;
4743
4743
  }
4744
4744
  U.unique = unique;
4745
+ function sanitizeCssName(name) {
4746
+ let sanitized = name.replace(/[^a-zA-Z0-9-_]/g, '_');
4747
+ if (!/^[a-zA-Z_]/.test(sanitized)) {
4748
+ sanitized = 'cls_' + sanitized;
4749
+ }
4750
+ return sanitized;
4751
+ }
4752
+ U.sanitizeCssName = sanitizeCssName;
4745
4753
  })(U = pxsim.U || (pxsim.U = {}));
4746
4754
  class BreakLoopException {
4747
4755
  }
@@ -6362,13 +6370,16 @@ var pxsim;
6362
6370
  const simulatorExtension = messageChannel &&
6363
6371
  this.options.simulatorExtensions &&
6364
6372
  this.options.simulatorExtensions[messageChannel];
6365
- const startSimulatorExtension = (url, permanent) => {
6373
+ const startSimulatorExtension = (url, permanent, aspectRatio) => {
6374
+ var _a;
6375
+ aspectRatio = aspectRatio || ((_a = this._runOptions) === null || _a === void 0 ? void 0 : _a.aspectRatio) || 1.22;
6366
6376
  let wrapper = this.createFrame(url);
6367
6377
  this.container.appendChild(wrapper);
6368
6378
  const messageFrame = wrapper.firstElementChild;
6369
6379
  messageFrame.dataset[FRAME_DATA_MESSAGE_CHANNEL] = messageChannel;
6380
+ messageFrame.dataset[FRAME_ASPECT_RATIO] = aspectRatio + "";
6370
6381
  pxsim.U.addClass(wrapper, "simmsg");
6371
- pxsim.U.addClass(wrapper, "simmsg" + messageChannel);
6382
+ pxsim.U.addClass(wrapper, "simmsg" + pxsim.U.sanitizeCssName(messageChannel));
6372
6383
  if (permanent)
6373
6384
  messageFrame.dataset[PERMANENT] = "true";
6374
6385
  this.startFrame(messageFrame);
@@ -6385,7 +6396,7 @@ var pxsim;
6385
6396
  url.searchParams.set("parentOrigin", encodeURIComponent(this.options.parentOrigin));
6386
6397
  if (this.options.userLanguage)
6387
6398
  url.searchParams.set("language", encodeURIComponent(this.options.userLanguage));
6388
- startSimulatorExtension(url.toString(), simulatorExtension.permanent);
6399
+ startSimulatorExtension(url.toString(), simulatorExtension.permanent, simulatorExtension.aspectRatio);
6389
6400
  }
6390
6401
  // not running the current run, restart
6391
6402
  else if (messageFrame.dataset['runid'] != this.runId) {
@@ -6402,7 +6413,7 @@ var pxsim;
6402
6413
  const url = ((useLocalHost && messageSimulator.localHostUrl) || messageSimulator.url)
6403
6414
  .replace("$PARENT_ORIGIN$", encodeURIComponent(this.options.parentOrigin || ""))
6404
6415
  .replace("$LANGUAGE$", encodeURIComponent(this.options.userLanguage));
6405
- startSimulatorExtension(url, messageSimulator.permanent);
6416
+ startSimulatorExtension(url, messageSimulator.permanent, messageSimulator.aspectRatio);
6406
6417
  }
6407
6418
  // not running the curren run, restart
6408
6419
  else if (messageFrame.dataset['runid'] != this.runId) {