pxt-core 12.3.20 → 12.3.22

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.
@@ -38,8 +38,8 @@ var pxt;
38
38
  loadConfigAsync(repopath, tag) {
39
39
  return this.loadAsync(repopath, tag, "pxt", (r, t) => this.db.loadConfigAsync(r, t));
40
40
  }
41
- loadPackageAsync(repopath, tag) {
42
- return this.loadAsync(repopath, tag, "pkg", (r, t) => this.db.loadPackageAsync(r, t));
41
+ loadPackageAsync(repopath, tag, fallbackPackageFiles) {
42
+ return this.loadAsync(repopath, tag, "pkg", (r, t) => this.db.loadPackageAsync(r, t, fallbackPackageFiles));
43
43
  }
44
44
  loadTutorialMarkdown(repopath, tag) {
45
45
  return this.loadAsync(repopath, tag, "tutorial", (r, t) => this.db.loadTutorialMarkdown(r, t));
@@ -9262,7 +9262,7 @@ var ts;
9262
9262
  function inspect(n) {
9263
9263
  pxt.log(stringKind(n));
9264
9264
  }
9265
- // next free error 9284
9265
+ // next free error 9285
9266
9266
  function userError(code, msg, secondary = false) {
9267
9267
  let e = new Error(msg);
9268
9268
  e.ksEmitterUserError = true;
@@ -12967,9 +12967,35 @@ ${lbl}: .short 0xffff
12967
12967
  let v = emitExpr(node);
12968
12968
  return v;
12969
12969
  }
12970
+ function maybeWarnOnBareFunctionReference(node) {
12971
+ if (!opts.enhancedErrors)
12972
+ return;
12973
+ if (!node || node.kind !== pxtc.SK.Identifier)
12974
+ return;
12975
+ if (hasPrecedingTsIgnoreComment(node))
12976
+ return;
12977
+ const exprType = typeOf(node);
12978
+ const signatures = exprType && !(exprType.flags & ts.TypeFlags.Any)
12979
+ && checker.getSignaturesOfType(exprType, ts.SignatureKind.Call);
12980
+ if (signatures && signatures.length)
12981
+ warning(node, 9284, lf("Function reference used as a statement; did you mean to call it with '()'?"));
12982
+ }
12983
+ function hasPrecedingTsIgnoreComment(node) {
12984
+ const src = node.getSourceFile();
12985
+ const line = ts.getLineAndCharacterOfPosition(src, node.getStart(src)).line;
12986
+ if (line <= 0)
12987
+ return false;
12988
+ const lineStarts = src.getLineStarts();
12989
+ const previousLineStart = lineStarts[line - 1];
12990
+ const previousLineEnd = lineStarts[line];
12991
+ const previousLine = src.text.slice(previousLineStart, previousLineEnd);
12992
+ return /^\s*\/\/\s*@ts-ignore\b/.test(previousLine);
12993
+ }
12970
12994
  function emitExprAsStmt(node) {
12971
- if (isNoopExpr(node))
12995
+ if (isNoopExpr(node)) {
12996
+ maybeWarnOnBareFunctionReference(node);
12972
12997
  return;
12998
+ }
12973
12999
  emitBrk(node);
12974
13000
  let v = emitIgnored(node);
12975
13001
  proc.emitExpr(v);
@@ -13951,6 +13977,14 @@ var ts;
13951
13977
  });
13952
13978
  }
13953
13979
  pxtc.patchUpDiagnostics = patchUpDiagnostics;
13980
+ function hasErrorDiagnostics(diags) {
13981
+ return diags.some(d => d.category == pxtc.DiagnosticCategory.Error);
13982
+ }
13983
+ pxtc.hasErrorDiagnostics = hasErrorDiagnostics;
13984
+ function hasBlockingDiagnostics(opts, diags) {
13985
+ return opts.enhancedErrors ? hasErrorDiagnostics(diags) : diags.length > 0;
13986
+ }
13987
+ pxtc.hasBlockingDiagnostics = hasBlockingDiagnostics;
13954
13988
  function py2tsIfNecessary(opts) {
13955
13989
  if (opts.target.preferredEditor == pxt.PYTHON_PROJECT_NAME) {
13956
13990
  let res = pxtc.transpile.pyToTs(opts);
@@ -14077,26 +14111,26 @@ var ts;
14077
14111
  }
14078
14112
  else {
14079
14113
  runConversionsAndStoreResults(opts, res);
14080
- if (res.diagnostics.length > 0)
14114
+ if (hasBlockingDiagnostics(opts, res.diagnostics))
14081
14115
  return res;
14082
14116
  program = buildProgram(opts, res);
14083
14117
  }
14084
14118
  const entryPoint = opts.sourceFiles.filter(f => pxtc.U.endsWith(f, ".ts")).pop().replace(/.*\//, "");
14085
14119
  // First get and report any syntactic errors.
14086
- res.diagnostics = patchUpDiagnostics(program.getSyntacticDiagnostics(), opts.ignoreFileResolutionErrors);
14087
- if (res.diagnostics.length > 0) {
14120
+ res.diagnostics = res.diagnostics.concat(patchUpDiagnostics(program.getSyntacticDiagnostics(), opts.ignoreFileResolutionErrors));
14121
+ if (hasBlockingDiagnostics(opts, res.diagnostics)) {
14088
14122
  if (opts.forceEmit) {
14089
14123
  pxt.debug('syntactic errors, forcing emit');
14090
14124
  pxtc.compileBinary(program, opts, res, entryPoint);
14091
14125
  }
14092
14126
  return res;
14093
14127
  }
14094
- // If we didn't have any syntactic errors, then also try getting the global and
14128
+ // If we didn't have any blocking syntactic errors, then also try getting the global and
14095
14129
  // semantic errors.
14096
- res.diagnostics = patchUpDiagnostics(program.getOptionsDiagnostics().concat(pxtc.Util.toArray(program.getGlobalDiagnostics())), opts.ignoreFileResolutionErrors);
14130
+ res.diagnostics = res.diagnostics.concat(patchUpDiagnostics(program.getOptionsDiagnostics().concat(pxtc.Util.toArray(program.getGlobalDiagnostics())), opts.ignoreFileResolutionErrors));
14097
14131
  const semStart = pxtc.U.cpuUs();
14098
- if (res.diagnostics.length == 0) {
14099
- res.diagnostics = patchUpDiagnostics(program.getSemanticDiagnostics(), opts.ignoreFileResolutionErrors);
14132
+ if (!hasBlockingDiagnostics(opts, res.diagnostics)) {
14133
+ res.diagnostics = res.diagnostics.concat(patchUpDiagnostics(program.getSemanticDiagnostics(), opts.ignoreFileResolutionErrors));
14100
14134
  }
14101
14135
  const emitStart = pxtc.U.cpuUs();
14102
14136
  res.times["typescript-syn"] = semStart - startTime;
@@ -14105,12 +14139,12 @@ var ts;
14105
14139
  if (opts.ast) {
14106
14140
  res.ast = program;
14107
14141
  }
14108
- if (opts.ast || opts.forceEmit || res.diagnostics.length == 0) {
14142
+ if (opts.ast || opts.forceEmit || !hasBlockingDiagnostics(opts, res.diagnostics)) {
14109
14143
  const binOutput = pxtc.compileBinary(program, opts, res, entryPoint);
14110
14144
  res.times["compilebinary"] = pxtc.U.cpuUs() - emitStart;
14111
14145
  res.diagnostics = res.diagnostics.concat(patchUpDiagnostics(binOutput.diagnostics));
14112
14146
  }
14113
- if (res.diagnostics.length == 0)
14147
+ if (!hasBlockingDiagnostics(opts, res.diagnostics))
14114
14148
  res.success = true;
14115
14149
  for (let f of opts.sourceFiles) {
14116
14150
  if (pxtc.Util.startsWith(f, "built/"))
@@ -17891,6 +17925,11 @@ var ts;
17891
17925
  if (param.labelLocalizationKey && param.label) {
17892
17926
  locStrings[param.labelLocalizationKey] = param.label;
17893
17927
  }
17928
+ const defaultString = pxt.blocks.parameterDefaultToLocalizationString(param.defaultValue, param.type);
17929
+ const defaultLocalizationKey = pxt.blocks.parameterDefaultLocalizationKey(si.qName, param.actualName);
17930
+ if (defaultLocalizationKey && defaultString !== undefined) {
17931
+ locStrings[defaultLocalizationKey] = defaultString;
17932
+ }
17894
17933
  }
17895
17934
  if ((_a = comp.handlerArgs) === null || _a === void 0 ? void 0 : _a.length) {
17896
17935
  for (const arg of comp.handlerArgs) {
@@ -17898,6 +17937,9 @@ var ts;
17898
17937
  }
17899
17938
  }
17900
17939
  }
17940
+ if (si.attributes.ariaLabel) {
17941
+ locStrings[`${si.qName}|ariaLabel`] = si.attributes.ariaLabel;
17942
+ }
17901
17943
  };
17902
17944
  const mapLocs = (m, name) => {
17903
17945
  if (!options.locs)
@@ -17920,6 +17962,8 @@ var ts;
17920
17962
  enumMembers.forEach(em => {
17921
17963
  if (em.attributes.block)
17922
17964
  locStrings[`${em.qName}|block`] = em.attributes.block;
17965
+ if (em.attributes.ariaLabel)
17966
+ locStrings[`${em.qName}|ariaLabel`] = em.attributes.ariaLabel;
17923
17967
  if (em.attributes.jsDoc)
17924
17968
  locStrings[em.qName] = em.attributes.jsDoc;
17925
17969
  });
@@ -18830,7 +18874,8 @@ var ts;
18830
18874
  for (let k of Object.keys(newFS))
18831
18875
  service_1.host.setFile(k, newFS[k]); // update version numbers
18832
18876
  res.fileSystem = pxtc.U.flatClone(newFS);
18833
- if (res.diagnostics.length == 0) {
18877
+ if (!pxtc.hasBlockingDiagnostics(service_1.host.opts, res.diagnostics)) {
18878
+ const conversionDiagnostics = res.diagnostics;
18834
18879
  service_1.host.opts.skipPxtModulesEmit = false;
18835
18880
  service_1.host.opts.skipPxtModulesTSC = false;
18836
18881
  const currKey = service_1.host.opts.target.isNative ? "native" : "js";
@@ -18845,13 +18890,13 @@ var ts;
18845
18890
  service_1.host.opts.skipPxtModulesEmit = true;
18846
18891
  }
18847
18892
  let ts2asm = pxtc.compile(service_1.host.opts, service_1.service);
18848
- res = Object.assign({ sourceMap: res.sourceMap, fileSystem: res.fileSystem }, ts2asm);
18849
- if (res.needsFullRecompile || ((!res.success || res.diagnostics.length) && service_1.host.opts.clearIncrBuildAndRetryOnError)) {
18893
+ res = Object.assign(Object.assign({ sourceMap: res.sourceMap, fileSystem: res.fileSystem }, ts2asm), { diagnostics: conversionDiagnostics.concat(ts2asm.diagnostics) });
18894
+ if (res.needsFullRecompile || ((!res.success || pxtc.hasBlockingDiagnostics(service_1.host.opts, res.diagnostics)) && service_1.host.opts.clearIncrBuildAndRetryOnError)) {
18850
18895
  pxt.debug("triggering full recompile");
18851
18896
  pxt.tickEvent("compile.fullrecompile");
18852
18897
  service_1.host.opts.skipPxtModulesEmit = false;
18853
18898
  ts2asm = pxtc.compile(service_1.host.opts, service_1.service);
18854
- res = Object.assign({ sourceMap: res.sourceMap }, ts2asm);
18899
+ res = Object.assign(Object.assign({ sourceMap: res.sourceMap }, ts2asm), { diagnostics: conversionDiagnostics.concat(ts2asm.diagnostics) });
18855
18900
  }
18856
18901
  if (res.diagnostics.every(d => !pxtc.isPxtModulesFilename(d.fileName)))
18857
18902
  service_1.host.pxtModulesOK = currKey;
package/built/pxtlib.d.ts CHANGED
@@ -733,6 +733,7 @@ declare namespace pxt {
733
733
  const TUTORIAL_CODE_STOP = "_onCodeStop.ts";
734
734
  const TUTORIAL_INFO_FILE = "tutorial-info-cache.json";
735
735
  const TUTORIAL_CUSTOM_TS = "tutorial.custom.ts";
736
+ const PACKAGED_EXTENSIONS = "_packaged-extensions.json";
736
737
  const BREAKPOINT_TABLET = 991;
737
738
  const PALETTES_FILE = "_palettes.json";
738
739
  const HISTORY_FILE = "_history";
@@ -786,6 +787,9 @@ declare namespace pxt.blocks {
786
787
  inBlockDef: boolean;
787
788
  localizationKey: string;
788
789
  }
790
+ function parameterDefaultLocalizationKey(qName: string, actualName: string): string;
791
+ function parameterDefaultToLocalizationString(defaultValue: string, type?: string): string;
792
+ function localizationStringToParameterDefault(value: string): string;
789
793
  const builtinFunctionInfo: pxt.Map<{
790
794
  params: string[];
791
795
  blockId: string;
@@ -1159,6 +1163,7 @@ declare namespace pxt.hexloader {
1159
1163
  let hideLoading: () => void;
1160
1164
  function storeWithLimitAsync(host: Host, idxkey: string, newkey: string, newval: string, maxLen?: number): Promise<void>;
1161
1165
  function recordGetAsync(host: Host, idxkey: string, newkey: string): Promise<void>;
1166
+ function stringifyHexInfoForCache(hexInfo: pxtc.HexInfo): string;
1162
1167
  function getHexInfoAsync(host: Host, extInfo: pxtc.ExtensionInfo, cloudModule?: any): Promise<pxtc.HexInfo>;
1163
1168
  }
1164
1169
  declare namespace pxt.crowdin {
@@ -1467,7 +1472,7 @@ declare namespace pxt.github {
1467
1472
  interface IGithubDb {
1468
1473
  latestVersionAsync(repopath: string, config: PackagesConfig): Promise<string>;
1469
1474
  loadConfigAsync(repopath: string, tag: string): Promise<pxt.PackageConfig>;
1470
- loadPackageAsync(repopath: string, tag: string): Promise<CachedPackage>;
1475
+ loadPackageAsync(repopath: string, tag: string, fallbackPackageFiles?: pxt.Map<string>): Promise<CachedPackage>;
1471
1476
  loadTutorialMarkdown(repopath: string, tag?: string): Promise<CachedPackage>;
1472
1477
  cacheReposAsync(response: GHTutorialResponse): Promise<void>;
1473
1478
  }
@@ -1480,7 +1485,7 @@ declare namespace pxt.github {
1480
1485
  private cacheConfig;
1481
1486
  loadConfigAsync(repopath: string, tag: string): Promise<pxt.PackageConfig>;
1482
1487
  latestVersionAsync(repopath: string, config: PackagesConfig): Promise<string>;
1483
- loadPackageAsync(repopath: string, tag: string): Promise<CachedPackage>;
1488
+ loadPackageAsync(repopath: string, tag: string, fallbackPackageFiles?: pxt.Map<string>): Promise<CachedPackage>;
1484
1489
  private githubLoadPackageAsync;
1485
1490
  loadTutorialMarkdown(repopath: string, tag?: string): Promise<GHTutorialRepoInfo>;
1486
1491
  cacheReposAsync(resp: GHTutorialResponse): Promise<void>;
@@ -1525,12 +1530,12 @@ declare namespace pxt.github {
1525
1530
  function listRefsAsync(repopath: string, namespace?: string, useProxy?: boolean, noCache?: boolean): Promise<string[]>;
1526
1531
  function listRefsExtAsync(repopath: string, namespace?: string, useProxy?: boolean, noCache?: boolean): Promise<RefsResult>;
1527
1532
  function pkgConfigAsync(repopath: string, tag: string, config: pxt.PackagesConfig): Promise<PackageConfig>;
1528
- function downloadPackageAsync(repoWithTag: string, config: pxt.PackagesConfig): Promise<CachedPackage>;
1533
+ function downloadPackageAsync(repoWithTag: string, config: pxt.PackagesConfig, fallbackPackageFiles?: pxt.Map<string>): Promise<CachedPackage>;
1529
1534
  function downloadLatestPackageAsync(repo: ParsedRepo, useProxy?: boolean, noCache?: boolean): Promise<{
1530
1535
  version: string;
1531
1536
  config: pxt.PackageConfig;
1532
1537
  }>;
1533
- function cacheProjectDependenciesAsync(cfg: pxt.PackageConfig): Promise<void>;
1538
+ function cacheProjectDependenciesAsync(cfg: pxt.PackageConfig, fallbackPackageFilesById?: pxt.Map<pxt.Map<string>>): Promise<void>;
1534
1539
  interface User {
1535
1540
  login: string;
1536
1541
  id: number;
@@ -2159,7 +2164,8 @@ declare namespace pxt {
2159
2164
  resolveBannedCategories(): string[];
2160
2165
  getCompileOptionsAsync(target?: pxtc.CompileTarget): Promise<pxtc.CompileOptions>;
2161
2166
  private prepareConfigToBePublished;
2162
- filesToBePublishedAsync(allowPrivate?: boolean): Promise<Map<string>>;
2167
+ filesToBePublishedAsync(allowPrivate?: boolean, packExternalExtensions?: boolean): Promise<Map<string>>;
2168
+ private packagedExternalExtensions;
2163
2169
  saveToJsonAsync(): Promise<pxt.cpp.HexFile>;
2164
2170
  compressToFileAsync(): Promise<Uint8Array>;
2165
2171
  computePartDefinitions(parts: string[]): pxt.Map<pxsim.PartDefinition>;