pxt-core 8.4.18 → 8.4.20

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/cli.js CHANGED
@@ -1856,11 +1856,11 @@ function buildReactAppAsync(app, parsed, opts) {
1856
1856
  else {
1857
1857
  nodeutil.cp("built/target.js", `${appRoot}/public/blb`);
1858
1858
  }
1859
- if (opts.usePxtEmbed) {
1860
- nodeutil.cp("node_modules/pxt-core/built/web/pxtembed.js", `${appRoot}/public/blb`);
1861
- }
1862
- else {
1863
- nodeutil.cp("node_modules/pxt-core/built/pxtlib.js", `${appRoot}/public/blb`);
1859
+ nodeutil.cp("node_modules/pxt-core/built/pxtlib.js", `${appRoot}/public/blb`);
1860
+ if (opts.includePxtSim) {
1861
+ nodeutil.cp("node_modules/pxt-core/built/pxtsim.js", `${appRoot}/public/blb`);
1862
+ nodeutil.cp("node_modules/pxt-core/built/web/worker.js", `${appRoot}/public/blb`);
1863
+ nodeutil.cp("node_modules/pxt-core/built/web/pxtworker.js", `${appRoot}/public/blb`);
1864
1864
  }
1865
1865
  nodeutil.cp("built/web/semantic.css", `${appRoot}/public/blb`);
1866
1866
  nodeutil.cp("node_modules/pxt-core/built/web/icons.css", `${appRoot}/public/blb`);
@@ -1891,7 +1891,7 @@ function buildAuthcodeAsync(parsed) {
1891
1891
  function buildMultiplayerAsync(parsed) {
1892
1892
  return buildReactAppAsync("multiplayer", parsed, {
1893
1893
  copyAssets: false,
1894
- usePxtEmbed: true,
1894
+ includePxtSim: true,
1895
1895
  expandedPxtTarget: true
1896
1896
  });
1897
1897
  }
package/built/pxt.js CHANGED
@@ -154690,25 +154690,13 @@ var pxsim;
154690
154690
  const origin = pxsim.U.isLocalHostDev() ? "*" : frame.dataset["origin"];
154691
154691
  frame.contentWindow.postMessage(msg, origin);
154692
154692
  }
154693
- createFrame(url) {
154694
- var _a, _b, _c;
154695
- const wrapper = document.createElement("div");
154696
- wrapper.className = `simframe ui embed`;
154697
- const frame = document.createElement('iframe');
154698
- frame.id = 'sim-frame-' + this.nextId();
154699
- frame.title = pxsim.localization.lf("Simulator");
154700
- frame.allowFullscreen = true;
154701
- frame.setAttribute('allow', 'autoplay;microphone');
154702
- frame.setAttribute('sandbox', 'allow-same-origin allow-scripts');
154703
- frame.className = 'no-select';
154704
- let furl = url || this.getSimUrl().toString();
154693
+ setRunOptionQueryParams(url) {
154694
+ var _a, _b;
154695
+ const urlObject = new URL(url);
154705
154696
  if ((_a = this._runOptions) === null || _a === void 0 ? void 0 : _a.hideSimButtons) {
154706
- const urlObject = new URL(furl);
154707
- urlObject.searchParams.append("hideSimButtons", "1");
154708
- furl = urlObject.toString();
154697
+ urlObject.searchParams.set("hideSimButtons", "1");
154709
154698
  }
154710
154699
  if ((_b = this._runOptions) === null || _b === void 0 ? void 0 : _b.queryParameters) {
154711
- const urlObject = new URL(furl);
154712
154700
  const parameters = this._runOptions.queryParameters.split("&");
154713
154701
  for (const param of parameters) {
154714
154702
  const [a, b] = param.split(/[:=]/);
@@ -154716,14 +154704,27 @@ var pxsim;
154716
154704
  urlObject.searchParams.set(a, b);
154717
154705
  }
154718
154706
  }
154719
- furl = urlObject.toString();
154720
154707
  }
154708
+ return urlObject.toString();
154709
+ }
154710
+ createFrame(url) {
154711
+ var _a;
154712
+ const wrapper = document.createElement("div");
154713
+ wrapper.className = `simframe ui embed`;
154714
+ const frame = document.createElement('iframe');
154715
+ frame.id = 'sim-frame-' + this.nextId();
154716
+ frame.title = pxsim.localization.lf("Simulator");
154717
+ frame.allowFullscreen = true;
154718
+ frame.setAttribute('allow', 'autoplay;microphone');
154719
+ frame.setAttribute('sandbox', 'allow-same-origin allow-scripts');
154720
+ frame.className = 'no-select';
154721
+ let furl = this.setRunOptionQueryParams(url || this.getSimUrl().toString());
154721
154722
  furl += '#' + frame.id;
154722
154723
  frame.src = furl;
154723
154724
  frame.frameBorder = "0";
154724
154725
  frame.dataset['runid'] = this.runId;
154725
154726
  frame.dataset['origin'] = new URL(furl).origin || "*";
154726
- if ((_c = this._runOptions) === null || _c === void 0 ? void 0 : _c.autofocus)
154727
+ if ((_a = this._runOptions) === null || _a === void 0 ? void 0 : _a.autofocus)
154727
154728
  frame.setAttribute("autofocus", "true");
154728
154729
  wrapper.appendChild(frame);
154729
154730
  const i = document.createElement("i");
@@ -154752,9 +154753,11 @@ var pxsim;
154752
154753
  return wrapper;
154753
154754
  }
154754
154755
  preload(aspectRatio, clearRuntime) {
154756
+ if (clearRuntime) {
154757
+ this._currentRuntime = undefined;
154758
+ this.container.textContent = "";
154759
+ }
154755
154760
  if (!this.simFrames().length) {
154756
- if (clearRuntime)
154757
- this._currentRuntime = undefined;
154758
154761
  this.container.appendChild(this.createFrame());
154759
154762
  this.applyAspectRatio(aspectRatio);
154760
154763
  this.setStarting();
@@ -160855,11 +160858,11 @@ function buildReactAppAsync(app, parsed, opts) {
160855
160858
  else {
160856
160859
  nodeutil.cp("built/target.js", `${appRoot}/public/blb`);
160857
160860
  }
160858
- if (opts.usePxtEmbed) {
160859
- nodeutil.cp("node_modules/pxt-core/built/web/pxtembed.js", `${appRoot}/public/blb`);
160860
- }
160861
- else {
160862
- nodeutil.cp("node_modules/pxt-core/built/pxtlib.js", `${appRoot}/public/blb`);
160861
+ nodeutil.cp("node_modules/pxt-core/built/pxtlib.js", `${appRoot}/public/blb`);
160862
+ if (opts.includePxtSim) {
160863
+ nodeutil.cp("node_modules/pxt-core/built/pxtsim.js", `${appRoot}/public/blb`);
160864
+ nodeutil.cp("node_modules/pxt-core/built/web/worker.js", `${appRoot}/public/blb`);
160865
+ nodeutil.cp("node_modules/pxt-core/built/web/pxtworker.js", `${appRoot}/public/blb`);
160863
160866
  }
160864
160867
  nodeutil.cp("built/web/semantic.css", `${appRoot}/public/blb`);
160865
160868
  nodeutil.cp("node_modules/pxt-core/built/web/icons.css", `${appRoot}/public/blb`);
@@ -160890,7 +160893,7 @@ function buildAuthcodeAsync(parsed) {
160890
160893
  function buildMultiplayerAsync(parsed) {
160891
160894
  return buildReactAppAsync("multiplayer", parsed, {
160892
160895
  copyAssets: false,
160893
- usePxtEmbed: true,
160896
+ includePxtSim: true,
160894
160897
  expandedPxtTarget: true
160895
160898
  });
160896
160899
  }
@@ -1537,6 +1537,8 @@ var pxt;
1537
1537
  function addPackageToConfig(cfg, dep) {
1538
1538
  let m = /^([a-zA-Z0-9_-]+)(=(.+))?$/.exec(dep);
1539
1539
  if (m) {
1540
+ // TODO this line seems bad, patchdependencies is on host not this?
1541
+ // looks like this should be a method in host
1540
1542
  if (m[3] && this && this.patchDependencies(cfg, m[1], m[3]))
1541
1543
  return false;
1542
1544
  cfg.dependencies[m[1]] = m[3] || "*";
package/built/pxtsim.d.ts CHANGED
@@ -1326,6 +1326,7 @@ declare namespace pxsim {
1326
1326
  private getSimUrl;
1327
1327
  postMessage(msg: pxsim.SimulatorMessage, source?: Window, frameID?: string): void;
1328
1328
  private postMessageCore;
1329
+ private setRunOptionQueryParams;
1329
1330
  private createFrame;
1330
1331
  preload(aspectRatio: number, clearRuntime?: boolean): void;
1331
1332
  stop(unload?: boolean, starting?: boolean): void;
package/built/pxtsim.js CHANGED
@@ -6326,25 +6326,13 @@ var pxsim;
6326
6326
  const origin = pxsim.U.isLocalHostDev() ? "*" : frame.dataset["origin"];
6327
6327
  frame.contentWindow.postMessage(msg, origin);
6328
6328
  }
6329
- createFrame(url) {
6330
- var _a, _b, _c;
6331
- const wrapper = document.createElement("div");
6332
- wrapper.className = `simframe ui embed`;
6333
- const frame = document.createElement('iframe');
6334
- frame.id = 'sim-frame-' + this.nextId();
6335
- frame.title = pxsim.localization.lf("Simulator");
6336
- frame.allowFullscreen = true;
6337
- frame.setAttribute('allow', 'autoplay;microphone');
6338
- frame.setAttribute('sandbox', 'allow-same-origin allow-scripts');
6339
- frame.className = 'no-select';
6340
- let furl = url || this.getSimUrl().toString();
6329
+ setRunOptionQueryParams(url) {
6330
+ var _a, _b;
6331
+ const urlObject = new URL(url);
6341
6332
  if ((_a = this._runOptions) === null || _a === void 0 ? void 0 : _a.hideSimButtons) {
6342
- const urlObject = new URL(furl);
6343
- urlObject.searchParams.append("hideSimButtons", "1");
6344
- furl = urlObject.toString();
6333
+ urlObject.searchParams.set("hideSimButtons", "1");
6345
6334
  }
6346
6335
  if ((_b = this._runOptions) === null || _b === void 0 ? void 0 : _b.queryParameters) {
6347
- const urlObject = new URL(furl);
6348
6336
  const parameters = this._runOptions.queryParameters.split("&");
6349
6337
  for (const param of parameters) {
6350
6338
  const [a, b] = param.split(/[:=]/);
@@ -6352,14 +6340,27 @@ var pxsim;
6352
6340
  urlObject.searchParams.set(a, b);
6353
6341
  }
6354
6342
  }
6355
- furl = urlObject.toString();
6356
6343
  }
6344
+ return urlObject.toString();
6345
+ }
6346
+ createFrame(url) {
6347
+ var _a;
6348
+ const wrapper = document.createElement("div");
6349
+ wrapper.className = `simframe ui embed`;
6350
+ const frame = document.createElement('iframe');
6351
+ frame.id = 'sim-frame-' + this.nextId();
6352
+ frame.title = pxsim.localization.lf("Simulator");
6353
+ frame.allowFullscreen = true;
6354
+ frame.setAttribute('allow', 'autoplay;microphone');
6355
+ frame.setAttribute('sandbox', 'allow-same-origin allow-scripts');
6356
+ frame.className = 'no-select';
6357
+ let furl = this.setRunOptionQueryParams(url || this.getSimUrl().toString());
6357
6358
  furl += '#' + frame.id;
6358
6359
  frame.src = furl;
6359
6360
  frame.frameBorder = "0";
6360
6361
  frame.dataset['runid'] = this.runId;
6361
6362
  frame.dataset['origin'] = new URL(furl).origin || "*";
6362
- if ((_c = this._runOptions) === null || _c === void 0 ? void 0 : _c.autofocus)
6363
+ if ((_a = this._runOptions) === null || _a === void 0 ? void 0 : _a.autofocus)
6363
6364
  frame.setAttribute("autofocus", "true");
6364
6365
  wrapper.appendChild(frame);
6365
6366
  const i = document.createElement("i");
@@ -6388,9 +6389,11 @@ var pxsim;
6388
6389
  return wrapper;
6389
6390
  }
6390
6391
  preload(aspectRatio, clearRuntime) {
6392
+ if (clearRuntime) {
6393
+ this._currentRuntime = undefined;
6394
+ this.container.textContent = "";
6395
+ }
6391
6396
  if (!this.simFrames().length) {
6392
- if (clearRuntime)
6393
- this._currentRuntime = undefined;
6394
6397
  this.container.appendChild(this.createFrame());
6395
6398
  this.applyAspectRatio(aspectRatio);
6396
6399
  this.setStarting();