pxt-core 8.4.9 → 8.4.11

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
@@ -1857,7 +1857,7 @@ function buildReactAppAsync(app, parsed, opts) {
1857
1857
  nodeutil.cp("built/target.js", `${appRoot}/public/blb`);
1858
1858
  }
1859
1859
  if (opts.usePxtEmbed) {
1860
- nodeutil.cp("node_modules/pxt-core/built/web/pxtembed.js", `${appRoot}/public/blb/web`);
1860
+ nodeutil.cp("node_modules/pxt-core/built/web/pxtembed.js", `${appRoot}/public/blb`);
1861
1861
  }
1862
1862
  else {
1863
1863
  nodeutil.cp("node_modules/pxt-core/built/pxtlib.js", `${appRoot}/public/blb`);
package/built/pxt.js CHANGED
@@ -140243,7 +140243,7 @@ var ts;
140243
140243
  position: v.position,
140244
140244
  type: v.infoType
140245
140245
  };
140246
- const isPython = opts.target.preferredEditor == pxt.PYTHON_PROJECT_NAME;
140246
+ const isPython = v.fileName.endsWith(".py");
140247
140247
  const isSymbolReq = opts.syntaxInfo.type === "symbol";
140248
140248
  const isSignatureReq = opts.syntaxInfo.type === "signature";
140249
140249
  if (isPython) {
@@ -143889,7 +143889,13 @@ var pxt;
143889
143889
  fn = B.mkText("super");
143890
143890
  }
143891
143891
  else {
143892
- fn = methName ? B.mkInfix(expr(recv), ".", B.mkText(methName)) : expr(n.func);
143892
+ if (methName) {
143893
+ fn = B.mkInfix(expr(recv), ".", B.mkText(methName));
143894
+ markInfoNode(n.func, "memberCompletion");
143895
+ }
143896
+ else {
143897
+ fn = expr(n.func);
143898
+ }
143893
143899
  }
143894
143900
  let nodes = [
143895
143901
  fn,
@@ -154733,8 +154739,10 @@ var pxsim;
154733
154739
  this.applyAspectRatioToFrame(frame);
154734
154740
  return wrapper;
154735
154741
  }
154736
- preload(aspectRatio) {
154742
+ preload(aspectRatio, clearRuntime) {
154737
154743
  if (!this.simFrames().length) {
154744
+ if (clearRuntime)
154745
+ this._currentRuntime = undefined;
154738
154746
  this.container.appendChild(this.createFrame());
154739
154747
  this.applyAspectRatio(aspectRatio);
154740
154748
  this.setStarting();
@@ -154875,8 +154883,11 @@ var pxsim;
154875
154883
  this.options.unhideElement(frame.parentElement);
154876
154884
  });
154877
154885
  }
154878
- run(js, opts = {}) {
154886
+ setRunOptions(opts = {}) {
154879
154887
  this._runOptions = opts;
154888
+ }
154889
+ run(js, opts = {}) {
154890
+ this.setRunOptions(opts);
154880
154891
  this.runId = this.nextId();
154881
154892
  // store information
154882
154893
  this._currentRuntime = {
@@ -160831,7 +160842,7 @@ function buildReactAppAsync(app, parsed, opts) {
160831
160842
  nodeutil.cp("built/target.js", `${appRoot}/public/blb`);
160832
160843
  }
160833
160844
  if (opts.usePxtEmbed) {
160834
- nodeutil.cp("node_modules/pxt-core/built/web/pxtembed.js", `${appRoot}/public/blb/web`);
160845
+ nodeutil.cp("node_modules/pxt-core/built/web/pxtembed.js", `${appRoot}/public/blb`);
160835
160846
  }
160836
160847
  else {
160837
160848
  nodeutil.cp("node_modules/pxt-core/built/pxtlib.js", `${appRoot}/public/blb`);
@@ -17878,7 +17878,7 @@ var ts;
17878
17878
  position: v.position,
17879
17879
  type: v.infoType
17880
17880
  };
17881
- const isPython = opts.target.preferredEditor == pxt.PYTHON_PROJECT_NAME;
17881
+ const isPython = v.fileName.endsWith(".py");
17882
17882
  const isSymbolReq = opts.syntaxInfo.type === "symbol";
17883
17883
  const isSignatureReq = opts.syntaxInfo.type === "signature";
17884
17884
  if (isPython) {
package/built/pxtpy.js CHANGED
@@ -2217,7 +2217,13 @@ var pxt;
2217
2217
  fn = B.mkText("super");
2218
2218
  }
2219
2219
  else {
2220
- fn = methName ? B.mkInfix(expr(recv), ".", B.mkText(methName)) : expr(n.func);
2220
+ if (methName) {
2221
+ fn = B.mkInfix(expr(recv), ".", B.mkText(methName));
2222
+ markInfoNode(n.func, "memberCompletion");
2223
+ }
2224
+ else {
2225
+ fn = expr(n.func);
2226
+ }
2221
2227
  }
2222
2228
  let nodes = [
2223
2229
  fn,
@@ -88,6 +88,7 @@ declare namespace pxt.runner {
88
88
  }
89
89
  declare namespace pxt.runner {
90
90
  interface SimulateOptions {
91
+ embedId?: string;
91
92
  id?: string;
92
93
  code?: string;
93
94
  assets?: string;
@@ -110,6 +111,7 @@ declare namespace pxt.runner {
110
111
  function generateHexFileAsync(options: SimulateOptions): Promise<string>;
111
112
  function generateVMFileAsync(options: SimulateOptions): Promise<any>;
112
113
  function simulateAsync(container: HTMLElement, simOptions: SimulateOptions): Promise<pxtc.BuiltSimJsInfo>;
114
+ function preloadSim(container: HTMLElement, simOpts: SimulateOptions): void;
113
115
  function currentDriver(): pxsim.SimulatorDriver;
114
116
  function postSimMessage(msg: pxsim.SimulatorMessage): void;
115
117
  function buildSimJsInfo(simOptions: SimulateOptions): Promise<pxtc.BuiltSimJsInfo>;
@@ -1730,17 +1730,17 @@ var pxt;
1730
1730
  });
1731
1731
  }
1732
1732
  runner.generateVMFileAsync = generateVMFileAsync;
1733
- let simDriver;
1734
1733
  async function simulateAsync(container, simOptions) {
1735
1734
  var _a, _b;
1736
1735
  const builtSimJS = simOptions.builtJsInfo || await buildSimJsInfo(simOptions);
1737
- const { js, fnArgs, parts, usedBuiltinParts, } = builtSimJS;
1736
+ const { js } = builtSimJS;
1738
1737
  if (!js) {
1739
1738
  console.error("Program failed to compile");
1740
1739
  return undefined;
1741
1740
  }
1742
- let options = {};
1743
- options.onSimulatorCommand = msg => {
1741
+ const runOptions = initDriverAndOptions(container, simOptions, builtSimJS);
1742
+ simDriver.options.messageSimulators = (_b = (_a = pxt.appTarget) === null || _a === void 0 ? void 0 : _a.simulator) === null || _b === void 0 ? void 0 : _b.messageSimulators;
1743
+ simDriver.options.onSimulatorCommand = msg => {
1744
1744
  if (msg.command === "restart") {
1745
1745
  runOptions.storedState = getStoredState(simOptions.id);
1746
1746
  simDriver.run(js, runOptions);
@@ -1751,8 +1751,25 @@ var pxt;
1751
1751
  }
1752
1752
  }
1753
1753
  };
1754
- options.messageSimulators = (_b = (_a = pxt.appTarget) === null || _a === void 0 ? void 0 : _a.simulator) === null || _b === void 0 ? void 0 : _b.messageSimulators;
1755
- simDriver = new pxsim.SimulatorDriver(container, options);
1754
+ if (builtSimJS.breakpoints && simOptions.debug) {
1755
+ simDriver.setBreakpoints(builtSimJS.breakpoints);
1756
+ }
1757
+ simDriver.run(js, runOptions);
1758
+ return builtSimJS;
1759
+ }
1760
+ runner.simulateAsync = simulateAsync;
1761
+ let simDriver;
1762
+ // iff matches and truthy, reuse existing simdriver
1763
+ let currDriverId;
1764
+ function initDriverAndOptions(container, simOptions, compileInfo) {
1765
+ if (!simDriver || !simOptions.embedId || currDriverId !== simOptions.embedId) {
1766
+ simDriver = new pxsim.SimulatorDriver(container);
1767
+ currDriverId = simOptions.embedId;
1768
+ }
1769
+ else {
1770
+ simDriver.container = container;
1771
+ }
1772
+ const { fnArgs, parts, usedBuiltinParts, } = compileInfo || {};
1756
1773
  let board = pxt.appTarget.simulator.boardDefinition;
1757
1774
  let storedState = getStoredState(simOptions.id);
1758
1775
  let runOptions = {
@@ -1776,13 +1793,15 @@ var pxt;
1776
1793
  runOptions.aspectRatio = parts.length && pxt.appTarget.simulator.partsAspectRatio
1777
1794
  ? pxt.appTarget.simulator.partsAspectRatio
1778
1795
  : pxt.appTarget.simulator.aspectRatio;
1779
- if (builtSimJS.breakpoints && simOptions.debug) {
1780
- simDriver.setBreakpoints(builtSimJS.breakpoints);
1781
- }
1782
- simDriver.run(js, runOptions);
1783
- return builtSimJS;
1796
+ simDriver.setRunOptions(runOptions);
1797
+ return runOptions;
1784
1798
  }
1785
- runner.simulateAsync = simulateAsync;
1799
+ function preloadSim(container, simOpts) {
1800
+ var _a, _b;
1801
+ initDriverAndOptions(container, simOpts);
1802
+ simDriver.preload(((_b = (_a = pxt.appTarget) === null || _a === void 0 ? void 0 : _a.simulator) === null || _b === void 0 ? void 0 : _b.aspectRatio) || 1, true /** no auto run **/);
1803
+ }
1804
+ runner.preloadSim = preloadSim;
1786
1805
  function currentDriver() {
1787
1806
  return simDriver;
1788
1807
  }
package/built/pxtsim.d.ts CHANGED
@@ -1327,7 +1327,7 @@ declare namespace pxsim {
1327
1327
  postMessage(msg: pxsim.SimulatorMessage, source?: Window, frameID?: string): void;
1328
1328
  private postMessageCore;
1329
1329
  private createFrame;
1330
- preload(aspectRatio: number): void;
1330
+ preload(aspectRatio: number, clearRuntime?: boolean): void;
1331
1331
  stop(unload?: boolean, starting?: boolean): void;
1332
1332
  suspend(): void;
1333
1333
  private unload;
@@ -1345,6 +1345,7 @@ declare namespace pxsim {
1345
1345
  private cleanupFrames;
1346
1346
  hide(completeHandler?: () => void): void;
1347
1347
  unhide(): void;
1348
+ setRunOptions(opts?: SimulatorRunOptions): void;
1348
1349
  run(js: string, opts?: SimulatorRunOptions): void;
1349
1350
  restart(): void;
1350
1351
  areBreakpointsSet(): boolean;
package/built/pxtsim.js CHANGED
@@ -6387,8 +6387,10 @@ var pxsim;
6387
6387
  this.applyAspectRatioToFrame(frame);
6388
6388
  return wrapper;
6389
6389
  }
6390
- preload(aspectRatio) {
6390
+ preload(aspectRatio, clearRuntime) {
6391
6391
  if (!this.simFrames().length) {
6392
+ if (clearRuntime)
6393
+ this._currentRuntime = undefined;
6392
6394
  this.container.appendChild(this.createFrame());
6393
6395
  this.applyAspectRatio(aspectRatio);
6394
6396
  this.setStarting();
@@ -6529,8 +6531,11 @@ var pxsim;
6529
6531
  this.options.unhideElement(frame.parentElement);
6530
6532
  });
6531
6533
  }
6532
- run(js, opts = {}) {
6534
+ setRunOptions(opts = {}) {
6533
6535
  this._runOptions = opts;
6536
+ }
6537
+ run(js, opts = {}) {
6538
+ this.setRunOptions(opts);
6534
6539
  this.runId = this.nextId();
6535
6540
  // store information
6536
6541
  this._currentRuntime = {