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

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.
@@ -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-lyapunov (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -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-lyapunov (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -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-lyapunov (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -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-lyapunov (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -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-lyapunov (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -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-lyapunov (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -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-lyapunov (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -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-lyapunov (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -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-lyapunov (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -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-lyapunov (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -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-lyapunov (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -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-lyapunov (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -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-lyapunov (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -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-lyapunov (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -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-lyapunov (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -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-lyapunov (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -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-lyapunov (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -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-lyapunov (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -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-lyapunov (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
package/dist/esm/index.js CHANGED
@@ -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-lyapunov (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -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-lyapunov (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -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-lyapunov (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -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-lyapunov (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
package/dist/esm/regex.js CHANGED
@@ -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-lyapunov (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -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-lyapunov (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -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-lyapunov (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -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-lyapunov (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
package/dist/esm/types.js CHANGED
@@ -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-lyapunov (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -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-lyapunov (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -140,8 +140,17 @@ export class CustomElementUtils {
140
140
  }
141
141
  /** Theming-related helpers. */
142
142
  static { this.Theme = {
143
- /** 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). */
143
+ /**
144
+ * Downloads the web fonts referenced by the current theme's `--{@link PCSS}-font-*` CSS custom properties,
145
+ * resolving once they are loaded and at least one font face is ready. Never rejects, never waits forever:
146
+ * a font that fails to load is skipped, and the whole wait is capped (fonts refine a page, they must not
147
+ * keep it hidden).
148
+ */
144
149
  importWebFonts() {
150
+ /** The longest wait (ms) for the fonts: then it resolves anyway. */
151
+ const WEB_FONTS_TIMEOUT = 3000;
152
+ /** The polls (every 250ms) for a first font face, before relying on `document.fonts.ready` anyway. */
153
+ const FONT_FACE_CHECKS = 4;
145
154
  function cleanupQuotes(input) {
146
155
  // check if the string is wrapped around quotes to escape ';' chars
147
156
  if (/^('|").*\1$/.test(input)) {
@@ -152,30 +161,32 @@ export class CustomElementUtils {
152
161
  function downloadFont(fontFace) {
153
162
  return Utils.isNullOrEmpty(fontFace) ? Promise.resolve() : document.fonts.load('1rem ' + fontFace);
154
163
  }
155
- const promises = ['icons', 'std', 'main', 'tech', 'btn'].map(f => {
164
+ function importFont(f) {
156
165
  const fontFace = Utils.Css.getVariableValue(`--${PCSS}-font-${f}`).split(',')[0];
157
- const url = cleanupQuotes(Utils.Css.getVariableValue(`--${PCSS}-font-${f}-api-url`));
166
+ const apiUrl = Utils.Css.getVariableValue(`--${PCSS}-font-${f}-api-url`);
167
+ const url = cleanupQuotes(apiUrl);
158
168
  if (Utils.isNullOrEmpty(url)) {
159
169
  return downloadFont(fontFace);
160
170
  }
161
- else {
162
- return CustomElementUtils.importcss(url).then(_ => downloadFont(fontFace));
163
- }
164
- });
171
+ return CustomElementUtils.importcss(url).then(_ => downloadFont(fontFace));
172
+ }
173
+ // (a failing font is skipped: one of them must not hold the others)
174
+ const promises = ['icons', 'std', 'main', 'tech', 'btn'].map(f => importFont(f).catch(_ => undefined));
165
175
  const atLeast1FontFaceReady = new Promise((resolve) => {
166
- function check(count = 0) {
176
+ function check(count) {
167
177
  // size against the specs: https://developer.mozilla.org/en-US/docs/Web/API/FontFaceSet/size#specifications
168
- if (count > 4 || !('size' in document.fonts) || typeof document.fonts.size === 'number' && document.fonts.size > 0) {
178
+ if (count > FONT_FACE_CHECKS || !('size' in document.fonts) || typeof document.fonts.size === 'number' && document.fonts.size > 0) {
169
179
  document.fonts.ready.then(resolve);
180
+ return;
170
181
  }
171
- else {
172
- setTimeout(check, 250, count++);
173
- }
182
+ setTimeout(check, 250, count + 1);
174
183
  }
175
- check();
184
+ check(0);
176
185
  });
177
186
  promises.push(atLeast1FontFaceReady);
178
- return Promise.all(promises);
187
+ const timeout = new Promise(resolve => setTimeout(resolve, WEB_FONTS_TIMEOUT));
188
+ const fontsReady = Promise.all(promises);
189
+ return Promise.race([fontsReady, timeout]);
179
190
  }
180
191
  }; }
181
192
  /**
@@ -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-lyapunov (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
package/dist/esm/utils.js CHANGED
@@ -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-lyapunov (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
package/package.json CHANGED
@@ -24,7 +24,7 @@
24
24
  "types": "./typings/index.d.ts"
25
25
  }
26
26
  },
27
- "version": "2.0.0-kepler",
27
+ "version": "2.0.0-lyapunov",
28
28
  "author": {
29
29
  "name": "Pacem",
30
30
  "url": "https://pacem.it"
@@ -393,7 +393,12 @@ export declare class CustomElementUtils {
393
393
  }, appendTo?: Node): Promise<HTMLElement>;
394
394
  /** Theming-related helpers. */
395
395
  static Theme: {
396
- /** 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). */
396
+ /**
397
+ * Downloads the web fonts referenced by the current theme's `--{@link PCSS}-font-*` CSS custom properties,
398
+ * resolving once they are loaded and at least one font face is ready. Never rejects, never waits forever:
399
+ * a font that fails to load is skipped, and the whole wait is capped (fonts refine a page, they must not
400
+ * keep it hidden).
401
+ */
397
402
  importWebFonts(): Promise<any>;
398
403
  };
399
404
  /**