pxt-core 11.3.2 → 11.3.4

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
@@ -107970,8 +107970,9 @@ var pxt;
107970
107970
  });
107971
107971
  });
107972
107972
  }
107973
- async loadTutorialMarkdown(repoPath, tag) {
107974
- const tutorialResponse = (await downloadMarkdownTutorialInfoAsync(repoPath, tag)).resp;
107973
+ async loadTutorialMarkdown(repopath, tag) {
107974
+ repopath = normalizeTutorialPath(repopath);
107975
+ const tutorialResponse = (await downloadMarkdownTutorialInfoAsync(repopath, tag)).resp;
107975
107976
  const repo = tutorialResponse.markdown;
107976
107977
  pxt.Util.assert(typeof repo === "object");
107977
107978
  await this.cacheReposAsync(tutorialResponse);
@@ -108945,6 +108946,33 @@ var pxt;
108945
108946
  }));
108946
108947
  }
108947
108948
  github.getPagesStatusAsync = getPagesStatusAsync;
108949
+ function normalizeTutorialPath(repopath) {
108950
+ // repopath will be one of these three formats:
108951
+ // 1. owner/repo/path/to/file
108952
+ // 2. github:owner/repo/path/to/file
108953
+ // 3. https://github.com/owner/repo/path/to/file
108954
+ //
108955
+ // That third format is not a valid URL (a proper github URL will have /blob/branchname/
108956
+ // in it after the repo) but we used to support it so maintain backwards compatibility
108957
+ if (/^github\:/i.test(repopath)) {
108958
+ repopath = repopath.slice(7);
108959
+ }
108960
+ if (/^https?\:/i.test(repopath)) {
108961
+ const parsed = new URL(repopath);
108962
+ // remove the leading slash
108963
+ repopath = parsed.pathname.slice(1);
108964
+ // check if this is an actual link to a file in github, for example:
108965
+ // Mojang/EducationContent/blob/master/computing/unit-2/lesson-1.md
108966
+ //
108967
+ // Note the "/blob/master/" which is not present in example 3 above
108968
+ const fullURLMatch = /^((?:[^\/]+\/){2})blob\/[^\/]+\/(.*)\.md$/.exec(repopath);
108969
+ if (fullURLMatch) {
108970
+ repopath = fullURLMatch[1] + fullURLMatch[2];
108971
+ }
108972
+ }
108973
+ return repopath;
108974
+ }
108975
+ github.normalizeTutorialPath = normalizeTutorialPath;
108948
108976
  })(github = pxt.github || (pxt.github = {}));
108949
108977
  })(pxt || (pxt = {}));
108950
108978
  var pxt;
@@ -122554,7 +122582,7 @@ var pxt;
122554
122582
  function useCdnApi() {
122555
122583
  return pxt.webConfig && !pxt.webConfig.isStatic
122556
122584
  && !pxt.BrowserUtils.isLocalHost() && !!pxt.webConfig.cdnUrl
122557
- && !/nocdn=1/i.test(window.location.href);
122585
+ && (typeof window === "undefined" || !/nocdn=1/i.test(window.location.href));
122558
122586
  }
122559
122587
  Cloud.useCdnApi = useCdnApi;
122560
122588
  function cdnApiUrl(url) {
package/built/pxtlib.d.ts CHANGED
@@ -1330,7 +1330,7 @@ declare namespace pxt.github {
1330
1330
  latestVersionAsync(repopath: string, config: PackagesConfig): Promise<string>;
1331
1331
  loadPackageAsync(repopath: string, tag: string): Promise<CachedPackage>;
1332
1332
  private githubLoadPackageAsync;
1333
- loadTutorialMarkdown(repoPath: string, tag?: string): Promise<GHTutorialRepoInfo>;
1333
+ loadTutorialMarkdown(repopath: string, tag?: string): Promise<GHTutorialRepoInfo>;
1334
1334
  cacheReposAsync(resp: GHTutorialResponse): Promise<void>;
1335
1335
  private cacheRepo;
1336
1336
  private cacheLatestVersion;
@@ -1467,6 +1467,7 @@ declare namespace pxt.github {
1467
1467
  };
1468
1468
  }
1469
1469
  function getPagesStatusAsync(repoPath: string): Promise<GitHubPagesStatus>;
1470
+ function normalizeTutorialPath(repopath: string): string;
1470
1471
  }
1471
1472
  declare namespace pxt {
1472
1473
  const REFCNT_FLASH = "0xfffe";
package/built/pxtlib.js CHANGED
@@ -10284,8 +10284,9 @@ var pxt;
10284
10284
  });
10285
10285
  });
10286
10286
  }
10287
- async loadTutorialMarkdown(repoPath, tag) {
10288
- const tutorialResponse = (await downloadMarkdownTutorialInfoAsync(repoPath, tag)).resp;
10287
+ async loadTutorialMarkdown(repopath, tag) {
10288
+ repopath = normalizeTutorialPath(repopath);
10289
+ const tutorialResponse = (await downloadMarkdownTutorialInfoAsync(repopath, tag)).resp;
10289
10290
  const repo = tutorialResponse.markdown;
10290
10291
  pxt.Util.assert(typeof repo === "object");
10291
10292
  await this.cacheReposAsync(tutorialResponse);
@@ -11259,6 +11260,33 @@ var pxt;
11259
11260
  }));
11260
11261
  }
11261
11262
  github.getPagesStatusAsync = getPagesStatusAsync;
11263
+ function normalizeTutorialPath(repopath) {
11264
+ // repopath will be one of these three formats:
11265
+ // 1. owner/repo/path/to/file
11266
+ // 2. github:owner/repo/path/to/file
11267
+ // 3. https://github.com/owner/repo/path/to/file
11268
+ //
11269
+ // That third format is not a valid URL (a proper github URL will have /blob/branchname/
11270
+ // in it after the repo) but we used to support it so maintain backwards compatibility
11271
+ if (/^github\:/i.test(repopath)) {
11272
+ repopath = repopath.slice(7);
11273
+ }
11274
+ if (/^https?\:/i.test(repopath)) {
11275
+ const parsed = new URL(repopath);
11276
+ // remove the leading slash
11277
+ repopath = parsed.pathname.slice(1);
11278
+ // check if this is an actual link to a file in github, for example:
11279
+ // Mojang/EducationContent/blob/master/computing/unit-2/lesson-1.md
11280
+ //
11281
+ // Note the "/blob/master/" which is not present in example 3 above
11282
+ const fullURLMatch = /^((?:[^\/]+\/){2})blob\/[^\/]+\/(.*)\.md$/.exec(repopath);
11283
+ if (fullURLMatch) {
11284
+ repopath = fullURLMatch[1] + fullURLMatch[2];
11285
+ }
11286
+ }
11287
+ return repopath;
11288
+ }
11289
+ github.normalizeTutorialPath = normalizeTutorialPath;
11262
11290
  })(github = pxt.github || (pxt.github = {}));
11263
11291
  })(pxt || (pxt = {}));
11264
11292
  var pxt;
@@ -24868,7 +24896,7 @@ var pxt;
24868
24896
  function useCdnApi() {
24869
24897
  return pxt.webConfig && !pxt.webConfig.isStatic
24870
24898
  && !pxt.BrowserUtils.isLocalHost() && !!pxt.webConfig.cdnUrl
24871
- && !/nocdn=1/i.test(window.location.href);
24899
+ && (typeof window === "undefined" || !/nocdn=1/i.test(window.location.href));
24872
24900
  }
24873
24901
  Cloud.useCdnApi = useCdnApi;
24874
24902
  function cdnApiUrl(url) {