pxt-core 7.5.3 → 7.5.6

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 (55) hide show
  1. package/built/cli.js +4 -41
  2. package/built/pxt.js +62 -80
  3. package/built/pxtblockly.js +15 -10
  4. package/built/pxtblocks.js +15 -10
  5. package/built/pxtcompiler.js +3 -0
  6. package/built/pxteditor.d.ts +1 -0
  7. package/built/pxtlib.d.ts +5 -2
  8. package/built/pxtlib.js +55 -39
  9. package/built/target.js +1 -1
  10. package/built/web/authcode/css/main.1cf9dc37.css +2 -0
  11. package/built/web/authcode/js/main.03da4c20.js +2 -0
  12. package/built/web/main.js +1 -1
  13. package/built/web/pxtapp.js +1 -1
  14. package/built/web/pxtasseteditor.js +1 -1
  15. package/built/web/pxtblockly.js +2 -2
  16. package/built/web/pxtblocks.js +1 -1
  17. package/built/web/pxtcompiler.js +1 -1
  18. package/built/web/pxtembed.js +2 -2
  19. package/built/web/pxtlib.js +1 -1
  20. package/built/web/pxtworker.js +1 -1
  21. package/built/web/react-common-authcode.css +206 -4
  22. package/built/web/react-common-skillmap.css +1 -1
  23. package/built/web/rtlreact-common-skillmap.css +1 -1
  24. package/built/web/rtlsemantic.css +1 -1
  25. package/built/web/semantic.css +1 -1
  26. package/built/web/skillmap/css/{main.e0620cee.chunk.css → main.73b22966.chunk.css} +1 -1
  27. package/built/web/skillmap/js/{2.f7cdfd75.chunk.js → 2.3e47a285.chunk.js} +2 -2
  28. package/built/web/skillmap/js/main.2485091f.chunk.js +1 -0
  29. package/docfiles/apptracking.html +1 -1
  30. package/docfiles/tracking.html +1 -1
  31. package/localtypings/projectheader.d.ts +7 -0
  32. package/package.json +3 -1
  33. package/react-common/components/controls/Button.tsx +4 -1
  34. package/react-common/components/controls/EditorToggle.tsx +83 -39
  35. package/react-common/components/controls/FocusList.tsx +120 -0
  36. package/react-common/components/controls/Input.tsx +4 -4
  37. package/react-common/components/controls/Link.tsx +36 -0
  38. package/react-common/components/controls/MenuBar.tsx +5 -95
  39. package/react-common/components/controls/MenuDropdown.tsx +4 -1
  40. package/react-common/components/controls/Textarea.tsx +103 -0
  41. package/react-common/components/share/GifInfo.tsx +63 -0
  42. package/react-common/components/share/GifRecorder.tsx +97 -0
  43. package/react-common/components/share/Share.tsx +51 -0
  44. package/react-common/components/share/ShareInfo.tsx +200 -0
  45. package/react-common/components/share/SocialButton.tsx +53 -0
  46. package/react-common/styles/controls/EditorToggle.less +38 -0
  47. package/react-common/styles/controls/Modal.less +7 -5
  48. package/react-common/styles/controls/Textarea.less +81 -0
  49. package/react-common/styles/react-common-variables.less +12 -0
  50. package/react-common/styles/react-common.less +2 -0
  51. package/react-common/styles/share/share.less +129 -0
  52. package/theme/image-editor/imageEditor.less +1 -0
  53. package/webapp/public/run.html +32 -5
  54. package/webapp/public/skillmap.html +2 -2
  55. package/built/web/skillmap/js/main.f6866fc6.chunk.js +0 -1
package/built/cli.js CHANGED
@@ -186,6 +186,9 @@ class FileGithubDb {
186
186
  return p;
187
187
  });
188
188
  }
189
+ latestVersionAsync(repopath, config) {
190
+ return this.db.latestVersionAsync(repopath, config);
191
+ }
189
192
  loadConfigAsync(repopath, tag) {
190
193
  return this.loadAsync(repopath, tag, "pxt", (r, t) => this.db.loadConfigAsync(r, t));
191
194
  }
@@ -202,46 +205,6 @@ function searchAsync(...query) {
202
205
  }
203
206
  });
204
207
  }
205
- function pkginfoAsync(repopath) {
206
- let parsed = pxt.github.parseRepoId(repopath);
207
- if (!parsed) {
208
- console.log('Unknown repo');
209
- return Promise.resolve();
210
- }
211
- const pkgInfo = (cfg, tag) => {
212
- pxt.log(`name: ${cfg.name}`);
213
- pxt.log(`description: ${cfg.description}`);
214
- if (pxt.appTarget.appTheme)
215
- pxt.log(`shareable url: ${pxt.appTarget.appTheme.embedUrl}#pub:gh/${parsed.fullName}${tag ? "#" + tag : ""}`);
216
- };
217
- return pxt.packagesConfigAsync()
218
- .then(config => {
219
- const status = pxt.github.repoStatus(parsed, config);
220
- pxt.log(`github org: ${parsed.owner}`);
221
- if (parsed.tag)
222
- pxt.log(`github tag: ${parsed.tag}`);
223
- pxt.log(`package status: ${status == pxt.github.GitRepoStatus.Approved ? "approved" : status == pxt.github.GitRepoStatus.Banned ? "banned" : "neutral"}`);
224
- if (parsed.tag)
225
- return pxt.github.downloadPackageAsync(repopath, config)
226
- .then(pkg => {
227
- let cfg = JSON.parse(pkg.files[pxt.CONFIG_NAME]);
228
- pkgInfo(cfg, parsed.tag);
229
- pxt.debug(`size: ${JSON.stringify(pkg.files).length}`);
230
- });
231
- return pxt.github.pkgConfigAsync(parsed.fullName)
232
- .then(cfg => {
233
- pkgInfo(cfg);
234
- return pxt.github.listRefsAsync(repopath)
235
- .then(tags => {
236
- pxt.log("tags: " + tags.join(", "));
237
- return pxt.github.listRefsAsync(repopath, "heads");
238
- })
239
- .then(heads => {
240
- pxt.log("branches: " + heads.join(", "));
241
- });
242
- });
243
- });
244
- }
245
208
  function pokeRepoAsync(parsed) {
246
209
  const repo = parsed.args[0];
247
210
  let data = {
@@ -2833,7 +2796,7 @@ function installPackageNameAsync(packageName) {
2833
2796
  return pxt.packagesConfigAsync()
2834
2797
  .then(config => (parsed.tag ? Promise.resolve(parsed.tag) : pxt.github.latestVersionAsync(parsed.slug, config))
2835
2798
  .then(tag => { parsed.tag = tag; })
2836
- .then(() => pxt.github.pkgConfigAsync(parsed.fullName, parsed.tag))
2799
+ .then(() => pxt.github.pkgConfigAsync(parsed.fullName, parsed.tag, config))
2837
2800
  .then(cfg => mainPkg.loadAsync(true)
2838
2801
  .then(() => {
2839
2802
  let ver = pxt.github.stringifyRepo(parsed);
package/built/pxt.js CHANGED
@@ -107535,6 +107535,7 @@ var pxt;
107535
107535
  github.isOrgAsync = isOrgAsync;
107536
107536
  class MemoryGithubDb {
107537
107537
  constructor() {
107538
+ this.latestVersions = {};
107538
107539
  this.configs = {};
107539
107540
  this.packages = {};
107540
107541
  }
@@ -107557,8 +107558,10 @@ var pxt;
107557
107558
  return pxt.U.clone(cfg);
107558
107559
  }
107559
107560
  async loadConfigAsync(repopath, tag) {
107560
- if (!tag)
107561
+ if (!tag) {
107562
+ pxt.debug(`dep: default to master branch`);
107561
107563
  tag = "master";
107564
+ }
107562
107565
  // cache lookup
107563
107566
  const key = `${repopath}/${tag}`;
107564
107567
  let res = this.configs[key];
@@ -107581,9 +107584,19 @@ var pxt;
107581
107584
  const cfg = await downloadTextAsync(repopath, tag, pxt.CONFIG_NAME);
107582
107585
  return this.cacheConfig(key, cfg);
107583
107586
  }
107587
+ async latestVersionAsync(repopath, config) {
107588
+ let resolved = this.latestVersions[repopath];
107589
+ if (!resolved) {
107590
+ pxt.debug(`dep: resolve latest version of ${repopath}`);
107591
+ this.latestVersions[repopath] = resolved = await pxt.github.latestVersionAsync(repopath, config, true, false);
107592
+ }
107593
+ return resolved;
107594
+ }
107584
107595
  async loadPackageAsync(repopath, tag) {
107585
- if (!tag)
107596
+ if (!tag) {
107597
+ pxt.debug(`load pkg: default to master branch`);
107586
107598
  tag = "master";
107599
+ }
107587
107600
  // try using github proxy first
107588
107601
  if (hasProxy()) {
107589
107602
  try {
@@ -107899,34 +107912,38 @@ var pxt;
107899
107912
  .then(resolveRefAsync, e => ghGetJsonAsync(`https://api.github.com/repos/${parsed.slug}/git/refs/heads/${tag}`)
107900
107913
  .then(resolveRefAsync));
107901
107914
  }
107902
- function pkgConfigAsync(repopath, tag = "master") {
107903
- return github.db.loadConfigAsync(repopath, tag);
107915
+ async function pkgConfigAsync(repopath, tag, config) {
107916
+ if (!tag)
107917
+ tag = await github.db.latestVersionAsync(repopath, config);
107918
+ return await github.db.loadConfigAsync(repopath, tag);
107904
107919
  }
107905
107920
  github.pkgConfigAsync = pkgConfigAsync;
107906
- function downloadPackageAsync(repoWithTag, config) {
107921
+ async function downloadPackageAsync(repoWithTag, config) {
107907
107922
  const p = parseRepoId(repoWithTag);
107908
107923
  if (!p) {
107909
107924
  pxt.log('Unknown GitHub syntax');
107910
- return Promise.resolve(undefined);
107925
+ return undefined;
107911
107926
  }
107912
107927
  if (isRepoBanned(p, config)) {
107913
107928
  pxt.tickEvent("github.download.banned");
107914
107929
  pxt.log('Github repo is banned');
107915
- return Promise.resolve(undefined);
107930
+ return undefined;
107916
107931
  }
107917
- return github.db.loadPackageAsync(p.fullName, p.tag)
107918
- .then(cached => {
107919
- const dv = upgradedDisablesVariants(config, repoWithTag);
107920
- if (dv) {
107921
- const cfg = pxt.Package.parseAndValidConfig(cached.files[pxt.CONFIG_NAME]);
107922
- if (cfg) {
107923
- pxt.log(`auto-disable ${dv.join(",")} due to targetconfig entry for ${repoWithTag}`);
107924
- cfg.disablesVariants = dv;
107925
- cached.files[pxt.CONFIG_NAME] = pxt.Package.stringifyConfig(cfg);
107926
- }
107932
+ // always try to upgrade unbound versions
107933
+ if (!p.tag) {
107934
+ p.tag = await github.db.latestVersionAsync(p.slug, config);
107935
+ }
107936
+ const cached = await github.db.loadPackageAsync(p.fullName, p.tag);
107937
+ const dv = upgradedDisablesVariants(config, repoWithTag);
107938
+ if (dv) {
107939
+ const cfg = pxt.Package.parseAndValidConfig(cached.files[pxt.CONFIG_NAME]);
107940
+ if (cfg) {
107941
+ pxt.log(`auto-disable ${dv.join(",")} due to targetconfig entry for ${repoWithTag}`);
107942
+ cfg.disablesVariants = dv;
107943
+ cached.files[pxt.CONFIG_NAME] = pxt.Package.stringifyConfig(cfg);
107927
107944
  }
107928
- return cached;
107929
- });
107945
+ }
107946
+ return cached;
107930
107947
  }
107931
107948
  github.downloadPackageAsync = downloadPackageAsync;
107932
107949
  async function downloadLatestPackageAsync(repo) {
@@ -107936,7 +107953,7 @@ var pxt;
107936
107953
  const repoWithTag = `${repo.fullName}#${tag}`;
107937
107954
  await pxt.github.downloadPackageAsync(repoWithTag, packageConfig);
107938
107955
  // return config
107939
- const config = await pkgConfigAsync(repo.fullName, tag);
107956
+ const config = await pkgConfigAsync(repo.fullName, tag, packageConfig);
107940
107957
  const version = `github:${repoWithTag}`;
107941
107958
  return { version, config };
107942
107959
  }
@@ -108266,14 +108283,15 @@ var pxt;
108266
108283
  }
108267
108284
  github.isGithubId = isGithubId;
108268
108285
  function stringifyRepo(p) {
108269
- return p ? "github:" + p.fullName.toLowerCase() + "#" + (p.tag || "master") : undefined;
108286
+ return p ? "github:" + p.fullName.toLowerCase() + (p.tag ? `#${p.tag}` : '') : undefined;
108270
108287
  }
108271
108288
  github.stringifyRepo = stringifyRepo;
108272
- function normalizeRepoId(id) {
108289
+ function normalizeRepoId(id, defaultTag) {
108273
108290
  const gid = parseRepoId(id);
108274
108291
  if (!gid)
108275
108292
  return undefined;
108276
- gid.tag = gid.tag || "master";
108293
+ if (!gid.tag && defaultTag)
108294
+ gid.tag = defaultTag;
108277
108295
  return stringifyRepo(gid);
108278
108296
  }
108279
108297
  github.normalizeRepoId = normalizeRepoId;
@@ -111415,22 +111433,20 @@ var pxt;
111415
111433
  && json.dependencies && Object.keys(json.dependencies).every(k => typeof json.dependencies[k] === "string")
111416
111434
  && json;
111417
111435
  }
111418
- static getConfigAsync(pkgTargetVersion, id, fullVers) {
111419
- return Promise.resolve().then(() => {
111420
- if (pxt.github.isGithubId(fullVers)) {
111421
- const repoInfo = pxt.github.parseRepoId(fullVers);
111422
- return pxt.packagesConfigAsync()
111423
- .then(config => pxt.github.repoAsync(repoInfo.fullName, config)) // Make sure repo exists and is whitelisted
111424
- .then(gitRepo => gitRepo ? pxt.github.pkgConfigAsync(repoInfo.fullName, repoInfo.tag) : null);
111425
- }
111426
- else {
111427
- // If it's not from GH, assume it's a bundled package
111428
- // TODO: Add logic for shared packages if we enable that
111429
- const updatedRef = pxt.patching.upgradePackageReference(pkgTargetVersion, id, fullVers);
111430
- const bundledPkg = pxt.appTarget.bundledpkgs[updatedRef];
111431
- return JSON.parse(bundledPkg[pxt.CONFIG_NAME]);
111432
- }
111433
- });
111436
+ static async getConfigAsync(pkgTargetVersion, id, fullVers) {
111437
+ if (pxt.github.isGithubId(fullVers)) {
111438
+ const repoInfo = pxt.github.parseRepoId(fullVers);
111439
+ const packagesConfig = await pxt.packagesConfigAsync();
111440
+ const gitRepo = await pxt.github.repoAsync(repoInfo.fullName, packagesConfig); // Make sure repo exists and is whitelisted
111441
+ return gitRepo ? await pxt.github.pkgConfigAsync(repoInfo.fullName, repoInfo.tag, packagesConfig) : null;
111442
+ }
111443
+ else {
111444
+ // If it's not from GH, assume it's a bundled package
111445
+ // TODO: Add logic for shared packages if we enable that
111446
+ const updatedRef = pxt.patching.upgradePackageReference(pkgTargetVersion, id, fullVers);
111447
+ const bundledPkg = pxt.appTarget.bundledpkgs[updatedRef];
111448
+ return JSON.parse(bundledPkg[pxt.CONFIG_NAME]);
111449
+ }
111434
111450
  }
111435
111451
  static corePackages() {
111436
111452
  const pkgs = pxt.appTarget.bundledpkgs;
@@ -120924,6 +120940,9 @@ var pxt;
120924
120940
  });
120925
120941
  });
120926
120942
  }
120943
+ latestVersionAsync(repopath, config) {
120944
+ return this.db.latestVersionAsync(repopath, config);
120945
+ }
120927
120946
  loadConfigAsync(repopath, tag) {
120928
120947
  return this.loadAsync(repopath, tag, "pxt", (r, t) => this.db.loadConfigAsync(r, t));
120929
120948
  }
@@ -156267,6 +156286,9 @@ class FileGithubDb {
156267
156286
  return p;
156268
156287
  });
156269
156288
  }
156289
+ latestVersionAsync(repopath, config) {
156290
+ return this.db.latestVersionAsync(repopath, config);
156291
+ }
156270
156292
  loadConfigAsync(repopath, tag) {
156271
156293
  return this.loadAsync(repopath, tag, "pxt", (r, t) => this.db.loadConfigAsync(r, t));
156272
156294
  }
@@ -156283,46 +156305,6 @@ function searchAsync(...query) {
156283
156305
  }
156284
156306
  });
156285
156307
  }
156286
- function pkginfoAsync(repopath) {
156287
- let parsed = pxt.github.parseRepoId(repopath);
156288
- if (!parsed) {
156289
- console.log('Unknown repo');
156290
- return Promise.resolve();
156291
- }
156292
- const pkgInfo = (cfg, tag) => {
156293
- pxt.log(`name: ${cfg.name}`);
156294
- pxt.log(`description: ${cfg.description}`);
156295
- if (pxt.appTarget.appTheme)
156296
- pxt.log(`shareable url: ${pxt.appTarget.appTheme.embedUrl}#pub:gh/${parsed.fullName}${tag ? "#" + tag : ""}`);
156297
- };
156298
- return pxt.packagesConfigAsync()
156299
- .then(config => {
156300
- const status = pxt.github.repoStatus(parsed, config);
156301
- pxt.log(`github org: ${parsed.owner}`);
156302
- if (parsed.tag)
156303
- pxt.log(`github tag: ${parsed.tag}`);
156304
- pxt.log(`package status: ${status == pxt.github.GitRepoStatus.Approved ? "approved" : status == pxt.github.GitRepoStatus.Banned ? "banned" : "neutral"}`);
156305
- if (parsed.tag)
156306
- return pxt.github.downloadPackageAsync(repopath, config)
156307
- .then(pkg => {
156308
- let cfg = JSON.parse(pkg.files[pxt.CONFIG_NAME]);
156309
- pkgInfo(cfg, parsed.tag);
156310
- pxt.debug(`size: ${JSON.stringify(pkg.files).length}`);
156311
- });
156312
- return pxt.github.pkgConfigAsync(parsed.fullName)
156313
- .then(cfg => {
156314
- pkgInfo(cfg);
156315
- return pxt.github.listRefsAsync(repopath)
156316
- .then(tags => {
156317
- pxt.log("tags: " + tags.join(", "));
156318
- return pxt.github.listRefsAsync(repopath, "heads");
156319
- })
156320
- .then(heads => {
156321
- pxt.log("branches: " + heads.join(", "));
156322
- });
156323
- });
156324
- });
156325
- }
156326
156308
  function pokeRepoAsync(parsed) {
156327
156309
  const repo = parsed.args[0];
156328
156310
  let data = {
@@ -158914,7 +158896,7 @@ function installPackageNameAsync(packageName) {
158914
158896
  return pxt.packagesConfigAsync()
158915
158897
  .then(config => (parsed.tag ? Promise.resolve(parsed.tag) : pxt.github.latestVersionAsync(parsed.slug, config))
158916
158898
  .then(tag => { parsed.tag = tag; })
158917
- .then(() => pxt.github.pkgConfigAsync(parsed.fullName, parsed.tag))
158899
+ .then(() => pxt.github.pkgConfigAsync(parsed.fullName, parsed.tag, config))
158918
158900
  .then(cfg => mainPkg.loadAsync(true)
158919
158901
  .then(() => {
158920
158902
  let ver = pxt.github.stringifyRepo(parsed);
@@ -9041,10 +9041,13 @@ var pxt;
9041
9041
  }
9042
9042
  }
9043
9043
  xmlList[xmlList.length - 1].setAttribute('gap', '24');
9044
- if (Blockly.Blocks['variables_set']) {
9045
- let gap = Blockly.Blocks['variables_change'] ? 8 : 24;
9044
+ if (Blockly.Blocks['variables_change'] || Blockly.Blocks['variables_set']) {
9045
+ xmlList.unshift(createFlyoutGroupLabel("Your Variables"));
9046
+ }
9047
+ if (Blockly.Blocks['variables_change']) {
9048
+ let gap = Blockly.Blocks['variables_get'] ? 20 : 8;
9046
9049
  let blockText = '<xml>' +
9047
- '<block type="variables_set" gap="' + gap + '">' +
9050
+ '<block type="variables_change" gap="' + gap + '">' +
9048
9051
  Blockly.Variables.generateVariableFieldXmlString(mostRecentVariable) +
9049
9052
  '</block>' +
9050
9053
  '</xml>';
@@ -9057,16 +9060,16 @@ var pxt;
9057
9060
  value.appendChild(shadow);
9058
9061
  let field = goog.dom.createDom('field');
9059
9062
  field.setAttribute('name', 'NUM');
9060
- field.appendChild(document.createTextNode("0"));
9063
+ field.appendChild(document.createTextNode("1"));
9061
9064
  shadow.appendChild(field);
9062
9065
  block.appendChild(value);
9063
9066
  }
9064
- xmlList.push(block);
9067
+ xmlList.unshift(block);
9065
9068
  }
9066
- if (Blockly.Blocks['variables_change']) {
9067
- let gap = Blockly.Blocks['variables_get'] ? 20 : 8;
9069
+ if (Blockly.Blocks['variables_set']) {
9070
+ let gap = Blockly.Blocks['variables_change'] ? 8 : 24;
9068
9071
  let blockText = '<xml>' +
9069
- '<block type="variables_change" gap="' + gap + '">' +
9072
+ '<block type="variables_set" gap="' + gap + '">' +
9070
9073
  Blockly.Variables.generateVariableFieldXmlString(mostRecentVariable) +
9071
9074
  '</block>' +
9072
9075
  '</xml>';
@@ -9079,11 +9082,11 @@ var pxt;
9079
9082
  value.appendChild(shadow);
9080
9083
  let field = goog.dom.createDom('field');
9081
9084
  field.setAttribute('name', 'NUM');
9082
- field.appendChild(document.createTextNode("1"));
9085
+ field.appendChild(document.createTextNode("0"));
9083
9086
  shadow.appendChild(field);
9084
9087
  block.appendChild(value);
9085
9088
  }
9086
- xmlList.push(block);
9089
+ xmlList.unshift(block);
9087
9090
  }
9088
9091
  }
9089
9092
  return xmlList;
@@ -9475,6 +9478,8 @@ var pxt;
9475
9478
  const elems = oldFlyout(workspace);
9476
9479
  if (elems.length > 1) {
9477
9480
  let returnBlock = mkReturnStatementBlock();
9481
+ // Add divider
9482
+ elems.splice(1, 0, createFlyoutGroupLabel("Your Functions"));
9478
9483
  // Insert after the "make a function" button
9479
9484
  elems.splice(1, 0, returnBlock);
9480
9485
  }
@@ -5479,10 +5479,13 @@ var pxt;
5479
5479
  }
5480
5480
  }
5481
5481
  xmlList[xmlList.length - 1].setAttribute('gap', '24');
5482
- if (Blockly.Blocks['variables_set']) {
5483
- let gap = Blockly.Blocks['variables_change'] ? 8 : 24;
5482
+ if (Blockly.Blocks['variables_change'] || Blockly.Blocks['variables_set']) {
5483
+ xmlList.unshift(createFlyoutGroupLabel("Your Variables"));
5484
+ }
5485
+ if (Blockly.Blocks['variables_change']) {
5486
+ let gap = Blockly.Blocks['variables_get'] ? 20 : 8;
5484
5487
  let blockText = '<xml>' +
5485
- '<block type="variables_set" gap="' + gap + '">' +
5488
+ '<block type="variables_change" gap="' + gap + '">' +
5486
5489
  Blockly.Variables.generateVariableFieldXmlString(mostRecentVariable) +
5487
5490
  '</block>' +
5488
5491
  '</xml>';
@@ -5495,16 +5498,16 @@ var pxt;
5495
5498
  value.appendChild(shadow);
5496
5499
  let field = goog.dom.createDom('field');
5497
5500
  field.setAttribute('name', 'NUM');
5498
- field.appendChild(document.createTextNode("0"));
5501
+ field.appendChild(document.createTextNode("1"));
5499
5502
  shadow.appendChild(field);
5500
5503
  block.appendChild(value);
5501
5504
  }
5502
- xmlList.push(block);
5505
+ xmlList.unshift(block);
5503
5506
  }
5504
- if (Blockly.Blocks['variables_change']) {
5505
- let gap = Blockly.Blocks['variables_get'] ? 20 : 8;
5507
+ if (Blockly.Blocks['variables_set']) {
5508
+ let gap = Blockly.Blocks['variables_change'] ? 8 : 24;
5506
5509
  let blockText = '<xml>' +
5507
- '<block type="variables_change" gap="' + gap + '">' +
5510
+ '<block type="variables_set" gap="' + gap + '">' +
5508
5511
  Blockly.Variables.generateVariableFieldXmlString(mostRecentVariable) +
5509
5512
  '</block>' +
5510
5513
  '</xml>';
@@ -5517,11 +5520,11 @@ var pxt;
5517
5520
  value.appendChild(shadow);
5518
5521
  let field = goog.dom.createDom('field');
5519
5522
  field.setAttribute('name', 'NUM');
5520
- field.appendChild(document.createTextNode("1"));
5523
+ field.appendChild(document.createTextNode("0"));
5521
5524
  shadow.appendChild(field);
5522
5525
  block.appendChild(value);
5523
5526
  }
5524
- xmlList.push(block);
5527
+ xmlList.unshift(block);
5525
5528
  }
5526
5529
  }
5527
5530
  return xmlList;
@@ -5913,6 +5916,8 @@ var pxt;
5913
5916
  const elems = oldFlyout(workspace);
5914
5917
  if (elems.length > 1) {
5915
5918
  let returnBlock = mkReturnStatementBlock();
5919
+ // Add divider
5920
+ elems.splice(1, 0, createFlyoutGroupLabel("Your Functions"));
5916
5921
  // Insert after the "make a function" button
5917
5922
  elems.splice(1, 0, returnBlock);
5918
5923
  }
@@ -32,6 +32,9 @@ var pxt;
32
32
  });
33
33
  });
34
34
  }
35
+ latestVersionAsync(repopath, config) {
36
+ return this.db.latestVersionAsync(repopath, config);
37
+ }
35
38
  loadConfigAsync(repopath, tag) {
36
39
  return this.loadAsync(repopath, tag, "pxt", (r, t) => this.db.loadConfigAsync(r, t));
37
40
  }
@@ -243,6 +243,7 @@ declare namespace pxt.editor {
243
243
  setEditorOffset(): void;
244
244
  anonymousPublishAsync(screenshotUri?: string): Promise<string>;
245
245
  anonymousPublishHeaderByIdAsync(headerId: string): Promise<Cloud.JsonScript>;
246
+ persistentPublishAsync(screenshotUri?: string): Promise<string>;
246
247
  startStopSimulator(opts?: SimulatorStartOptions): void;
247
248
  stopSimulator(unload?: boolean, opts?: SimulatorStartOptions): void;
248
249
  restartSimulator(): void;
package/built/pxtlib.d.ts CHANGED
@@ -1217,16 +1217,19 @@ declare namespace pxt.github {
1217
1217
  files: Map<string>;
1218
1218
  }
1219
1219
  interface IGithubDb {
1220
+ latestVersionAsync(repopath: string, config: PackagesConfig): Promise<string>;
1220
1221
  loadConfigAsync(repopath: string, tag: string): Promise<pxt.PackageConfig>;
1221
1222
  loadPackageAsync(repopath: string, tag: string): Promise<CachedPackage>;
1222
1223
  }
1223
1224
  function isOrgAsync(owner: string): Promise<boolean>;
1224
1225
  class MemoryGithubDb implements IGithubDb {
1226
+ private latestVersions;
1225
1227
  private configs;
1226
1228
  private packages;
1227
1229
  private proxyWithCdnLoadPackageAsync;
1228
1230
  private cacheConfig;
1229
1231
  loadConfigAsync(repopath: string, tag: string): Promise<pxt.PackageConfig>;
1232
+ latestVersionAsync(repopath: string, config: PackagesConfig): Promise<string>;
1230
1233
  loadPackageAsync(repopath: string, tag: string): Promise<CachedPackage>;
1231
1234
  private githubLoadPackageAsync;
1232
1235
  }
@@ -1262,7 +1265,7 @@ declare namespace pxt.github {
1262
1265
  function forkRepoAsync(repopath: string, commitid: string, pref?: string): Promise<string>;
1263
1266
  function listRefsAsync(repopath: string, namespace?: string, useProxy?: boolean, noCache?: boolean): Promise<string[]>;
1264
1267
  function listRefsExtAsync(repopath: string, namespace?: string, useProxy?: boolean, noCache?: boolean): Promise<RefsResult>;
1265
- function pkgConfigAsync(repopath: string, tag?: string): Promise<PackageConfig>;
1268
+ function pkgConfigAsync(repopath: string, tag: string, config: pxt.PackagesConfig): Promise<PackageConfig>;
1266
1269
  function downloadPackageAsync(repoWithTag: string, config: pxt.PackagesConfig): Promise<CachedPackage>;
1267
1270
  function downloadLatestPackageAsync(repo: ParsedRepo): Promise<{
1268
1271
  version: string;
@@ -1313,7 +1316,7 @@ declare namespace pxt.github {
1313
1316
  function toGithubDependencyPath(path: string, tag?: string): string;
1314
1317
  function isGithubId(id: string): boolean;
1315
1318
  function stringifyRepo(p: ParsedRepo): string;
1316
- function normalizeRepoId(id: string): string;
1319
+ function normalizeRepoId(id: string, defaultTag?: string): string;
1317
1320
  function join(...parts: string[]): string;
1318
1321
  function upgradedPackageReference(cfg: PackagesConfig, id: string): string;
1319
1322
  function upgradedPackageId(cfg: PackagesConfig, id: string): string;
package/built/pxtlib.js CHANGED
@@ -9849,6 +9849,7 @@ var pxt;
9849
9849
  github.isOrgAsync = isOrgAsync;
9850
9850
  class MemoryGithubDb {
9851
9851
  constructor() {
9852
+ this.latestVersions = {};
9852
9853
  this.configs = {};
9853
9854
  this.packages = {};
9854
9855
  }
@@ -9871,8 +9872,10 @@ var pxt;
9871
9872
  return pxt.U.clone(cfg);
9872
9873
  }
9873
9874
  async loadConfigAsync(repopath, tag) {
9874
- if (!tag)
9875
+ if (!tag) {
9876
+ pxt.debug(`dep: default to master branch`);
9875
9877
  tag = "master";
9878
+ }
9876
9879
  // cache lookup
9877
9880
  const key = `${repopath}/${tag}`;
9878
9881
  let res = this.configs[key];
@@ -9895,9 +9898,19 @@ var pxt;
9895
9898
  const cfg = await downloadTextAsync(repopath, tag, pxt.CONFIG_NAME);
9896
9899
  return this.cacheConfig(key, cfg);
9897
9900
  }
9901
+ async latestVersionAsync(repopath, config) {
9902
+ let resolved = this.latestVersions[repopath];
9903
+ if (!resolved) {
9904
+ pxt.debug(`dep: resolve latest version of ${repopath}`);
9905
+ this.latestVersions[repopath] = resolved = await pxt.github.latestVersionAsync(repopath, config, true, false);
9906
+ }
9907
+ return resolved;
9908
+ }
9898
9909
  async loadPackageAsync(repopath, tag) {
9899
- if (!tag)
9910
+ if (!tag) {
9911
+ pxt.debug(`load pkg: default to master branch`);
9900
9912
  tag = "master";
9913
+ }
9901
9914
  // try using github proxy first
9902
9915
  if (hasProxy()) {
9903
9916
  try {
@@ -10213,34 +10226,38 @@ var pxt;
10213
10226
  .then(resolveRefAsync, e => ghGetJsonAsync(`https://api.github.com/repos/${parsed.slug}/git/refs/heads/${tag}`)
10214
10227
  .then(resolveRefAsync));
10215
10228
  }
10216
- function pkgConfigAsync(repopath, tag = "master") {
10217
- return github.db.loadConfigAsync(repopath, tag);
10229
+ async function pkgConfigAsync(repopath, tag, config) {
10230
+ if (!tag)
10231
+ tag = await github.db.latestVersionAsync(repopath, config);
10232
+ return await github.db.loadConfigAsync(repopath, tag);
10218
10233
  }
10219
10234
  github.pkgConfigAsync = pkgConfigAsync;
10220
- function downloadPackageAsync(repoWithTag, config) {
10235
+ async function downloadPackageAsync(repoWithTag, config) {
10221
10236
  const p = parseRepoId(repoWithTag);
10222
10237
  if (!p) {
10223
10238
  pxt.log('Unknown GitHub syntax');
10224
- return Promise.resolve(undefined);
10239
+ return undefined;
10225
10240
  }
10226
10241
  if (isRepoBanned(p, config)) {
10227
10242
  pxt.tickEvent("github.download.banned");
10228
10243
  pxt.log('Github repo is banned');
10229
- return Promise.resolve(undefined);
10244
+ return undefined;
10230
10245
  }
10231
- return github.db.loadPackageAsync(p.fullName, p.tag)
10232
- .then(cached => {
10233
- const dv = upgradedDisablesVariants(config, repoWithTag);
10234
- if (dv) {
10235
- const cfg = pxt.Package.parseAndValidConfig(cached.files[pxt.CONFIG_NAME]);
10236
- if (cfg) {
10237
- pxt.log(`auto-disable ${dv.join(",")} due to targetconfig entry for ${repoWithTag}`);
10238
- cfg.disablesVariants = dv;
10239
- cached.files[pxt.CONFIG_NAME] = pxt.Package.stringifyConfig(cfg);
10240
- }
10246
+ // always try to upgrade unbound versions
10247
+ if (!p.tag) {
10248
+ p.tag = await github.db.latestVersionAsync(p.slug, config);
10249
+ }
10250
+ const cached = await github.db.loadPackageAsync(p.fullName, p.tag);
10251
+ const dv = upgradedDisablesVariants(config, repoWithTag);
10252
+ if (dv) {
10253
+ const cfg = pxt.Package.parseAndValidConfig(cached.files[pxt.CONFIG_NAME]);
10254
+ if (cfg) {
10255
+ pxt.log(`auto-disable ${dv.join(",")} due to targetconfig entry for ${repoWithTag}`);
10256
+ cfg.disablesVariants = dv;
10257
+ cached.files[pxt.CONFIG_NAME] = pxt.Package.stringifyConfig(cfg);
10241
10258
  }
10242
- return cached;
10243
- });
10259
+ }
10260
+ return cached;
10244
10261
  }
10245
10262
  github.downloadPackageAsync = downloadPackageAsync;
10246
10263
  async function downloadLatestPackageAsync(repo) {
@@ -10250,7 +10267,7 @@ var pxt;
10250
10267
  const repoWithTag = `${repo.fullName}#${tag}`;
10251
10268
  await pxt.github.downloadPackageAsync(repoWithTag, packageConfig);
10252
10269
  // return config
10253
- const config = await pkgConfigAsync(repo.fullName, tag);
10270
+ const config = await pkgConfigAsync(repo.fullName, tag, packageConfig);
10254
10271
  const version = `github:${repoWithTag}`;
10255
10272
  return { version, config };
10256
10273
  }
@@ -10580,14 +10597,15 @@ var pxt;
10580
10597
  }
10581
10598
  github.isGithubId = isGithubId;
10582
10599
  function stringifyRepo(p) {
10583
- return p ? "github:" + p.fullName.toLowerCase() + "#" + (p.tag || "master") : undefined;
10600
+ return p ? "github:" + p.fullName.toLowerCase() + (p.tag ? `#${p.tag}` : '') : undefined;
10584
10601
  }
10585
10602
  github.stringifyRepo = stringifyRepo;
10586
- function normalizeRepoId(id) {
10603
+ function normalizeRepoId(id, defaultTag) {
10587
10604
  const gid = parseRepoId(id);
10588
10605
  if (!gid)
10589
10606
  return undefined;
10590
- gid.tag = gid.tag || "master";
10607
+ if (!gid.tag && defaultTag)
10608
+ gid.tag = defaultTag;
10591
10609
  return stringifyRepo(gid);
10592
10610
  }
10593
10611
  github.normalizeRepoId = normalizeRepoId;
@@ -13729,22 +13747,20 @@ var pxt;
13729
13747
  && json.dependencies && Object.keys(json.dependencies).every(k => typeof json.dependencies[k] === "string")
13730
13748
  && json;
13731
13749
  }
13732
- static getConfigAsync(pkgTargetVersion, id, fullVers) {
13733
- return Promise.resolve().then(() => {
13734
- if (pxt.github.isGithubId(fullVers)) {
13735
- const repoInfo = pxt.github.parseRepoId(fullVers);
13736
- return pxt.packagesConfigAsync()
13737
- .then(config => pxt.github.repoAsync(repoInfo.fullName, config)) // Make sure repo exists and is whitelisted
13738
- .then(gitRepo => gitRepo ? pxt.github.pkgConfigAsync(repoInfo.fullName, repoInfo.tag) : null);
13739
- }
13740
- else {
13741
- // If it's not from GH, assume it's a bundled package
13742
- // TODO: Add logic for shared packages if we enable that
13743
- const updatedRef = pxt.patching.upgradePackageReference(pkgTargetVersion, id, fullVers);
13744
- const bundledPkg = pxt.appTarget.bundledpkgs[updatedRef];
13745
- return JSON.parse(bundledPkg[pxt.CONFIG_NAME]);
13746
- }
13747
- });
13750
+ static async getConfigAsync(pkgTargetVersion, id, fullVers) {
13751
+ if (pxt.github.isGithubId(fullVers)) {
13752
+ const repoInfo = pxt.github.parseRepoId(fullVers);
13753
+ const packagesConfig = await pxt.packagesConfigAsync();
13754
+ const gitRepo = await pxt.github.repoAsync(repoInfo.fullName, packagesConfig); // Make sure repo exists and is whitelisted
13755
+ return gitRepo ? await pxt.github.pkgConfigAsync(repoInfo.fullName, repoInfo.tag, packagesConfig) : null;
13756
+ }
13757
+ else {
13758
+ // If it's not from GH, assume it's a bundled package
13759
+ // TODO: Add logic for shared packages if we enable that
13760
+ const updatedRef = pxt.patching.upgradePackageReference(pkgTargetVersion, id, fullVers);
13761
+ const bundledPkg = pxt.appTarget.bundledpkgs[updatedRef];
13762
+ return JSON.parse(bundledPkg[pxt.CONFIG_NAME]);
13763
+ }
13748
13764
  }
13749
13765
  static corePackages() {
13750
13766
  const pkgs = pxt.appTarget.bundledpkgs;