pxt-core 13.2.1 → 13.2.3

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.
Files changed (48) hide show
  1. package/README.md +1 -1
  2. package/built/pxt.js +646 -137
  3. package/built/pxtcompiler.d.ts +19 -1
  4. package/built/pxtcompiler.js +519 -64
  5. package/built/pxtlib.d.ts +1 -1
  6. package/built/pxtlib.js +127 -73
  7. package/built/react-common/components/controls/DropdownModal.d.ts +6 -0
  8. package/built/react-common/components/controls/Input.d.ts +1 -1
  9. package/built/target.js +1 -1
  10. package/built/targetlight.js +1 -1
  11. package/built/tests/thumb-test/asmchecks.d.ts +73 -0
  12. package/built/tests/thumb-test/thumbrunner.d.ts +3 -0
  13. package/built/web/main.js +30 -30
  14. package/built/web/pxtapp.js +1 -1
  15. package/built/web/pxtasseteditor.js +20 -20
  16. package/built/web/pxtcompiler.js +1 -1
  17. package/built/web/pxtembed.js +4 -4
  18. package/built/web/pxtlib.js +1 -1
  19. package/built/web/pxtworker.js +1 -1
  20. package/built/web/react-common-authcode.css +1 -1
  21. package/built/web/react-common-multiplayer.css +1 -1
  22. package/built/web/react-common-skillmap.css +1 -1
  23. package/built/web/rtlreact-common-authcode.css +1 -1
  24. package/built/web/rtlreact-common-multiplayer.css +1 -1
  25. package/built/web/rtlreact-common-skillmap.css +1 -1
  26. package/built/web/rtlsemantic.css +2 -2
  27. package/built/web/runnerembed.js +5 -5
  28. package/built/web/semantic.css +2 -2
  29. package/common-docs/blocks-embed.md +2 -2
  30. package/common-docs/github/commit.md +1 -1
  31. package/common-docs/github/private-assignments.md +1 -1
  32. package/common-docs/github/test-extension.md +1 -1
  33. package/common-docs/online-learning.md +2 -2
  34. package/common-docs/reference/arrays/pick-random.md +1 -1
  35. package/common-docs/reference/text/char-code-at.md +1 -1
  36. package/common-docs/share.md +2 -2
  37. package/common-docs/types/function/define.md +1 -1
  38. package/localtypings/pxtarget.d.ts +3 -1
  39. package/package.json +3 -2
  40. package/react-common/components/controls/DropdownModal.tsx +66 -0
  41. package/react-common/components/controls/Input.tsx +1 -1
  42. package/react-common/styles/controls/DropdownModal.less +17 -0
  43. package/react-common/styles/react-common.less +1 -0
  44. package/react-common/styles/theming/ThemePickerModal.less +5 -0
  45. package/theme/monaco.less +2 -0
  46. package/theme/music-editor/gallery.less +10 -1
  47. package/theme/piano-roll/piano-roll.less +33 -2
  48. package/theme/pxtjson.less +0 -12
package/built/pxtlib.d.ts CHANGED
@@ -1543,7 +1543,7 @@ declare namespace pxt.github {
1543
1543
  function createReleaseAsync(repopath: string, tag: string, commitid: string): Promise<void>;
1544
1544
  function createPRFromBranchAsync(repopath: string, baseBranch: string, headBranch: string, title: string, msg?: string): Promise<string>;
1545
1545
  function mergeAsync(repopath: string, base: string, head: string, message?: string): Promise<string>;
1546
- function getRefAsync(repopath: string, branch: string): Promise<any>;
1546
+ function getRefAsync(repopath: string, branch: string): Promise<string | undefined>;
1547
1547
  function getNewBranchNameAsync(repopath: string, pref?: string): Promise<string>;
1548
1548
  function createNewBranchAsync(repopath: string, branchName: string, commitid: string): Promise<string>;
1549
1549
  function forkRepoAsync(repopath: string, commitid: string, pref?: string): Promise<string>;
package/built/pxtlib.js CHANGED
@@ -10890,8 +10890,29 @@ var pxt;
10890
10890
  }
10891
10891
  async loadConfigAsync(repopath, tag) {
10892
10892
  if (!tag) {
10893
- pxt.debug(`dep: default to master branch`);
10894
- tag = "master";
10893
+ pxt.debug(`dep: no tag specified, try master and main`);
10894
+ let res;
10895
+ let error;
10896
+ try {
10897
+ res = await this.loadConfigAsync(repopath, "master");
10898
+ }
10899
+ catch (e) {
10900
+ error = e;
10901
+ pxt.log(`Error loading default master config for ${repopath}: ${e.message}`);
10902
+ }
10903
+ if (res)
10904
+ return res;
10905
+ try {
10906
+ res = await this.loadConfigAsync(repopath, "main");
10907
+ }
10908
+ catch (e) {
10909
+ error = e;
10910
+ pxt.log(`Error loading default main config for ${repopath}: ${e.message}`);
10911
+ }
10912
+ if (res)
10913
+ return res;
10914
+ else
10915
+ throw error;
10895
10916
  }
10896
10917
  // cache lookup
10897
10918
  const key = `${repopath}/${tag}`;
@@ -10925,8 +10946,29 @@ var pxt;
10925
10946
  }
10926
10947
  async loadPackageAsync(repopath, tag, fallbackPackageFiles) {
10927
10948
  if (!tag) {
10928
- pxt.debug(`load pkg: default to master branch`);
10929
- tag = "master";
10949
+ pxt.debug(`load pkg: no tag specified, try master and main`);
10950
+ let res;
10951
+ let error;
10952
+ try {
10953
+ res = await this.loadPackageAsync(repopath, "master", fallbackPackageFiles);
10954
+ }
10955
+ catch (e) {
10956
+ error = e;
10957
+ pxt.log(`Error loading default master package for ${repopath}: ${e.message}`);
10958
+ }
10959
+ if (res)
10960
+ return res;
10961
+ try {
10962
+ res = await this.loadPackageAsync(repopath, "main", fallbackPackageFiles);
10963
+ }
10964
+ catch (e) {
10965
+ error = e;
10966
+ pxt.log(`Error loading default main package for ${repopath}: ${e.message}`);
10967
+ }
10968
+ if (res)
10969
+ return res;
10970
+ else
10971
+ throw error;
10930
10972
  }
10931
10973
  // try using github proxy first
10932
10974
  if (hasProxy()) {
@@ -11212,16 +11254,27 @@ var pxt;
11212
11254
  });
11213
11255
  }
11214
11256
  github.mergeAsync = mergeAsync;
11215
- function getRefAsync(repopath, branch) {
11216
- branch = branch || "master";
11217
- return ghGetJsonAsync("https://api.github.com/repos/" + repopath + "/git/refs/heads/" + branch)
11218
- .then(resolveRefAsync)
11219
- .catch(err => {
11220
- if (err.statusCode == 404)
11257
+ async function getRefAsync(repopath, branch) {
11258
+ if (!branch) {
11259
+ // try master and main
11260
+ let res = await getRefAsync(repopath, "master");
11261
+ if (!res)
11262
+ res = await getRefAsync(repopath, "main");
11263
+ return res;
11264
+ }
11265
+ try {
11266
+ const ref = await ghGetJsonAsync("https://api.github.com/repos/" + repopath + "/git/refs/heads/" + branch);
11267
+ return resolveRefAsync(ref);
11268
+ }
11269
+ catch (e) {
11270
+ pxt.debug(`Error fetching ref for ${repopath} branch ${branch}: ${e.message}`);
11271
+ if (e.statusCode === 404) {
11221
11272
  return undefined;
11222
- else
11223
- Promise.reject(err);
11224
- });
11273
+ }
11274
+ else {
11275
+ throw e;
11276
+ }
11277
+ }
11225
11278
  }
11226
11279
  github.getRefAsync = getRefAsync;
11227
11280
  function generateNextRefName(res, pref) {
@@ -15807,7 +15860,7 @@ var pxt;
15807
15860
  }]
15808
15861
  },
15809
15862
  {
15810
- name: lf("booming kick"),
15863
+ name: lf("boom kick"),
15811
15864
  startFrequency: 100,
15812
15865
  startVolume: 1024,
15813
15866
  steps: [{
@@ -21312,10 +21365,12 @@ var pxt;
21312
21365
  * @param skipIDs string[] a list of string ids (block id, asset id, or file name) to ignore
21313
21366
  **/
21314
21367
  isAssetUsed(asset, files, skipIDs) {
21315
- var _a, _b, _c;
21316
- let blockIds = ((_b = (_a = asset.meta) === null || _a === void 0 ? void 0 : _a.blockIDs) === null || _b === void 0 ? void 0 : _b.filter(id => !skipIDs || (skipIDs === null || skipIDs === void 0 ? void 0 : skipIDs.indexOf(id)) < 0)) || [];
21317
- if (blockIds.length > 0)
21318
- return true;
21368
+ var _a, _b, _c, _d, _e;
21369
+ if (!((_a = asset.meta) === null || _a === void 0 ? void 0 : _a.displayName) || !files) {
21370
+ let blockIds = ((_c = (_b = asset.meta) === null || _b === void 0 ? void 0 : _b.blockIDs) === null || _c === void 0 ? void 0 : _c.filter(id => !skipIDs || (skipIDs === null || skipIDs === void 0 ? void 0 : skipIDs.indexOf(id)) < 0)) || [];
21371
+ if (blockIds.length > 0)
21372
+ return true;
21373
+ }
21319
21374
  if (asset.type == "tile" /* pxt.AssetType.Tile */) {
21320
21375
  for (const tm of this.getAssets("tilemap" /* AssetType.Tilemap */)) {
21321
21376
  if ((skipIDs === null || skipIDs === void 0 ? void 0 : skipIDs.indexOf(tm.id)) >= 0) {
@@ -21327,84 +21382,83 @@ var pxt;
21327
21382
  }
21328
21383
  }
21329
21384
  if (files) {
21330
- const shortId = pxt.Util.escapeForRegex(getShortIDForAsset(asset));
21331
- const displayName = pxt.Util.escapeForRegex((_c = asset.meta) === null || _c === void 0 ? void 0 : _c.displayName) || "";
21332
- let assetTsRefs;
21333
- switch (asset.type) {
21334
- case "tile" /* pxt.AssetType.Tile */:
21335
- assetTsRefs = `myTiles.${shortId}|assets.tile\`${shortId}\``;
21336
- if (displayName)
21337
- assetTsRefs += `|assets.tile\`${displayName}\``;
21338
- break;
21339
- case "tilemap" /* pxt.AssetType.Tilemap */:
21340
- assetTsRefs = `tilemap\`${shortId}\``;
21341
- break;
21342
- case "animation" /* pxt.AssetType.Animation */:
21343
- assetTsRefs = `assets.animation\`${shortId}\``;
21344
- if (displayName)
21345
- assetTsRefs += `|assets.animation\`${displayName}\``;
21346
- break;
21347
- case "song" /* pxt.AssetType.Song */:
21348
- assetTsRefs = `assets.song\`${shortId}\``;
21349
- if (displayName)
21350
- assetTsRefs += `|assets.song\`${displayName}\``;
21351
- break;
21352
- case "json" /* pxt.AssetType.Json */:
21353
- assetTsRefs = `assets.json\`${shortId}\``;
21354
- if (displayName)
21355
- assetTsRefs += `|assets.json\`${displayName}\``;
21356
- break;
21357
- default:
21358
- assetTsRefs = `assets.image\`${shortId}\``;
21359
- if (displayName)
21360
- assetTsRefs += `|assets.image\`${displayName}\``;
21361
- break;
21385
+ const config = pxt.U.jsonTryParse((_d = files["pxt.json"]) === null || _d === void 0 ? void 0 : _d.content);
21386
+ const filesToCheck = [];
21387
+ if (config === null || config === void 0 ? void 0 : config.files) {
21388
+ for (const file of config.files) {
21389
+ if (file.endsWith(".g.ts"))
21390
+ continue;
21391
+ if (skipIDs && (skipIDs.indexOf(file) !== -1))
21392
+ continue;
21393
+ if (file.endsWith(".ts") && file !== pxt.MAIN_TS || file.endsWith(".py") && file !== pxt.MAIN_PY) {
21394
+ filesToCheck.push(file);
21395
+ }
21396
+ }
21397
+ }
21398
+ if ((config === null || config === void 0 ? void 0 : config.preferredEditor) === pxt.BLOCKS_PROJECT_NAME) {
21399
+ filesToCheck.push(pxt.MAIN_BLOCKS);
21362
21400
  }
21363
- const assetTsRegex = new RegExp(assetTsRefs, "gm");
21364
- let assetPyRefs;
21401
+ else if ((config === null || config === void 0 ? void 0 : config.preferredEditor) === pxt.JAVASCRIPT_PROJECT_NAME) {
21402
+ filesToCheck.push(pxt.MAIN_TS);
21403
+ }
21404
+ else if ((config === null || config === void 0 ? void 0 : config.preferredEditor) === pxt.PYTHON_PROJECT_NAME) {
21405
+ filesToCheck.push(pxt.MAIN_PY);
21406
+ }
21407
+ const references = [];
21408
+ const shortId = pxt.Util.escapeForRegex(getShortIDForAsset(asset));
21409
+ const displayName = pxt.Util.escapeForRegex((_e = asset.meta) === null || _e === void 0 ? void 0 : _e.displayName) || "";
21410
+ const addNamespaceReference = (namespace, fun, id) => {
21411
+ references.push(`${namespace}\\s*\\.\\s*${fun}\`\\s*${id}\\s*\``);
21412
+ };
21365
21413
  switch (asset.type) {
21366
21414
  case "tile" /* pxt.AssetType.Tile */:
21367
- assetPyRefs = `myTiles.${shortId}|assets.tile\("""${shortId}"""\)`;
21415
+ references.push(`myTiles\\s*\\.\\s*${shortId}\\s*`);
21416
+ addNamespaceReference("assets", "tile", shortId);
21368
21417
  if (displayName)
21369
- assetPyRefs += `|assets.tile\("""${displayName}"""\)`;
21418
+ addNamespaceReference("assets", "tile", displayName);
21370
21419
  break;
21371
21420
  case "tilemap" /* pxt.AssetType.Tilemap */:
21372
- assetPyRefs = `assets.tilemap\("""${shortId}"""\)`;
21421
+ references.push(`tilemap\`\\s*${shortId}\\s*\``);
21422
+ addNamespaceReference("assets", "tilemap", shortId);
21423
+ if (displayName) {
21424
+ references.push(`tilemap\`\\s*${displayName}\\s*\``);
21425
+ addNamespaceReference("assets", "tilemap", displayName);
21426
+ }
21373
21427
  break;
21374
21428
  case "animation" /* pxt.AssetType.Animation */:
21375
- assetPyRefs = `assets.animation\("""${shortId}"""\)`;
21429
+ addNamespaceReference("assets", "animation", shortId);
21376
21430
  if (displayName)
21377
- assetPyRefs += `|assets.animation\("""${displayName}"""\)`;
21431
+ addNamespaceReference("assets", "animation", displayName);
21378
21432
  break;
21379
21433
  case "song" /* pxt.AssetType.Song */:
21380
- assetPyRefs = `assets.song\("""${shortId}"""\)`;
21434
+ addNamespaceReference("assets", "song", shortId);
21381
21435
  if (displayName)
21382
- assetPyRefs += `|assets.song\("""${displayName}"""\)`;
21436
+ addNamespaceReference("assets", "song", displayName);
21383
21437
  break;
21384
21438
  case "json" /* pxt.AssetType.Json */:
21385
- assetPyRefs = `assets.json\("""${shortId}"""\)`;
21439
+ addNamespaceReference("assets", "json", shortId);
21386
21440
  if (displayName)
21387
- assetPyRefs += `|assets.json\("""${displayName}"""\)`;
21441
+ addNamespaceReference("assets", "json", displayName);
21388
21442
  break;
21389
21443
  default:
21390
- assetPyRefs = `assets.image\("""${shortId}"""\)`;
21444
+ addNamespaceReference("assets", "image", shortId);
21391
21445
  if (displayName)
21392
- assetPyRefs += `|assets.image\("""${displayName}"""\)`;
21446
+ addNamespaceReference("assets", "image", displayName);
21393
21447
  break;
21394
21448
  }
21395
- const assetPyRegex = new RegExp(assetPyRefs, "gm");
21396
- for (let filename of Object.keys(files)) {
21397
- if ((skipIDs === null || skipIDs === void 0 ? void 0 : skipIDs.indexOf(filename)) >= 0)
21398
- continue;
21399
- const f = files[filename];
21400
- // Match .ts files that are not generated (.g.ts)
21401
- if (filename.match(/((?!\.g).{2}|^.{0,1})\.ts$/i)) {
21402
- if (f.content.match(assetTsRegex))
21449
+ const regex = new RegExp(references.map(r => `(?:${r})`).join("|"));
21450
+ const pyRegex = new RegExp(references.map(r => `(?:${r})`).join("|").replace(/`/g, '"""'));
21451
+ for (const file of filesToCheck) {
21452
+ const content = files[file].content;
21453
+ if (file.endsWith(".py")) {
21454
+ if (pyRegex.test(content)) {
21403
21455
  return true;
21456
+ }
21404
21457
  }
21405
- else if (filename.endsWith(".py")) {
21406
- if (f.content.match(assetPyRegex))
21458
+ else {
21459
+ if (regex.test(content)) {
21407
21460
  return true;
21461
+ }
21408
21462
  }
21409
21463
  }
21410
21464
  }
@@ -0,0 +1,6 @@
1
+ import { DropdownProps } from "./Dropdown";
2
+ interface DropdownModalProps extends DropdownProps {
3
+ onClose: () => void;
4
+ }
5
+ export declare const DropdownModal: (props: DropdownModalProps) => JSX.Element;
6
+ export {};
@@ -4,7 +4,7 @@ export interface InputProps extends ControlProps {
4
4
  inputClassName?: string;
5
5
  groupClassName?: string;
6
6
  initialValue?: string;
7
- label?: string;
7
+ label?: string | JSX.Element;
8
8
  title?: string;
9
9
  placeholder?: string;
10
10
  icon?: string;