pxt-core 7.3.7 → 7.4.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.
package/built/cli.js CHANGED
@@ -1768,7 +1768,9 @@ function buildSemanticUIAsync(parsed) {
1768
1768
  // Append icons.css to semantic.css (custom pxt icons)
1769
1769
  const iconsFile = (pkg["name"] == "pxt-core") ? 'built/web/icons.css' : 'node_modules/pxt-core/built/web/icons.css';
1770
1770
  const iconsCss = fs.readFileSync(iconsFile, "utf-8");
1771
- semCss = semCss + "\n" + iconsCss;
1771
+ const reactCommonFile = (pkg["name"] == "pxt-core") ? 'built/web/react-common.css' : 'node_modules/pxt-core/built/web/react-common.css';
1772
+ const reactCommonCss = fs.readFileSync(reactCommonFile, "utf-8");
1773
+ semCss = semCss + "\n" + iconsCss + "\n" + reactCommonCss;
1772
1774
  nodeutil.writeFileSync('built/web/semantic.css', semCss);
1773
1775
  }).then(() => {
1774
1776
  // generate blockly css
@@ -1836,6 +1838,7 @@ function buildSkillMapAsync(parsed) {
1836
1838
  nodeutil.cp("node_modules/pxt-core/built/pxtlib.js", `${skillmapRoot}/public/blb`);
1837
1839
  nodeutil.cp("built/web/semantic.css", `${skillmapRoot}/public/blb`);
1838
1840
  nodeutil.cp("node_modules/pxt-core/built/web/icons.css", `${skillmapRoot}/public/blb`);
1841
+ nodeutil.cp("node_modules/pxt-core/built/web/react-common.css", `${skillmapRoot}/public/blb`);
1839
1842
  // copy 'assets' over from docs/static
1840
1843
  nodeutil.cpR("docs/static/skillmap/assets", `${skillmapRoot}/public/assets`);
1841
1844
  if (docsPath) {
package/built/pxt.js CHANGED
@@ -98356,6 +98356,17 @@ var pxt;
98356
98356
  }
98357
98357
  }
98358
98358
  auth.generateUserProfilePicDataUrl = generateUserProfilePicDataUrl;
98359
+ /**
98360
+ * Checks only the ID and sourceURL
98361
+ */
98362
+ function badgeEquals(badgeA, badgeB) {
98363
+ return badgeA.id === badgeB.id && badgeA.sourceURL === badgeB.sourceURL;
98364
+ }
98365
+ auth.badgeEquals = badgeEquals;
98366
+ function hasBadge(preferences, badge) {
98367
+ return preferences.badges.some(toCheck => badgeEquals(toCheck, badge));
98368
+ }
98369
+ auth.hasBadge = hasBadge;
98359
98370
  })(auth = pxt.auth || (pxt.auth = {}));
98360
98371
  })(pxt || (pxt = {}));
98361
98372
  // Needs to be in its own file to avoid a circular dependency: util.ts -> main.ts -> util.ts
@@ -139048,6 +139059,7 @@ var ts;
139048
139059
  }
139049
139060
  service.snippetAddsDefinitions = snippetAddsDefinitions;
139050
139061
  function getSnippet(context, fn, decl, python, recursionDepth = 0) {
139062
+ var _a;
139051
139063
  // TODO: a lot of this is duplicate logic with blocklyloader.ts:buildBlockFromDef; we should
139052
139064
  // unify these approaches
139053
139065
  let { apis, takenNames, blocksInfo, screenSize, checker } = context;
@@ -139080,10 +139092,15 @@ var ts;
139080
139092
  if (attrs.shim === "TD_ID" && recursionDepth && decl.parameters.length) {
139081
139093
  return getParameterDefault(decl.parameters[0]);
139082
139094
  }
139095
+ const element = fn;
139096
+ const params = pxt.blocks.compileInfo(element);
139083
139097
  const blocksById = blocksInfo.blocksById;
139084
139098
  // TODO: move out of getSnippet for general reuse
139099
+ const blockParameters = ((_a = attrs._def) === null || _a === void 0 ? void 0 : _a.parameters.filter(param => !!params.definitionNameToParam[param.name]).map(param => params.definitionNameToParam[param.name].actualName)) || [];
139085
139100
  const includedParameters = decl.parameters ? decl.parameters
139086
- .filter(param => !param.initializer && !param.questionToken) : [];
139101
+ // Only keep required parameters and parameters included in the blockdef
139102
+ .filter(param => (!param.initializer && !param.questionToken)
139103
+ || (blockParameters.indexOf(param.name.getText()) >= 0)) : [];
139087
139104
  const args = includedParameters
139088
139105
  .map(getParameterDefault)
139089
139106
  .map(p =>
@@ -139093,7 +139110,6 @@ var ts;
139093
139110
  default: p,
139094
139111
  isLiteral: true
139095
139112
  }));
139096
- const element = fn;
139097
139113
  if (element.attributes.block) {
139098
139114
  if (element.attributes.defaultInstance) {
139099
139115
  snippetPrefix = element.attributes.defaultInstance;
@@ -139141,7 +139157,6 @@ var ts;
139141
139157
  isInstance = true;
139142
139158
  }
139143
139159
  else if (element.kind == 1 /* Method */ || element.kind == 2 /* Property */) {
139144
- const params = pxt.blocks.compileInfo(element);
139145
139160
  if (params.thisParameter) {
139146
139161
  let varName = undefined;
139147
139162
  if (params.thisParameter.definitionName) {
@@ -157637,7 +157652,9 @@ function buildSemanticUIAsync(parsed) {
157637
157652
  // Append icons.css to semantic.css (custom pxt icons)
157638
157653
  const iconsFile = (pkg["name"] == "pxt-core") ? 'built/web/icons.css' : 'node_modules/pxt-core/built/web/icons.css';
157639
157654
  const iconsCss = fs.readFileSync(iconsFile, "utf-8");
157640
- semCss = semCss + "\n" + iconsCss;
157655
+ const reactCommonFile = (pkg["name"] == "pxt-core") ? 'built/web/react-common.css' : 'node_modules/pxt-core/built/web/react-common.css';
157656
+ const reactCommonCss = fs.readFileSync(reactCommonFile, "utf-8");
157657
+ semCss = semCss + "\n" + iconsCss + "\n" + reactCommonCss;
157641
157658
  nodeutil.writeFileSync('built/web/semantic.css', semCss);
157642
157659
  }).then(() => {
157643
157660
  // generate blockly css
@@ -157705,6 +157722,7 @@ function buildSkillMapAsync(parsed) {
157705
157722
  nodeutil.cp("node_modules/pxt-core/built/pxtlib.js", `${skillmapRoot}/public/blb`);
157706
157723
  nodeutil.cp("built/web/semantic.css", `${skillmapRoot}/public/blb`);
157707
157724
  nodeutil.cp("node_modules/pxt-core/built/web/icons.css", `${skillmapRoot}/public/blb`);
157725
+ nodeutil.cp("node_modules/pxt-core/built/web/react-common.css", `${skillmapRoot}/public/blb`);
157708
157726
  // copy 'assets' over from docs/static
157709
157727
  nodeutil.cpR("docs/static/skillmap/assets", `${skillmapRoot}/public/assets`);
157710
157728
  if (docsPath) {
@@ -18255,6 +18255,7 @@ var ts;
18255
18255
  }
18256
18256
  service.snippetAddsDefinitions = snippetAddsDefinitions;
18257
18257
  function getSnippet(context, fn, decl, python, recursionDepth = 0) {
18258
+ var _a;
18258
18259
  // TODO: a lot of this is duplicate logic with blocklyloader.ts:buildBlockFromDef; we should
18259
18260
  // unify these approaches
18260
18261
  let { apis, takenNames, blocksInfo, screenSize, checker } = context;
@@ -18287,10 +18288,15 @@ var ts;
18287
18288
  if (attrs.shim === "TD_ID" && recursionDepth && decl.parameters.length) {
18288
18289
  return getParameterDefault(decl.parameters[0]);
18289
18290
  }
18291
+ const element = fn;
18292
+ const params = pxt.blocks.compileInfo(element);
18290
18293
  const blocksById = blocksInfo.blocksById;
18291
18294
  // TODO: move out of getSnippet for general reuse
18295
+ const blockParameters = ((_a = attrs._def) === null || _a === void 0 ? void 0 : _a.parameters.filter(param => !!params.definitionNameToParam[param.name]).map(param => params.definitionNameToParam[param.name].actualName)) || [];
18292
18296
  const includedParameters = decl.parameters ? decl.parameters
18293
- .filter(param => !param.initializer && !param.questionToken) : [];
18297
+ // Only keep required parameters and parameters included in the blockdef
18298
+ .filter(param => (!param.initializer && !param.questionToken)
18299
+ || (blockParameters.indexOf(param.name.getText()) >= 0)) : [];
18294
18300
  const args = includedParameters
18295
18301
  .map(getParameterDefault)
18296
18302
  .map(p =>
@@ -18300,7 +18306,6 @@ var ts;
18300
18306
  default: p,
18301
18307
  isLiteral: true
18302
18308
  }));
18303
- const element = fn;
18304
18309
  if (element.attributes.block) {
18305
18310
  if (element.attributes.defaultInstance) {
18306
18311
  snippetPrefix = element.attributes.defaultInstance;
@@ -18348,7 +18353,6 @@ var ts;
18348
18353
  isInstance = true;
18349
18354
  }
18350
18355
  else if (element.kind == 1 /* Method */ || element.kind == 2 /* Property */) {
18351
- const params = pxt.blocks.compileInfo(element);
18352
18356
  if (params.thisParameter) {
18353
18357
  let varName = undefined;
18354
18358
  if (params.thisParameter.definitionName) {
package/built/pxtlib.d.ts CHANGED
@@ -54,6 +54,9 @@ declare namespace pxt.auth {
54
54
  mapProgress: any;
55
55
  completedTags: any;
56
56
  };
57
+ type UserBadgeState = {
58
+ badges: Badge[];
59
+ };
57
60
  /**
58
61
  * User preference state that should be synced with the cloud.
59
62
  */
@@ -62,6 +65,7 @@ declare namespace pxt.auth {
62
65
  highContrast?: boolean;
63
66
  reader?: string;
64
67
  skillmap?: UserSkillmapState;
68
+ badges?: UserBadgeState;
65
69
  };
66
70
  const DEFAULT_USER_PREFERENCES: () => UserPreferences;
67
71
  /**
@@ -165,6 +169,11 @@ declare namespace pxt.auth {
165
169
  function userName(user: pxt.auth.UserProfile): string;
166
170
  function userInitials(user: pxt.auth.UserProfile): string;
167
171
  function generateUserProfilePicDataUrl(profile: pxt.auth.UserProfile): void;
172
+ /**
173
+ * Checks only the ID and sourceURL
174
+ */
175
+ function badgeEquals(badgeA: pxt.auth.Badge, badgeB: pxt.auth.Badge): boolean;
176
+ function hasBadge(preferences: pxt.auth.UserBadgeState, badge: pxt.auth.Badge): boolean;
168
177
  }
169
178
  declare namespace pxt {
170
179
  interface TelemetryEventOptions {
package/built/pxtlib.js CHANGED
@@ -670,6 +670,17 @@ var pxt;
670
670
  }
671
671
  }
672
672
  auth.generateUserProfilePicDataUrl = generateUserProfilePicDataUrl;
673
+ /**
674
+ * Checks only the ID and sourceURL
675
+ */
676
+ function badgeEquals(badgeA, badgeB) {
677
+ return badgeA.id === badgeB.id && badgeA.sourceURL === badgeB.sourceURL;
678
+ }
679
+ auth.badgeEquals = badgeEquals;
680
+ function hasBadge(preferences, badge) {
681
+ return preferences.badges.some(toCheck => badgeEquals(toCheck, badge));
682
+ }
683
+ auth.hasBadge = hasBadge;
673
684
  })(auth = pxt.auth || (pxt.auth = {}));
674
685
  })(pxt || (pxt = {}));
675
686
  // Needs to be in its own file to avoid a circular dependency: util.ts -> main.ts -> util.ts