@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
|
@@ -39433,6 +39433,15 @@
|
|
|
39433
39433
|
"text": "Strings.leftPad",
|
|
39434
39434
|
"canonicalReference": "@pacem/pacem-foundation!Strings.leftPad:member"
|
|
39435
39435
|
},
|
|
39436
|
+
{
|
|
39437
|
+
"kind": "Content",
|
|
39438
|
+
"text": ";\n rightPad: typeof "
|
|
39439
|
+
},
|
|
39440
|
+
{
|
|
39441
|
+
"kind": "Reference",
|
|
39442
|
+
"text": "Strings.rightPad",
|
|
39443
|
+
"canonicalReference": "@pacem/pacem-foundation!Strings.rightPad:member"
|
|
39444
|
+
},
|
|
39436
39445
|
{
|
|
39437
39446
|
"kind": "Content",
|
|
39438
39447
|
"text": ";\n format: typeof "
|
|
@@ -39466,7 +39475,7 @@
|
|
|
39466
39475
|
"name": "Strings",
|
|
39467
39476
|
"propertyTypeTokenRange": {
|
|
39468
39477
|
"startIndex": 1,
|
|
39469
|
-
"endIndex":
|
|
39478
|
+
"endIndex": 10
|
|
39470
39479
|
},
|
|
39471
39480
|
"isStatic": true,
|
|
39472
39481
|
"isProtected": false,
|
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-mersenne (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
|
@@ -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
|
*/
|
|
@@ -194,6 +194,7 @@ export class Utils {
|
|
|
194
194
|
static { this.diff = Strings.diff; }
|
|
195
195
|
static { this.Strings = {
|
|
196
196
|
leftPad: Strings.leftPad,
|
|
197
|
+
rightPad: Strings.rightPad,
|
|
197
198
|
format: Strings.format,
|
|
198
199
|
diff: Strings.diff,
|
|
199
200
|
/** Strips HTML markup from `html`, returning its plain-text content. */
|
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
|
/**
|
|
@@ -3255,6 +3260,7 @@ export declare class Utils {
|
|
|
3255
3260
|
static diff: typeof Strings.diff;
|
|
3256
3261
|
static Strings: {
|
|
3257
3262
|
leftPad: typeof Strings.leftPad;
|
|
3263
|
+
rightPad: typeof Strings.rightPad;
|
|
3258
3264
|
format: typeof Strings.format;
|
|
3259
3265
|
diff: typeof Strings.diff;
|
|
3260
3266
|
/** Strips HTML markup from `html`, returning its plain-text content. */
|