@pacem/pacem-core 2.0.0-kepler → 2.0.0-mersenne

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 (40) hide show
  1. package/dist/browser/pacem-core.js +27 -15
  2. package/dist/browser/pacem-core.js.map +1 -1
  3. package/dist/browser/pacem-core.min.js +2 -2
  4. package/dist/bundle/pacem-core.min.mjs +5 -5
  5. package/dist/bundle/pacem-core.mjs +24 -13
  6. package/dist/bundle/pacem-core.mjs.map +2 -2
  7. package/dist/docs/pacem-core.json +10 -1
  8. package/dist/esm/adapter.js +1 -1
  9. package/dist/esm/binding-parser.js +1 -1
  10. package/dist/esm/command.js +1 -1
  11. package/dist/esm/comparers.js +1 -1
  12. package/dist/esm/converters.js +1 -1
  13. package/dist/esm/decorators-next.js +1 -1
  14. package/dist/esm/decorators.js +1 -1
  15. package/dist/esm/defaults.js +1 -1
  16. package/dist/esm/events.js +1 -1
  17. package/dist/esm/eventtarget.js +1 -1
  18. package/dist/esm/expression.js +1 -1
  19. package/dist/esm/index-animations.js +1 -1
  20. package/dist/esm/index-behaviors.js +1 -1
  21. package/dist/esm/index-components.js +1 -1
  22. package/dist/esm/index-iife.js +1 -1
  23. package/dist/esm/index-logging.js +1 -1
  24. package/dist/esm/index-net.js +1 -1
  25. package/dist/esm/index-root.js +1 -1
  26. package/dist/esm/index-ui.js +1 -1
  27. package/dist/esm/index.js +1 -1
  28. package/dist/esm/logger.js +1 -1
  29. package/dist/esm/prefix.js +1 -1
  30. package/dist/esm/promise.js +1 -1
  31. package/dist/esm/regex.js +1 -1
  32. package/dist/esm/storage.js +1 -1
  33. package/dist/esm/template.js +1 -1
  34. package/dist/esm/transforms.js +1 -1
  35. package/dist/esm/types.js +1 -1
  36. package/dist/esm/utils-customelement.js +26 -15
  37. package/dist/esm/utils-customevent.js +1 -1
  38. package/dist/esm/utils.js +2 -1
  39. package/package.json +1 -1
  40. package/typings/index.d.ts +7 -1
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @pacem/pacem-core v2.0.0-kepler (https://js.pacem.it)
2
+ * @pacem/pacem-core v2.0.0-mersenne (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -416,6 +416,7 @@ var Utils = class _Utils {
416
416
  static {
417
417
  this.Strings = {
418
418
  leftPad: Strings.leftPad,
419
+ rightPad: Strings.rightPad,
419
420
  format: Strings.format,
420
421
  diff: Strings.diff,
421
422
  /** Strips HTML markup from `html`, returning its plain-text content. */
@@ -1842,8 +1843,15 @@ var CustomElementUtils = class _CustomElementUtils {
1842
1843
  }
1843
1844
  static {
1844
1845
  this.Theme = {
1845
- /** Downloads the web fonts referenced by the current theme's `--{@link PCSS}-font-*` CSS custom properties, resolving once at least one font face is ready (or after a short timeout). */
1846
+ /**
1847
+ * Downloads the web fonts referenced by the current theme's `--{@link PCSS}-font-*` CSS custom properties,
1848
+ * resolving once they are loaded and at least one font face is ready. Never rejects, never waits forever:
1849
+ * a font that fails to load is skipped, and the whole wait is capped (fonts refine a page, they must not
1850
+ * keep it hidden).
1851
+ */
1846
1852
  importWebFonts() {
1853
+ const WEB_FONTS_TIMEOUT = 3e3;
1854
+ const FONT_FACE_CHECKS = 4;
1847
1855
  function cleanupQuotes(input) {
1848
1856
  if (/^('|").*\1$/.test(input)) {
1849
1857
  return input.substring(1, input.length - 1);
@@ -1853,27 +1861,30 @@ var CustomElementUtils = class _CustomElementUtils {
1853
1861
  function downloadFont(fontFace) {
1854
1862
  return Utils.isNullOrEmpty(fontFace) ? Promise.resolve() : document.fonts.load("1rem " + fontFace);
1855
1863
  }
1856
- const promises = ["icons", "std", "main", "tech", "btn"].map((f) => {
1864
+ function importFont(f) {
1857
1865
  const fontFace = Utils.Css.getVariableValue(`--${PCSS}-font-${f}`).split(",")[0];
1858
- const url = cleanupQuotes(Utils.Css.getVariableValue(`--${PCSS}-font-${f}-api-url`));
1866
+ const apiUrl = Utils.Css.getVariableValue(`--${PCSS}-font-${f}-api-url`);
1867
+ const url = cleanupQuotes(apiUrl);
1859
1868
  if (Utils.isNullOrEmpty(url)) {
1860
1869
  return downloadFont(fontFace);
1861
- } else {
1862
- return _CustomElementUtils.importcss(url).then((_) => downloadFont(fontFace));
1863
1870
  }
1864
- });
1871
+ return _CustomElementUtils.importcss(url).then((_) => downloadFont(fontFace));
1872
+ }
1873
+ const promises = ["icons", "std", "main", "tech", "btn"].map((f) => importFont(f).catch((_) => void 0));
1865
1874
  const atLeast1FontFaceReady = new Promise((resolve) => {
1866
- function check(count = 0) {
1867
- if (count > 4 || !("size" in document.fonts) || typeof document.fonts.size === "number" && document.fonts.size > 0) {
1875
+ function check(count) {
1876
+ if (count > FONT_FACE_CHECKS || !("size" in document.fonts) || typeof document.fonts.size === "number" && document.fonts.size > 0) {
1868
1877
  document.fonts.ready.then(resolve);
1869
- } else {
1870
- setTimeout(check, 250, count++);
1878
+ return;
1871
1879
  }
1880
+ setTimeout(check, 250, count + 1);
1872
1881
  }
1873
- check();
1882
+ check(0);
1874
1883
  });
1875
1884
  promises.push(atLeast1FontFaceReady);
1876
- return Promise.all(promises);
1885
+ const timeout = new Promise((resolve) => setTimeout(resolve, WEB_FONTS_TIMEOUT));
1886
+ const fontsReady = Promise.all(promises);
1887
+ return Promise.race([fontsReady, timeout]);
1877
1888
  }
1878
1889
  };
1879
1890
  }