@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.
- package/dist/browser/pacem-core.js +27 -15
- package/dist/browser/pacem-core.js.map +1 -1
- package/dist/browser/pacem-core.min.js +2 -2
- package/dist/bundle/pacem-core.min.mjs +5 -5
- package/dist/bundle/pacem-core.mjs +24 -13
- package/dist/bundle/pacem-core.mjs.map +2 -2
- package/dist/docs/pacem-core.json +10 -1
- package/dist/esm/adapter.js +1 -1
- package/dist/esm/binding-parser.js +1 -1
- package/dist/esm/command.js +1 -1
- package/dist/esm/comparers.js +1 -1
- package/dist/esm/converters.js +1 -1
- package/dist/esm/decorators-next.js +1 -1
- package/dist/esm/decorators.js +1 -1
- package/dist/esm/defaults.js +1 -1
- package/dist/esm/events.js +1 -1
- package/dist/esm/eventtarget.js +1 -1
- package/dist/esm/expression.js +1 -1
- package/dist/esm/index-animations.js +1 -1
- package/dist/esm/index-behaviors.js +1 -1
- package/dist/esm/index-components.js +1 -1
- package/dist/esm/index-iife.js +1 -1
- package/dist/esm/index-logging.js +1 -1
- package/dist/esm/index-net.js +1 -1
- package/dist/esm/index-root.js +1 -1
- package/dist/esm/index-ui.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/logger.js +1 -1
- package/dist/esm/prefix.js +1 -1
- package/dist/esm/promise.js +1 -1
- package/dist/esm/regex.js +1 -1
- package/dist/esm/storage.js +1 -1
- package/dist/esm/template.js +1 -1
- package/dist/esm/transforms.js +1 -1
- package/dist/esm/types.js +1 -1
- package/dist/esm/utils-customelement.js +26 -15
- package/dist/esm/utils-customevent.js +1 -1
- package/dist/esm/utils.js +2 -1
- package/package.json +1 -1
- package/typings/index.d.ts +7 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @pacem/pacem-core v2.0.0-
|
|
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
|
*/
|
|
@@ -462,6 +462,7 @@
|
|
|
462
462
|
static { this.diff = pacemFoundation.Strings.diff; }
|
|
463
463
|
static { this.Strings = {
|
|
464
464
|
leftPad: pacemFoundation.Strings.leftPad,
|
|
465
|
+
rightPad: pacemFoundation.Strings.rightPad,
|
|
465
466
|
format: pacemFoundation.Strings.format,
|
|
466
467
|
diff: pacemFoundation.Strings.diff,
|
|
467
468
|
/** Strips HTML markup from `html`, returning its plain-text content. */
|
|
@@ -1991,8 +1992,17 @@
|
|
|
1991
1992
|
}
|
|
1992
1993
|
/** Theming-related helpers. */
|
|
1993
1994
|
static { this.Theme = {
|
|
1994
|
-
/**
|
|
1995
|
+
/**
|
|
1996
|
+
* Downloads the web fonts referenced by the current theme's `--{@link PCSS}-font-*` CSS custom properties,
|
|
1997
|
+
* resolving once they are loaded and at least one font face is ready. Never rejects, never waits forever:
|
|
1998
|
+
* a font that fails to load is skipped, and the whole wait is capped (fonts refine a page, they must not
|
|
1999
|
+
* keep it hidden).
|
|
2000
|
+
*/
|
|
1995
2001
|
importWebFonts() {
|
|
2002
|
+
/** The longest wait (ms) for the fonts: then it resolves anyway. */
|
|
2003
|
+
const WEB_FONTS_TIMEOUT = 3000;
|
|
2004
|
+
/** The polls (every 250ms) for a first font face, before relying on `document.fonts.ready` anyway. */
|
|
2005
|
+
const FONT_FACE_CHECKS = 4;
|
|
1996
2006
|
function cleanupQuotes(input) {
|
|
1997
2007
|
// check if the string is wrapped around quotes to escape ';' chars
|
|
1998
2008
|
if (/^('|").*\1$/.test(input)) {
|
|
@@ -2003,30 +2013,32 @@
|
|
|
2003
2013
|
function downloadFont(fontFace) {
|
|
2004
2014
|
return Utils.isNullOrEmpty(fontFace) ? Promise.resolve() : document.fonts.load('1rem ' + fontFace);
|
|
2005
2015
|
}
|
|
2006
|
-
|
|
2016
|
+
function importFont(f) {
|
|
2007
2017
|
const fontFace = Utils.Css.getVariableValue(`--${PCSS}-font-${f}`).split(',')[0];
|
|
2008
|
-
const
|
|
2018
|
+
const apiUrl = Utils.Css.getVariableValue(`--${PCSS}-font-${f}-api-url`);
|
|
2019
|
+
const url = cleanupQuotes(apiUrl);
|
|
2009
2020
|
if (Utils.isNullOrEmpty(url)) {
|
|
2010
2021
|
return downloadFont(fontFace);
|
|
2011
2022
|
}
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2023
|
+
return CustomElementUtils.importcss(url).then(_ => downloadFont(fontFace));
|
|
2024
|
+
}
|
|
2025
|
+
// (a failing font is skipped: one of them must not hold the others)
|
|
2026
|
+
const promises = ['icons', 'std', 'main', 'tech', 'btn'].map(f => importFont(f).catch(_ => undefined));
|
|
2016
2027
|
const atLeast1FontFaceReady = new Promise((resolve) => {
|
|
2017
|
-
function check(count
|
|
2028
|
+
function check(count) {
|
|
2018
2029
|
// size against the specs: https://developer.mozilla.org/en-US/docs/Web/API/FontFaceSet/size#specifications
|
|
2019
|
-
if (count >
|
|
2030
|
+
if (count > FONT_FACE_CHECKS || !('size' in document.fonts) || typeof document.fonts.size === 'number' && document.fonts.size > 0) {
|
|
2020
2031
|
document.fonts.ready.then(resolve);
|
|
2032
|
+
return;
|
|
2021
2033
|
}
|
|
2022
|
-
|
|
2023
|
-
setTimeout(check, 250, count++);
|
|
2024
|
-
}
|
|
2034
|
+
setTimeout(check, 250, count + 1);
|
|
2025
2035
|
}
|
|
2026
|
-
check();
|
|
2036
|
+
check(0);
|
|
2027
2037
|
});
|
|
2028
2038
|
promises.push(atLeast1FontFaceReady);
|
|
2029
|
-
|
|
2039
|
+
const timeout = new Promise(resolve => setTimeout(resolve, WEB_FONTS_TIMEOUT));
|
|
2040
|
+
const fontsReady = Promise.all(promises);
|
|
2041
|
+
return Promise.race([fontsReady, timeout]);
|
|
2030
2042
|
}
|
|
2031
2043
|
}; }
|
|
2032
2044
|
/**
|