pxt-core 8.5.38 → 8.5.39

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
@@ -107133,6 +107133,14 @@ var pxt;
107133
107133
  return {};
107134
107134
  }
107135
107135
  gallery_1.parseTemplateProjectJSON = parseTemplateProjectJSON;
107136
+ function parseSimThemeJSON(md) {
107137
+ const pm = /```simtheme\s+([\s\S]*?)```/i.exec(md);
107138
+ if (pm) {
107139
+ return pxt.tutorial.parseSimThemeJson(pm[1]);
107140
+ }
107141
+ return {};
107142
+ }
107143
+ gallery_1.parseSimThemeJSON = parseSimThemeJSON;
107136
107144
  function parseExampleMarkdown(name, md) {
107137
107145
  if (!md)
107138
107146
  return undefined;
@@ -107144,6 +107152,7 @@ var pxt;
107144
107152
  const source = m[2];
107145
107153
  const features = parseFeaturesFromMarkdown(md);
107146
107154
  const jres = parseJResFromMarkdown(md);
107155
+ const simTheme = parseSimThemeJSON(md);
107147
107156
  const prj = {
107148
107157
  name,
107149
107158
  filesOverride: {
@@ -107153,7 +107162,8 @@ var pxt;
107153
107162
  dependencies,
107154
107163
  features,
107155
107164
  snippetType,
107156
- source
107165
+ source,
107166
+ simTheme
107157
107167
  };
107158
107168
  prj.filesOverride = Object.assign(Object.assign({}, prj.filesOverride), parseTemplateProjectJSON(md));
107159
107169
  if (jres) {
@@ -118518,7 +118528,7 @@ var pxt;
118518
118528
  if (!steps)
118519
118529
  return undefined; // error parsing steps
118520
118530
  // collect code and infer editor
118521
- const { code, templateCode, editor, language, jres, assetJson, customTs, tutorialValidationRulesStr } = computeBodyMetadata(body);
118531
+ const { code, templateCode, editor, language, jres, assetJson, customTs, tutorialValidationRulesStr, simThemeJson } = computeBodyMetadata(body);
118522
118532
  // parses tutorial rules string into a map of rules and enablement flag
118523
118533
  let tutorialValidationRules;
118524
118534
  if (metadata.tutorialCodeValidation) {
@@ -118534,6 +118544,7 @@ var pxt;
118534
118544
  diffify(steps, activities);
118535
118545
  }
118536
118546
  const assetFiles = parseAssetJson(assetJson);
118547
+ const simTheme = parseSimThemeJson(simThemeJson);
118537
118548
  const globalBlockConfig = parseTutorialBlockConfig("global", tutorialmd);
118538
118549
  const globalValidationConfig = parseTutorialValidationConfig("global", tutorialmd);
118539
118550
  // strip hidden snippets
@@ -118557,12 +118568,13 @@ var pxt;
118557
118568
  customTs,
118558
118569
  tutorialValidationRules,
118559
118570
  globalBlockConfig,
118560
- globalValidationConfig
118571
+ globalValidationConfig,
118572
+ simTheme
118561
118573
  };
118562
118574
  }
118563
118575
  tutorial.parseTutorial = parseTutorial;
118564
118576
  function getMetadataRegex() {
118565
- return /``` *(sim|block|blocks|filterblocks|spy|ghost|typescript|ts|js|javascript|template|python|jres|assetjson|customts|tutorialValidationRules|requiredTutorialBlock)\s*\n([\s\S]*?)\n```/gmi;
118577
+ return /``` *(sim|block|blocks|filterblocks|spy|ghost|typescript|ts|js|javascript|template|python|jres|assetjson|customts|tutorialValidationRules|requiredTutorialBlock|simtheme)\s*\n([\s\S]*?)\n```/gmi;
118566
118578
  }
118567
118579
  tutorial.getMetadataRegex = getMetadataRegex;
118568
118580
  function computeBodyMetadata(body) {
@@ -118576,6 +118588,7 @@ var pxt;
118576
118588
  let idx = 0;
118577
118589
  let assetJson;
118578
118590
  let customTs;
118591
+ let simThemeJson;
118579
118592
  let tutorialValidationRulesStr;
118580
118593
  // Concatenate all blocks in separate code blocks and decompile so we can detect what blocks are used (for the toolbox)
118581
118594
  body
@@ -118614,6 +118627,9 @@ var pxt;
118614
118627
  case "assetjson":
118615
118628
  assetJson = m2;
118616
118629
  break;
118630
+ case "simtheme":
118631
+ simThemeJson = m2;
118632
+ break;
118617
118633
  case "customts":
118618
118634
  customTs = m2;
118619
118635
  m2 = "";
@@ -118628,7 +118644,17 @@ var pxt;
118628
118644
  });
118629
118645
  // default to blocks
118630
118646
  editor = editor || pxt.BLOCKS_PROJECT_NAME;
118631
- return { code, templateCode, editor, language, jres, assetJson, customTs, tutorialValidationRulesStr };
118647
+ return {
118648
+ code,
118649
+ templateCode,
118650
+ editor,
118651
+ language,
118652
+ jres,
118653
+ assetJson,
118654
+ customTs,
118655
+ tutorialValidationRulesStr,
118656
+ simThemeJson
118657
+ };
118632
118658
  function checkTutorialEditor(expected) {
118633
118659
  if (editor && editor != expected) {
118634
118660
  pxt.debug(`tutorial ambiguous: contains snippets of different types`);
@@ -118850,7 +118876,7 @@ ${code}
118850
118876
  function stripHiddenSnippets(str) {
118851
118877
  if (!str)
118852
118878
  return str;
118853
- const hiddenSnippetRegex = /```(filterblocks|package|ghost|config|template|jres|assetjson|customts|blockconfig\.local|blockconfig\.global|validation\.local|validation\.global)\s*\n([\s\S]*?)\n```/gmi;
118879
+ const hiddenSnippetRegex = /```(filterblocks|package|ghost|config|template|jres|assetjson|simtheme|customts|blockconfig\.local|blockconfig\.global|validation\.local|validation\.global)\s*\n([\s\S]*?)\n```/gmi;
118854
118880
  return str.replace(hiddenSnippetRegex, '').trim();
118855
118881
  }
118856
118882
  /*
@@ -118934,7 +118960,8 @@ ${code}
118934
118960
  customTs: tutorialInfo.customTs,
118935
118961
  tutorialValidationRules: tutorialInfo.tutorialValidationRules,
118936
118962
  globalBlockConfig: tutorialInfo.globalBlockConfig,
118937
- globalValidationConfig: tutorialInfo.globalValidationConfig
118963
+ globalValidationConfig: tutorialInfo.globalValidationConfig,
118964
+ simTheme: tutorialInfo.simTheme,
118938
118965
  };
118939
118966
  return { options: tutorialOptions, editor: tutorialInfo.editor };
118940
118967
  }
@@ -118991,6 +119018,20 @@ ${code}
118991
119018
  };
118992
119019
  }
118993
119020
  tutorial.parseAssetJson = parseAssetJson;
119021
+ function parseSimThemeJson(json) {
119022
+ const pxtJson = pxt.Util.jsonTryParse(json);
119023
+ if (!pxtJson)
119024
+ return undefined;
119025
+ const res = {};
119026
+ if (pxtJson.theme) {
119027
+ res.theme = pxtJson.theme;
119028
+ }
119029
+ if (pxtJson.palette) {
119030
+ res.palette = pxtJson.palette;
119031
+ }
119032
+ return res;
119033
+ }
119034
+ tutorial.parseSimThemeJson = parseSimThemeJson;
118994
119035
  })(tutorial = pxt.tutorial || (pxt.tutorial = {}));
118995
119036
  })(pxt || (pxt = {}));
118996
119037
  var pxt;
@@ -129293,12 +129334,10 @@ ${output}</xml>`;
129293
129334
  return pxtc.Util.lf("Tagged templates only supported in custom fields with param.fieldOptions.taggedTemplate set");
129294
129335
  }
129295
129336
  const tag = unwrapNode(e.tag);
129296
- if (tag.kind !== SK.Identifier) {
129297
- return pxtc.Util.lf("Tagged template literals must use an identifier as the tag");
129298
- }
129299
129337
  const tagText = tag.getText();
129300
- if (tagText.trim() != tagName.trim()) {
129301
- return pxtc.Util.lf("Function only supports template literals with tag '{0}'", tagName);
129338
+ const possibleTags = tagName.split(";").map(t => t.trim());
129339
+ if (possibleTags.indexOf(tagText) === -1) {
129340
+ return pxtc.Util.lf("Function only supports template literals with tag '{0}'", possibleTags.join(", "));
129302
129341
  }
129303
129342
  const template = e.template;
129304
129343
  if (template.kind !== SK.NoSubstitutionTemplateLiteral) {
@@ -155418,6 +155457,7 @@ var pxsim;
155418
155457
  single: opts.single,
155419
155458
  dependencies: opts.dependencies,
155420
155459
  activePlayer: opts.activePlayer,
155460
+ theme: opts.theme,
155421
155461
  };
155422
155462
  this.start();
155423
155463
  }
@@ -6455,12 +6455,10 @@ ${output}</xml>`;
6455
6455
  return pxtc.Util.lf("Tagged templates only supported in custom fields with param.fieldOptions.taggedTemplate set");
6456
6456
  }
6457
6457
  const tag = unwrapNode(e.tag);
6458
- if (tag.kind !== SK.Identifier) {
6459
- return pxtc.Util.lf("Tagged template literals must use an identifier as the tag");
6460
- }
6461
6458
  const tagText = tag.getText();
6462
- if (tagText.trim() != tagName.trim()) {
6463
- return pxtc.Util.lf("Function only supports template literals with tag '{0}'", tagName);
6459
+ const possibleTags = tagName.split(";").map(t => t.trim());
6460
+ if (possibleTags.indexOf(tagText) === -1) {
6461
+ return pxtc.Util.lf("Function only supports template literals with tag '{0}'", possibleTags.join(", "));
6464
6462
  }
6465
6463
  const template = e.template;
6466
6464
  if (template.kind !== SK.NoSubstitutionTemplateLiteral) {
@@ -110,6 +110,7 @@ declare namespace pxt.editor {
110
110
  preferredEditor?: string;
111
111
  extensionUnderTest?: string;
112
112
  skillmapProject?: boolean;
113
+ simTheme?: Partial<pxt.PackageConfig>;
113
114
  }
114
115
  interface ExampleImportOptions {
115
116
  name: string;
package/built/pxtlib.d.ts CHANGED
@@ -1132,6 +1132,7 @@ declare namespace pxt.gallery {
1132
1132
  filesOverride: pxt.Map<string>;
1133
1133
  dependencies: pxt.Map<string>;
1134
1134
  features?: string[];
1135
+ simTheme?: Partial<pxt.PackageConfig>;
1135
1136
  }
1136
1137
  function parsePackagesFromMarkdown(md: string): pxt.Map<string>;
1137
1138
  function parseFeaturesFromMarkdown(md: string): string[];
@@ -1140,6 +1141,7 @@ declare namespace pxt.gallery {
1140
1141
  ts: string;
1141
1142
  };
1142
1143
  function parseTemplateProjectJSON(md: string): pxt.Map<string>;
1144
+ function parseSimThemeJSON(md: string): Partial<pxt.PackageConfig>;
1143
1145
  function parseExampleMarkdown(name: string, md: string): GalleryProject;
1144
1146
  function parseCodeCards(md: string): pxt.CodeCard[];
1145
1147
  function parseCodeCardsHtml(el: HTMLElement): CodeCard[];
@@ -2965,6 +2967,7 @@ declare namespace pxt.tutorial {
2965
2967
  function parseCachedTutorialInfo(json: string, id?: string): Promise<void>;
2966
2968
  function resolveLocalizedMarkdown(ghid: pxt.github.ParsedRepo, files: pxt.Map<string>, fileName?: string): string;
2967
2969
  function parseAssetJson(json: string): pxt.Map<string>;
2970
+ function parseSimThemeJson(json: string): Partial<pxt.PackageConfig>;
2968
2971
  }
2969
2972
  declare namespace pxt.tutorial {
2970
2973
  interface TutorialRuleStatus {
package/built/pxtlib.js CHANGED
@@ -9447,6 +9447,14 @@ var pxt;
9447
9447
  return {};
9448
9448
  }
9449
9449
  gallery_1.parseTemplateProjectJSON = parseTemplateProjectJSON;
9450
+ function parseSimThemeJSON(md) {
9451
+ const pm = /```simtheme\s+([\s\S]*?)```/i.exec(md);
9452
+ if (pm) {
9453
+ return pxt.tutorial.parseSimThemeJson(pm[1]);
9454
+ }
9455
+ return {};
9456
+ }
9457
+ gallery_1.parseSimThemeJSON = parseSimThemeJSON;
9450
9458
  function parseExampleMarkdown(name, md) {
9451
9459
  if (!md)
9452
9460
  return undefined;
@@ -9458,6 +9466,7 @@ var pxt;
9458
9466
  const source = m[2];
9459
9467
  const features = parseFeaturesFromMarkdown(md);
9460
9468
  const jres = parseJResFromMarkdown(md);
9469
+ const simTheme = parseSimThemeJSON(md);
9461
9470
  const prj = {
9462
9471
  name,
9463
9472
  filesOverride: {
@@ -9467,7 +9476,8 @@ var pxt;
9467
9476
  dependencies,
9468
9477
  features,
9469
9478
  snippetType,
9470
- source
9479
+ source,
9480
+ simTheme
9471
9481
  };
9472
9482
  prj.filesOverride = Object.assign(Object.assign({}, prj.filesOverride), parseTemplateProjectJSON(md));
9473
9483
  if (jres) {
@@ -20832,7 +20842,7 @@ var pxt;
20832
20842
  if (!steps)
20833
20843
  return undefined; // error parsing steps
20834
20844
  // collect code and infer editor
20835
- const { code, templateCode, editor, language, jres, assetJson, customTs, tutorialValidationRulesStr } = computeBodyMetadata(body);
20845
+ const { code, templateCode, editor, language, jres, assetJson, customTs, tutorialValidationRulesStr, simThemeJson } = computeBodyMetadata(body);
20836
20846
  // parses tutorial rules string into a map of rules and enablement flag
20837
20847
  let tutorialValidationRules;
20838
20848
  if (metadata.tutorialCodeValidation) {
@@ -20848,6 +20858,7 @@ var pxt;
20848
20858
  diffify(steps, activities);
20849
20859
  }
20850
20860
  const assetFiles = parseAssetJson(assetJson);
20861
+ const simTheme = parseSimThemeJson(simThemeJson);
20851
20862
  const globalBlockConfig = parseTutorialBlockConfig("global", tutorialmd);
20852
20863
  const globalValidationConfig = parseTutorialValidationConfig("global", tutorialmd);
20853
20864
  // strip hidden snippets
@@ -20871,12 +20882,13 @@ var pxt;
20871
20882
  customTs,
20872
20883
  tutorialValidationRules,
20873
20884
  globalBlockConfig,
20874
- globalValidationConfig
20885
+ globalValidationConfig,
20886
+ simTheme
20875
20887
  };
20876
20888
  }
20877
20889
  tutorial.parseTutorial = parseTutorial;
20878
20890
  function getMetadataRegex() {
20879
- return /``` *(sim|block|blocks|filterblocks|spy|ghost|typescript|ts|js|javascript|template|python|jres|assetjson|customts|tutorialValidationRules|requiredTutorialBlock)\s*\n([\s\S]*?)\n```/gmi;
20891
+ return /``` *(sim|block|blocks|filterblocks|spy|ghost|typescript|ts|js|javascript|template|python|jres|assetjson|customts|tutorialValidationRules|requiredTutorialBlock|simtheme)\s*\n([\s\S]*?)\n```/gmi;
20880
20892
  }
20881
20893
  tutorial.getMetadataRegex = getMetadataRegex;
20882
20894
  function computeBodyMetadata(body) {
@@ -20890,6 +20902,7 @@ var pxt;
20890
20902
  let idx = 0;
20891
20903
  let assetJson;
20892
20904
  let customTs;
20905
+ let simThemeJson;
20893
20906
  let tutorialValidationRulesStr;
20894
20907
  // Concatenate all blocks in separate code blocks and decompile so we can detect what blocks are used (for the toolbox)
20895
20908
  body
@@ -20928,6 +20941,9 @@ var pxt;
20928
20941
  case "assetjson":
20929
20942
  assetJson = m2;
20930
20943
  break;
20944
+ case "simtheme":
20945
+ simThemeJson = m2;
20946
+ break;
20931
20947
  case "customts":
20932
20948
  customTs = m2;
20933
20949
  m2 = "";
@@ -20942,7 +20958,17 @@ var pxt;
20942
20958
  });
20943
20959
  // default to blocks
20944
20960
  editor = editor || pxt.BLOCKS_PROJECT_NAME;
20945
- return { code, templateCode, editor, language, jres, assetJson, customTs, tutorialValidationRulesStr };
20961
+ return {
20962
+ code,
20963
+ templateCode,
20964
+ editor,
20965
+ language,
20966
+ jres,
20967
+ assetJson,
20968
+ customTs,
20969
+ tutorialValidationRulesStr,
20970
+ simThemeJson
20971
+ };
20946
20972
  function checkTutorialEditor(expected) {
20947
20973
  if (editor && editor != expected) {
20948
20974
  pxt.debug(`tutorial ambiguous: contains snippets of different types`);
@@ -21164,7 +21190,7 @@ ${code}
21164
21190
  function stripHiddenSnippets(str) {
21165
21191
  if (!str)
21166
21192
  return str;
21167
- const hiddenSnippetRegex = /```(filterblocks|package|ghost|config|template|jres|assetjson|customts|blockconfig\.local|blockconfig\.global|validation\.local|validation\.global)\s*\n([\s\S]*?)\n```/gmi;
21193
+ const hiddenSnippetRegex = /```(filterblocks|package|ghost|config|template|jres|assetjson|simtheme|customts|blockconfig\.local|blockconfig\.global|validation\.local|validation\.global)\s*\n([\s\S]*?)\n```/gmi;
21168
21194
  return str.replace(hiddenSnippetRegex, '').trim();
21169
21195
  }
21170
21196
  /*
@@ -21248,7 +21274,8 @@ ${code}
21248
21274
  customTs: tutorialInfo.customTs,
21249
21275
  tutorialValidationRules: tutorialInfo.tutorialValidationRules,
21250
21276
  globalBlockConfig: tutorialInfo.globalBlockConfig,
21251
- globalValidationConfig: tutorialInfo.globalValidationConfig
21277
+ globalValidationConfig: tutorialInfo.globalValidationConfig,
21278
+ simTheme: tutorialInfo.simTheme,
21252
21279
  };
21253
21280
  return { options: tutorialOptions, editor: tutorialInfo.editor };
21254
21281
  }
@@ -21305,6 +21332,20 @@ ${code}
21305
21332
  };
21306
21333
  }
21307
21334
  tutorial.parseAssetJson = parseAssetJson;
21335
+ function parseSimThemeJson(json) {
21336
+ const pxtJson = pxt.Util.jsonTryParse(json);
21337
+ if (!pxtJson)
21338
+ return undefined;
21339
+ const res = {};
21340
+ if (pxtJson.theme) {
21341
+ res.theme = pxtJson.theme;
21342
+ }
21343
+ if (pxtJson.palette) {
21344
+ res.palette = pxtJson.palette;
21345
+ }
21346
+ return res;
21347
+ }
21348
+ tutorial.parseSimThemeJson = parseSimThemeJson;
21308
21349
  })(tutorial = pxt.tutorial || (pxt.tutorial = {}));
21309
21350
  })(pxt || (pxt = {}));
21310
21351
  var pxt;
@@ -1764,6 +1764,7 @@ var pxt;
1764
1764
  // iff matches and truthy, reuse existing simdriver
1765
1765
  let currDriverId;
1766
1766
  function initDriverAndOptions(container, simOptions, compileInfo) {
1767
+ var _a;
1767
1768
  if (!simDriver || !simOptions.embedId || currDriverId !== simOptions.embedId) {
1768
1769
  simDriver = new pxsim.SimulatorDriver(container);
1769
1770
  currDriverId = simOptions.embedId;
@@ -1791,6 +1792,7 @@ var pxt;
1791
1792
  autofocus: simOptions.autofocus,
1792
1793
  queryParameters: simOptions.additionalQueryParameters,
1793
1794
  mpRole: simOptions.mpRole,
1795
+ theme: (_a = runner.mainPkg.config) === null || _a === void 0 ? void 0 : _a.theme,
1794
1796
  };
1795
1797
  if (pxt.appTarget.simulator && !simOptions.fullScreen)
1796
1798
  runOptions.aspectRatio = parts.length && pxt.appTarget.simulator.partsAspectRatio
package/built/pxtsim.d.ts CHANGED
@@ -341,6 +341,7 @@ declare namespace pxsim {
341
341
  single?: boolean;
342
342
  traceDisabled?: boolean;
343
343
  activePlayer?: 1 | 2 | 3 | 4 | undefined;
344
+ theme?: string | pxt.Map<string>;
344
345
  }
345
346
  interface SimulatorInstructionsMessage extends SimulatorMessage {
346
347
  type: "instructions";
@@ -1335,6 +1336,7 @@ declare namespace pxsim {
1335
1336
  queryParameters?: string;
1336
1337
  mpRole?: "server" | "client";
1337
1338
  activePlayer?: 1 | 2 | 3 | 4 | undefined;
1339
+ theme?: string | pxt.Map<string>;
1338
1340
  }
1339
1341
  interface HwDebugger {
1340
1342
  postMessage: (msg: pxsim.SimulatorMessage) => void;
package/built/pxtsim.js CHANGED
@@ -6572,6 +6572,7 @@ var pxsim;
6572
6572
  single: opts.single,
6573
6573
  dependencies: opts.dependencies,
6574
6574
  activePlayer: opts.activePlayer,
6575
+ theme: opts.theme,
6575
6576
  };
6576
6577
  this.start();
6577
6578
  }