pxt-core 8.2.7 → 8.2.8

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
@@ -117004,6 +117004,7 @@ var pxt;
117004
117004
  diffify(steps, activities);
117005
117005
  }
117006
117006
  const assetFiles = parseAssetJson(assetJson);
117007
+ const globalBlockConfig = parseTutorialBlockConfig("global", tutorialmd);
117007
117008
  // strip hidden snippets
117008
117009
  steps.forEach(step => {
117009
117010
  step.contentMd = stripHiddenSnippets(step.contentMd);
@@ -117023,7 +117024,8 @@ var pxt;
117023
117024
  jres,
117024
117025
  assetFiles,
117025
117026
  customTs,
117026
- tutorialValidationRules
117027
+ tutorialValidationRules,
117028
+ globalBlockConfig
117027
117029
  };
117028
117030
  }
117029
117031
  tutorial.parseTutorial = parseTutorial;
@@ -117050,6 +117052,8 @@ var pxt;
117050
117052
  switch (m1) {
117051
117053
  case "block":
117052
117054
  case "blocks":
117055
+ case "blockconfig.local":
117056
+ case "blockconfig.global":
117053
117057
  case "requiredTutorialBlock":
117054
117058
  case "filterblocks":
117055
117059
  if (!checkTutorialEditor(pxt.BLOCKS_PROJECT_NAME))
@@ -117202,6 +117206,7 @@ ${code}
117202
117206
  markdown.replace(stepRegex, function (match, flags, step) {
117203
117207
  step = step.trim();
117204
117208
  let { header, hint, requiredBlocks } = parseTutorialHint(step, metadata && metadata.explicitHints, metadata.tutorialCodeValidation);
117209
+ const blockConfig = parseTutorialBlockConfig("local", step);
117205
117210
  // if title is not hidden ("{TITLE HERE}"), strip flags
117206
117211
  const title = !flags.match(/^\{.*\}$/)
117207
117212
  ? flags.replace(/@(fullscreen|unplugged|showdialog|showhint|tutorialCompleted|resetDiff)/gi, "").trim()
@@ -117209,7 +117214,8 @@ ${code}
117209
117214
  let info = {
117210
117215
  title,
117211
117216
  contentMd: step,
117212
- headerContentMd: header
117217
+ headerContentMd: header,
117218
+ localBlockConfig: blockConfig
117213
117219
  };
117214
117220
  if (/@(fullscreen|unplugged|showdialog|showhint)/i.test(flags))
117215
117221
  info.showHint = true;
@@ -117264,6 +117270,18 @@ ${code}
117264
117270
  }
117265
117271
  return { header, hint, requiredBlocks };
117266
117272
  }
117273
+ function parseTutorialBlockConfig(scope, content) {
117274
+ let blockConfig = {
117275
+ md: "",
117276
+ blocks: [],
117277
+ };
117278
+ const regex = new RegExp(`\`\`\`\\s*blockconfig\\.${scope}\\s*\\n([\\s\\S]*?)\\n\`\`\``, "gmi");
117279
+ content.replace(regex, (m0, m1) => {
117280
+ blockConfig.md += `${m1}\n`;
117281
+ return "";
117282
+ });
117283
+ return blockConfig;
117284
+ }
117267
117285
  function categorizingValidationRules(listOfRules, title) {
117268
117286
  const ruleNames = Object.keys(listOfRules);
117269
117287
  for (let i = 0; i < ruleNames.length; i++) {
@@ -117279,7 +117297,7 @@ ${code}
117279
117297
  function stripHiddenSnippets(str) {
117280
117298
  if (!str)
117281
117299
  return str;
117282
- const hiddenSnippetRegex = /```(filterblocks|package|ghost|config|template|jres|assetjson|customts)\s*\n([\s\S]*?)\n```/gmi;
117300
+ const hiddenSnippetRegex = /```(filterblocks|package|ghost|config|template|jres|assetjson|customts|blockconfig\.local|blockconfig\.global)\s*\n([\s\S]*?)\n```/gmi;
117283
117301
  return str.replace(hiddenSnippetRegex, '').trim();
117284
117302
  }
117285
117303
  /*
@@ -117361,7 +117379,8 @@ ${code}
117361
117379
  jres: tutorialInfo.jres,
117362
117380
  assetFiles: tutorialInfo.assetFiles,
117363
117381
  customTs: tutorialInfo.customTs,
117364
- tutorialValidationRules: tutorialInfo.tutorialValidationRules
117382
+ tutorialValidationRules: tutorialInfo.tutorialValidationRules,
117383
+ globalBlockConfig: tutorialInfo.globalBlockConfig
117365
117384
  };
117366
117385
  return { options: tutorialOptions, editor: tutorialInfo.editor };
117367
117386
  }
@@ -127519,7 +127538,7 @@ ${output}</xml>`;
127519
127538
  if (alias) {
127520
127539
  info.decompilerBlockAlias = env.aliasBlocks[info.qName];
127521
127540
  }
127522
- else {
127541
+ else if (!env.opts.snippetMode) {
127523
127542
  return pxtc.Util.lf("No output expressions as statements");
127524
127543
  }
127525
127544
  }
@@ -135078,7 +135097,7 @@ var ts;
135078
135097
  snippetMode: opts.snippetMode || false,
135079
135098
  alwaysEmitOnStart: opts.alwaysDecompileOnStart,
135080
135099
  includeGreyBlockMessages,
135081
- generateSourceMap: !!opts.ast,
135100
+ generateSourceMap: opts.generateSourceMap !== undefined ? opts.generateSourceMap : !!opts.ast,
135082
135101
  allowedArgumentTypes: opts.allowedArgumentTypes || ["number", "boolean", "string"],
135083
135102
  errorOnGreyBlocks: !!opts.errorOnGreyBlocks
135084
135103
  };
@@ -135096,7 +135115,7 @@ var ts;
135096
135115
  snippetMode: opts.snippetMode || false,
135097
135116
  alwaysEmitOnStart: opts.alwaysDecompileOnStart,
135098
135117
  includeGreyBlockMessages,
135099
- generateSourceMap: !!opts.ast,
135118
+ generateSourceMap: opts.generateSourceMap !== undefined ? opts.generateSourceMap : !!opts.ast,
135100
135119
  allowedArgumentTypes: opts.allowedArgumentTypes || ["number", "boolean", "string"],
135101
135120
  errorOnGreyBlocks: !!opts.errorOnGreyBlocks
135102
135121
  };
@@ -13485,7 +13485,7 @@ var pxtblockly;
13485
13485
  return function () {
13486
13486
  const res = [];
13487
13487
  const that = this;
13488
- if (that.sourceBlock_ && that.sourceBlock_.workspace) {
13488
+ if (that.sourceBlock_ && that.sourceBlock_.workspace && !that.sourceBlock_.isInFlyout) {
13489
13489
  const options = that.sourceBlock_.workspace.getVariablesOfType(kindType(opts.name));
13490
13490
  options.forEach(model => {
13491
13491
  res.push([model.name, model.name]);
@@ -9923,7 +9923,7 @@ var pxtblockly;
9923
9923
  return function () {
9924
9924
  const res = [];
9925
9925
  const that = this;
9926
- if (that.sourceBlock_ && that.sourceBlock_.workspace) {
9926
+ if (that.sourceBlock_ && that.sourceBlock_.workspace && !that.sourceBlock_.isInFlyout) {
9927
9927
  const options = that.sourceBlock_.workspace.getVariablesOfType(kindType(opts.name));
9928
9928
  options.forEach(model => {
9929
9929
  res.push([model.name, model.name]);
@@ -6258,7 +6258,7 @@ ${output}</xml>`;
6258
6258
  if (alias) {
6259
6259
  info.decompilerBlockAlias = env.aliasBlocks[info.qName];
6260
6260
  }
6261
- else {
6261
+ else if (!env.opts.snippetMode) {
6262
6262
  return pxtc.Util.lf("No output expressions as statements");
6263
6263
  }
6264
6264
  }
@@ -13817,7 +13817,7 @@ var ts;
13817
13817
  snippetMode: opts.snippetMode || false,
13818
13818
  alwaysEmitOnStart: opts.alwaysDecompileOnStart,
13819
13819
  includeGreyBlockMessages,
13820
- generateSourceMap: !!opts.ast,
13820
+ generateSourceMap: opts.generateSourceMap !== undefined ? opts.generateSourceMap : !!opts.ast,
13821
13821
  allowedArgumentTypes: opts.allowedArgumentTypes || ["number", "boolean", "string"],
13822
13822
  errorOnGreyBlocks: !!opts.errorOnGreyBlocks
13823
13823
  };
@@ -13835,7 +13835,7 @@ var ts;
13835
13835
  snippetMode: opts.snippetMode || false,
13836
13836
  alwaysEmitOnStart: opts.alwaysDecompileOnStart,
13837
13837
  includeGreyBlockMessages,
13838
- generateSourceMap: !!opts.ast,
13838
+ generateSourceMap: opts.generateSourceMap !== undefined ? opts.generateSourceMap : !!opts.ast,
13839
13839
  allowedArgumentTypes: opts.allowedArgumentTypes || ["number", "boolean", "string"],
13840
13840
  errorOnGreyBlocks: !!opts.errorOnGreyBlocks
13841
13841
  };
package/built/pxtlib.js CHANGED
@@ -19318,6 +19318,7 @@ var pxt;
19318
19318
  diffify(steps, activities);
19319
19319
  }
19320
19320
  const assetFiles = parseAssetJson(assetJson);
19321
+ const globalBlockConfig = parseTutorialBlockConfig("global", tutorialmd);
19321
19322
  // strip hidden snippets
19322
19323
  steps.forEach(step => {
19323
19324
  step.contentMd = stripHiddenSnippets(step.contentMd);
@@ -19337,7 +19338,8 @@ var pxt;
19337
19338
  jres,
19338
19339
  assetFiles,
19339
19340
  customTs,
19340
- tutorialValidationRules
19341
+ tutorialValidationRules,
19342
+ globalBlockConfig
19341
19343
  };
19342
19344
  }
19343
19345
  tutorial.parseTutorial = parseTutorial;
@@ -19364,6 +19366,8 @@ var pxt;
19364
19366
  switch (m1) {
19365
19367
  case "block":
19366
19368
  case "blocks":
19369
+ case "blockconfig.local":
19370
+ case "blockconfig.global":
19367
19371
  case "requiredTutorialBlock":
19368
19372
  case "filterblocks":
19369
19373
  if (!checkTutorialEditor(pxt.BLOCKS_PROJECT_NAME))
@@ -19516,6 +19520,7 @@ ${code}
19516
19520
  markdown.replace(stepRegex, function (match, flags, step) {
19517
19521
  step = step.trim();
19518
19522
  let { header, hint, requiredBlocks } = parseTutorialHint(step, metadata && metadata.explicitHints, metadata.tutorialCodeValidation);
19523
+ const blockConfig = parseTutorialBlockConfig("local", step);
19519
19524
  // if title is not hidden ("{TITLE HERE}"), strip flags
19520
19525
  const title = !flags.match(/^\{.*\}$/)
19521
19526
  ? flags.replace(/@(fullscreen|unplugged|showdialog|showhint|tutorialCompleted|resetDiff)/gi, "").trim()
@@ -19523,7 +19528,8 @@ ${code}
19523
19528
  let info = {
19524
19529
  title,
19525
19530
  contentMd: step,
19526
- headerContentMd: header
19531
+ headerContentMd: header,
19532
+ localBlockConfig: blockConfig
19527
19533
  };
19528
19534
  if (/@(fullscreen|unplugged|showdialog|showhint)/i.test(flags))
19529
19535
  info.showHint = true;
@@ -19578,6 +19584,18 @@ ${code}
19578
19584
  }
19579
19585
  return { header, hint, requiredBlocks };
19580
19586
  }
19587
+ function parseTutorialBlockConfig(scope, content) {
19588
+ let blockConfig = {
19589
+ md: "",
19590
+ blocks: [],
19591
+ };
19592
+ const regex = new RegExp(`\`\`\`\\s*blockconfig\\.${scope}\\s*\\n([\\s\\S]*?)\\n\`\`\``, "gmi");
19593
+ content.replace(regex, (m0, m1) => {
19594
+ blockConfig.md += `${m1}\n`;
19595
+ return "";
19596
+ });
19597
+ return blockConfig;
19598
+ }
19581
19599
  function categorizingValidationRules(listOfRules, title) {
19582
19600
  const ruleNames = Object.keys(listOfRules);
19583
19601
  for (let i = 0; i < ruleNames.length; i++) {
@@ -19593,7 +19611,7 @@ ${code}
19593
19611
  function stripHiddenSnippets(str) {
19594
19612
  if (!str)
19595
19613
  return str;
19596
- const hiddenSnippetRegex = /```(filterblocks|package|ghost|config|template|jres|assetjson|customts)\s*\n([\s\S]*?)\n```/gmi;
19614
+ const hiddenSnippetRegex = /```(filterblocks|package|ghost|config|template|jres|assetjson|customts|blockconfig\.local|blockconfig\.global)\s*\n([\s\S]*?)\n```/gmi;
19597
19615
  return str.replace(hiddenSnippetRegex, '').trim();
19598
19616
  }
19599
19617
  /*
@@ -19675,7 +19693,8 @@ ${code}
19675
19693
  jres: tutorialInfo.jres,
19676
19694
  assetFiles: tutorialInfo.assetFiles,
19677
19695
  customTs: tutorialInfo.customTs,
19678
- tutorialValidationRules: tutorialInfo.tutorialValidationRules
19696
+ tutorialValidationRules: tutorialInfo.tutorialValidationRules,
19697
+ globalBlockConfig: tutorialInfo.globalBlockConfig
19679
19698
  };
19680
19699
  return { options: tutorialOptions, editor: tutorialInfo.editor };
19681
19700
  }
@@ -1319,6 +1319,18 @@ var pxt;
1319
1319
  c = c.parent();
1320
1320
  c.remove();
1321
1321
  }
1322
+ function renderBlockConfig(options) {
1323
+ function render(scope) {
1324
+ $(`code.lang-blockconfig.${scope}`).each((i, c) => {
1325
+ let $c = $(c);
1326
+ if (options.snippetReplaceParent)
1327
+ $c = $c.parent();
1328
+ $c.remove();
1329
+ });
1330
+ }
1331
+ render("local");
1332
+ render("global");
1333
+ }
1322
1334
  function renderSims(options) {
1323
1335
  if (!options.simulatorClass)
1324
1336
  return;
@@ -1359,6 +1371,7 @@ var pxt;
1359
1371
  readAssetJson(options);
1360
1372
  renderQueue = [];
1361
1373
  renderGhost(options);
1374
+ renderBlockConfig(options);
1362
1375
  renderSims(options);
1363
1376
  renderTypeScript(options);
1364
1377
  renderDirectPython(options);