pxt-core 9.2.5 → 9.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
@@ -97781,6 +97781,17 @@ var pxt;
97781
97781
  };
97782
97782
  }
97783
97783
  analytics.enable = enable;
97784
+ function trackPerformanceReport() {
97785
+ if (pxt.perf.perfReportLogged)
97786
+ return;
97787
+ const data = pxt.perf.report();
97788
+ if (data) {
97789
+ const { durations, milestones } = data;
97790
+ pxt.tickEvent("performance.milestones", milestones);
97791
+ pxt.tickEvent("performance.durations", durations);
97792
+ }
97793
+ }
97794
+ analytics.trackPerformanceReport = trackPerformanceReport;
97784
97795
  })(analytics = pxt.analytics || (pxt.analytics = {}));
97785
97796
  })(pxt || (pxt = {}));
97786
97797
  var pxt;
@@ -101155,7 +101166,7 @@ var pxt;
101155
101166
  // Sometimes these aren't initialized, for example in tests. We only care about them
101156
101167
  // doing anything in the browser.
101157
101168
  if (!pxt.perf.report)
101158
- pxt.perf.report = () => { };
101169
+ pxt.perf.report = () => undefined;
101159
101170
  if (!pxt.perf.recordMilestone)
101160
101171
  pxt.perf.recordMilestone = () => { };
101161
101172
  if (!pxt.perf.measureStart)
@@ -114388,6 +114399,17 @@ var pxt;
114388
114399
  const patches = pxt.appTarget.compile ? pxt.appTarget.compile.patches : undefined;
114389
114400
  if (!patches)
114390
114401
  return undefined;
114402
+ return parsePatches(version, patches, kind);
114403
+ }
114404
+ patching.computePatches = computePatches;
114405
+ function computePyPatches(version, kind) {
114406
+ const patches = pxt.appTarget.compile ? pxt.appTarget.compile.pyPatches : undefined;
114407
+ if (!patches)
114408
+ return undefined;
114409
+ return parsePatches(version, patches, kind);
114410
+ }
114411
+ patching.computePyPatches = computePyPatches;
114412
+ function parsePatches(version, patches, kind) {
114391
114413
  const v = pxt.semver.tryParse(version || "0.0.0") || pxt.semver.tryParse("0.0.0");
114392
114414
  let r = [];
114393
114415
  Object.keys(patches)
@@ -114397,7 +114419,6 @@ var pxt;
114397
114419
  r = r.filter(p => p.type == kind);
114398
114420
  return r.length ? r : undefined;
114399
114421
  }
114400
- patching.computePatches = computePatches;
114401
114422
  function upgradePackageReference(pkgTargetVersion, pkg, val) {
114402
114423
  if (val != "*")
114403
114424
  return pkg;
@@ -114417,6 +114438,15 @@ var pxt;
114417
114438
  patching.upgradePackageReference = upgradePackageReference;
114418
114439
  function patchJavaScript(pkgTargetVersion, fileContents) {
114419
114440
  const upgrades = pxt.patching.computePatches(pkgTargetVersion);
114441
+ return patchTextCode(pkgTargetVersion, fileContents, upgrades);
114442
+ }
114443
+ patching.patchJavaScript = patchJavaScript;
114444
+ function patchPython(pkgTargetVersion, fileContents) {
114445
+ const upgrades = pxt.patching.computePyPatches(pkgTargetVersion);
114446
+ return patchTextCode(pkgTargetVersion, fileContents, upgrades);
114447
+ }
114448
+ patching.patchPython = patchPython;
114449
+ function patchTextCode(pkgTargetVersion, fileContents, upgrades) {
114420
114450
  let updatedContents = fileContents;
114421
114451
  if (upgrades) {
114422
114452
  upgrades.filter(u => u.type === "api").forEach(rule => {
@@ -114436,7 +114466,6 @@ var pxt;
114436
114466
  }
114437
114467
  return updatedContents;
114438
114468
  }
114439
- patching.patchJavaScript = patchJavaScript;
114440
114469
  })(patching = pxt.patching || (pxt.patching = {}));
114441
114470
  })(pxt || (pxt = {}));
114442
114471
  var pxt;
@@ -123210,6 +123239,9 @@ var pxt;
123210
123239
  return mainPkg.getCompileOptionsAsync(target);
123211
123240
  }).then(opts => {
123212
123241
  patchTS(mainPkg.targetVersion(), opts);
123242
+ if (mainPkg.getPreferredEditor() === pxt.PYTHON_PROJECT_NAME) {
123243
+ patchPY(mainPkg.targetVersion(), opts);
123244
+ }
123213
123245
  prepPythonOptions(opts);
123214
123246
  return opts;
123215
123247
  });
@@ -123243,6 +123275,22 @@ var pxt;
123243
123275
  }
123244
123276
  }
123245
123277
  pxt.patchTS = patchTS;
123278
+ function patchPY(version, opts) {
123279
+ if (!version)
123280
+ return;
123281
+ pxt.debug(`applying PY patches relative to ${version}`);
123282
+ for (let fn of Object.keys(opts.fileSystem)) {
123283
+ if (fn.indexOf("/") == -1 && pxt.U.endsWith(fn, ".py")) {
123284
+ const initial = opts.fileSystem[fn];
123285
+ const patched = pxt.patching.patchPython(version, initial);
123286
+ if (initial != patched) {
123287
+ pxt.debug(`applying PY patch to ${fn}`);
123288
+ opts.fileSystem[fn] = patched;
123289
+ }
123290
+ }
123291
+ }
123292
+ }
123293
+ pxt.patchPY = patchPY;
123246
123294
  function setupSimpleCompile(cfg) {
123247
123295
  if (typeof global != "undefined" && !global.btoa) {
123248
123296
  global.btoa = function (str) { return Buffer.from(str, "binary").toString("base64"); };
@@ -141718,7 +141766,7 @@ var ts;
141718
141766
  }
141719
141767
  const type = checker === null || checker === void 0 ? void 0 : checker.getTypeAtLocation(param);
141720
141768
  const typeSymbol = service.getPxtSymbolFromTsSymbol(type === null || type === void 0 ? void 0 : type.symbol, apis, checker);
141721
- if (((typeSymbol === null || typeSymbol === void 0 ? void 0 : typeSymbol.attributes.fixedInstances) || (typeSymbol === null || typeSymbol === void 0 ? void 0 : typeSymbol.attributes.emitAsConstant)) && python) {
141769
+ if ((typeSymbol === null || typeSymbol === void 0 ? void 0 : typeSymbol.attributes.fixedInstances) && python) {
141722
141770
  return pxt.Util.snakify(paramDefl);
141723
141771
  }
141724
141772
  if (python) {
@@ -155509,6 +155557,7 @@ var pxsim;
155509
155557
  return wrapper;
155510
155558
  }
155511
155559
  preload(aspectRatio, clearRuntime) {
155560
+ this.addEventListeners();
155512
155561
  if (clearRuntime) {
155513
155562
  this._currentRuntime = undefined;
155514
155563
  this.container.textContent = "";
@@ -31,6 +31,7 @@ declare namespace pxt {
31
31
  function simpleGetCompileOptionsAsync(files: pxt.Map<string>, simpleOptions: SimpleCompileOptions): Promise<pxtc.CompileOptions>;
32
32
  function simpleCompileAsync(files: pxt.Map<string>, optionsOrNative?: SimpleCompileOptions | boolean): Promise<CompileResultWithErrors>;
33
33
  function patchTS(version: string, opts: pxtc.CompileOptions): void;
34
+ function patchPY(version: string, opts: pxtc.CompileOptions): void;
34
35
  function setupSimpleCompile(cfg?: SimpleDriverCallbacks): void;
35
36
  }
36
37
  declare namespace pxt {
@@ -141,6 +141,9 @@ var pxt;
141
141
  return mainPkg.getCompileOptionsAsync(target);
142
142
  }).then(opts => {
143
143
  patchTS(mainPkg.targetVersion(), opts);
144
+ if (mainPkg.getPreferredEditor() === pxt.PYTHON_PROJECT_NAME) {
145
+ patchPY(mainPkg.targetVersion(), opts);
146
+ }
144
147
  prepPythonOptions(opts);
145
148
  return opts;
146
149
  });
@@ -174,6 +177,22 @@ var pxt;
174
177
  }
175
178
  }
176
179
  pxt.patchTS = patchTS;
180
+ function patchPY(version, opts) {
181
+ if (!version)
182
+ return;
183
+ pxt.debug(`applying PY patches relative to ${version}`);
184
+ for (let fn of Object.keys(opts.fileSystem)) {
185
+ if (fn.indexOf("/") == -1 && pxt.U.endsWith(fn, ".py")) {
186
+ const initial = opts.fileSystem[fn];
187
+ const patched = pxt.patching.patchPython(version, initial);
188
+ if (initial != patched) {
189
+ pxt.debug(`applying PY patch to ${fn}`);
190
+ opts.fileSystem[fn] = patched;
191
+ }
192
+ }
193
+ }
194
+ }
195
+ pxt.patchPY = patchPY;
177
196
  function setupSimpleCompile(cfg) {
178
197
  if (typeof global != "undefined" && !global.btoa) {
179
198
  global.btoa = function (str) { return Buffer.from(str, "binary").toString("base64"); };
@@ -18649,7 +18668,7 @@ var ts;
18649
18668
  }
18650
18669
  const type = checker === null || checker === void 0 ? void 0 : checker.getTypeAtLocation(param);
18651
18670
  const typeSymbol = service.getPxtSymbolFromTsSymbol(type === null || type === void 0 ? void 0 : type.symbol, apis, checker);
18652
- if (((typeSymbol === null || typeSymbol === void 0 ? void 0 : typeSymbol.attributes.fixedInstances) || (typeSymbol === null || typeSymbol === void 0 ? void 0 : typeSymbol.attributes.emitAsConstant)) && python) {
18671
+ if ((typeSymbol === null || typeSymbol === void 0 ? void 0 : typeSymbol.attributes.fixedInstances) && python) {
18653
18672
  return pxt.Util.snakify(paramDefl);
18654
18673
  }
18655
18674
  if (python) {
package/built/pxtlib.d.ts CHANGED
@@ -22,6 +22,7 @@ declare namespace pxt.analytics {
22
22
  let consoleTicks: ConsoleTickOptions;
23
23
  function addDefaultProperties(props: Map<string | number>): void;
24
24
  function enable(lang: string): void;
25
+ function trackPerformanceReport(): void;
25
26
  }
26
27
  declare namespace pxt {
27
28
  let appTarget: TargetBundle;
@@ -484,7 +485,14 @@ declare namespace ts.pxtc.jsonPatch.tests {
484
485
  }
485
486
  declare namespace pxt.perf {
486
487
  let perfReportLogged: boolean;
487
- function report(): void;
488
+ function report(): {
489
+ milestones: {
490
+ [index: string]: number;
491
+ };
492
+ durations: {
493
+ [index: string]: number;
494
+ };
495
+ } | undefined;
488
496
  function recordMilestone(msg: string, time?: number): void;
489
497
  function measureStart(name: string): void;
490
498
  function measureEnd(name: string): void;
@@ -1986,8 +1994,10 @@ declare namespace pxt.packetio {
1986
1994
  }
1987
1995
  declare namespace pxt.patching {
1988
1996
  function computePatches(version: string, kind?: string): ts.pxtc.UpgradePolicy[];
1997
+ function computePyPatches(version: string, kind?: string): ts.pxtc.UpgradePolicy[];
1989
1998
  function upgradePackageReference(pkgTargetVersion: string, pkg: string, val: string): string;
1990
1999
  function patchJavaScript(pkgTargetVersion: string, fileContents: string): string;
2000
+ function patchPython(pkgTargetVersion: string, fileContents: string): string;
1991
2001
  }
1992
2002
  declare namespace pxt.react {
1993
2003
  interface FieldEditorView<U> {
package/built/pxtlib.js CHANGED
@@ -95,6 +95,17 @@ var pxt;
95
95
  };
96
96
  }
97
97
  analytics.enable = enable;
98
+ function trackPerformanceReport() {
99
+ if (pxt.perf.perfReportLogged)
100
+ return;
101
+ const data = pxt.perf.report();
102
+ if (data) {
103
+ const { durations, milestones } = data;
104
+ pxt.tickEvent("performance.milestones", milestones);
105
+ pxt.tickEvent("performance.durations", durations);
106
+ }
107
+ }
108
+ analytics.trackPerformanceReport = trackPerformanceReport;
98
109
  })(analytics = pxt.analytics || (pxt.analytics = {}));
99
110
  })(pxt || (pxt = {}));
100
111
  var pxt;
@@ -3469,7 +3480,7 @@ var pxt;
3469
3480
  // Sometimes these aren't initialized, for example in tests. We only care about them
3470
3481
  // doing anything in the browser.
3471
3482
  if (!pxt.perf.report)
3472
- pxt.perf.report = () => { };
3483
+ pxt.perf.report = () => undefined;
3473
3484
  if (!pxt.perf.recordMilestone)
3474
3485
  pxt.perf.recordMilestone = () => { };
3475
3486
  if (!pxt.perf.measureStart)
@@ -16702,6 +16713,17 @@ var pxt;
16702
16713
  const patches = pxt.appTarget.compile ? pxt.appTarget.compile.patches : undefined;
16703
16714
  if (!patches)
16704
16715
  return undefined;
16716
+ return parsePatches(version, patches, kind);
16717
+ }
16718
+ patching.computePatches = computePatches;
16719
+ function computePyPatches(version, kind) {
16720
+ const patches = pxt.appTarget.compile ? pxt.appTarget.compile.pyPatches : undefined;
16721
+ if (!patches)
16722
+ return undefined;
16723
+ return parsePatches(version, patches, kind);
16724
+ }
16725
+ patching.computePyPatches = computePyPatches;
16726
+ function parsePatches(version, patches, kind) {
16705
16727
  const v = pxt.semver.tryParse(version || "0.0.0") || pxt.semver.tryParse("0.0.0");
16706
16728
  let r = [];
16707
16729
  Object.keys(patches)
@@ -16711,7 +16733,6 @@ var pxt;
16711
16733
  r = r.filter(p => p.type == kind);
16712
16734
  return r.length ? r : undefined;
16713
16735
  }
16714
- patching.computePatches = computePatches;
16715
16736
  function upgradePackageReference(pkgTargetVersion, pkg, val) {
16716
16737
  if (val != "*")
16717
16738
  return pkg;
@@ -16731,6 +16752,15 @@ var pxt;
16731
16752
  patching.upgradePackageReference = upgradePackageReference;
16732
16753
  function patchJavaScript(pkgTargetVersion, fileContents) {
16733
16754
  const upgrades = pxt.patching.computePatches(pkgTargetVersion);
16755
+ return patchTextCode(pkgTargetVersion, fileContents, upgrades);
16756
+ }
16757
+ patching.patchJavaScript = patchJavaScript;
16758
+ function patchPython(pkgTargetVersion, fileContents) {
16759
+ const upgrades = pxt.patching.computePyPatches(pkgTargetVersion);
16760
+ return patchTextCode(pkgTargetVersion, fileContents, upgrades);
16761
+ }
16762
+ patching.patchPython = patchPython;
16763
+ function patchTextCode(pkgTargetVersion, fileContents, upgrades) {
16734
16764
  let updatedContents = fileContents;
16735
16765
  if (upgrades) {
16736
16766
  upgrades.filter(u => u.type === "api").forEach(rule => {
@@ -16750,7 +16780,6 @@ var pxt;
16750
16780
  }
16751
16781
  return updatedContents;
16752
16782
  }
16753
- patching.patchJavaScript = patchJavaScript;
16754
16783
  })(patching = pxt.patching || (pxt.patching = {}));
16755
16784
  })(pxt || (pxt = {}));
16756
16785
  var pxt;
package/built/pxtsim.js CHANGED
@@ -6424,6 +6424,7 @@ var pxsim;
6424
6424
  return wrapper;
6425
6425
  }
6426
6426
  preload(aspectRatio, clearRuntime) {
6427
+ this.addEventListeners();
6427
6428
  if (clearRuntime) {
6428
6429
  this._currentRuntime = undefined;
6429
6430
  this.container.textContent = "";