@pacem/pacem-core 2.0.0-jacobi → 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.
- package/dist/browser/pacem-core.js +26 -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 +23 -13
- package/dist/bundle/pacem-core.mjs.map +2 -2
- 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 +1 -1
- package/package.json +1 -1
- package/typings/index.d.ts +6 -1
package/dist/esm/adapter.js
CHANGED
package/dist/esm/command.js
CHANGED
package/dist/esm/comparers.js
CHANGED
package/dist/esm/converters.js
CHANGED
package/dist/esm/decorators.js
CHANGED
package/dist/esm/defaults.js
CHANGED
package/dist/esm/events.js
CHANGED
package/dist/esm/eventtarget.js
CHANGED
package/dist/esm/expression.js
CHANGED
package/dist/esm/index-iife.js
CHANGED
package/dist/esm/index-net.js
CHANGED
package/dist/esm/index-root.js
CHANGED
package/dist/esm/index-ui.js
CHANGED
package/dist/esm/index.js
CHANGED
package/dist/esm/logger.js
CHANGED
package/dist/esm/prefix.js
CHANGED
package/dist/esm/promise.js
CHANGED
package/dist/esm/regex.js
CHANGED
package/dist/esm/storage.js
CHANGED
package/dist/esm/template.js
CHANGED
package/dist/esm/transforms.js
CHANGED
package/dist/esm/types.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @pacem/pacem-core v2.0.0-
|
|
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
|
-
/**
|
|
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
|
-
|
|
164
|
+
function importFont(f) {
|
|
156
165
|
const fontFace = Utils.Css.getVariableValue(`--${PCSS}-font-${f}`).split(',')[0];
|
|
157
|
-
const
|
|
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
|
-
|
|
162
|
-
|
|
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
|
|
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 >
|
|
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
|
-
|
|
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
|
-
|
|
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
|
/**
|
package/dist/esm/utils.js
CHANGED
package/package.json
CHANGED
package/typings/index.d.ts
CHANGED
|
@@ -393,7 +393,12 @@ export declare class CustomElementUtils {
|
|
|
393
393
|
}, appendTo?: Node): Promise<HTMLElement>;
|
|
394
394
|
/** Theming-related helpers. */
|
|
395
395
|
static Theme: {
|
|
396
|
-
/**
|
|
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
|
/**
|